AMBARI-6376. Excessive requests are sending on hosts page. (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7e370c3b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7e370c3b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7e370c3b Branch: refs/heads/trunk Commit: 7e370c3b632a1b0647b23dd6f290e2b124a0a7d2 Parents: ccc4c3b Author: Aleksandr Kovalenko <[email protected]> Authored: Thu Jul 3 23:13:14 2014 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Thu Jul 3 23:13:14 2014 +0300 ---------------------------------------------------------------------- .../app/mixins/common/tableServerProvider.js | 21 ++++++++------ ambari-web/app/views/common/sort_view.js | 3 +- ambari-web/app/views/common/table_view.js | 8 ++++-- ambari-web/app/views/main/host.js | 29 ++++++++------------ 4 files changed, 31 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7e370c3b/ambari-web/app/mixins/common/tableServerProvider.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/tableServerProvider.js b/ambari-web/app/mixins/common/tableServerProvider.js index 113f24e..b1942ce 100644 --- a/ambari-web/app/mixins/common/tableServerProvider.js +++ b/ambari-web/app/mixins/common/tableServerProvider.js @@ -83,15 +83,18 @@ App.TableServerProvider = Em.Mixin.create({ */ updateFilter: function (iColumn, value, type) { 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(); + this.saveFilterConditions(iColumn, value, type, false); + // if initial load finished + if (this.get('tableFilteringComplete')) { + 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.refresh(); + } } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/7e370c3b/ambari-web/app/views/common/sort_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/sort_view.js b/ambari-web/app/views/common/sort_view.js index 77db481..79ea140 100644 --- a/ambari-web/app/views/common/sort_view.js +++ b/ambari-web/app/views/common/sort_view.js @@ -199,7 +199,8 @@ var serverWrapperView = Em.View.extend({ var self = this; statuses.forEach(function (st) { if (st.status !== 'sorting') { - self.sort(childViews.findProperty('name', st.name), (st.status === 'sorting_desc')); + self.get('childViews').findProperty('name', childViews.findProperty('name', st.name).get('name')).set('status', st.status); + self.saveSortStatuses(); self.get('controller').set('sortingColumn', childViews.findProperty('name', st.name)); } else { childViews.findProperty('name', st.name).set('status', st.status); http://git-wip-us.apache.org/repos/asf/ambari/blob/7e370c3b/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 3e515bf..087df8f 100644 --- a/ambari-web/app/views/common/table_view.js +++ b/ambari-web/app/views/common/table_view.js @@ -82,19 +82,23 @@ App.TableView = Em.View.extend(App.UserPref, { var childViews = this.get('childViews'); - filterConditions.forEach(function(condition) { + filterConditions.forEach(function(condition, index, filteredConditions) { var view = !Em.isNone(condition.iColumn) && childViews.findProperty('column', condition.iColumn); if (view) { view.set('value', condition.value); Em.run.next(function() { view.showClearFilter(); + // check if it is the last iteration + if (filteredConditions.length - index - 1 === 0) { + self.set('tableFilteringComplete', true); + } }); } }); } else { this.clearFilters(); + this.set('tableFilteringComplete', true); } - self.set('tableFilteringComplete', true); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/7e370c3b/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 c20994c..c315ebf 100644 --- a/ambari-web/app/views/main/host.js +++ b/ambari-web/app/views/main/host.js @@ -105,7 +105,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, { */ paginationInfo: function () { return this.t('tableView.filters.paginationInfo').format(this.get('startIndex'), this.get('endIndex'), this.get('filteredCount')); - }.property('totalCount', 'endIndex', 'filteredCount'), + }.property('startIndex', 'endIndex', 'filteredCount'), paginationLeftClass: function () { if (this.get("startIndex") > 1 && this.get('filteringComplete')) { @@ -147,7 +147,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, { change: function () { this.get('parentView').saveDisplayLength(); var self = this; - if (this.get('parentView.startIndex') === 1) { + if (this.get('parentView.startIndex') === 1 || this.get('parentView.startIndex') === 0) { Ember.run.next(function () { self.get('parentView').updateViewProperty(); }); @@ -178,7 +178,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, { } else if (!this.get('startIndex')) { this.set('startIndex', 1); } - }.observes('displayLength', 'filteredCount'), + }, clearFiltersObs: function() { @@ -195,21 +195,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, { willInsertElement: function () { this._super(); this.set('startIndex', this.get('controller.startIndex')); - var filterConditions = App.db.getFilterConditions(this.get('controller.name')); - if (filterConditions) { - var childViews = this.get('childViews'); - filterConditions.forEach(function(condition) { - var view = !Em.isNone(condition.iColumn) && childViews.findProperty('column', condition.iColumn); - if (view) { - view.set('value', condition.value); - Em.run.next(function() { - view.showClearFilter(); - }); - } - }); - } else { - this.clearFilters(); - } this.addObserver('[email protected]', this, this.selectedHostsObserver); }, @@ -234,9 +219,17 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, { this.set('controller.isCountersUpdating', true); this.get('controller').updateStatusCounters(); this.addObserver('filteringComplete', this, this.overlayObserver); + this.addObserver('displayLength', this, this.updatePaging); + this.addObserver('filteredCount', this, this.updatePaging); this.overlayObserver(); }, + onInitialLoad: function () { + if (this.get('tableFilteringComplete')) { + this.refresh(); + } + }.observes('tableFilteringComplete'), + /** * synchronize properties of view with controller to generate query parameters */
