Repository: ambari Updated Branches: refs/heads/trunk 589faa74a -> 9b2291bfa
AMBARI-10237. 'Reload Page' popup issues: multiple instances, broken reload link, displaying popup after connection is established (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9b2291bf Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9b2291bf Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9b2291bf Branch: refs/heads/trunk Commit: 9b2291bfa33017cf3ce64214b4da2a9eb7fa7259 Parents: 589faa7 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Fri Mar 27 16:24:30 2015 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Fri Mar 27 16:24:30 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../app/controllers/wizard/step3_controller.js | 32 +++++----- .../app/controllers/wizard/step9_controller.js | 10 +++- ambari-web/app/mixins.js | 1 + ambari-web/app/mixins/common/reload_popup.js | 52 +++++++++++++++++ ambari-web/app/utils/polling.js | 16 +++-- ambari-web/app/views.js | 1 - .../views/common/modal_popups/reload_popup.js | 30 ---------- .../test/mixins/common/reload_popup_test.js | 61 ++++++++++++++++++++ 9 files changed, 152 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index de14b7c..c668a9f 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -138,6 +138,7 @@ var files = ['test/init_model_test', 'test/mixins/common/configs/enhanced_configs_test', 'test/mixins/common/chart/storm_linear_time_test', 'test/mixins/common/localStorage_test', + 'test/mixins/common/reload_popup_test', 'test/mixins/common/serverValidator_test', 'test/mixins/common/table_server_view_mixin_test', 'test/mixins/main/host/details/host_components/decommissionable_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/controllers/wizard/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js index 61cf64f..aeff5ad 100644 --- a/ambari-web/app/controllers/wizard/step3_controller.js +++ b/ambari-web/app/controllers/wizard/step3_controller.js @@ -20,7 +20,7 @@ var App = require('app'); var lazyloading = require('utils/lazy_loading'); var numberUtils = require('utils/number_utils'); -App.WizardStep3Controller = Em.Controller.extend({ +App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, { name: 'wizardStep3Controller', @@ -477,6 +477,7 @@ App.WizardStep3Controller = Em.Controller.extend({ * @return {$.ajax|null} */ doBootstrap: function () { + var self = this; if (this.get('stopBootstrap')) { return null; } @@ -496,12 +497,14 @@ App.WizardStep3Controller = Em.Controller.extend({ timeout: App.timeout }). then( - null, - function () { - App.showReloadPopup(); - console.log('Bootstrap failed'); - } - ); + function () { + self.closeReloadPopup(); + }, + function () { + self.showReloadPopup(); + console.log('Bootstrap failed'); + } + ); }, /** @@ -578,6 +581,7 @@ App.WizardStep3Controller = Em.Controller.extend({ if (this.get('stopBootstrap')) { return null; } + var self = this; return App.ajax.send({ name: 'wizard.step3.is_hosts_registered', sender: this, @@ -588,12 +592,14 @@ App.WizardStep3Controller = Em.Controller.extend({ timeout: App.timeout }). then( - null, - function () { - App.showReloadPopup(); - console.log('Error: Getting registered host information from the server'); - } - ); + function () { + self.closeReloadPopup(); + }, + function () { + self.showReloadPopup(); + console.log('Error: Getting registered host information from the server'); + } + ); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/controllers/wizard/step9_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js index e1bb090..4422f3f 100644 --- a/ambari-web/app/controllers/wizard/step9_controller.js +++ b/ambari-web/app/controllers/wizard/step9_controller.js @@ -18,7 +18,7 @@ var App = require('app'); var stringUtils = require('utils/string_utils'); -App.WizardStep9Controller = Em.Controller.extend({ +App.WizardStep9Controller = Em.Controller.extend(App.ReloadPopupMixin, { name: 'wizardStep9Controller', @@ -1023,6 +1023,7 @@ App.WizardStep9Controller = Em.Controller.extend({ * @return {$.ajax|null} */ getLogsByRequest: function (polling, requestId) { + var self = this; return App.ajax.send({ name: 'wizard.step9.load_log', sender: this, @@ -1034,9 +1035,12 @@ App.WizardStep9Controller = Em.Controller.extend({ }, success: 'getLogsByRequestSuccessCallback', error: 'getLogsByRequestErrorCallback' - }).retry({times: App.maxRetries, timeout: 3000}).then(null, + }).retry({times: App.maxRetries, timeout: 3000}).then( + function () { + self.closeReloadPopup(); + }, function () { - App.showReloadPopup(); + self.showReloadPopup(); console.log('Install services all retries failed'); } ); http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/mixins.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js index 7517c0d..52091c1 100644 --- a/ambari-web/app/mixins.js +++ b/ambari-web/app/mixins.js @@ -22,6 +22,7 @@ require('mixins/common/blueprint'); require('mixins/common/localStorage'); require('mixins/common/userPref'); +require('mixins/common/reload_popup'); require('mixins/common/serverValidator'); require('mixins/common/table_server_view_mixin'); require('mixins/common/table_server_mixin'); http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/mixins/common/reload_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/reload_popup.js b/ambari-web/app/mixins/common/reload_popup.js new file mode 100644 index 0000000..539d1d5 --- /dev/null +++ b/ambari-web/app/mixins/common/reload_popup.js @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +App.ReloadPopupMixin = Em.Mixin.create({ + + reloadPopup: null, + + showReloadPopup: function () { + var self = this; + if (!this.get('reloadPopup')) { + this.set('reloadPopup', App.ModalPopup.show({ + primary: null, + secondary: null, + showFooter: false, + header: this.t('app.reloadPopup.header'), + body: "<div id='reload_popup' class='alert alert-info'><div class='spinner'><span>" + + this.t('app.reloadPopup.text') + "</span></div></div><div><a href='javascript:void(null)' onclick='location.reload();'>" + + this.t('app.reloadPopup.link') + "</a></div>", + encodeBody: false, + onClose: function () { + self.set('reloadPopup', null); + this._super(); + } + })); + } + }, + + closeReloadPopup: function () { + var reloadPopup = this.get('reloadPopup'); + if (reloadPopup) { + reloadPopup.onClose(); + } + } + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/utils/polling.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js index aeff492..339efcf 100644 --- a/ambari-web/app/utils/polling.js +++ b/ambari-web/app/utils/polling.js @@ -17,7 +17,7 @@ */ var App = require('app'); -App.Poll = Em.Object.extend({ +App.Poll = Em.Object.extend(App.ReloadPopupMixin, { name: '', stage: '', label: '', @@ -151,6 +151,7 @@ App.Poll = Em.Object.extend({ */ startPolling: function () { if (!this.get('requestId')) return false; + var self = this; this.pollTaskLog(); App.ajax.send({ @@ -163,10 +164,15 @@ App.Poll = Em.Object.extend({ error: 'startPollingErrorCallback' }) .retry({times: App.maxRetries, timeout: App.timeout}) - .then(null, function () { - App.showReloadPopup(); - console.log('Install services all retries failed'); - }); + .then( + function () { + self.closeReloadPopup(); + }, + function () { + self.showReloadPopup(); + console.log('Install services all retries failed'); + } + ); return true; }, http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index f450182..a7719fc 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -30,7 +30,6 @@ require('views/common/modal_popups/alert_popup'); require('views/common/modal_popups/confirmation_feedback_popup'); require('views/common/modal_popups/confirmation_popup'); require('views/common/modal_popups/prompt_popup'); -require('views/common/modal_popups/reload_popup'); require('views/common/modal_popups/cluster_check_popup'); require('views/common/modal_popups/invalid_KDC_popup'); require('views/common/modal_popups/dependent_configs_list_popup'); http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/app/views/common/modal_popups/reload_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/reload_popup.js b/ambari-web/app/views/common/modal_popups/reload_popup.js deleted file mode 100644 index 0c5eaf0..0000000 --- a/ambari-web/app/views/common/modal_popups/reload_popup.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var App = require('app'); - -App.showReloadPopup = function () { - return App.ModalPopup.show({ - primary: null, - secondary: null, - showFooter: false, - header: this.t('app.reloadPopup.header'), - body: "<div id='reload_popup' class='alert alert-info'><div class='spinner'><span>" + this.t('app.reloadPopup.text') + "</span></div></div><div><a href='#' onclick='location.reload();'>" + this.t('app.reloadPopup.link') + "</a></div>", - encodeBody: false - }); -}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/9b2291bf/ambari-web/test/mixins/common/reload_popup_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/reload_popup_test.js b/ambari-web/test/mixins/common/reload_popup_test.js new file mode 100644 index 0000000..28c865a --- /dev/null +++ b/ambari-web/test/mixins/common/reload_popup_test.js @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +require('mixins/common/reload_popup'); + +describe('App.ReloadPopupMixin', function () { + + var obj; + + beforeEach(function () { + obj = Em.Object.create(App.ReloadPopupMixin); + }); + + describe('#showReloadPopup', function () { + + var mockObj = { + key: 'value' + }; + + beforeEach(function () { + sinon.stub(App.ModalPopup, 'show').returns(mockObj); + }); + + afterEach(function () { + App.ModalPopup.show.restore(); + }); + + it('should show modal popup', function () { + obj.showReloadPopup(); + expect(obj.get('reloadPopup')).to.eql(mockObj); + }); + }); + + describe('#closeReloadPopup', function () { + + it('should hide modal popup', function () { + obj.showReloadPopup(); + obj.closeReloadPopup(); + expect(obj.get('reloadPopup')).to.be.null; + }); + + }); + +});