Преглед изворни кода

HUE-7009 [editor] Do not show any progress during automatic uploads of stats

Romain Rigaux пре 8 година
родитељ
комит
9d65704

+ 7 - 4
desktop/core/src/desktop/templates/assist.mako

@@ -1951,7 +1951,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
           <div class="margin-top-20">
             <!-- ko hueSpinner: { spin: uploadingTableStats, inline: true} --><!-- /ko -->
             <!-- ko ifnot: uploadingTableStats -->
-            <a href="javascript:void(0)" data-bind="visible: activeTables().length > 0, click: uploadTableStats, attr: { 'title': ('${ _("Add table ") }'  + (isMissingDDL() ? 'DDL' : '') + (isMissingDDL() && isMissingStats() ? ' ${ _("and") } ' : '') + (isMissingStats() ? 'stats' : '')) }">
+            <a href="javascript:void(0)" data-bind="visible: activeTables().length > 0, click: function() { uploadTableStats(true) }, attr: { 'title': ('${ _("Add table ") }'  + (isMissingDDL() ? 'DDL' : '') + (isMissingDDL() && isMissingStats() ? ' ${ _("and") } ' : '') + (isMissingStats() ? 'stats' : '')) }">
               <i class="fa fa-fw fa-plus-circle"></i> ${_('Improve Analysis')}
             </a>
             <!-- /ko -->
@@ -1977,7 +1977,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
         self.activeRisks = ko.observable({});
         self.activeRisks.subscribe(function() {
           if (self.isMissingDDL()) {
-            self.uploadTableStats();
+            self.uploadTableStats(false);
           }
         });
         self.statementCount = ko.observable(0);
@@ -2142,13 +2142,16 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
 
       }
 
-      AssistantPanel.prototype.uploadTableStats = function () {
+      AssistantPanel.prototype.uploadTableStats = function (showProgress) {
         var self = this;
         if (self.uploadingTableStats()) {
           return;
         }
         self.uploadingTableStats(true);
-        huePubSub.publish('editor.upload.table.stats', { activeTables: self.activeTables(), callback: function () {
+        huePubSub.publish('editor.upload.table.stats', {
+          activeTables: self.activeTables(),
+          showProgress: showProgress,
+          callback: function () {
             self.uploadingTableStats(false);
           }
         });

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

@@ -1787,7 +1787,9 @@ var EditorViewModel = (function() {
 
     self.uploadTableStats = function (options) {
       hueAnalytics.log('notebook', 'load_table_stats');
-      $(document).trigger("info", "Preparing table data...");
+      if (options.showProgress) {
+        $(document).trigger("info", "Preparing table data...");
+      }
 
       $.post("/metadata/api/optimizer/upload/table_stats", {
         db_tables: ko.mapping.toJSON($.map(options.activeTables, function(table) {
@@ -1798,12 +1800,16 @@ var EditorViewModel = (function() {
         with_ddl: ko.mapping.toJSON(true)
       }, function(data) {
         if (data.status == 0) {
-          $(document).trigger("info", $.map(options.activeTables, function(table) { return table.tableName; }) + " stats sent to analyse");
+          if (options.showProgress) {
+            $(document).trigger("info", $.map(options.activeTables, function(table) { return table.tableName; }) + " stats sent to analyse");
+          }
           if (data.upload_table_ddl) {
-            self.watchUploadStatus(data.upload_table_ddl.status.workloadId);
+            self.watchUploadStatus(data.upload_table_ddl.status.workloadId, options.showProgress);
           }
         } else {
-          $(document).trigger("error", data.message);
+          if (options.showProgress) {
+            $(document).trigger("error", data.message);
+          }
         }
       }).always(function () {
         if (options.callback) {
@@ -1812,21 +1818,27 @@ var EditorViewModel = (function() {
       });
     };
 
-    self.watchUploadStatus = function (workloadId) {
+    self.watchUploadStatus = function (workloadId, showProgress) {
       $.post("/metadata/api/optimizer/upload/status", {
         workloadId: workloadId
       }, function(data) {
         if (data.status == 0) {
-          $(document).trigger("info", "Query processing: " + data.upload_status.status.state);
+          if (showProgress) {
+            $(document).trigger("info", "Query processing: " + data.upload_status.status.state);
+          }
           if (['WAITING', 'IN_PROGRESS'].indexOf(data.upload_status.status.state) != -1) {
             window.setTimeout(function () {
               self.watchUploadStatus(workloadId);
             }, 2000);
           } else {
-            $(document).trigger("warn", data.upload_status.status.statusMsg + (data.upload_status.status.failedQueries > 0 ? '. ' + data.upload_status.status.failQueryDetails.map(function(query) { return query.error; }) : ''));
+            if (showProgress) {
+              $(document).trigger("warn", data.upload_status.status.statusMsg + (data.upload_status.status.failedQueries > 0 ? '. ' + data.upload_status.status.failQueryDetails.map(function(query) { return query.error; }) : ''));
+            }
           }
         } else {
-          $(document).trigger("error", data.message);
+          if (showProgress) {
+            $(document).trigger("error", data.message);
+          }
         }
       });
     };