ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-4455 Failure saving configuration in a new Host Config Group. (atkach)
Date Wed, 29 Jan 2014 13:45:57 GMT
Updated Branches:
  refs/heads/branch-1.4.4 9398eb8bc -> c63df3bb9


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/c63df3bb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c63df3bb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c63df3bb

Branch: refs/heads/branch-1.4.4
Commit: c63df3bb913f8cf868364a162942ea53ea059cb9
Parents: 9398eb8
Author: atkach <atkach@hortonworks.com>
Authored: Wed Jan 29 15:45:51 2014 +0200
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Jan 29 15:45:51 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/c63df3bb/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 58b4c99..fee77e5 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1970,7 +1970,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/c63df3bb/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 4c1eadf..ff26826 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;
@@ -267,7 +252,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/c63df3bb/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 3f97220..f128b67 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1748,6 +1748,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/c63df3bb/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 2d4654c..e398360 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1083,7 +1083,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);
@@ -1192,32 +1203,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({
@@ -1227,25 +1219,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');
       }


Mime
View raw message