Просмотр исходного кода

HUE-4081 [core] Skip idle session timeout relogin popup on running jb jobs call when idle session timeout is disabled

Also fixed a null pointer on notebook execute that would prevent the login popup to show
Enrico Berti 9 лет назад
Родитель
Сommit
611a51a1f1

+ 3 - 0
desktop/core/src/desktop/templates/common_footer.mako

@@ -52,6 +52,9 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
     // global catch for ajax calls after the user has logged out
     var isLoginRequired = false;
     $(document).ajaxComplete(function (event, xhr, settings) {
+      if (IDLE_SESSION_TIMEOUT == -1 && settings && settings.url === '/jobbrowser/jobs/') {
+        return;
+      }
       if (xhr.responseText === '/* login required */' && !isLoginRequired) {
         isLoginRequired = true;
         $('.blurred').removeClass('blurred');

+ 4 - 1
desktop/core/src/desktop/templates/common_header.mako

@@ -233,6 +233,8 @@ if USE_NEW_EDITOR.get():
     // sets global apiHelper TTL
     $.totalStorage('hue.cacheable.ttl', ${conf.CUSTOM.CACHEABLE_TTL.get()});
 
+    var IDLE_SESSION_TIMEOUT = -1;
+
     $(document).ready(function () {
       // forces IE's ajax calls not to cache
       if ($.browser.msie) {
@@ -251,13 +253,14 @@ if USE_NEW_EDITOR.get():
       }
 
       %if conf.AUTH.IDLE_SESSION_TIMEOUT.get() > -1 and not skip_idle_timeout:
+      IDLE_SESSION_TIMEOUT = ${conf.AUTH.IDLE_SESSION_TIMEOUT.get()};
       var idleTimer;
       function resetIdleTimer() {
         clearTimeout(idleTimer);
         idleTimer = setTimeout(function () {
           // Check if logged out
           $.get('/desktop/debug/is_idle');
-        }, (${conf.AUTH.IDLE_SESSION_TIMEOUT.get()} * 1000) + 1000);
+        }, (IDLE_SESSION_TIMEOUT * 1000) + 1000);
       }
 
       $(document).on('mousemove', resetIdleTimer);

+ 22 - 20
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -739,28 +739,30 @@
           self._ajaxError(data, self.execute);
         }
 
-        if (vm.editorMode()) {
-          notebook.history.unshift(
-            notebook._makeHistoryRecord(
-              url,
-              data.handle.statement,
-              self.lastExecuted(),
-              self.status(),
-              notebook.name(),
-              notebook.uuid()
-            )
-          );
-        }
+        if (data.handle) {
+          if (vm.editorMode()) {
+            notebook.history.unshift(
+              notebook._makeHistoryRecord(
+                url,
+                data.handle.statement,
+                self.lastExecuted(),
+                self.status(),
+                notebook.name(),
+                notebook.uuid()
+              )
+            );
+          }
 
-        if (data.handle.statements_count != null) {
-          self.result.statements_count(data.handle.statements_count);
-          self.result.statement_id(data.handle.statement_id);
+          if (data.handle.statements_count != null) {
+            self.result.statements_count(data.handle.statements_count);
+            self.result.statement_id(data.handle.statement_id);
 
-          if (data.handle.statements_count > 1 && data.handle.start != null && data.handle.end != null) {
-            self.result.statement_range({
-              start: data.handle.start,
-              end: data.handle.end
-            });
+            if (data.handle.statements_count > 1 && data.handle.start != null && data.handle.end != null) {
+              self.result.statement_range({
+                start: data.handle.start,
+                end: data.handle.end
+              });
+            }
           }
         }
       }).fail(function (xhr, textStatus, errorThrown) {