瀏覽代碼

HUE-7325 [assist] Gracefully handle missing tables or backend errors in the assistant panel

Johan Ahlen 8 年之前
父節點
當前提交
ea101d3aa5

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 8 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistDbEntry.js

@@ -268,7 +268,7 @@ var AssistDbEntry = (function () {
     }
   };
 
-  AssistDbEntry.prototype.loadEntries = function(callback) {
+  AssistDbEntry.prototype.loadEntries = function(callback, silenceErrors) {
     var self = this;
     if (!self.expandable || self.loading()) {
       return;
@@ -282,6 +282,11 @@ var AssistDbEntry = (function () {
       self.hasErrors(false);
       self.loading(false);
 
+      if (data.status === 0 && data.code === 500 && !data.tables_meta) {
+        self.hasErrors(true);
+        return;
+      }
+
       var newEntries = [];
       var index = 0;
       if (typeof data.tables_meta !== "undefined") {
@@ -425,7 +430,8 @@ var AssistDbEntry = (function () {
       sourceType: self.assistDbSource.sourceType,
       hierarchy: self.getHierarchy(),
       successCallback: successCallback,
-      errorCallback: errorCallback
+      errorCallback: errorCallback,
+      silenceErrors: !!silenceErrors
     });
   };
 

+ 4 - 0
desktop/core/src/desktop/static/desktop/less/hue-cross-version.less

@@ -185,6 +185,10 @@ input[type='password']::-ms-reveal {
   filter: blur(5px);
 }
 
+.hue-warning {
+  color: @hue-warning-color !important;
+}
+
 .hue-ace-syntax-error {
   position: absolute;
   border-bottom: 1px dotted @hue-error-color;

+ 11 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -2016,8 +2016,18 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
           <!-- /ko -->
           <!-- ko if: filteredTables().length > 0 -->
           <ul class="database-tree assist-tables" data-bind="foreachVisible: { data: activeTables, minHeight: 23, container: '.assist-db-scrollable' }">
+            <!-- ko if: hasErrors -->
+            <li class="assist-table hue-warning" title="${ _('Error loading table details.') }">
+              <span class="assist-entry">
+                <i class="hue-warning fa fa-fw muted valign-middle fa-warning"></i>
+                <span data-bind="text: definition.displayName"></span>
+              </span>
+            </li>
+            <!-- /ko -->
+            <!-- ko ifnot: hasErrors -->
             <!-- ko template: { if: definition.isTable || definition.isView, name: 'assist-table-entry' } --><!-- /ko -->
             <!-- ko template: { ifnot: definition.isTable || definition.isView, name: 'assist-column-entry' } --><!-- /ko -->
+            <!-- /ko -->
           </ul>
           <!-- /ko -->
         </div>
@@ -2209,7 +2219,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
                 delete activeTableIndex[key];
                 updateTables = true;
               } else if (!activeTableIndex[key].loaded) {
-                activeTableIndex[key].loadEntries();
+                activeTableIndex[key].loadEntries(function () {}, true);
               }
             });
 

Some files were not shown because too many files changed in this diff