Browse Source

AMBARI-4208 Add Service Wizard: Removing group from installed service not applied to configs. (Denys Buzhor via atkach)

atkach 11 years ago
parent
commit
67bc855462

+ 4 - 1
ambari-web/app/controllers/main/service/info/configs.js

@@ -1907,18 +1907,21 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         if (!this.get('enablePrimary')) {
           return false;
         }
+        var modifiedConfigGroups = this.get('subViewController.hostsModifiedConfigGroups');
         // Save modified config-groups
         if (!!controller) {
           controller.set('selectedService.configGroups', App.router.get('manageConfigGroupsController.configGroups'));
           controller.selectedServiceObserver();
           if (controller.get('name') == "wizardStep7Controller") {
+            if (controller.get('selectedService.selected') === false && modifiedConfigGroups.toDelete.length > 0) {
+              controller.setGroupsToDelete(modifiedConfigGroups.toDelete);
+            }
             App.config.persistWizardStep7ConfigGroups();
             this.updateConfigGroupOnServicePage();
           }
           this.hide();
           return;
         }
-        var modifiedConfigGroups = this.get('subViewController.hostsModifiedConfigGroups');
         console.log("manageConfigurationGroups(): Saving modified config-groups: ", modifiedConfigGroups);
         var self = this;
         var errors = [];

+ 13 - 0
ambari-web/app/controllers/wizard/step7_controller.js

@@ -52,6 +52,8 @@ App.WizardStep7Controller = Em.Controller.extend({
 
   configGroups: [],
 
+  groupsToDelete: [],
+
   selectedConfigGroup: null,
 
   serviceConfigsData: require('data/service_configs'),
@@ -320,6 +322,7 @@ App.WizardStep7Controller = Em.Controller.extend({
     if(this.get('allInstalledServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi){
       configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
     }
+    this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
     var localDB = {
       hosts: this.get('wizardController').getDBProperty('hosts'),
       masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
@@ -361,6 +364,16 @@ App.WizardStep7Controller = Em.Controller.extend({
     }
   },
 
+  setGroupsToDelete: function(groups) {
+    var groupsToDelete = this.get('groupsToDelete');
+    groups.forEach(function(group) {
+      if (group.get('id'))
+        groupsToDelete.push({
+          id: group.get('id')
+        });
+    });
+    this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
+  },
   selectedServiceObserver: function () {
     if (App.supports.hostOverridesInstaller && this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
       var serviceGroups = this.get('selectedService.configGroups');

+ 10 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -1487,6 +1487,10 @@ App.WizardStep8Controller = Em.Controller.extend({
     var sendData = [];
     var updateData = [];
     var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
+    var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
+    if (groupsToDelete && groupsToDelete.length > 0) {
+      this.removeInstalledServicesConfigurationGroups(groupsToDelete);
+    }
     configGroups.forEach(function (configGroup) {
       var groupConfigs = [];
       var groupData = {
@@ -1542,6 +1546,12 @@ App.WizardStep8Controller = Em.Controller.extend({
     });
   },
 
+  removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
+    groupsToDelete.forEach(function(item) {
+      App.config.deleteConfigGroup(Em.Object.create(item));
+    });
+  },
+
   createGlobalSiteObj: function () {
     var globalSiteProperties = {};
     var globalSiteObj = this.get('globals');

+ 1 - 0
ambari-web/app/routes/add_service_routes.js

@@ -172,6 +172,7 @@ module.exports = Em.Route.extend({
         addServiceController.saveSlaveComponentHosts(wizardStep6Controller);
         addServiceController.get('content').set('serviceConfigProperties', null);
         addServiceController.setDBProperty('serviceConfigProperties', null);
+        addServiceController.setDBProperty('groupsToDelete', []);
         router.transitionTo('step4');
       }
     }