Ver código fonte

HUE-7996 [editor] The history height calculation is wrong for multi line queries

Enrico Berti 7 anos atrás
pai
commit
84ff8eae37

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

@@ -1385,6 +1385,7 @@ var EditorViewModel = (function() {
       if (self.status() == 'running' || self.status() == 'loading' || now - self.lastExecuted() < 1000 || ! self.isReady()) {
         return;
       }
+
       if (self.isSqlDialect()) {
         huePubSub.publish('editor.refresh.statement.locations', self);
       }
@@ -1401,6 +1402,8 @@ var EditorViewModel = (function() {
       $(".jHueNotify").remove();
       hueAnalytics.log('notebook', 'execute/' + self.type());
 
+      notebook.forceHistoryInitialHeight(true);
+
       if (self.result.handle()) {
         self.close();
         self.statusForButtons('executed');
@@ -2242,7 +2245,8 @@ var EditorViewModel = (function() {
       }
     });
     self.loadingHistory = ko.observable(self.history().length == 0);
-    self.historyInitialHeight = ko.observable(0);
+    self.historyInitialHeight = ko.observable(0).extend({ throttle: 1000 });
+    self.forceHistoryInitialHeight = ko.observable(false);
     self.historyCurrentPage = ko.observable(vm.selectedNotebook() ? vm.selectedNotebook().historyCurrentPage() : 1);
     self.historyCurrentPage.subscribe(function(val) {
       self.fetchHistory();
@@ -2855,7 +2859,6 @@ var EditorViewModel = (function() {
       }
       if (vm.editorMode() && self.history().length == 0) {
         self.fetchHistory(function() {
-          self.historyInitialHeight((self.history().length * 32) + 80); // add pagination too
           self.updateHistory(['starting', 'running'], 30000);
           self.updateHistory(['available'], 60000 * 5);
         });

+ 8 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -750,7 +750,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 
             <!-- ko if: $parent.history().length > 0 -->
             <table class="table table-condensed margin-top-10 history-table">
-              <tbody data-bind="foreach: $parent.history">
+              <tbody data-bind="foreach: { data: $parent.history, afterRender: function(){ huePubSub.publish('editor.calculate.history.height'); } }">
                 <tr data-bind="click: function() { if (uuid() != $root.selectedNotebook().uuid()) { $root.openNotebook(uuid()); } }, css: { 'highlight': uuid() == $root.selectedNotebook().uuid(), 'pointer': uuid() != $root.selectedNotebook().uuid() }">
                   <td style="width: 100px" class="muted" data-bind="style: {'border-top-width': $index() == 0 ? '0' : ''}">
                     <span data-bind="momentFromNow: {data: lastExecuted, interval: 10000, titleFormat: 'LLL'}"></span>
@@ -3018,6 +3018,13 @@ function togglePresentation(value) {};
       }
     }, HUE_PUB_SUB_EDITOR_ID);
 
+    huePubSub.subscribe('editor.calculate.history.height', function () {
+      if (viewModel.editorMode() && (viewModel.selectedNotebook().historyInitialHeight() === 0 || viewModel.selectedNotebook().forceHistoryInitialHeight())) {
+        viewModel.selectedNotebook().historyInitialHeight($('.history-table').height() + 80); // add pagination too
+        viewModel.selectedNotebook().forceHistoryInitialHeight(false);
+      }
+    }, HUE_PUB_SUB_EDITOR_ID);
+
     window.redrawFixedHeaders = redrawFixedHeaders;
 
     function addAce(content, snippetType) {