AMBARI-7196 Config history table pagination strange behavior. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8b26d8b0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8b26d8b0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8b26d8b0 Branch: refs/heads/branch-alerts-dev Commit: 8b26d8b0b215d3d8385a4051a070ddc6b2752e3f Parents: 3d29c28 Author: atkach <atk...@hortonworks.com> Authored: Mon Sep 8 15:01:17 2014 +0300 Committer: atkach <atk...@hortonworks.com> Committed: Mon Sep 8 15:01:17 2014 +0300 ---------------------------------------------------------------------- .../main/dashboard/config_history_controller.js | 6 ++++-- ambari-web/app/mixins/common/table_server_mixin.js | 3 --- .../app/views/main/dashboard/config_history_view.js | 11 ++++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8b26d8b0/ambari-web/app/controllers/main/dashboard/config_history_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/dashboard/config_history_controller.js b/ambari-web/app/controllers/main/dashboard/config_history_controller.js index a747017..41816bc 100644 --- a/ambari-web/app/controllers/main/dashboard/config_history_controller.js +++ b/ambari-web/app/controllers/main/dashboard/config_history_controller.js @@ -29,6 +29,8 @@ App.MainConfigHistoryController = Em.ArrayController.extend(App.TableServerMixin isPolling: false, totalCount: 0, filteredCount: 0, + timeoutRef: null, + resetStartIndex: true, mockUrl: '/data/configurations/service_versions.json', realUrl: function () { return App.apiPrefix + '/clusters/' + App.get('clusterName') + '/configurations/service_config_versions?<parameters>fields=service_config_version,user,group_id,group_name,is_current,createtime,service_name,service_config_version_note&minimal_response=true'; @@ -208,12 +210,12 @@ App.MainConfigHistoryController = Em.ArrayController.extend(App.TableServerMixin doPolling: function () { var self = this; - setTimeout(function () { + this.set('timeoutRef', setTimeout(function () { if (self.get('isPolling')) { self.load().done(function () { self.doPolling(); }) } - }, App.componentsUpdateInterval); + }, App.componentsUpdateInterval)); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b26d8b0/ambari-web/app/mixins/common/table_server_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/table_server_mixin.js b/ambari-web/app/mixins/common/table_server_mixin.js index d449125..41a0bf9 100644 --- a/ambari-web/app/mixins/common/table_server_mixin.js +++ b/ambari-web/app/mixins/common/table_server_mixin.js @@ -65,9 +65,6 @@ App.TableServerMixin = Em.Mixin.create({ var startIndex = App.db.getStartIndex(this.get('name')); if (!Em.isNone(startIndex)) { startIndex = (startIndex > 0) ? startIndex - 1 : startIndex; - if (this.get('resetStartIndex')) { - startIndex = 0; - } this.get('paginationProps').findProperty('name', 'startIndex').value = startIndex; } return this.get('paginationProps'); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b26d8b0/ambari-web/app/views/main/dashboard/config_history_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/config_history_view.js b/ambari-web/app/views/main/dashboard/config_history_view.js index feeae73..ea01bb6 100644 --- a/ambari-web/app/views/main/dashboard/config_history_view.js +++ b/ambari-web/app/views/main/dashboard/config_history_view.js @@ -24,7 +24,7 @@ App.MainConfigHistoryView = App.TableView.extend({ templateName: require('templates/main/dashboard/config_history'), controllerBinding: 'App.router.mainConfigHistoryController', - filteringComplete: true, + filteringComplete: false, timeOut: null, content: function () { @@ -59,7 +59,7 @@ App.MainConfigHistoryView = App.TableView.extend({ /** * synchronize properties of view with controller to generate query parameters */ - updatePagination: function () { + updatePagination: function (key) { if (!Em.isNone(this.get('displayLength'))) { App.db.setDisplayLength(this.get('controller.name'), this.get('displayLength')); this.get('controller.paginationProps').findProperty('name', 'displayLength').value = this.get('displayLength'); @@ -69,12 +69,15 @@ App.MainConfigHistoryView = App.TableView.extend({ this.get('controller.paginationProps').findProperty('name', 'startIndex').value = this.get('startIndex'); } - this.refresh(); + if (key !== 'SKIP_REFRESH') { + this.refresh(); + } }, didInsertElement: function () { this.addObserver('startIndex', this, 'updatePagination'); this.addObserver('displayLength', this, 'updatePagination'); + this.refresh(); this.set('controller.isPolling', true); this.get('controller').doPolling(); }, @@ -84,6 +87,7 @@ App.MainConfigHistoryView = App.TableView.extend({ */ willDestroyElement: function () { this.set('controller.isPolling', false); + clearTimeout(this.get('controller.timeoutRef')); }, sortView: sort.serverWrapperView, @@ -218,6 +222,7 @@ App.MainConfigHistoryView = App.TableView.extend({ resetStartIndex: function () { if (this.get('controller.resetStartIndex') && this.get('filteredCount') > 0) { this.set('startIndex', 1); + this.updatePagination('SKIP_REFRESH'); } }.observes('controller.resetStartIndex')