ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-18111. Interactive Query configs are not reset after refresh/back on Install Wizard.
Date Thu, 11 Aug 2016 18:12:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 2acc46fe1 -> 54efb18f5


AMBARI-18111. Interactive Query configs are not reset after refresh/back on Install Wizard.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/54efb18f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/54efb18f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/54efb18f

Branch: refs/heads/branch-2.4
Commit: 54efb18f5f7e7b15a2f50b997798f1acb2f7970a
Parents: 2acc46f
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Thu Aug 11 11:18:00 2016 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Thu Aug 11 11:18:00 2016 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         | 39 ++++++++++++++++----
 ambari-web/app/controllers/wizard.js            | 13 ++++++-
 .../app/controllers/wizard/step5_controller.js  |  7 ++++
 .../app/controllers/wizard/step6_controller.js  |  5 +++
 .../wizard/step7/assign_master_controller.js    | 15 +++++---
 .../app/controllers/wizard/step7_controller.js  |  4 +-
 .../mixins/wizard/assign_master_components.js   |  3 ++
 ambari-web/app/routes/installer.js              |  7 +++-
 ambari-web/test/controllers/installer_test.js   | 24 ++++++++++++
 .../step7/assign_master_controller_test.js      |  5 ++-
 .../test/controllers/wizard/step7_test.js       |  2 +-
 11 files changed, 105 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index a2bac41..f8f70a0 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -42,6 +42,8 @@ App.InstallerController = App.WizardController.extend({
     slaveGroupProperties: null,
     stacks: null,
     clients: [],
+    // list of components, that was added from configs page via AssignMasterOnStep7Controller
+    componentsFromConfigs: [],
     /**
      * recommendations for host groups loaded from server
      */
@@ -80,7 +82,8 @@ App.InstallerController = App.WizardController.extend({
     'hostInfo',
     'recommendations',
     'recommendationsHostGroups',
-    'recommendationsConfigs'
+    'recommendationsConfigs',
+    'componentsFromConfigs'
   ],
 
   init: function () {
@@ -473,8 +476,9 @@ App.InstallerController = App.WizardController.extend({
   /**
    * Save Master Component Hosts data to Main Controller
    * @param stepController App.WizardStep5Controller
+   * @param  skip  {Boolean}
    */
-  saveMasterComponentHosts: function (stepController) {
+  saveMasterComponentHosts: function (stepController, skip) {
     var obj = stepController.get('selectedServicesMasters'),
       hosts = this.getDBProperty('hosts');
 
@@ -489,22 +493,24 @@ App.InstallerController = App.WizardController.extend({
       });
     });
 
-    this.setDBProperty('masterComponentHosts', masterComponentHosts);
     this.set('content.masterComponentHosts', masterComponentHosts);
+    if (!skip) {
+      this.setDBProperty('masterComponentHosts', masterComponentHosts);
+    }
   },
 
   /**
    * Load master component hosts data for using in required step controllers
+   * @param inMemory {Boolean}: Load master component hosts from memory
    */
-  loadMasterComponentHosts: function () {
+  loadMasterComponentHosts: function (inMemory) {
     var props = this.getDBProperties(['masterComponentHosts', 'hosts']);
-    var masterComponentHosts = props.masterComponentHosts,
+    var masterComponentHosts = !!inMemory ? this.get("content.masterComponentHosts") : props.masterComponentHosts,
       hosts = props.hosts || {},
       hostNames = Em.keys(hosts);
     if (Em.isNone(masterComponentHosts)) {
       masterComponentHosts = [];
-    }
-    else {
+    } else {
       masterComponentHosts.forEach(function (component) {
         for (var i = 0; i < hostNames.length; i++) {
           if (hosts[hostNames[i]].id === component.host_id) {
@@ -975,6 +981,7 @@ App.InstallerController = App.WizardController.extend({
           this.setSkipSlavesStep(App.StackService.find().filterProperty('isSelected'), 6);
           this.loadMasterComponentHosts();
           this.loadConfirmedHosts();
+          this.loadComponentsFromConfigs();
           this.loadRecommendations();
         }
       }
@@ -985,6 +992,7 @@ App.InstallerController = App.WizardController.extend({
         callback: function () {
           this.loadSlaveComponentHosts();
           this.loadClients();
+          this.loadComponentsFromConfigs();
           this.loadRecommendations();
         }
       }
@@ -997,11 +1005,28 @@ App.InstallerController = App.WizardController.extend({
           this.loadServiceConfigProperties();
           this.loadCurrentHostGroups();
           this.loadRecommendationsConfigs();
+          this.loadComponentsFromConfigs();
           return this.loadConfigThemes();
         }
       }
     ]
   },
+
+
+  clearConfigActionComponents: function() {
+    var masterComponentHosts = this.get('content.masterComponentHosts');
+    var componentsAddedFromConfigAction = this.get('content.componentsFromConfigs');
+
+    if (componentsAddedFromConfigAction && componentsAddedFromConfigAction.length)
{
+      componentsAddedFromConfigAction.forEach(function(_masterComponent){
+        masterComponentHosts = masterComponentHosts.rejectProperty('component', _masterComponent);
+      });
+    }
+    this.set('content.masterComponentHosts', masterComponentHosts);
+    this.setDBProperty('masterComponentHosts', masterComponentHosts);
+  },
+
+
   /**
    * Clear all temporary data
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 2eab760..def6b84 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -44,7 +44,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     'installOptions',
     'allHostNamesPattern',
     'serviceComponents',
-    'fileNamesToUpdate'
+    'fileNamesToUpdate',
+    'componentsFromConfigs'
   ],
 
   sensibleConfigs: [
@@ -1406,6 +1407,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     this.set('content.requestIds', requestIds);
   },
 
+  saveComponentsFromConfigs: function (componentsFromConfigs) {
+    this.set('content.componentsFromConfigs', componentsFromConfigs);
+    this.setDBProperty('componentsFromConfigs', componentsFromConfigs);
+  },
+
+  loadComponentsFromConfigs: function() {
+    var componentsFromConfigs = this.getDBProperty('componentsFromConfigs');
+    this.set('content.componentsFromConfigs', componentsFromConfigs);
+  },
+
   loadRecommendations: function () {
     this.set("content.recommendations", this.getDBProperty('recommendations'));
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index 5597165..8736652 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -29,4 +29,11 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, App.AssignM
     }
   },
 
+  _additionalClearSteps: function() {
+    var parentController = App.router.get(this.get('content.controllerName'));
+    if (parentController && parentController.get('content.componentsFromConfigs'))
{
+      parentController.clearConfigActionComponents();
+    }
+  }
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index 24b03f9..1697028 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -300,6 +300,11 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin,
{
    */
   loadStep: function () {
     this.clearStep();
+    var parentController = App.router.get(this.get('content.controllerName'));
+    if (parentController && parentController.get('content.componentsFromConfigs'))
{
+      parentController.clearConfigActionComponents();
+    }
+
     var selectedServices = App.StackService.find().filterProperty('isSelected');
     var installedServices = App.StackService.find().filterProperty('isInstalled');
     var services;

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
index f369143..1d21b62 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -186,8 +186,8 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
    */
   removeMasterComponent: function () {
     var componentsToDelete = this.get('mastersToCreate');
+    var componentsFromConfigs = this.get('content.componentsFromConfigs');
     if (this.get('content.controllerName')) {
-      var parentController = App.router.get(this.get('content.controllerName'));
       var masterComponentHosts = this.get('content.masterComponentHosts');
       var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
       componentsToDelete.forEach(function (_componentName) {
@@ -195,10 +195,11 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
         recommendationsHostGroups.blueprint.host_groups.forEach(function(hostGroup){
           hostGroup.components = hostGroup.components.rejectProperty('name', _componentName);
         }, this);
+        componentsFromConfigs = componentsFromConfigs.without(_componentName);
       }, this);
       this.get('content').set('masterComponentHosts', masterComponentHosts);
-      parentController.setDBProperty('masterComponentHosts', masterComponentHosts);
-      parentController.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
+      this.set('content.componentsFromConfigs', componentsFromConfigs);
+      this.set('content.recommendationsHostGroups', recommendationsHostGroups);
     } else {
       this.clearComponentsToBeAdded(componentsToDelete[0]);
       var hostComponent = App.HostComponent.find().findProperty('componentName', componentsToDelete[0]);
@@ -289,8 +290,11 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
    */
   saveMasterComponentHosts: function() {
     var controller = App.router.get(this.get('content.controllerName'));
-    controller.saveMasterComponentHosts(this);
+    var componentsFromConfigs = this.get('content.componentsFromConfigs');
+    controller.saveMasterComponentHosts(this, true);
     controller.loadMasterComponentHosts();
+    componentsFromConfigs = componentsFromConfigs.concat(this.get('mastersToCreate'));
+    this.set('content.componentsFromConfigs', componentsFromConfigs);
   },
 
   /**
@@ -299,7 +303,6 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
    * @method {saveRecommendationsHostGroups}
    */
   saveRecommendationsHostGroups: function() {
-    var controller = App.router.get(this.get('content.controllerName'));
     var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
     var mastersToCreate = this.get('mastersToCreate');
     mastersToCreate.forEach(function(componentName) {
@@ -324,7 +327,7 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
         }
       }
     }, this);
-    controller.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
+    this.set('content.recommendationsHostGroups', recommendationsHostGroups);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 2b7bbcc..9e4845c 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -563,6 +563,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
           serviceConfig.set('description', serviceConfig.get('description') + notEditableText);
           serviceConfig.set('isReconfigurable', false);
           config.isReconfigurable = false;
+          serviceConfig.set('isEditable', false);
+          config.isEditable = false;
         }
       }
     }, this);
@@ -1178,7 +1180,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
       if (isServiceInstalled) {
         isEditable = config.get('isReconfigurable') && selectedGroup.get('isDefault');
       } else {
-        isEditable = selectedGroup.get('isDefault');
+        isEditable = isEditable  && selectedGroup.get('isDefault');
       }
       if (config.get('group')) {
         isEditable = config.get('group.name') === this.get('selectedConfigGroup.name');

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/mixins/wizard/assign_master_components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js
index decafcc..46409b2 100644
--- a/ambari-web/app/mixins/wizard/assign_master_components.js
+++ b/ambari-web/app/mixins/wizard/assign_master_components.js
@@ -528,6 +528,9 @@ App.AssignMasterComponents = Em.Mixin.create({
    */
   loadStep: function () {
     this.clearStep();
+    if (this._additionalClearSteps) {
+      this._additionalClearSteps();
+    }
     this.renderHostInfo();
     this.loadComponentsRecommendationsFromServer(this.loadStepCallback);
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index 6aa8d8c..5b00aa2 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -358,11 +358,13 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
             App.set('router.nextBtnClickInProgress', true);
             controller.saveSlaveComponentHosts(wizardStep6Controller);
             controller.get('content').set('serviceConfigProperties', null);
+            controller.get('content').set('componentsFromConfigs', []);
             controller.setDBProperties({
               serviceConfigProperties: null,
               serviceConfigGroups: null,
               recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
-              recommendationsConfigs: null
+              recommendationsConfigs: null,
+              componentsFromConfigs: []
             });
             router.transitionTo('step7');
             console.timeEnd('step6 next');
@@ -419,6 +421,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         controller.saveServiceConfigProperties(wizardStep7Controller);
         controller.saveServiceConfigGroups(wizardStep7Controller);
         controller.setDBProperty('recommendationsConfigs', wizardStep7Controller.get('recommendationsConfigs'));
+        controller.saveComponentsFromConfigs(controller.get('content.componentsFromConfigs'));
+        controller.setDBProperty('recommendationsHostGroup', wizardStep7Controller.get('recommendationsHostGroup'));
+        controller.setDBProperty('masterComponentHosts', wizardStep7Controller.get('masterComponentHosts'));
         router.transitionTo('step8');
         console.timeEnd('step7 next');
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 881d6ae..5b78cbc 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -547,6 +547,7 @@ describe('App.InstallerController', function () {
       var setSkipSlavesStep = false;
       var loadMasterComponentHosts = false;
       var loadConfirmedHosts = false;
+      var loadComponentsFromConfigs = false;
       var loadRecommendations = false;
 
       var checker = {
@@ -559,6 +560,9 @@ describe('App.InstallerController', function () {
         loadConfirmedHosts: function() {
           loadConfirmedHosts = true;
         },
+        loadComponentsFromConfigs: function() {
+          loadComponentsFromConfigs = true;
+        },
         loadRecommendations: function() {
           loadRecommendations = true;
         }
@@ -580,6 +584,10 @@ describe('App.InstallerController', function () {
         expect(loadMasterComponentHosts).to.be.true;
       });
 
+      it('components added via configs are loaded', function () {
+        expect(loadComponentsFromConfigs).to.be.true;
+      });
+
       it('recommendations are loaded', function() {
         expect(loadRecommendations).to.be.true;
       });
@@ -591,6 +599,7 @@ describe('App.InstallerController', function () {
       var loadServiceConfigProperties = false;
       var loadCurrentHostGroups = false;
       var loadRecommendationsConfigs = false;
+      var loadComponentsFromConfigs = false;
       var loadConfigThemes = false;
 
       var checker = {
@@ -606,6 +615,9 @@ describe('App.InstallerController', function () {
         loadRecommendationsConfigs: function() {
           loadRecommendationsConfigs = true;
         },
+        loadComponentsFromConfigs: function() {
+          loadComponentsFromConfigs = true;
+        },
         loadConfigThemes: function() {
           loadConfigThemes = true;
         }
@@ -631,6 +643,10 @@ describe('App.InstallerController', function () {
         expect(loadRecommendationsConfigs).to.be.true;
       });
 
+      it('components added via configs are loaded', function () {
+        expect(loadComponentsFromConfigs).to.be.true;
+      });
+
       it('config themes are loaded', function () {
         expect(loadConfigThemes).to.be.true;
       });
@@ -641,6 +657,7 @@ describe('App.InstallerController', function () {
       var loadSlaveComponentHosts = false;
       var loadClients = false;
       var loadRecommendations = false;
+      var loadComponentsFromConfigs = false;
 
       var checker = {
         loadSlaveComponentHosts: function() {
@@ -649,6 +666,9 @@ describe('App.InstallerController', function () {
         loadClients: function() {
           loadClients = true;
         },
+        loadComponentsFromConfigs: function() {
+          loadComponentsFromConfigs = true;
+        },
         loadRecommendations: function() {
           loadRecommendations = true;
         }
@@ -666,6 +686,10 @@ describe('App.InstallerController', function () {
         expect(loadClients).to.be.true;
       });
 
+      it('components added via configs are loaded', function () {
+        expect(loadComponentsFromConfigs).to.be.true;
+      });
+
       it('recommendations are loaded', function () {
         expect(loadRecommendations).to.be.true;
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
index 14c7e20..f1f6487 100644
--- a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
+++ b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
@@ -201,6 +201,7 @@ describe('App.AssignMasterOnStep7Controller', function () {
             {component: 'C1'},
             {component: 'C2'}
           ],
+          componentsFromConfigs: ["C1","C2"],
           recommendationsHostGroups: {
             blueprint: {host_groups: [{name: 'host-group-1', components: [{name: 'C1'}, {name:
'C2'}]}]},
             blueprint_cluster_binding: {host_groups: [{name: 'host-group-1', hosts: [{fqdn:
'localhost'}]}]}
@@ -214,7 +215,6 @@ describe('App.AssignMasterOnStep7Controller', function () {
       view.removeMasterComponent();
       expect(view.get('content.masterComponentHosts')).to.be.eql([{component: 'C1'}]);
       expect(view.get('content.recommendationsHostGroups').blueprint).to.be.eql({host_groups:
[{name: 'host-group-1', components: [{name: 'C1'}]}]});
-      expect(mock.setDBProperty.calledWith('masterComponentHosts', [{component: 'C1'}])).to.be.true;
     });
   });
 
@@ -342,7 +342,8 @@ describe('App.AssignMasterOnStep7Controller', function () {
       sinon.stub(mock, 'loadConfigRecommendations');
       view.reopen({
         content: Em.Object.create({
-          controllerName: 'ctrl1'
+          controllerName: 'ctrl1',
+          componentsFromConfigs: []
         }),
         selectedServicesMasters: [
           {

http://git-wip-us.apache.org/repos/asf/ambari/blob/54efb18f/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 0104405..3ec63d1 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -590,7 +590,7 @@ describe('App.InstallerStep7Controller', function () {
         selectedService: {serviceName: 'abc'},
         selectedConfigGroup: Em.Object.create({isDefault: isDefault})
       });
-      var config = Em.Object.create({isEditable: null});
+      var config = Em.Object.create({isEditable: true});
       var updatedConfig = installerStep7Controller._setEditableValue(config);
       expect(updatedConfig.get('isEditable')).to.equal(isDefault);
       installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');


Mime
View raw message