Updated Branches: refs/heads/trunk 6573ac0d5 -> 66a7a7f66
AMBARI-2630: Security wizard: wrong behavior for retry stage 2. (jaimin) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/66a7a7f6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/66a7a7f6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/66a7a7f6 Branch: refs/heads/trunk Commit: 66a7a7f66b03859f97d6cb29b9f23dadb74b7849 Parents: 6573ac0 Author: Jaimin Jetly <[email protected]> Authored: Thu Jul 11 13:44:53 2013 -0700 Committer: Jaimin Jetly <[email protected]> Committed: Thu Jul 11 13:45:07 2013 -0700 ---------------------------------------------------------------------- .../main/admin/security/add/step4.js | 70 ++++++++++------- .../controllers/main/admin/security/disable.js | 80 +++++++++++++------- ambari-web/app/routes/add_security.js | 8 +- ambari-web/app/utils/polling.js | 1 + 4 files changed, 101 insertions(+), 58 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/66a7a7f6/ambari-web/app/controllers/main/admin/security/add/step4.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/security/add/step4.js b/ambari-web/app/controllers/main/admin/security/add/step4.js index 7f6180a..4a8d26e 100644 --- a/ambari-web/app/controllers/main/admin/security/add/step4.js +++ b/ambari-web/app/controllers/main/admin/security/add/step4.js @@ -28,6 +28,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ secureServices: [], serviceConfigTags: [], globalProperties: [], + totalSteps: 3, isSubmitDisabled: true, isBackBtnDisabled: function () { @@ -72,13 +73,12 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ }, retry: function () { - if (this.get('stages').someProperty('isError', true)) { - var failedStages = this.get('stages').filterProperty('isError', true); - failedStages.setEach('isError', false); - failedStages.setEach('isSuccess', false); - failedStages.setEach('isStarted', false); + var failedStage = this.get('stages').findProperty('isError', true); + if (failedStage) { + failedStage.set('isStarted', false); + failedStage.set('isError', false); + this.startStage(failedStage); } - this.moveToNextStage(); }, loadStep: function () { @@ -92,6 +92,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ }, this); if (stages.someProperty('isError', true)) { this.get('stages').pushObjects(stages); + this.addObserver('[email protected]', this.onCompleteStage); return; } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) { var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false); @@ -110,6 +111,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ stopStage.set('requestId', stopAllOperation.get('id')); } } + this.addObserver('[email protected]', this.onCompleteStage); this.moveToNextStage(); }, @@ -157,38 +159,46 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ ]); }, - startStage: function () { - var startedStages = this.get('stages').filterProperty('isStarted', true); - if (startedStages.length) { - var currentStage = startedStages.findProperty('isCompleted', false); + startStage: function (currentStage) { + if (this.get('stages').length === this.totalSteps) { + if (!currentStage) { + var startedStages = this.get('stages').filterProperty('isStarted', true); + currentStage = startedStages.findProperty('isCompleted', false); + } if (currentStage && currentStage.get('isPolling') === true) { + currentStage.set('isStarted', true); currentStage.start(); } else if (currentStage && currentStage.get('stage') === 'stage3') { + currentStage.set('isStarted', true); if (App.testMode) { - currentStage.set('isSuccess', true); - App.router.get('mainAdminSecurityController').setAddSecurityWizardStatus(null); + currentStage.set('isError', false); + currentStage.set('isCompleted', true); } else { - this.loadClusterConfigs() + this.loadClusterConfigs(); } } } - }.observes('[email protected]'), + }, onCompleteStage: function () { - var index = this.get('stages').filterProperty('isCompleted', true).length; - if (index > 0) { - var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess'); - if (lastCompletedStageResult) { - this.moveToNextStage(); + if (this.get('stages').length === this.totalSteps) { + var index = this.get('stages').filterProperty('isSuccess', true).length; + if (index > 0) { + var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess'); + if (lastCompletedStageResult) { + var nextStage = this.get('stages').objectAt(index); + this.moveToNextStage(nextStage); + } } } - }.observes('[email protected]'), + }, - moveToNextStage: function () { - var leftStages = this.get('stages').filterProperty('isStarted', false); - var nextStage = leftStages.findProperty('isCompleted', false); + moveToNextStage: function (nextStage) { + if (!nextStage) { + nextStage = this.get('stages').findProperty('isStarted', false); + } if (nextStage) { - nextStage.set('isStarted', true); + this.startStage(nextStage); } }, @@ -613,9 +623,17 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ }, this); }, + saveStagesOnRequestId: function () { + this.saveStages(); + }.observes('[email protected]'), + + saveStagesOnCompleted: function () { + this.saveStages(); + }.observes('[email protected]'), + saveStages: function () { var stages = []; - if (this.get('stages').length === 3) { + if (this.get('stages').length === this.totalSteps) { this.get('stages').forEach(function (_stage) { var stage = { name: _stage.get('name'), @@ -642,5 +660,5 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({ }); } } - }.observes('[email protected]') + } }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/66a7a7f6/ambari-web/app/controllers/main/admin/security/disable.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/security/disable.js b/ambari-web/app/controllers/main/admin/security/disable.js index 6d1bf9e..77457d7 100644 --- a/ambari-web/app/controllers/main/admin/security/disable.js +++ b/ambari-web/app/controllers/main/admin/security/disable.js @@ -33,6 +33,7 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ services: [], serviceTimestamp: null, isSubmitDisabled: true, + totalSteps: 3, clearStep: function () { this.get('stages').clear(); @@ -41,13 +42,12 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ }, retry: function () { - if (this.get('stages').someProperty('isError', true)) { - var failedStages = this.get('stages').filterProperty('isError', true); - failedStages.setEach('isError', false); - failedStages.setEach('isSuccess', false); - failedStages.setEach('isStarted', false); + var failedStage = this.get('stages').findProperty('isError', true); + if (failedStage) { + failedStage.set('isStarted', false); + failedStage.set('isError', false); + this.startStage(failedStage); } - this.moveToNextStage(); }, loadStep: function () { @@ -59,6 +59,8 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ }, this); if (stages.someProperty('isError', true)) { this.get('stages').pushObjects(stages); + this.loadSecureServices(); + this.addObserver('[email protected]', this.onCompleteStage); return; } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) { var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false); @@ -78,6 +80,7 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ } } this.loadSecureServices(); + this.addObserver('[email protected]', this.onCompleteStage); this.moveToNextStage(); }, @@ -90,14 +93,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ ]); }, - - moveToNextStage: function () { - var nextStage = this.get('stages').findProperty('isStarted', false); - if (nextStage) { - nextStage.set('isStarted', true); - } - }, - enableSubmit: function () { if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) { this.set('isSubmitDisabled', false); @@ -106,32 +101,48 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ } }.observes('[email protected]'), - startStage: function () { - var startedStages = this.get('stages').filterProperty('isStarted', true); - if (startedStages.length) { - var currentStage = startedStages.findProperty('isCompleted', false); + startStage: function (currentStage) { + if (this.get('stages').length === this.totalSteps) { + if (!currentStage) { + var startedStages = this.get('stages').filterProperty('isStarted', true); + currentStage = startedStages.findProperty('isCompleted', false); + } if (currentStage && currentStage.get('isPolling') === true) { + currentStage.set('isStarted', true); currentStage.start(); } else if (currentStage && currentStage.get('stage') === 'stage3') { + currentStage.set('isStarted', true); if (App.testMode) { - currentStage.set('isSuccess', true); - this.moveToNextStage(); + currentStage.set('isError', false); + currentStage.set('isCompleted', true); } else { this.loadClusterConfigs(); } } } - }.observes('[email protected]'), + }, onCompleteStage: function () { - var index = this.get('stages').filterProperty('isCompleted', true).length; - if (index > 0) { - var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess'); - if (lastCompletedStageResult) { - this.moveToNextStage(); + if (this.get('stages').length === this.totalSteps) { + var index = this.get('stages').filterProperty('isSuccess', true).length; + if (index > 0) { + var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess'); + if (lastCompletedStageResult) { + var nextStage = this.get('stages').objectAt(index); + this.moveToNextStage(nextStage); + } } } - }.observes('[email protected]'), + }, + + moveToNextStage: function (nextStage) { + if (!nextStage) { + nextStage = this.get('stages').findProperty('isStarted', false); + } + if (nextStage) { + this.startStage(nextStage); + } + }, updateServices: function () { this.services.clear(); @@ -380,9 +391,20 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ }, this); }, + saveStagesOnRequestId: function () { + this.saveStages(); + }.observes('[email protected]'), + + saveStagesOnCompleted: function () { + var nonPollingStages = this.get('stages').filterProperty('isPolling', false).someProperty('isCompleted', true); + if (nonPollingStages) { + this.saveStages(); + } + }.observes('[email protected]'), + saveStages: function () { var stages = []; - if (this.get('stages').length === 3) { + if (this.get('stages').length === this.totalSteps) { this.get('stages').forEach(function (_stage) { var stage = { name: _stage.get('name'), @@ -409,6 +431,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({ }); } } - }.observes('[email protected]') + } }); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/66a7a7f6/ambari-web/app/routes/add_security.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_security.js b/ambari-web/app/routes/add_security.js index ac7e93e..dc57706 100644 --- a/ambari-web/app/routes/add_security.js +++ b/ambari-web/app/routes/add_security.js @@ -85,7 +85,7 @@ module.exports = Em.Route.extend({ clusterName: router.get('content.cluster.name'), clusterState: 'SECURITY_COMPLETED', wizardControllerName: router.get('addSecurityController.name'), - localdb: App.db.data + localdb: App.db.data.AddSecurity }); router.transitionTo('adminSecurity.index'); }, @@ -160,7 +160,6 @@ module.exports = Em.Route.extend({ var addSecurityController = router.get('addSecurityController'); var addSecurityStep2Controller = router.get('mainAdminSecurityAddStep2Controller'); addSecurityController.saveServiceConfigProperties(addSecurityStep2Controller); - App.db.setSecurityDeployStages(undefined); router.transitionTo('step3'); } }), @@ -188,7 +187,10 @@ module.exports = Em.Route.extend({ }) }, back: Em.Router.transitionTo('step2'), - next: Em.Router.transitionTo('step4') + next: function (router) { + App.db.setSecurityDeployStages(undefined); + router.transitionTo('step4'); + } }), step4: Em.Route.extend({ http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/66a7a7f6/ambari-web/app/utils/polling.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js index 717b819..2b05131 100644 --- a/ambari-web/app/utils/polling.js +++ b/ambari-web/app/utils/polling.js @@ -84,6 +84,7 @@ App.Poll = Em.Object.extend({ if (jsonData === null) { self.set('isSuccess', true); self.set('isError', false); + self.set('requestId',undefined); } else { var requestId = jsonData.Requests.id; self.set('requestId', requestId);
