ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [3/3] ambari git commit: AMBARI-12066 Service Configs: config groups list is not updated. (ababiichuk)
Date Mon, 22 Jun 2015 15:13:03 GMT
AMBARI-12066 Service Configs: config groups list is not updated. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: c07374f64ef4e66ac3ce9a30e3608f3d85526529
Parents: 15a369b
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Jun 22 18:03:10 2015 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Mon Jun 22 18:03:10 2015 +0300

----------------------------------------------------------------------
 .../service/manage_config_groups_controller.js  |  4 ++
 .../app/mappers/configs/config_groups_mapper.js | 53 +++++++++++---------
 .../app/mixins/common/configs/configs_loader.js |  4 +-
 .../main/service/configs/config_overridable.js  |  2 +-
 .../app/mixins/main/service/groups_mapping.js   |  6 +--
 5 files changed, 37 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c07374f6/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 0e66270..cdc2c6b 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
@@ -532,6 +532,10 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable,
{
     this.set('selectedHosts', selectedConfigGroup.get('hosts'));
     this.deleteHosts();
     this.get('configGroups').removeObject(selectedConfigGroup);
+    var groupFromModel = App.ServiceConfigGroup.find().filterProperty('serviceName', selectedConfigGroup.get('service.serviceName')).findProperty('name',
selectedConfigGroup.get('name'));
+    if (groupFromModel) {
+      App.configGroupsMapper.deleteRecord(groupFromModel);
+    }
     this.set('selectedConfigGroup', this.get('configGroups').findProperty('isDefault'));
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c07374f6/ambari-web/app/mappers/configs/config_groups_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/config_groups_mapper.js b/ambari-web/app/mappers/configs/config_groups_mapper.js
index 55b1185..ae6d049 100644
--- a/ambari-web/app/mappers/configs/config_groups_mapper.js
+++ b/ambari-web/app/mappers/configs/config_groups_mapper.js
@@ -47,7 +47,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
   },
 
 
