소스 검색

HUE-6420 [editor] The huePubSub subscribers should have a specific type to be paused correctly

Enrico Berti 8 년 전
부모
커밋
c37766c

+ 3 - 3
desktop/core/src/desktop/static/desktop/js/hue.utils.js

@@ -471,7 +471,7 @@ var huePubSub = (function () {
       if (app) {
         Object.keys(topics).forEach(function (topicName) {
           topics[topicName].forEach(function (topic) {
-            if (topic.app === app) {
+            if (typeof topic.app !== 'undefined' && (topic.app === app || topic.app.split('-')[0] === app)) {
               topic.status = 'paused';
             }
           });
@@ -482,7 +482,7 @@ var huePubSub = (function () {
       if (app) {
         Object.keys(topics).forEach(function (topicName) {
           topics[topicName].forEach(function (topic) {
-            if (topic.app === app) {
+            if (typeof topic.app !== 'undefined' && (topic.app === app || topic.app.split('-')[0] === app)) {
               topic.status = 'running';
             }
           });
@@ -492,7 +492,7 @@ var huePubSub = (function () {
     clearAppSubscribers: function (app) {
       if (app) {
         Object.keys(topics).forEach(function (topicName) {
-          topics[topicName] = topics[topicName].filter(function(obj){ return obj.app !== app});
+          topics[topicName] = topics[topicName].filter(function(obj){ return obj.app !== app });
         });
       }
     }

+ 3 - 3
desktop/core/src/desktop/static/desktop/js/hue4.utils.js

@@ -72,7 +72,7 @@
    */
   window.pauseAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.app == app) {
+      if (typeof interval.app !== 'undefined' && (interval.app === app || interval.app.split('-')[0] === app)) {
         interval.status = 'paused';
         originalClearInterval(interval.id);
       }
@@ -84,7 +84,7 @@
    */
   window.resumeAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.app == app && interval.status === 'paused') {
+      if (typeof interval.app !== 'undefined' && (interval.app == app || interval.app.split('-')[0] === app) && interval.status === 'paused') {
         interval.status = 'running';
         var id = originalSetInterval(interval.fn, interval.timeout);
         interval.id = id;
@@ -97,7 +97,7 @@
    */
   window.clearAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.app == app) {
+      if (interval.app == app || (interval.app && interval.app.split('-')[0] === app)) {
         window.clearInterval(interval.originalId);
       }
     });

+ 9 - 2
desktop/core/src/desktop/templates/hue.mako

@@ -729,8 +729,15 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           } else {
             self.isLoadingEmbeddable(false);
           }
-          window.resumeAppIntervals(app);
-          huePubSub.resumeAppSubscribers(app);
+          if (app === 'editor'){
+            var affix = (window.location.getParameter('type') ? '-' + window.location.getParameter('type') : '');
+            window.resumeAppIntervals(app + affix);
+            huePubSub.resumeAppSubscribers(app + affix);
+          }
+          else {
+            window.resumeAppIntervals(app);
+            huePubSub.resumeAppSubscribers(app);
+          }
           $('.embeddable').hide();
           $('#embeddable_' + app).insertBefore($('.embeddable:first')).show();
           huePubSub.publish('app.gained.focus', app);

+ 29 - 26
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -84,7 +84,6 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('desktop/js/queryBuilder.js') }"></script>
 <script>
 
-
   // query-builder-menu is the class to use
   // Callback will run after each rule add, just focus to the queryBuilder tab
   QueryBuilder.bindMenu('.query-builder-menu', function () {
@@ -109,7 +108,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       $('#queryBuilder').hide();
       $('#queryBuilderAlert').show();
     }
-  }, 500, 'editor');
+  }, 500, 'editor' + (window.location.getParameter('type') ? '-' + window.location.getParameter('type') : ''));
 
 </script>
 <!-- End query builder imports -->
@@ -1976,14 +1975,18 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script type="text/javascript">
   % if is_embeddable:
   var MAIN_SCROLLABLE = '.page-content';
+  var HUE_PUB_SUB_AFFIX = (window.location.getParameter('type') ? '-' + window.location.getParameter('type') : '');
   % else:
   var MAIN_SCROLLABLE = '.content-panel';
+  var HUE_PUB_SUB_AFFIX = '';
   % endif
 
+  var HUE_PUB_SUB_APP = 'editor' + HUE_PUB_SUB_AFFIX;
+
   var isLeftNavOpen = false;
   huePubSub.subscribe('left.nav.open.toggle', function(val) {
     isLeftNavOpen = val;
-  }, 'editor');
+  }, HUE_PUB_SUB_APP);
 
   var showHoverMsg = function (e) {
     var dt = null;
@@ -2841,28 +2844,28 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       splitDraggableTimeout = window.setTimeout(function () {
         redrawFixedHeaders(100);
       }, 200);
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('redraw.fixed.headers', function () {
       hideFixedHeaders();
       redrawFixedHeaders(200);
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('app.gained.focus', function (app) {
       if (app === 'editor') {
         huePubSub.publish('redraw.fixed.headers');
       }
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('show.saveToFile.modal', function () {
       $('#saveToFileModal').modal('show');
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('tab.switched', function (tab) {
       if (tab !== 'queryResults') {
         $('.hue-datatable-search').hide();
       }
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('detach.scrolls', function (snippet) {
       var scrollElement = $('#snippet_' + snippet.id()).find('.dataTables_wrapper');
@@ -2872,7 +2875,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       if (scrollElement.data('scrollFnDt')) {
         scrollElement.off('scroll', scrollElement.data('scrollFnDt'));
       }
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     huePubSub.subscribe('table.row.dblclick', function(data){
       var $el = $(data.table);
@@ -2892,7 +2895,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       $('#detailsModal').modal('show');
 
-    }, 'editor');
+    }, HUE_PUB_SUB_APP);
 
     window.redrawFixedHeaders = redrawFixedHeaders;
 
@@ -3104,15 +3107,15 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       huePubSub.subscribe('editor.upload.table.stats', function (options) {
         viewModel.selectedNotebook().snippets()[0].uploadTableStats(options);
-      });
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe("editor.upload.history", function () {
         viewModel.selectedNotebook().snippets()[0].uploadQueryHistory(5);
-      });
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe("editor.upload.query", function (query_id) {
         viewModel.selectedNotebook().snippets()[0].uploadQuery(query_id);
-      });
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe('editor.active.statement.changed', function (statementDetails) {
         if (statementDetails.activeStatement) {
@@ -3120,7 +3123,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         } else {
           viewModel.selectedNotebook().snippets()[0].positionStatement('');
         }
-      });
+      }, HUE_PUB_SUB_APP);
 
       viewModel.selectedNotebook.subscribe(function (newVal) {
         huePubSub.publish('selected.notebook.changed', newVal);
@@ -3128,7 +3131,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       huePubSub.subscribe('get.selected.notebook', function () {
         huePubSub.publish('set.selected.notebook', viewModel.selectedNotebook());
-      });
+      }, HUE_PUB_SUB_APP);
 
 
       var isAssistAvailable = viewModel.assistAvailable();
@@ -3172,7 +3175,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       huePubSub.subscribe('assist.set.manual.visibility', function () {
         wasAssistVisible = viewModel.isLeftPanelVisible();
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       viewModel.isLeftPanelVisible.subscribe(function (value) {
         redrawFixedHeaders(200);
@@ -3197,11 +3200,11 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
       huePubSub.subscribe('show.retry.modal', function (data) {
         $('#retryModal').modal('show');
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe('hide.retry.modal', function (data) {
         $('#retryModal').modal('hide');
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       // Close the notebook snippets when leaving the page
       window.onbeforeunload = function (e) {
@@ -3228,7 +3231,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         return false;
       });
 
-      huePubSub.subscribe('editor.save', saveKeyHandler, 'editor');
+      huePubSub.subscribe('editor.save', saveKeyHandler, HUE_PUB_SUB_APP);
 
       $(document).bind('keyup', function (e) {
         if (e.keyCode == 191 && e.shiftKey && !$(e.target).is('input') && !$(e.target).is('textarea')) {
@@ -3260,7 +3263,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         return false;
       });
 
-      huePubSub.subscribe('editor.create.new', newKeyHandler, 'editor');
+      huePubSub.subscribe('editor.create.new', newKeyHandler, HUE_PUB_SUB_APP);
 
       var initialResizePosition = 100;
 
@@ -3472,7 +3475,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '0'});
         $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '0'});
         $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '0.55'});
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe('editor.snippet.result.normal', function (snippet) {
         var $snippet = $("#snippet_" + snippet.id());
@@ -3480,11 +3483,11 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         $snippet.find(".dataTables_wrapper .fixed-header-row").css({opacity: '1'});
         $snippet.find(".dataTables_wrapper .fixed-first-cell").css({opacity: '1'});
         $snippet.find(".dataTables_wrapper .resultTable").css({opacity: '1'});
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       $(document).on("renderDataError", function (e, options) {
         huePubSub.publish('editor.snippet.result.normal', options.snippet);
-      }, 'editor');
+      });
 
       $(document).on("progress", function (e, options) {
         if (options.data == 100) {
@@ -3503,7 +3506,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         if (typeof renderJqCron !== 'undefined'){
           renderJqCron();
         }
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe('submit.popup.return', function (data) {
         viewModel.selectedNotebook().viewSchedulerId(data.job_id);
@@ -3511,7 +3514,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         $('.submit-modal').modal('hide');
 
         $('a[href=\'#scheduledJobsTab\']').click();
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       huePubSub.subscribe('jobbrowser.data', function (jobs) {
         if (jobs.length > 0) {
@@ -3533,7 +3536,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
             });
           }
         }
-      }, 'editor');
+      }, HUE_PUB_SUB_APP);
 
       $(document).on("gridShown", function (e, snippet) {
         window.setTimeout(function () {