Browse Source

HUE-6087 [core] Initial port of per-app intervals to the new format

Enrico Berti 8 years ago
parent
commit
466ac05

+ 2 - 1
apps/metastore/src/metastore/templates/metastore.mako

@@ -1263,7 +1263,8 @@ ${ components.menubar() }
                     classToRemove: 'sample-table',
                     mainScrollable: '.content-panel',
                     stickToTopPosition: 73,
-                    clonedContainerPosition: "fixed"
+                    clonedContainerPosition: 'fixed',
+                    app: 'metastore'
                   });
                   $(selector).jHueHorizontalScrollbar();
                 },

+ 1 - 1
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -1026,7 +1026,7 @@ $(document).ready(function () {
     }
   });
 
-  window.setInterval(checkModelDirtiness, 500);
+  window.setInterval(checkModelDirtiness, 500, 'oozie_workflow');
   $('#clone-btn').on('click', function () {
     var _url = $(this).data('clone-url');
     $.post(_url, function (data) {

+ 17 - 5
desktop/core/src/desktop/static/desktop/js/hue4.utils.js

@@ -20,6 +20,16 @@
   var originalClearInterval = window.clearInterval;
   var hueIntervals = [];
 
+  /**
+   * @param {string} [app] - context for the intervals
+   */
+  window.getIntervals = function(app) {
+    if (app) {
+      return hueIntervals.filter(function(obj){ return obj.app == app; });
+    }
+    return hueIntervals;
+  }
+
   /**
    * @param {Function} fn - the function to be called at intervals
    * @param {Number} timeout - timeout in milliseconds
@@ -28,7 +38,9 @@
   window.setInterval = function (fn, timeout, app) {
     var id = originalSetInterval(fn, timeout);
     hueIntervals.push({
-      args: arguments,
+      fn: fn,
+      timeout: timeout,
+      app: app,
       id: id,
       originalId: id,
       status: 'running'
@@ -60,7 +72,7 @@
    */
   window.pauseAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.args[2] && interval.args[2] === app) {
+      if (interval.app == app) {
         interval.status = 'paused';
         originalClearInterval(interval.id);
       }
@@ -72,9 +84,9 @@
    */
   window.resumeAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.args[2] && interval.args[2] === app && interval.status === 'paused') {
+      if (interval.app == app && interval.status === 'paused') {
         interval.status = 'running';
-        var id = originalSetInterval(interval.args[0], interval.args[1]);
+        var id = originalSetInterval(interval.fn, interval.timeout);
         interval.id = id;
       }
     });
@@ -85,7 +97,7 @@
    */
   window.clearAppIntervals = function (app) {
     hueIntervals.forEach(function (interval) {
-      if (interval.args[2] && interval.args[2] === app) {
+      if (interval.app == app) {
         window.clearInterval(interval.originalId);
       }
     });

+ 3 - 2
desktop/core/src/desktop/static/desktop/js/jquery.tableextender.js

@@ -33,6 +33,7 @@
       includeNavigator: true,
       mainScrollable: window,
       stickToTopPosition: -1,
+      app: null,
       labels: {
         GO_TO_COLUMN: "Go to column:",
         PLACEHOLDER: "column name...",
@@ -347,7 +348,7 @@
         clonedTableVisibleContainer.height($pluginElement.parent().height());
         $pluginElement.parent().data("h", clonedTableVisibleContainer.height());
       }
-    }, 250);
+    }, 250, plugin.options.app);
     $pluginElement.data('firstcol_interval', firstColInt);
 
     $pluginElement.parent().resize(function () {
@@ -484,7 +485,7 @@
             clonedTable.find("thead>tr th:eq(" + i + ")").width($(this).width()).css("background-color", "#FFFFFF");
           });
         }
-      }, 250);
+      }, 250, plugin.options.app);
       $pluginElement.data('header_interval', headerInt);
 
       $pluginElement.parent().resize(function () {

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/jquery.tableextender2.js

@@ -28,6 +28,7 @@
     classToRemove: 'resultTable',
     hintElement: null,
     mainScrollable: window,
+    app: null,
     stickToTopPosition: -1,
     labels: {
       GO_TO_COLUMN: "Go to column:",
@@ -154,7 +155,7 @@
       }
     };
     adjustSizes();
-    var sizeInterval = window.setInterval(adjustSizes, 300);
+    var sizeInterval = window.setInterval(adjustSizes, 300, self.options.app);
     self.disposeFunctions.push(function () {
       window.clearInterval(sizeInterval);
     });

+ 1 - 1
desktop/core/src/desktop/templates/common_notebook_ko_components.mako

@@ -440,7 +440,7 @@ except ImportError, e:
             }
           }
           timesChecked++;
-        }, 500);
+        }, 500, 'editor');
 
         self.notebook.avoidClosing = true;
         self.$downloadForm.submit();

+ 1 - 1
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -3742,7 +3742,7 @@ function newSearch() {
             window.clearInterval(_widgetDropInterval);
             row.autosizeWidgets();
           }
-        }, 100)
+        }, 100, 'search')
       }
       else {
         row.autosizeWidgets();

+ 2 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -2023,7 +2023,7 @@ var EditorViewModel = (function() {
 
       var index = 0;
       self.snippets()[index].execute();
-      var clock = setInterval(next, 100);
+      var clock = window.setInterval(next, 100, 'editor');
 
       function next() {
         if (self.snippets()[index].status() == 'available' || self.snippets()[index].status() == 'failed') {
@@ -2031,7 +2031,7 @@ var EditorViewModel = (function() {
           if (self.snippets().length > index) {
             self.snippets()[index].execute();
           } else {
-            clearInterval(clock);
+            window.clearInterval(clock);
           }
         }
       }

+ 5 - 3
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -110,7 +110,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       $('#queryBuilder').hide();
       $('#queryBuilderAlert').show();
     }
-  }, 500);
+  }, 500, 'editor');
 
 </script>
 <!-- End query builder imports -->
@@ -2124,14 +2124,16 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
           stickToTopPosition: function() { return vm.isPlayerMode() ? 1 : 73 + bannerTopHeight },
           % endif
           parentId: 'snippet_' + snippet.id(),
-          clonedContainerPosition: "fixed"
+          clonedContainerPosition: 'fixed',
+          app: 'editor'
         });
         $(el).jHueHorizontalScrollbar();
       } else {
         $(el).jHueTableExtender2({
           mainScrollable: $(el).parents('.dataTables_wrapper')[0],
           parentId: 'snippet_' + snippet.id(),
-          clonedContainerPosition: "absolute"
+          clonedContainerPosition: 'absolute',
+          app: 'editor'
         });
       }
     }, 0);