Browse Source

AMBARI-13811 Typing fast in 'name' filter field of the Hosts table misses trailing character. (atkach)

Andrii Tkach 9 năm trước cách đây
mục cha
commit
101dc1d8fe

+ 2 - 2
ambari-web/app/mixins/common/table_server_view_mixin.js

@@ -80,7 +80,6 @@ App.TableServerViewMixin = Em.Mixin.create({
 
     var self = this;
     this.set('controller.resetStartIndex', false);
-    this.saveFilterConditions(iColumn, value, type, false);
     if (!this.get('filteringComplete')) {
       clearTimeout(this.get('timeOut'));
       this.set('timeOut', setTimeout(function () {
@@ -89,6 +88,8 @@ App.TableServerViewMixin = Em.Mixin.create({
     } else {
       clearTimeout(this.get('timeOut'));
       this.set('controller.resetStartIndex', true);
+      //save filter only when it's applied
+      this.saveFilterConditions(iColumn, value, type, false);
       this.refresh();
     }
   },
@@ -120,7 +121,6 @@ App.TableServerViewMixin = Em.Mixin.create({
    * success callback for updater request
    */
   updaterSuccessCb: function () {
-    clearTimeout(this.get('timeOut'));
     this.set('filteringComplete', true);
     this.propertyDidChange('pageContent');
     App.loadTimer.finish('Hosts Page');

+ 17 - 1
ambari-web/test/mixins/common/table_server_view_mixin_test.js

@@ -149,7 +149,7 @@ describe('App.MainConfigHistoryView', function() {
       view.set('filteringComplete', false);
       view.updateFilter(1, '1', 'string');
       expect(view.get('controller.resetStartIndex')).to.be.false;
-      expect(view.saveFilterConditions.calledWith(1, '1', 'string', false)).to.be.true;
+      expect(view.saveFilterConditions.called).to.be.false;
       view.set('filteringComplete', true);
       this.clock.tick(view.get('filterWaitingTime'));
       expect(view.updateFilter.calledWith(1, '1', 'string')).to.be.true;
@@ -160,6 +160,7 @@ describe('App.MainConfigHistoryView', function() {
 
       view.updateFilter(1, '1', 'string');
       expect(view.get('controller.resetStartIndex')).to.be.true;
+      expect(view.saveFilterConditions.calledWith(1, '1', 'string', false)).to.be.true;
       expect(view.refresh.calledOnce).to.be.true;
     });
 
@@ -212,4 +213,19 @@ describe('App.MainConfigHistoryView', function() {
       expect(view.get('startIndex')).to.equal(1);
     });
   });
+
+  describe("#updaterSuccessCb()", function () {
+    beforeEach(function () {
+      sinon.stub(view, 'propertyDidChange');
+    });
+    afterEach(function () {
+      view.propertyDidChange.restore();
+    });
+    it("", function () {
+      view.set('filteringComplete', false);
+      view.updaterSuccessCb();
+      expect(view.propertyDidChange.calledWith('pageContent')).to.be.true;
+      expect(view.get('filteringComplete')).to.be.true;
+    });
+  });
 });

+ 1 - 0
ambari-web/test/views/main/dashboard/config_history_view_test.js

@@ -256,6 +256,7 @@ describe('App.MainConfigHistoryView', function() {
     ];
     beforeEach(function () {
       sinon.stub(view, 'saveFilterConditions', Em.K);
+      view.set('filteringComplete', true);
     });
     afterEach(function () {
       view.saveFilterConditions.restore();