You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/01/29 14:44:45 UTC

git commit: AMBARI-4455 Failure saving configuration in a new Host Config Group. (atkach)

Updated Branches:
  refs/heads/trunk 17da19222 -> 7bf2d3712


AMBARI-4455 Failure saving configuration in a new Host Config Group. (atkach)


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

Branch: refs/heads/trunk
Commit: 7bf2d37128dfc2264e190e1fa2626fbdb57be727
Parents: 17da192
Author: atkach <at...@hortonworks.com>
Authored: Wed Jan 29 15:44:40 2014 +0200
Committer: atkach <at...@hortonworks.com>
Committed: Wed Jan 29 15:44:40 2014 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  2 +-
 .../service/manage_config_groups_controller.js  | 20 ++------
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/utils/config.js                  | 49 ++++++++------------
 4 files changed, 25 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7bf2d371/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 2b8e6d0..874683a 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1937,7 +1937,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
               App.config.updateConfigurationGroup(cg, finishFunction, finishFunction);
             }, this);
             modifiedConfigGroups.toCreate.forEach(function (cg) {
-              App.config.createNewConfigurationGroup(cg.get('service.id'), cg.get('name'), cg.get('description'), cg.get('hosts'),  false, finishFunction);
+              App.config.postNewConfigurationGroup(cg, finishFunction);
             }, this);
           }
         };

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bf2d371/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index ae20d9a..f1677f7 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -188,21 +188,6 @@ App.ManageConfigGroupsController = Em.Controller.extend({
       App.showAlertPopup(Em.I18n.t('services.service.config_groups_popup.properties'), properies);
     }
   },
-  /**
-   * add hosts to group
-   * @return {Array}
-   */
-  componentsForFilter: function() {
-    var components = componentHelper.getInstalledComponents().filterProperty('serviceName', this.get('serviceName'));
-    return components.map(function(component) {
-      return Em.Object.create({
-        displayName: component.displayName,
-        componentName: component.id,
-        selected: false
-      });
-    });
-  }.property('serviceName'),
-
   addHosts: function () {
     if (this.get('selectedConfigGroup.isAddHostsDisabled')){
       return false;
@@ -263,7 +248,10 @@ App.ManageConfigGroupsController = Em.Controller.extend({
       self.deleteConfigGroup();
     });
   },
-
+  /**
+   * add hosts to group
+   * @return {Array}
+   */
   componentsForFilter: function () {
     return serviceComponents.filterProperty('service_name', this.get('serviceName')).map(function (component) {
       return Em.Object.create({

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bf2d371/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 8884af5..151983d 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1856,6 +1856,7 @@ Em.I18n.translations = {
   'config.group.save.confirmation.configGroup': 'Configuration Group',
   'config.group.save.confirmation.saved': 'has been successfully saved',
   'config.group.save.confirmation.manage.button': 'Manage Hosts',
+  'config.group.description.default': 'New configuration group created on {0}',
 
   'utils.ajax.errorMessage': 'Error message'
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bf2d371/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 18f6b1c..bc88a7a 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1118,7 +1118,18 @@ App.config = Em.Object.create({
           callback(selectedConfigGroup);
         } else {
           var newConfigGroupName = this.get('newConfigGroupName').trim();
-          var newConfigGroup = self.createNewConfigurationGroup(serviceId, newConfigGroupName, null, [], isInstaller);
+          var newConfigGroup = App.ConfigGroup.create({
+            id: null,
+            name: newConfigGroupName,
+            description: Em.I18n.t('config.group.description.default').format(new Date().toDateString()),
+            isDefault: false,
+            parentConfigGroup: null,
+            service: (isInstaller) ? Em.Object.create({id: serviceId}) : App.Service.find().findProperty('serviceName', serviceId),
+            hosts: [],
+            configSiteTags: [],
+            properties: []
+          });
+          self.postNewConfigurationGroup(newConfigGroup);
           if (newConfigGroup) {
             newConfigGroup.set('parentConfigGroup', configGroups.findProperty('isDefault'));
             configGroups.pushObject(newConfigGroup);
@@ -1227,32 +1238,13 @@ App.config = Em.Object.create({
     });
   },
   /**
-   * Creates a new config-group for a service.
+   * Create a new config-group for a service.
    *
-   * @param serviceId   Service for which this group has to be created
-   * @param configGroupName    Name of the new config-group
-   * @param description    Description of the new config-group
-   * @param hosts    Hosts for the new config-group
-   * @param isInstaller    Determines whether send data to server or not
+   * @param newConfigGroupData   config group to post to server
    * @param callback    Callback function for Success or Error handling
    * @return  Returns the created config-group
    */
-  createNewConfigurationGroup: function (serviceId, configGroupName, description, hosts, isInstaller, callback) {
-    var newConfigGroupData = App.ConfigGroup.create({
-      id: null,
-      name: configGroupName,
-      description: description || "New configuration group created on " + new Date().toDateString(),
-      isDefault: false,
-      parentConfigGroup: null,
-      service: App.Service.find().findProperty('serviceName', serviceId),
-      hosts: hosts || [],
-      configSiteTags: [],
-      properties: []
-    });
-    if (isInstaller) {
-      newConfigGroupData.set('service', Em.Object.create({id: serviceId}));
-      return newConfigGroupData;
-    }
+  postNewConfigurationGroup: function (newConfigGroupData, callback) {
     var dataHosts = [];
     newConfigGroupData.get('hosts').forEach(function (_host) {
       dataHosts.push({
@@ -1262,25 +1254,22 @@ App.config = Em.Object.create({
     var sendData = {
       name: 'config_groups.create',
       data: {
-        'group_name': configGroupName,
-        'service_id': serviceId,
-        'description': newConfigGroupData.description,
+        'group_name': newConfigGroupData.get('name'),
+        'service_id': newConfigGroupData.get('service.id'),
+        'description': newConfigGroupData.get('description'),
         'hosts': dataHosts
       },
       success: 'successFunction',
       error: 'errorFunction',
       successFunction: function (response) {
+        newConfigGroupData.set('id', response.resources[0].ConfigGroup.id);
         if (callback) {
           callback();
-        } else {
-          newConfigGroupData.id = response.resources[0].ConfigGroup.id;
         }
       },
       errorFunction: function (xhr, text, errorThrown) {
         if (callback) {
           callback(xhr, text, errorThrown);
-        } else {
-          newConfigGroupData = null;
         }
         console.error('Error in creating new Config Group');
       }