Browse Source

HUE-8213 [assist] Improve table filter response snappiness

Johan Ahlen 7 years ago
parent
commit
ba50f50b5d

+ 4 - 4
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -74,7 +74,7 @@ var AssistDbSource = (function () {
     });
 
     self.filter = {
-      querySpec: ko.observable({})
+      querySpec: ko.observable({}).extend({ rateLimit: 300 })
     };
 
     self.filterActive = ko.pureComputed(function () {
@@ -189,9 +189,9 @@ var AssistDbSource = (function () {
     self.dbIndex = {};
 
     var nestedFilter = {
-      querySpec: ko.observable({}),
-      showTables: ko.observable(true),
-      showViews: ko.observable(true)
+      querySpec: ko.observable({}).extend({ rateLimit: 300 }),
+      showTables: ko.observable(true).extend({ rateLimit: 300 }),
+      showViews: ko.observable(true).extend({ rateLimit: 300 })
     };
 
     self.setDatabase = function (databaseName) {

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

@@ -268,7 +268,7 @@ from desktop.views import _ko
   <script type="text/html" id="assist-db-entries">
     <!-- ko if: ! hasErrors() && hasEntries() && ! loading() && filteredEntries().length == 0 -->
     <ul class="assist-tables">
-      <li class="assist-entry assist-no-entries"><!-- ko if: catalogEntry.isTable() -->${_('No columns found')}<!--/ko--><!-- ko if: catalogEntry.isDatabase() -->${_('No tables found')}<!--/ko--><!-- ko if: catalogEntry.isField() -->${_('No results found')}<!--/ko--></li>
+      <li class="assist-entry assist-no-entries"><!-- ko if: catalogEntry.isTableOrView() -->${_('No columns found')}<!--/ko--><!-- ko if: catalogEntry.isDatabase() -->${_('No tables found')}<!--/ko--><!-- ko if: catalogEntry.isField() -->${_('No results found')}<!--/ko--></li>
     </ul>
     <!-- /ko -->
     <!-- ko if: ! hasErrors() && hasEntries() && ! loading() && filteredEntries().length > 0 -->
@@ -2379,7 +2379,7 @@ from desktop.views import _ko
             getFilteredTablesPureComputed: function (vm) {
               var openedByFilter = [];
               return ko.pureComputed(function () {
-                if (vm.filter == null || !vm.filter.querySpec() || ((!vm.filter.querySpec().facets || Object.keys(vm.filter.querySpec().facets).length === 0) && (!vm.filter.querySpec().text || vm.filter.querySpec().text.length === 0))) {
+                if (vm.filter === null || !vm.filter.querySpec() || ((!vm.filter.querySpec().facets || Object.keys(vm.filter.querySpec().facets).length === 0) && (!vm.filter.querySpec().text || vm.filter.querySpec().text.length === 0))) {
                   while (openedByFilter.length) {
                     openedByFilter.pop().open(false);
                   }
@@ -2483,9 +2483,9 @@ from desktop.views import _ko
             query: '',
             facets: {},
             text: []
-          }),
-          showViews: ko.observable(true),
-          showTables: ko.observable(true)
+          }).extend({ rateLimit: 300 }),
+          showViews: ko.observable(true).extend({ rateLimit: 300 }),
+          showTables: ko.observable(true).extend({ rateLimit: 300 })
         };
 
         self.filteredTables = AssistantUtils.getFilteredTablesPureComputed(self);
@@ -2528,7 +2528,7 @@ from desktop.views import _ko
           var added = {};
           var result = [];
           var partialLower = partial.toLowerCase();
-          self.activeTables().forEach(function (table) {
+          self.filteredTables().forEach(function (table) {
             if (!added[table.catalogEntry.name] && table.catalogEntry.name.toLowerCase().indexOf(partialLower) === 0) {
               added[table.catalogEntry.name] = true;
               result.push(nonPartial + partial + table.catalogEntry.name.substring(partial.length))
@@ -2966,7 +2966,7 @@ from desktop.views import _ko
             query: '',
             facets: {},
             text: []
-          })
+          }).extend({ rateLimit: 300 })
         };
 
         self.activeTables = ko.observableArray();