Browse Source

AMBARI-8094. Install Wizard completely breaks after install fails and going back to a previous step. (jaimin)

Jaimin Jetly 10 years ago
parent
commit
29c42549b4
2 changed files with 15 additions and 4 deletions
  1. 2 2
      ambari-web/app/router.js
  2. 13 2
      ambari-web/app/routes/installer.js

+ 2 - 2
ambari-web/app/router.js

@@ -124,7 +124,7 @@ App.Router = Em.Router.extend({
   },
 
   onAuthenticationSuccess: function (data) {
-    this.set('loggedIn', true);
+    this.setAuthenticated(true);
     if (data.items.length) {
       this.setClusterInstalled(data);
     }
@@ -132,7 +132,7 @@ App.Router = Em.Router.extend({
 
   onAuthenticationError: function (data) {
     if (data.status === 403) {
-      this.set('loggedIn', false);
+      this.setAuthenticated(false);
     } else {
       console.log('error in getAuthenticated');
     }

+ 13 - 2
ambari-web/app/routes/installer.js

@@ -42,18 +42,28 @@ module.exports = Em.Route.extend({
             console.log('current step=' + router.get('installerController.currentStep'));
             Ember.run.next(function () {
               var installerController = router.get('installerController');
-
               App.clusterStatus.updateFromServer().complete(function () {
                 var currentClusterStatus = App.clusterStatus.get('value');
-
+                //@TODO: Clean up  following states. Navigation should be done solely via currentStep stored in the localDb and API persist endpoint.
+                //       Actual currentStep value for the installer controller should always remain in sync with localdb and at persist store in the server.
                 if (currentClusterStatus) {
                   switch (currentClusterStatus.clusterState) {
                     case 'CLUSTER_NOT_CREATED_1' :
+                      var localDb = currentClusterStatus.localdb;
+                      if (localDb && localDb.Installer && localDb.Installer.currentStep) {
+                        App.db.data = currentClusterStatus.localdb;
+                        App.router.setAuthenticated(true);
+                        var controllerName = installerController.get('name');
+                        var suffixLength = 10;
+                        var currentStep = App.get('router').getWizardCurrentStep(controllerName.substr(0, controllerName.length - suffixLength));
+                        installerController.setCurrentStep(currentStep);
+                      }
                       router.transitionTo('step' + installerController.get('currentStep'));
                       break;
                     case 'CLUSTER_DEPLOY_PREP_2' :
                       installerController.setCurrentStep('8');
                       App.db.data = currentClusterStatus.localdb;
+                      App.router.setAuthenticated(true);
                       router.transitionTo('step' + installerController.get('currentStep'));
                       break;
                     case 'CLUSTER_INSTALLING_3' :
@@ -68,6 +78,7 @@ module.exports = Em.Route.extend({
                         installerController.setCurrentStep('10');
                       }
                       App.db.data = currentClusterStatus.localdb;
+                      App.router.setAuthenticated(true);
                       router.transitionTo('step' + installerController.get('currentStep'));
                       break;
                     case 'DEFAULT' :