You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rz...@apache.org on 2015/08/12 03:26:40 UTC
[2/3] ambari git commit: AMBARI-12655. Hosts Page Performance: Filter
update/save related problems (rzang)
AMBARI-12655. Hosts Page Performance: Filter update/save related problems (rzang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8b96592a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8b96592a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8b96592a
Branch: refs/heads/trunk
Commit: 8b96592a0e30fb01f8f4f81412b6bdd972255e2e
Parents: 38d5eaf
Author: Richard Zang <rz...@apache.org>
Authored: Wed Aug 5 17:30:40 2015 -0700
Committer: Richard Zang <rz...@apache.org>
Committed: Tue Aug 11 18:22:20 2015 -0700
----------------------------------------------------------------------
.../mixins/common/table_server_view_mixin.js | 26 ++++++++++++++++++++
ambari-web/app/views/common/table_view.js | 12 +++++++--
.../common/table_server_view_mixin_test.js | 8 +++---
3 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/8b96592a/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 76c2167..3716d42 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -75,6 +75,9 @@ App.TableServerViewMixin = Em.Mixin.create({
* @param type
*/
updateFilter: function (iColumn, value, type) {
+ // Do not even trigger update flow if it's a blank update
+ if (this.isBlankFilterUpdate(iColumn, value, type)) { return; }
+
var self = this;
this.set('controller.resetStartIndex', false);
this.saveFilterConditions(iColumn, value, type, false);
@@ -91,6 +94,29 @@ App.TableServerViewMixin = Em.Mixin.create({
},
/**
+ * 1) Has previous saved filter
+ * 2) Value to update is empty
+ * 3) Value to update is same as before
+ * Returns true if (!1&&2 || 1&&3)
+ * @param iColumn
+ * @param value
+ * @param type
+ * @returns {boolean|*}
+ */
+ isBlankFilterUpdate: function(iColumn, value, type) {
+ var result = false;
+ var filterConfitions = this.get('filterConditions');
+ var filterCondition = filterConfitions? filterConfitions.findProperty('iColumn', iColumn) : null;
+ if ((!filterCondition && Em.isEmpty(value))
+ || (filterCondition && filterCondition.value == value)
+ || (filterCondition && typeof filterCondition.value == 'object'
+ && JSON.stringify(filterCondition.value) == JSON.stringify(value))) {
+ result = true;
+ }
+ return result;
+ },
+
+ /**
* success callback for updater request
*/
updaterSuccessCb: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/8b96592a/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js
index 9a8426b..12bf9f3 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -104,7 +104,7 @@ App.TableView = Em.View.extend(App.UserPref, {
var name = this.get('controller.name');
var self = this;
var filterConditions = App.db.getFilterConditions(name);
- if (filterConditions) {
+ if (!Em.isEmpty(filterConditions)) {
this.set('filterConditions', filterConditions);
var childViews = this.get('childViews');
@@ -367,6 +367,8 @@ App.TableView = Em.View.extend(App.UserPref, {
};
this.get('filterConditions').push(filterCondition);
}
+ // remove empty entries
+ this.set('filterConditions', this.get('filterConditions').filter(function(item){ return !Em.isEmpty(item.value); }));
App.db.setFilterConditions(this.get('controller.name'), this.get('filterConditions'));
},
@@ -383,7 +385,13 @@ App.TableView = Em.View.extend(App.UserPref, {
},
clearFilterCondition: function() {
- App.db.setFilterConditions(this.get('controller.name'), null);
+ var result = false;
+ var currentFCs = App.db.getFilterConditions(this.get('controller.name'));
+ if (currentFCs != null) {
+ App.db.setFilterConditions(this.get('controller.name'), null);
+ result = true;
+ }
+ return result;
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/8b96592a/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 60e0663..4944a7b 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
@@ -147,18 +147,18 @@ describe('App.MainConfigHistoryView', function() {
this.clock = sinon.useFakeTimers();
view.set('filteringComplete', false);
- view.updateFilter(1, '', 'string');
+ view.updateFilter(1, '1', 'string');
expect(view.get('controller.resetStartIndex')).to.be.false;
- expect(view.saveFilterConditions.calledWith(1, '', 'string', false)).to.be.true;
+ expect(view.saveFilterConditions.calledWith(1, '1', 'string', false)).to.be.true;
view.set('filteringComplete', true);
this.clock.tick(view.get('filterWaitingTime'));
- expect(view.updateFilter.calledWith(1, '', 'string')).to.be.true;
+ expect(view.updateFilter.calledWith(1, '1', 'string')).to.be.true;
this.clock.restore();
});
it('filteringComplete is true', function() {
view.set('filteringComplete', true);
- view.updateFilter(1, '', 'string');
+ view.updateFilter(1, '1', 'string');
expect(view.get('controller.resetStartIndex')).to.be.true;
expect(view.refresh.calledOnce).to.be.true;
});