You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/01/09 12:43:57 UTC

ambari git commit: AMBARI-9057. Alerts UI: need to preserve filtering, sorting and paging results (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 37e3f924e -> 0e8b717b2


AMBARI-9057. Alerts UI: need to preserve filtering, sorting and paging results (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 0e8b717b246fc9534efa93ef5c588804b415a6ce
Parents: 37e3f92
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Fri Jan 9 13:29:19 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Fri Jan 9 13:29:19 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/views/common/filter_view.js      |  4 +--
 .../app/views/main/alert_definitions_view.js    | 31 ++++++++++++++++++++
 .../views/main/alert_definitions_view_test.js   | 10 +++++--
 3 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0e8b717b/ambari-web/app/views/common/filter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/filter_view.js b/ambari-web/app/views/common/filter_view.js
index 137fac4..2145254 100644
--- a/ambari-web/app/views/common/filter_view.js
+++ b/ambari-web/app/views/common/filter_view.js
@@ -142,9 +142,7 @@ var wrapperView = Ember.View.extend({
   /**
    * Callback for value changes
    */
-  onChangeValue: function () {
-
-  },
+  onChangeValue: Em.K,
 
   /**
    * Filter components is located here. Should be redefined

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e8b717b/ambari-web/app/views/main/alert_definitions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alert_definitions_view.js b/ambari-web/app/views/main/alert_definitions_view.js
index 8786c66..e90d8a9 100644
--- a/ambari-web/app/views/main/alert_definitions_view.js
+++ b/ambari-web/app/views/main/alert_definitions_view.js
@@ -32,7 +32,22 @@ App.MainAlertDefinitionsView = App.TableView.extend({
   willInsertElement: function () {
     if (!this.get('controller.showFilterConditionsFirstLoad')) {
       this.clearFilterCondition();
+      this.clearStartIndex();
     }
+    this.removeObserver('filteredCount', this, 'updatePaging');
+    this.removeObserver('displayLength', this, 'updatePaging');
+    var startIndex = App.db.getStartIndex(this.get('controller.name'));
+    this._super();
+    this.set('startIndex', startIndex ? startIndex : 1);
+    this.addObserver('filteredCount', this, 'updatePaging');
+    this.addObserver('displayLength', this, 'updatePaging');
+  },
+
+  /**
+   * Method is same as in the parentView, but observes are set in the <code>willInsertElement</code>
+   * and not in the declaration
+   */
+  updatePaging: function () {
     this._super();
   },
 
@@ -45,6 +60,22 @@ App.MainAlertDefinitionsView = App.TableView.extend({
   },
 
   /**
+   * Save <code>startIndex</code> to the localStorage
+   * @method saveStartIndex
+   */
+  saveStartIndex: function() {
+    App.db.setStartIndex(this.get('controller.name'), this.get('startIndex'));
+  }.observes('startIndex'),
+
+  /**
+   * Clear <code>startIndex</code> from the localStorage
+   * @method clearStartIndex
+   */
+  clearStartIndex: function () {
+    App.db.setStartIndex(this.get('controller.name'), null);
+  },
+
+  /**
    * @type {number}
    */
   totalCount: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e8b717b/ambari-web/test/views/main/alert_definitions_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alert_definitions_view_test.js b/ambari-web/test/views/main/alert_definitions_view_test.js
index 0e8773c..b9796d1 100644
--- a/ambari-web/test/views/main/alert_definitions_view_test.js
+++ b/ambari-web/test/views/main/alert_definitions_view_test.js
@@ -41,22 +41,26 @@ describe('App.MainAlertDefinitionsView', function () {
 
     beforeEach(function(){
       sinon.stub(view, 'clearFilterCondition', Em.K);
+      sinon.stub(view, 'clearStartIndex', Em.K);
     });
 
     afterEach(function(){
       view.clearFilterCondition.restore();
+      view.clearStartIndex.restore();
     });
 
-    it('should call clearFilterCondition if controller.showFilterConditionsFirstLoad is false', function () {
+    it('should call clearFilterCondition, clearStartIndex if controller.showFilterConditionsFirstLoad is false', function () {
       view.set('controller', {showFilterConditionsFirstLoad: false, content: []});
       view.willInsertElement();
       expect(view.clearFilterCondition.calledOnce).to.be.true;
+      expect(view.clearStartIndex.calledOnce).to.be.true;
     });
 
-    it('should not call clearFilterCondition if controller.showFilterConditionsFirstLoad is true', function () {
+    it('should not call clearFilterCondition, clearStartIndex if controller.showFilterConditionsFirstLoad is true', function () {
       view.set('controller', {showFilterConditionsFirstLoad: true, content: []});
       view.willInsertElement();
-      expect(view.clearFilterCondition.calledOnce).to.be.false;
+      expect(view.clearFilterCondition.called).to.be.false;
+      expect(view.clearStartIndex.called).to.be.false;
     });
   });