Browse Source

AMBARI-6411. Add Host Wizard does not work if page refresh is issued on Review page. (jaimin)

Jaimin Jetly 11 years ago
parent
commit
18183be428

+ 0 - 2
ambari-web/app/controllers/main/host/addHost/step4_controller.js

@@ -21,8 +21,6 @@ var App = require('app');
 App.AddHostStep4Controller= Em.Controller.extend({
 
   name:"addHostStep4Controller",
-
-  serviceConfigGroups: null,
   isConfigGroupLoaded: false,
 
   loadConfigGroups: function () {

+ 27 - 7
ambari-web/app/controllers/main/host/add_controller.js

@@ -190,7 +190,7 @@ App.AddHostController = App.WizardController.extend({
    *  Apply config groups from step4 Configurations
    */
   applyConfigGroup: function () {
-    var serviceConfigGroups = this.get('content.serviceConfigGroups');
+    var serviceConfigGroups = this.get('content.configGroups');
     serviceConfigGroups.forEach(function (group) {
       if (group.configGroups.someProperty('ConfigGroup.group_name', group.selectedConfigGroup)) {
         var configGroup = group.configGroups.findProperty('ConfigGroup.group_name', group.selectedConfigGroup);
@@ -217,26 +217,25 @@ App.AddHostController = App.WizardController.extend({
    */
   getServiceConfigGroups: function () {
     var serviceConfigGroups = this.getDBProperty('serviceConfigGroups');
-    this.set('content.serviceConfigGroups', serviceConfigGroups);
+    this.set('content.configGroups', serviceConfigGroups);
   },
 
   /**
    * Save information about selected config groups
    */
   saveServiceConfigGroups: function () {
-    this.setDBProperty('serviceConfigGroups', this.get('content.serviceConfigGroups'));
-    this.set('content.serviceConfigGroups', this.get('content.serviceConfigGroups'));
+    this.setDBProperty('serviceConfigGroups', this.get('content.configGroups'));
   },
 
   /**
-   * Set content.serviceConfigGroups for step4
+   * Set content.configGroups for step4
    */
   loadServiceConfigGroups: function () {
     var selectedServices = [];
     this.loadServiceConfigGroupsBySlaves(selectedServices);
     this.loadServiceConfigGroupsByClients(selectedServices);
     this.sortServiceConfigGroups(selectedServices);
-    this.set('content.serviceConfigGroups', selectedServices);
+    this.set('content.configGroups', selectedServices);
   },
   /**
    * sort config groups by name
@@ -366,13 +365,34 @@ App.AddHostController = App.WizardController.extend({
     this.set('content.cluster', this.getCluster());
   },
 
+  clearStorageData: function () {
+    this._super();
+    App.db.cleanAddHost();
+  },
+
+  /**
+   * save the local db data stored on the server as value to the key api/v1/persist/CLUSTER_CURRENT_STATUS
+   */
+  saveClusterState: function () {
+    App.clusterStatus.setClusterStatus({
+      clusterName: App.router.getClusterName(),
+      clusterState: 'DEFAULT'
+    });
+  },
+
+  clearData: function () {
+    // Clear Add Host namespace in Browser Local storage and save it to server persist data
+    this.clearStorageData();
+    this.saveClusterState();
+  },
+
   /**
    * Clear all temporary data
    */
   finish: function () {
     this.setCurrentStep('1');
     this.clearAllSteps();
-    this.clearStorageData();
+    this.clearData();
     App.router.get('updateController').updateAll();
     App.updater.immediateRun('updateHost');
   },

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

@@ -22,13 +22,9 @@ module.exports = App.WizardRoute.extend({
   route: '/host/add',
 
   clearData: function (router) {
+    var addHostController = router.get('addHostController');
     App.router.get('updateController').set('isWorking', true);
-    App.clusterStatus.setClusterStatus({
-      clusterName: App.router.get('content.cluster.name'),
-      clusterState: 'DEFAULT',
-      wizardControllerName: App.router.get('addHostController.name'),
-      localdb: App.db.data
-    });
+    addHostController.finish();
     router.transitionTo('hosts.index');
   },
 
@@ -62,8 +58,6 @@ module.exports = App.WizardRoute.extend({
               body: Em.I18n.t('hosts.add.exit.body'),
               onPrimary: function () {
                 this.hide();
-                addHostController.finish();
-                App.router.get('updateController').set('isWorking', true);
                 self.clearData(router);
                 location.reload();
               }
@@ -353,12 +347,7 @@ module.exports = App.WizardRoute.extend({
         console.log('Request for hosts, with immutable parameters')
       });
       router.get('updateController').updateAll();
-      addHostController.finish();
       $(context.currentTarget).parents("#modal").find(".close").trigger('click');
-
-      // We need to do recovery based on whether we are in Add Host or Installer wizard
-      addHostController.saveClusterState('DEFAULT');
-
       location.reload();
     }
   }),

+ 1 - 1
ambari-web/app/templates/main/host/addHost/step4.hbs

@@ -29,7 +29,7 @@
           </tr>
         </thead>
         <tbody>
-          {{#each service in controller.content.serviceConfigGroups}}
+          {{#each service in controller.content.configGroups}}
             <tr>
               <td>{{service.displayName}}</td>
               <td>

+ 5 - 0
ambari-web/app/utils/db.js

@@ -81,6 +81,11 @@ App.db.cleanTmp = function() {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.cleanAddHost = function() {
+  App.db.data.AddHost = {};
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.updateStorage = function() {
   App.db.data = localStorage.getObject('ambari');
   if (App.db.data && App.db.data.app && App.db.data.app.tables && App.db.data.app.configs) {