فهرست منبع

AMBARI-5489. Security wizard (HDP-2.1 stack) : browser refresh stops the execution of the wizard on deploy step. (jaimin via yusaku)

Yusaku Sako 11 سال پیش
والد
کامیت
ce9a6eff41

+ 3 - 4
ambari-web/app/controllers/main/admin/security/add/step4.js

@@ -68,9 +68,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
     // no need to remove ATS component if YARN and ATS are not installed
     if (this.get('secureServices').findProperty('serviceName', 'YARN') && App.Service.find('YARN').get('hostComponents').someProperty('componentName', 'APP_TIMELINE_SERVER')) {
       this.get('commands').splice(2, 0, App.Poll.create({name: 'DELETE_ATS', label: Em.I18n.translations['admin.addSecurity.apply.delete.ats'], isPolling: false}));
-      this.set('totalSteps', 4);
     }
-    this.setIndex(this.get('commands'));
   },
 
   loadStep: function () {
@@ -84,7 +82,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
       }, this);
       if (commands.someProperty('isError', true)) {
         this.get('commands').pushObjects(commands);
-        this.addObserver('commands.@each.isSuccess', this, 'onCompleteCommand');
+        this.addObserverToCommands();
         return;
       } else if (commands.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
         var runningCommand = commands.filterProperty('isStarted', true).findProperty('isCompleted', false);
@@ -103,10 +101,11 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
         stopCommand.set('requestId', stopAllOperation.get('id'));
       }
     }
-    this.addObserver('commands.@each.isSuccess', this, 'onCompleteCommand');
+    this.addObserverToCommands();
     this.moveToNextCommand();
   },
 
+
   enableSubmit: function () {
     var addSecurityController = App.router.get('addSecurityController');
     if (this.get('commands').someProperty('isError', true) || this.get('commands').everyProperty('isSuccess', true)) {

+ 2 - 2
ambari-web/app/controllers/main/admin/security/disable.js

@@ -38,7 +38,7 @@ App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController
       if (commands.someProperty('isError', true)) {
         this.get('commands').pushObjects(commands);
         this.loadSecureServices();
-        this.addObserver('commands.@each.isSuccess', this, 'onCompleteCommand');
+        this.addObserverToCommands();
         return;
       } else if (commands.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
         var runningCommand = commands.filterProperty('isStarted', true).findProperty('isCompleted', false);
@@ -58,7 +58,7 @@ App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController
       }
     }
     this.loadSecureServices();
-    this.addObserver('commands.@each.isSuccess', this, 'onCompleteCommand');
+    this.addObserverToCommands();
     this.moveToNextCommand();
   },
 

+ 8 - 3
ambari-web/app/controllers/main/admin/security/security_progress_controller.js

@@ -85,17 +85,22 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
       App.Poll.create({name: 'APPLY_CONFIGURATIONS', label: Em.I18n.translations['admin.addSecurity.apply.save.config'], isPolling: false }),
       App.Poll.create({name: 'START_SERVICES', label: Em.I18n.translations['admin.addSecurity.apply.start.services'], isPolling: true })
     ]);
+  },
+
+  addObserverToCommands: function() {
     this.setIndex(this.get('commands'));
+    this.addObserver('commands.@each.isSuccess', this, 'onCompleteCommand');
   },
 
   setIndex: function(commandArray) {
     commandArray.forEach(function(command,index){
       command.set('index',index+1);
     },this);
+    this.set('totalSteps', commandArray.length);
   },
 
   startCommand: function (commnad) {
-    if (this.get('commands').length === this.totalSteps) {
+    if (this.get('commands').length === this.get('totalSteps')) {
       if (!commnad) {
         var startedCommand = this.get('commands').filterProperty('isStarted', true);
         commnad = startedCommand.findProperty('isCompleted', false);
@@ -126,7 +131,7 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
 
 
   onCompleteCommand: function () {
-    if (this.get('commands').length === this.totalSteps) {
+    if (this.get('commands').length === this.get('totalSteps')) {
       var index = this.get('commands').filterProperty('isSuccess', true).length;
       if (index > 0) {
         var lastCompletedCommandResult = this.get('commands').objectAt(index - 1).get('isSuccess');
@@ -330,7 +335,7 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
 
   saveCommands: function () {
     var commands = [];
-    if (this.get('commands').length === this.totalSteps) {
+    if (this.get('commands').length === this.get('totalSteps')) {
       this.get('commands').forEach(function (_command) {
         var command = {
           name: _command.get('name'),

+ 0 - 7
ambari-web/test/controllers/main/admin/security/add/step4_test.js

@@ -99,9 +99,6 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
         expect(controller.get('commands').length).to.eql(4);
       });
 
-      it('total steps should be equal to 4', function() {
-        expect(controller.get('totalSteps')).to.eql(4);
-      });
     });
 
     describe('YARN installed without ATS', function() {
@@ -129,10 +126,6 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
       it('commands length should be equal to 3', function() {
         expect(controller.get('commands').length).to.eql(3);
       });
-
-      it('total steps should be equal to 3', function() {
-        expect(controller.get('totalSteps')).to.eql(3);
-      });
     });
 
   });