|
@@ -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('stages.@each.isSuccess', 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('stages.@each.isSuccess', 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('stages.@each.isCompleted'),
|
|
|
|
|
|
- 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('stages.@each.isStarted'),
|
|
|
+ },
|
|
|
|
|
|
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('stages.@each.isCompleted'),
|
|
|
+ },
|
|
|
+
|
|
|
+ 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('stages.@each.requestId'),
|
|
|
+
|
|
|
+ saveStagesOnCompleted: function () {
|
|
|
+ var nonPollingStages = this.get('stages').filterProperty('isPolling', false).someProperty('isCompleted', true);
|
|
|
+ if (nonPollingStages) {
|
|
|
+ this.saveStages();
|
|
|
+ }
|
|
|
+ }.observes('stages.@each.isCompleted'),
|
|
|
+
|
|
|
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('stages.@each.requestId')
|
|
|
+ }
|
|
|
|
|
|
});
|