瀏覽代碼

HUE-5929 [metastore] Show sample API errors in the panel instead of as a page notification

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

+ 4 - 0
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -280,6 +280,7 @@ var MetastoreViewModel = (function () {
     self.apiHelper = options.apiHelper;
     self.i18n = options.i18n;
 
+    self.hasErrors = ko.observable(false);
     self.loaded = ko.observable(false);
     self.loading = ko.observable(true);
 
@@ -294,10 +295,12 @@ var MetastoreViewModel = (function () {
     if (self.loaded()) {
       return;
     }
+    self.hasErrors(false);
     self.apiHelper.fetchTableSample({
       sourceType: "hive",
       databaseName: self.metastoreTable.database.name,
       tableName: self.metastoreTable.name,
+      silenceErrors: true,
       successCallback: function (data) {
         self.rows(data.rows);
         self.headers(data.headers);
@@ -307,6 +310,7 @@ var MetastoreViewModel = (function () {
         self.loaded(true);
       },
       errorCallback: function (data) {
+        self.hasErrors(true);
         self.loading(false);
         self.loaded(true);
       }

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

@@ -646,7 +646,7 @@ ${ components.menubar() }
   <div class="tile">
     <h4>${ _('Sample') } <i data-bind="visible: samples.loading" class='fa fa-spinner fa-spin' style="display: none;"></i></h4>
     <!-- ko with: samples -->
-      <!-- ko if: loaded -->
+      <!-- ko if: loaded() && !hasErrors() -->
         <!-- ko with: preview -->
         <!-- ko template: { if: rows().length, name: 'metastore-samples-table' } --><!-- /ko -->
         <a class="pointer" data-bind="visible: rows().length >= 3, click: function() { $('li a[href=\'#sample\']').click(); }"  style="display: none;">
@@ -656,6 +656,9 @@ ${ components.menubar() }
         <div data-bind="visible: !rows().length && metastoreTable.tableDetails().is_view" style="display: none;">${ _('The view does not contain any data.') }</div>
         <div data-bind="visible: !rows().length && !metastoreTable.tableDetails().is_view" style="display: none;">${ _('The table does not contain any data.') }</div>
       <!-- /ko -->
+      <!-- ko if: hasErrors() -->
+      <div>${ _('Could not load the sample, see the server log for details.') }</div>
+      <!-- /ko -->
     <!-- /ko -->
   </div>
 
@@ -705,11 +708,14 @@ ${ components.menubar() }
     <i data-bind="visible: loading" class='fa fa-spinner fa-spin' style="display: none;"></i>
   </div>
   <!-- /ko -->
-  <!-- ko if: loaded -->
+  <!-- ko if: loaded() && !hasErrors() -->
   <!-- ko template: { if: rows().length, name: 'metastore-samples-table' } --><!-- /ko -->
   <div data-bind="visible: !rows().length && metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The view does not contain any data.') }</div>
   <div data-bind="visible: !rows().length && !metastoreTable.tableDetails().is_view" style="display: none;" class="empty-message">${ _('The table does not contain any data.') }</div>
   <!-- /ko -->
+  <!-- ko if: hasErrors() -->
+  <div class="empty-message">${ _('Could not load the sample, see the server log for details.') }</div>
+  <!-- /ko -->
   <!-- /ko -->
 </script>