Browse Source

AMBARI-6353 Hosts page: filtering by hostname sometimes displays incorrect result after overlay goes away (but eventually catches up). (ababiichuk)

aBabiichuk 11 years ago
parent
commit
e04dc67a6d
1 changed files with 13 additions and 5 deletions
  1. 13 5
      ambari-web/app/mixins/common/tableServerProvider.js

+ 13 - 5
ambari-web/app/mixins/common/tableServerProvider.js

@@ -24,6 +24,8 @@ App.TableServerProvider = Em.Mixin.create({
   updaterBinding: 'App.router.updateController',
   filteringComplete: true,
   filterConditions: [],
+  filterWaitingTime: 500,
+  timeOut: null,
   /**
    * total number of entities in table
    */
@@ -48,9 +50,6 @@ App.TableServerProvider = Em.Mixin.create({
    */
   refresh: function () {
     var self = this;
-
-    if (!this.get('filteringComplete')) return false;
-
     this.set('filteringComplete', false);
     var updaterMethodName = this.get('updater.tableUpdaterMap')[this.get('tableName')];
     this.get('updater')[updaterMethodName](function () {
@@ -83,8 +82,17 @@ App.TableServerProvider = Em.Mixin.create({
    * @param type {String}
    */
   updateFilter: function (iColumn, value, type) {
-    this.saveFilterConditions(iColumn, value, type, false);
-    this.refresh();
+    var self = this;
+    if (!this.get('filteringComplete')) {
+      clearTimeout(this.get('timeOut'));
+      this.set('timeOut', setTimeout(function() {
+        self.updateFilter(iColumn, value, type);
+      }, this.get('filterWaitingTime')));
+    } else {
+      clearTimeout(this.get('timeOut'));
+      this.saveFilterConditions(iColumn, value, type, false);
+      this.refresh();
+    }
   },
 
   /**