瀏覽代碼

HUE-4942 [metadata] Proof that we can have a different search by assist

Also renamed 'db' assist to 'hive'.
Romain Rigaux 9 年之前
父節點
當前提交
db47398

+ 15 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -500,7 +500,7 @@ from metadata.conf import has_navigator
     </div>
   </script>
 
-  <script type="text/html" id="assist-db-inner-panel">
+  <script type="text/html" id="assist-hive-inner-panel">
     <div class="assist-inner-panel">
       <div class="assist-flex-panel">
         <!-- ko template: { if: breadcrumb() !== null, name: 'assist-db-breadcrumb' } --><!-- /ko -->
@@ -596,6 +596,9 @@ from metadata.conf import has_navigator
         </div>
         <!-- /ko -->
       </div>
+      <!-- ko with: $parents[1] -->
+      <!-- ko template: { if: (searchInput() !== '' || searchHasFocus()) && navigatorEnabled(), name: 'nav-search-result' } --><!-- /ko -->
+      <!-- /ko -->
     </div>
   </script>
 
@@ -830,6 +833,9 @@ from metadata.conf import has_navigator
     <div style="position:absolute; left:0; right: 0; top: 0; bottom: 0; overflow: hidden; background-color: #FFF;">
       <!-- ko hueSpinner: { spin: searching, center: true, size: 'large' } --><!-- /ko -->
       <!-- ko if: !searching() -->
+      <!-- ko if: searchResult().length == 0 -->
+        ${ _('No result found.') }
+      <!-- /ko -->
       <!-- ko foreach: searchResult -->
       <div class="result-entry">
         <div class="icon-col">
@@ -1250,7 +1256,7 @@ from metadata.conf import has_navigator
             }, params.sql)),
             apiHelper: self.apiHelper,
             name: '${ _("SQL") }',
-            type: 'db',
+            type: 'hive',
             icon: 'fa-database',
             minHeight: 75
           })
@@ -1307,7 +1313,7 @@ from metadata.conf import has_navigator
           $.post('/metadata/api/navigator/search_entities', {
             query_s: self.searchInput(),
             limit: 25,
-            sources: ko.mapping.toJSON($.map(self.availablePanels[0].panelData.sources(), function(source) { return source.sourceType; })) // type empty for some reason, using name
+            sources: ko.mapping.toJSON([self.visiblePanel().type])
           })
           .done(function (data) {
             data.entities.forEach(function (entity) {
@@ -1339,6 +1345,12 @@ from metadata.conf import has_navigator
         };
 
         self.visiblePanel = ko.observable(self.availablePanels[0]);
+        self.visiblePanel.subscribe(function() {
+          if (self.navigatorEnabled()) {
+            lastQuery = 'refresh';
+            self.performSearch();
+          }
+        });
       }
 
       ko.components.register('assist-panel', {

+ 3 - 1
desktop/libs/metadata/src/metadata/navigator_client.py

@@ -74,12 +74,14 @@ class NavigatorApi(object):
       TODO: support smarter boolean searching with arbitrary ordering and precedence of conditionals
     """
     search_fields = ('originalName', 'originalDescription', 'name', 'description', 'tags')
-    entity_types = ('DATABASE', 'TABLE', 'PARTITION', 'FIELD', 'FILE', 'VIEW', 'OPERATION')
+    entity_types = ('DATABASE', 'TABLE', 'PARTITION', 'FIELD', 'FILE', 'VIEW', 'OPERATION', 'DIRECTORY')
 
     sources = filters.get('sources', [])
 
     if 'hive' in sources or 'impala' in sources:
       entity_types = ('TABLE', 'VIEW') # 'DATABASE', 'PARTITION', 'FIELD'
+    elif 'hdfs' in sources:
+      entity_types = ('FILE', 'DIRECTORY')
 
     try:
       params = self.__params

+ 3 - 3
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -539,8 +539,10 @@
       }
     });
 
-    function prepopulateChart(newValue) {
+    function prepopulateChart() {
       var type = self.chartType();
+      logGA('chart/' + type);
+
       if (type === ko.HUE_CHARTS.TYPES.MAP && self.chartMapLabel() === null && self.chartX() === null && self.result.cleanedNumericMeta().length === 2) {
         self.chartX(self.result.cleanedNumericMeta()[0].name);
         self.chartMapLabel(self.result.cleanedNumericMeta()[1].name);
@@ -556,8 +558,6 @@
       } else if (self.chartYSingle() === null && self.result.cleanedNumericMeta().length === 2 && (type === ko.HUE_CHARTS.TYPES.PIECHART || type === ko.HUE_CHARTS.TYPES.MAP || type === ko.HUE_CHARTS.TYPES.GRADIENTMAP || type === ko.HUE_CHARTS.TYPES.SCATTERCHART)) {
         self.chartYSingle(self.result.cleanedNumericMeta()[1].name);
       }
-
-      logGA('chart/' + newValue);
     }
 
     self.showChart.subscribe(function (val) {