Browse Source

HUE-6928 [assist] Add filter to right assistant

Johan Ahlen 8 years ago
parent
commit
48a76df

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


+ 12 - 0
desktop/core/src/desktop/static/desktop/less/hue-assist.less

@@ -511,6 +511,13 @@
   white-space: nowrap;
 }
 
+.assist-flex-column-search {
+  overflow: hidden;
+  position: relative;
+  .flex(0 0 30px);
+  white-space: nowrap;
+}
+
 .assist-flex-hdfs-search,
 .assist-flex-documents-search,
 .assist-flex-function-search {
@@ -929,6 +936,11 @@
     color: @cui-gray-600;
   }
 
+  .col-filter-toggle {
+    float: right;
+    margin-right: 20px;
+  }
+
   .assist-active-tables {
     list-style: none;
     margin: 0;

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

@@ -199,7 +199,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
   </script>
 
   <script type="text/html" id="assist-table-entry">
-    <li class="assist-table" data-bind="appAwareTemplateContextMenu: { template: 'sql-context-items', scrollContainer: '.assist-db-scrollable' }, visibleOnHover: { override: statsVisible, selector: '.table-actions' }">
+    <li class="assist-table" data-bind="appAwareTemplateContextMenu: { template: 'sql-context-items', scrollContainer: '.assist-db-scrollable' }, visibleOnHover: { override: statsVisible() || navigationSettings.rightAssist, selector: '.table-actions' }">
       <div class="assist-actions table-actions" data-bind="css: { 'assist-actions-left': navigationSettings.rightAssist }" style="opacity: 0">
         <a class="inactive-action" href="javascript:void(0)" data-bind="visible: navigationSettings.showStats, click: showContextPopover, css: { 'blue': statsVisible }"><i class="fa fa-fw fa-info" title="${_('Show details')}"></i></a>
         <a class="inactive-action" href="javascript:void(0)" data-bind="visible: navigationSettings.openItem, click: openItem"><i class="fa fa-long-arrow-right" title="${_('Open')}"></i></a>
@@ -1864,16 +1864,23 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
 
         <div class="assist-flex-header">
           <div class="assist-inner-header">${ _('Tables') }
+            <a class="col-filter-toggle inactive-action" href="javascript:void(0)" data-bind="toggle: isFilterVisible, css: { 'blue': isFilterVisible }" title="Filter"><i class="pointer fa fa-filter"></i></a>
             <!-- ko if: statementCount() > 1 -->
             <div class="statement-count">${ _('Statement') } <span data-bind="text: activeStatementIndex() + '/' + statementCount()"></span></div>
             <!-- /ko -->
           </div>
         </div>
+        <div class="assist-flex-column-search" data-bind="visible: isFilterVisible">
+          <div class="assist-filter"><input id="searchInput" class="clearable" type="text" data-bind="clearable: filter.query, value: filter.query, valueUpdate: 'afterkeydown'" placeholder="${ _('Search...') }" /></div>
+        </div>
         <div class="assist-flex-half assist-db-scrollable">
-          <!-- ko if: activeTables().length === 0 -->
+          <!-- ko if: filteredTables().length === 0 && filter.query() === '' -->
           <div class="assist-no-entries">${ _('No tables identified.') }</div>
           <!-- /ko -->
-          <!-- ko if: activeTables().length > 0 -->
+          <!-- ko if: filteredTables().length === 0 && filter.query() !== '' -->
+          <div class="assist-no-entries">${ _('No entries found.') }</div>
+          <!-- /ko -->
+          <!-- ko if: filteredTables().length > 0 -->
           <ul class="database-tree assist-tables" data-bind="foreachVisible: { data: activeTables, minHeight: 23, container: '.assist-db-scrollable' }">
             <!-- ko template: { if: definition.isTable || definition.isView, name: 'assist-table-entry' } --><!-- /ko -->
             <!-- ko template: { ifnot: definition.isTable || definition.isView, name: 'assist-column-entry' } --><!-- /ko -->
@@ -1929,6 +1936,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
         self.statementCount = ko.observable(0);
         self.activeStatementIndex = ko.observable(0);
 
+        self.isFilterVisible = ko.observable(true);
+
         self.hasActiveRisks = ko.pureComputed(function () {
            return self.activeRisks().hints && self.activeRisks().hints.length > 0;
         });
@@ -1954,11 +1963,34 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
         var databaseIndex = {};
 
         var activeTableIndex = {};
-        var filter = {
+
+        self.filter = {
           query: ko.observable(''),
           showViews: ko.observable(true),
           showTables: ko.observable(true)
         };
+
+        var openedByFilter = [];
+
+        self.filteredTables = ko.pureComputed(function () {
+          if (self.filter.query() === '' || !self.isFilterVisible()) {
+            while (openedByFilter.length) {
+              openedByFilter.pop().open(false);
+            }
+            return self.activeTables();
+          }
+          return self.activeTables().filter(function (table) {
+            if (table.filteredEntries().length > 0) {
+              if (!table.open()) {
+                table.open(true);
+                openedByFilter.push(table);
+              }
+              return true;
+            }
+            return false;
+          });
+        });
+
         var navigationSettings = {
           showStats: true,
           rightAssist: true
@@ -1996,11 +2028,11 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
                     },
                     null,
                     assistDbSource,
-                    filter,
+                    self.filter,
                     i18n,
                     navigationSettings,
                     {}
-                  )
+                  );
                 }
                 var qid = createQualifiedIdentifier(location.identifierChain);
                 tableQidIndex[qid] = true;
@@ -2017,7 +2049,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
                     },
                     databaseIndex[database],
                     assistDbSource,
-                    filter,
+                    self.filter,
                     {},
                     navigationSettings,
                     {}
@@ -2030,6 +2062,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
               if (!tableQidIndex[key]) {
                 delete activeTableIndex[key];
                 updateTables = true;
+              } else if (!activeTableIndex[key].loaded) {
+                activeTableIndex[key].loadEntries();
               }
             });
 

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