-  map: function (json, mapFromVersions, serviceNames, skipDefault) {
+  map: function (json, mapFromVersions, serviceNames) {
     if (serviceNames && serviceNames.length > 0) {
       var configGroups = [];
 
@@ -61,7 +61,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
       var hostNamesForService = {};
 
       if (json && json.items) {
-        json.items.forEach(function(configGroup) {
+        json.items.forEach(function (configGroup) {
           if (configGroup.group_name != 'default') {
             if (mapFromVersions) {
               configGroup.id = configGroup.service_name + configGroup.group_id;
@@ -71,40 +71,43 @@ App.configGroupsMapper = App.QuickDataMapper.create({
               configGroup.service_name = configGroup.ConfigGroup.tag;
             }
 
-            if (!skipDefault) {
-              /**
-               * creating (if not exists) field in <code>hostNamesForService<code>
with host names for default group
-               */
-              if (!hostNamesForService[configGroup.service_name]) {
-                hostNamesForService[configGroup.service_name] = $.merge([], App.get('allHostNames'));
-              }
-
-              /**
-               * excluding host names that belongs for current config group from default
group
-               */
-              configGroup.hosts.forEach(function(host) {
-                hostNamesForService[configGroup.service_name].splice(hostNamesForService[configGroup.service_name].indexOf(host),
1);
-              });
+            /**
+             * creating (if not exists) field in <code>hostNamesForService<code>
with host names for default group
+             */
+            if (!hostNamesForService[configGroup.service_name]) {
+              hostNamesForService[configGroup.service_name] = $.merge([], App.get('allHostNames'));
             }
 
+            /**
+             * excluding host names that belongs for current config group from default group
+             */
+            configGroup.hosts.forEach(function (host) {
+              hostNamesForService[configGroup.service_name].splice(hostNamesForService[configGroup.service_name].indexOf(host),
1);
+            });
             var template = mapFromVersions ? this.get('config2') : this.get('config');
             configGroups.push(this.parseIt(configGroup, template));
           }
         }, this);
       }
-      if (!skipDefault) {
-        /**
-         * generating default config groups
-         */
-        serviceNames.forEach(function(serviceName) {
+
+      /**
+       * generating default config groups
+       */
+      serviceNames.forEach(function (serviceName) {
+        var defaultGroup = App.ServiceConfigGroup.find().findProperty('id', serviceName +
"0");
+        if (!defaultGroup) {
           configGroups.push(this.generateDefaultGroup(serviceName, hostNamesForService[serviceName]));
-        }, this);
-      }
+        } else {
+          defaultGroup.set('hostNames', hostNamesForService[serviceName] || App.get('allHostNames'));
+        }
+      }, this);
+
 
       configGroups.sort(function (configGroupA, configGroupB) {
         return configGroupA.config_group_id == -1 || (configGroupA.name > configGroupB.name);
       });
       App.store.loadMany(this.get('model'), configGroups);
+      App.store.commit();
     }
   },
 
@@ -114,14 +117,14 @@ App.configGroupsMapper = App.QuickDataMapper.create({
    * @param {string[]} [hostNames=null]
    * @returns {{id: string, config_group_id: string, name: string, service_name: string,
description: string, host_names: [string], service_id: string}}
    */
-  generateDefaultGroup: function(serviceName, hostNames) {
+  generateDefaultGroup: function (serviceName, hostNames) {
     var displayName = App.StackService.find(serviceName).get('displayName');
     return {
       id: serviceName + '0',
       config_group_id: '-1',
       name: displayName + ' Default',
       service_name: serviceName,
-      description: 'Default cluster level '+ displayName +' configuration',
+      description: 'Default cluster level ' + displayName + ' configuration',
       host_names: hostNames ? hostNames : App.get('allHostNames'),
       service_id: serviceName
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c07374f6/ambari-web/app/mixins/common/configs/configs_loader.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_loader.js b/ambari-web/app/mixins/common/configs/configs_loader.js
index 6b07d80..9f94fd9 100644
--- a/ambari-web/app/mixins/common/configs/configs_loader.js
+++ b/ambari-web/app/mixins/common/configs/configs_loader.js
@@ -79,7 +79,7 @@ App.ConfigsLoader = Em.Mixin.create(App.GroupsMappingMixin, {
     if (this.get('preSelectedConfigVersion')) {
       /** handling redirecting from config history page **/
       var self = this;
-      this.loadConfigGroups(this.get('servicesToLoad'), false).done(function() {
+      this.loadConfigGroups(this.get('servicesToLoad')).done(function() {
         var selectedGroup = App.ServiceConfigGroup.find().find(function(g) {
           return g.get('serviceName') == self.get('preSelectedConfigVersion.serviceName')
             && (g.get('name') == self.get('preSelectedConfigVersion.groupName') ||
(self.get('preSelectedConfigVersion.groupName') == 'default' && g.get('isDefault')));
@@ -121,7 +121,7 @@ App.ConfigsLoader = Em.Mixin.create(App.GroupsMappingMixin, {
     App.configGroupsMapper.map(data, true, params.serviceNames.split(','));
     this.set('selectedConfigGroup', App.ServiceConfigGroup.find().filterProperty('serviceName',
this.get('content.serviceName')).findProperty('isDefault'));
     this.parseConfigData(data);
-    this.loadConfigGroups(params.serviceNames.split(','), true);
+    this.loadConfigGroups(params.serviceNames.split(','));
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/c07374f6/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 61eeb3d..a93f2e9 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -445,7 +445,7 @@ App.ConfigOverridable = Em.Mixin.create({
       }),
       onPrimary:function() {
         if (self.get('controller.name') == 'mainServiceInfoConfigsController') {
-          self.get('controller').loadConfigGroups([self.get('content.serviceName')], true).done(function()
{
+          self.get('controller').loadConfigGroups([self.get('content.serviceName')]).done(function()
{
             var group = App.ServiceConfigGroup.find().find(function(g) {
               return g.get('serviceName') == self.get('content.serviceName') && g.get('name')
== groupName;
             });

http://git-wip-us.apache.org/repos/asf/ambari/blob/c07374f6/ambari-web/app/mixins/main/service/groups_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/groups_mapping.js b/ambari-web/app/mixins/main/service/groups_mapping.js
index dbbf5ed..93a760d 100644
--- a/ambari-web/app/mixins/main/service/groups_mapping.js
+++ b/ambari-web/app/mixins/main/service/groups_mapping.js
@@ -28,11 +28,10 @@ App.GroupsMappingMixin = Em.Mixin.create({
   /**
    * Load config groups
    * @param {String[]} serviceNames
-   * @param skipDefault
    * @returns {$.Deferred()}
    * @method loadConfigGroups
    */
-  loadConfigGroups: function (serviceNames, skipDefault) {
+  loadConfigGroups: function (serviceNames) {
     var dfd = $.Deferred();
     if (!serviceNames || serviceNames.length === 0) {
       dfd.resolve();
@@ -42,7 +41,6 @@ App.GroupsMappingMixin = Em.Mixin.create({
         sender: this,
         data: {
           serviceNames: serviceNames.join(','),
-          skipDefault: skipDefault,
           dfd: dfd
         },
         success: 'saveConfigGroupsToModel'
@@ -59,7 +57,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
    * @method saveConfigGroupsToModel
    */
   saveConfigGroupsToModel: function (data, opt, params) {
-    App.configGroupsMapper.map(data, false, params.serviceNames.split(','), params.skipDefault);
+    App.configGroupsMapper.map(data, false, params.serviceNames.split(','));
     params.dfd.resolve();
   }
 


Mime
View raw message