ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject ambari git commit: AMBARI-14482 Properties are missed in Manage Configuration Groups popup (akovalenko)
Date Wed, 23 Dec 2015 15:53:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9f59ed5b0 -> 5592240b6


AMBARI-14482 Properties are missed in Manage Configuration Groups popup (akovalenko)


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

Branch: refs/heads/trunk
Commit: 5592240b68bb4b7d86d0c2518378014753f12f2f
Parents: 9f59ed5
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Wed Dec 23 15:06:43 2015 +0200
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Wed Dec 23 17:08:49 2015 +0200

----------------------------------------------------------------------
 .../service/manage_config_groups_controller.js  |  20 ++--
 .../main/service/configs/config_overridable.js  |  12 +-
 .../manage_config_groups_controller_test.js     | 113 +++++++++++++++++++
 3 files changed, 134 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5592240b/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 8db6e2f..c1afb33 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
@@ -462,17 +462,23 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
    * @method _onLoadPropertiesSuccess
    */
   _onLoadPropertiesSuccess: function (data, opt, params) {
+    var groupToPropertiesMap = {};
     data.items.forEach(function (configs) {
-      var typeTagConfigs = [];
       var group = params.typeTagToGroupMap[configs.type + "///" + configs.tag];
+      if (!groupToPropertiesMap[group]) {
+        groupToPropertiesMap[group] = [];
+      }
       for (var config in configs.properties) {
-        typeTagConfigs.push({
+        groupToPropertiesMap[group].push({
           name: config,
-          value: configs.properties[config]
+          value: configs.properties[config],
+          type: configs.type
         });
       }
-      this.get('configGroups').findProperty('name', group).set('properties', typeTagConfigs);
     }, this);
+    for (var g in groupToPropertiesMap) {
+      this.get('configGroups').findProperty('name', g).set('properties', groupToPropertiesMap[g]);
+    }
   },
 
   /**
@@ -480,9 +486,9 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
    * @method showProperties
    */
   showProperties: function () {
-    var properies = this.get('selectedConfigGroup.propertiesList').htmlSafe();
-    if (properies) {
-      App.showAlertPopup(Em.I18n.t('services.service.config_groups_popup.properties'), properies);
+    var properties = this.get('selectedConfigGroup.propertiesList').htmlSafe();
+    if (properties) {
+      App.showAlertPopup(Em.I18n.t('services.service.config_groups_popup.properties'), properties);
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5592240b/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index b92e4f0..cf99baa 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -225,9 +225,12 @@ App.ConfigOverridable = Em.Mixin.create({
    * @method postNewConfigurationGroup
    */
   postNewConfigurationGroup: function (newConfigGroupData, callback) {
-    var properties = {};
+    var typeToPropertiesMap = {};
     newConfigGroupData.properties.forEach(function (property) {
-      properties[property.get('name')] = property.get('value');
+      if (!typeToPropertiesMap[property.get('type')]) {
+        typeToPropertiesMap[property.get('type')] = {};
+      }
+      typeToPropertiesMap[property.get('type')][property.get('name')] = property.get('value');
     });
     var newGroupData = {
       "ConfigGroup": {
@@ -235,10 +238,11 @@ App.ConfigOverridable = Em.Mixin.create({
         "tag": newConfigGroupData.service_id,
         "description": newConfigGroupData.description,
         "desired_configs": newConfigGroupData.desired_configs.map(function (cst) {
+          var type = Em.get(cst, 'site') || Em.get(cst, 'type');
           return {
-            type: Em.get(cst, 'site') || Em.get(cst, 'type'),
+            type: type,
             tag: 'version' + (new Date).getTime(),
-            properties: properties
+            properties: typeToPropertiesMap[type]
           };
         }),
         "hosts": newConfigGroupData.hosts.map(function (h) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5592240b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index dffeabb..15d22fd 100644
--- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -370,4 +370,117 @@ describe('App.ManageConfigGroupsController', function() {
       });
     });
   });
+
+  describe('#_onLoadPropertiesSuccess', function () {
+
+    beforeEach(function () {
+      sinon.stub(c, 'resortConfigGroup', Em.K);
+    });
+
+    afterEach(function () {
+      c.resortConfigGroup.restore();
+    });
+
+    it('should set properties to config groups', function () {
+
+      c.set('configGroups', [
+        Em.Object.create({
+          name: 'group1',
+          properties: []
+        }),
+        Em.Object.create({
+          name: 'group2',
+          properties: []
+        }),
+        Em.Object.create({
+          name: 'group3',
+          properties: []
+        }),
+        Em.Object.create({
+          name: 'group4',
+          properties: []
+        })
+      ]);
+
+      var data = {
+        items: [
+          {
+            type: 'type1',
+            tag: 'tag1',
+            properties: {
+              prop1: 'val1',
+              prop2: 'val2'
+            }
+          },
+          {
+            type: 'type1',
+            tag: 'tag2',
+            properties: {
+              prop3: 'val3'
+            }
+          },
+          {
+            type: 'type2',
+            tag: 'tag1',
+            properties: {
+              prop4: 'val4'
+            }
+          }
+        ]
+      };
+
+      var params = {
+        typeTagToGroupMap: {
+          'type1///tag1': 'group1',
+          'type1///tag2': 'group2',
+          'type2///tag1': 'group3'
+        }
+      };
+
+      c._onLoadPropertiesSuccess(data, null, params);
+
+      expect(JSON.stringify(c.get('configGroups'))).to.equal(JSON.stringify([
+        Em.Object.create({
+          properties: [
+            {
+              name: 'prop1',
+              value: 'val1',
+              type: 'type1'
+            },
+            {
+              name: 'prop2',
+              value: 'val2',
+              type: 'type1'
+            }
+          ],
+          name: 'group1'
+        }),
+        Em.Object.create({
+          properties: [
+            {
+              name: 'prop3',
+              value: 'val3',
+              type: 'type1'
+            }
+          ],
+          name: 'group2'
+        }),
+        Em.Object.create({
+          properties: [
+            {
+              name: 'prop4',
+              value: 'val4',
+              type: 'type2'
+            }
+          ],
+          name: 'group3'
+        }),
+        Em.Object.create({
+          properties: [],
+          name: 'group4'
+        })
+      ]));
+    });
+
+  });
 });


Mime
View raw message