浏览代码

HUE-6059 [assist] Show authentication error messages in the assist search

Johan Ahlen 8 年之前
父节点
当前提交
f4bb8bc

+ 5 - 0
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -1689,6 +1689,11 @@ var ApiHelper = (function () {
           source: 'navigator',
           source: 'navigator',
           message: data.message.message
           message: data.message.message
         })
         })
+      } else if (data.status === -2 && typeof data.message !== 'undefined') {
+        options.errorCallback({
+          source: 'navigator',
+          message: data.message
+        })
       } else {
       } else {
         self.assistErrorCallback(options)(data);
         self.assistErrorCallback(options)(data);
       }
       }

+ 14 - 0
desktop/core/src/desktop/templates/assist_search.mako

@@ -94,8 +94,13 @@ from notebook.conf import ENABLE_QUERY_BUILDER
         <!-- ko hueSpinner: { spin: searching, center: true, size: 'large' } --><!-- /ko -->
         <!-- ko hueSpinner: { spin: searching, center: true, size: 'large' } --><!-- /ko -->
         <!-- ko if: !searching() -->
         <!-- ko if: !searching() -->
         <!-- ko if: hasErrors() -->
         <!-- ko if: hasErrors() -->
+        <!-- ko if: errorMessage() !== '' -->
+        <div class="result-entry" data-bind="text: errorMessage"></div>
+        <!-- /ko -->
+        <!-- ko if: errorMessage() === '' -->
         <div class="result-entry">${ _('Error searching, see logs for details.') }</div>
         <div class="result-entry">${ _('Error searching, see logs for details.') }</div>
         <!-- /ko -->
         <!-- /ko -->
+        <!-- /ko -->
         <!-- ko ifnot: hasErrors() -->
         <!-- ko ifnot: hasErrors() -->
         <!-- ko if: searchResult().length == 0 -->
         <!-- ko if: searchResult().length == 0 -->
         <div class="result-entry">${ _('No result found.') }</div>
         <div class="result-entry">${ _('No result found.') }</div>
@@ -159,6 +164,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER
         self.searchResult = ko.observableArray();
         self.searchResult = ko.observableArray();
 
 
         self.hasErrors = ko.observable(false);
         self.hasErrors = ko.observable(false);
+        self.errorMessage = ko.observable('');
         self.searchHasFocus = ko.observable(false);
         self.searchHasFocus = ko.observable(false);
         self.searching = ko.observable(false);
         self.searching = ko.observable(false);
         self.searchActive = ko.observable(false);
         self.searchActive = ko.observable(false);
@@ -196,6 +202,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER
           lastQuery = self.searchInput();
           lastQuery = self.searchInput();
           self.searching(true);
           self.searching(true);
           self.hasErrors(false);
           self.hasErrors(false);
+          self.errorMessage('');
 
 
           var showInAssist = function (entry) {
           var showInAssist = function (entry) {
             self.searchInput('');
             self.searchInput('');
@@ -265,6 +272,13 @@ from notebook.conf import ENABLE_QUERY_BUILDER
             if (typeof data.entities === 'undefined') {
             if (typeof data.entities === 'undefined') {
               data.entities = [];
               data.entities = [];
             }
             }
+            if (data.status === -2) {
+              self.hasErrors(true);
+              if (typeof data.message !== 'undefined') {
+                self.errorMessage(data.message);
+              }
+              return;
+            }
             data.entities.forEach(function (entity) {
             data.entities.forEach(function (entity) {
               entity.statsVisible = ko.observable(false);
               entity.statsVisible = ko.observable(false);
               entity.showNavContextPopoverDelayed = showNavContextPopoverDelayed;
               entity.showNavContextPopoverDelayed = showNavContextPopoverDelayed;