Explorar o código

HUE-9100 [editor] Close dangling sessions

Jean-Francois Desjeans Gauthier %!s(int64=6) %!d(string=hai) anos
pai
achega
10cdfc2cca

+ 13 - 0
desktop/core/src/desktop/js/api/apiHelper.js

@@ -2469,6 +2469,19 @@ class ApiHelper {
                     };
                     data.hueTimestamp = Date.now();
                     deferred.resolve(data);
+
+                    if (
+                      window.CLOSE_SESSIONS[options.sourceType] &&
+                      queryResult.result.handle &&
+                      queryResult.result.handle.session_id
+                    ) {
+                      self.closeSession({
+                        session: {
+                          type: options.sourceType,
+                          id: queryResult.result.handle.session_id
+                        }
+                      });
+                    }
                   })
                   .fail(deferred.reject);
 

+ 1 - 0
desktop/core/src/desktop/js/apps/notebook/editorViewModel.js

@@ -429,6 +429,7 @@ class EditorViewModel {
     self.loadNotebook = function(notebookRaw, queryTab) {
       let currentQueries;
       if (self.selectedNotebook() != null) {
+        self.selectedNotebook().close();
         currentQueries = self.selectedNotebook().unload();
       }
 

+ 1 - 0
desktop/core/src/desktop/js/ko/components/ko.historyPanel.js

@@ -271,6 +271,7 @@ class HistoryPanel {
               } else if (notebook.onSuccessUrl()) {
                 huePubSub.publish(notebook.pubSubUrl());
               }
+              notebook.close(); // TODO: Don't close when onSuccessUrl is editor?
             } else {
               // Perform last DROP statement execute
               snippet.execute();

+ 2 - 1
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -23,7 +23,7 @@
       USE_DEFAULT_CONFIGURATION, USE_NEW_SIDE_PANELS, VCS, ENABLE_GIST, ENABLE_LINK_SHARING
   from desktop.models import hue_version, _get_apps, get_cluster_config
 
-  from beeswax.conf import DOWNLOAD_BYTES_LIMIT, DOWNLOAD_ROW_LIMIT, LIST_PARTITIONS_LIMIT
+  from beeswax.conf import DOWNLOAD_BYTES_LIMIT, DOWNLOAD_ROW_LIMIT, LIST_PARTITIONS_LIMIT, CLOSE_SESSIONS
   from dashboard.conf import HAS_SQL_ENABLED
   from filebrowser.conf import SHOW_UPLOAD_BUTTON
   from indexer.conf import ENABLE_NEW_INDEXER
@@ -119,6 +119,7 @@
   window.JB_HEADER_CHECK_INTERVAL_IN_MILLIS = 30000;
   window.JB_SINGLE_CHECK_INTERVAL_IN_MILLIS = 5000;
   window.JB_MULTI_CHECK_INTERVAL_IN_MILLIS = 20000;
+  window.CLOSE_SESSIONS = {'hive': '${ CLOSE_SESSIONS.get() }' === 'True'};
 
   window.HUE_URLS = {
     IMPORTER_CREATE_TABLE: '${ 'indexer' in apps and url('indexer:importer_prefill', source_type = 'all', target_type = 'table')}',