ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [2/5] ambari git commit: AMBARI-9864. Double spinner appears after "clear filters" press on Hosts page (alexantonenko)
Date Sun, 01 Mar 2015 22:22:16 GMT
AMBARI-9864. Double spinner appears after "clear filters" press on Hosts page (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/303628ce
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/303628ce
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/303628ce

Branch: refs/heads/trunk
Commit: 303628ce396ee3427099d1c8bf2c29fb75d65f54
Parents: 95de72e
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Sun Mar 1 20:36:43 2015 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Mon Mar 2 00:19:40 2015 +0200

----------------------------------------------------------------------
 .../app/mixins/common/table_server_view_mixin.js  | 17 +++++++++++++++++
 ambari-web/app/views/main/host.js                 |  9 ++-------
 .../mixins/common/table_server_view_mixin_test.js | 18 ++++++++++++++++++
 3 files changed, 37 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/303628ce/ambari-web/app/mixins/common/table_server_view_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_view_mixin.js b/ambari-web/app/mixins/common/table_server_view_mixin.js
index 111be84..e46bd2e 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -87,6 +87,23 @@ App.TableServerViewMixin = Em.Mixin.create({
       this.refresh();
     }
   },
+
+  /**
+   * success callback for updater request
+   */
+  updaterSuccessCb: function () {
+    clearTimeout(this.get('timeOut'));
+    this.set('filteringComplete', true);
+    this.propertyDidChange('pageContent');
+  },
+
+  /**
+   * error callback for updater request
+   */
+  updaterErrorCb: function () {
+    this.set('requestError', arguments);
+  },
+
   /**
    * synchronize properties of view with controller to generate query parameters
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/303628ce/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js
index c7b7e56..7f49486 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -91,17 +91,12 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
    * called when trigger property(<code>refreshTriggers</code>) is changed
    */
   refresh: function () {
-    var self = this;
     this.set('filteringComplete', false);
     var updaterMethodName = this.get('updater.tableUpdaterMap')[this.get('tableName')];
-    this.get('updater')[updaterMethodName](function () {
-      self.set('filteringComplete', true);
-      self.propertyDidChange('pageContent');
-    }, function() {
-      self.set('requestError', arguments);
-    });
+    this.get('updater')[updaterMethodName](this.updaterSuccessCb.bind(this), this.updaterErrorCb.bind(this));
     return true;
   },
+
   /**
    * reset filters value by column to which filter belongs
    * @param columns {Array}

http://git-wip-us.apache.org/repos/asf/ambari/blob/303628ce/ambari-web/test/mixins/common/table_server_view_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/table_server_view_mixin_test.js b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
index 51d9d4c..60e0663 100644
--- a/ambari-web/test/mixins/common/table_server_view_mixin_test.js
+++ b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
@@ -162,6 +162,24 @@ describe('App.MainConfigHistoryView', function() {
       expect(view.get('controller.resetStartIndex')).to.be.true;
       expect(view.refresh.calledOnce).to.be.true;
     });
+
+    it('clear filters - refresh() clears timer', function () {
+      this.clock = sinon.useFakeTimers();
+
+      //clear filters simulation
+      view.set('filteringComplete', false);
+      view.updateFilter(0, '', 'string');
+
+      //filters cleared success
+      view.updaterSuccessCb();
+
+      //timeout in updateFilter() runs out
+      this.clock.tick(view.get('filterWaitingTime'));
+
+      //should not call update filter again
+      expect(view.updateFilter.calledOnce).to.be.true;
+      this.clock.restore();
+    })
   });
 
   describe('#resetStartIndex()', function() {


Mime
View raw message