|
@@ -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) {
|
|
if (serviceNames && serviceNames.length > 0) {
|
|
var configGroups = [];
|
|
var configGroups = [];
|
|
|
|
|
|
@@ -61,7 +61,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
|
|
var hostNamesForService = {};
|
|
var hostNamesForService = {};
|
|
|
|
|
|
if (json && json.items) {
|
|
if (json && json.items) {
|
|
- json.items.forEach(function(configGroup) {
|
|
|
|
|
|
+ json.items.forEach(function (configGroup) {
|
|
if (configGroup.group_name != 'default') {
|
|
if (configGroup.group_name != 'default') {
|
|
if (mapFromVersions) {
|
|
if (mapFromVersions) {
|
|
configGroup.id = configGroup.service_name + configGroup.group_id;
|
|
configGroup.id = configGroup.service_name + configGroup.group_id;
|
|
@@ -71,40 +71,43 @@ App.configGroupsMapper = App.QuickDataMapper.create({
|
|
configGroup.service_name = configGroup.ConfigGroup.tag;
|
|
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');
|
|
var template = mapFromVersions ? this.get('config2') : this.get('config');
|
|
configGroups.push(this.parseIt(configGroup, template));
|
|
configGroups.push(this.parseIt(configGroup, template));
|
|
}
|
|
}
|
|
}, this);
|
|
}, 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]));
|
|
configGroups.push(this.generateDefaultGroup(serviceName, hostNamesForService[serviceName]));
|
|
- }, this);
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ defaultGroup.set('hostNames', hostNamesForService[serviceName] || App.get('allHostNames'));
|
|
|
|
+ }
|
|
|
|
+ }, this);
|
|
|
|
+
|
|
|
|
|
|
configGroups.sort(function (configGroupA, configGroupB) {
|
|
configGroups.sort(function (configGroupA, configGroupB) {
|
|
return configGroupA.config_group_id == -1 || (configGroupA.name > configGroupB.name);
|
|
return configGroupA.config_group_id == -1 || (configGroupA.name > configGroupB.name);
|
|
});
|
|
});
|
|
App.store.loadMany(this.get('model'), configGroups);
|
|
App.store.loadMany(this.get('model'), configGroups);
|
|
|
|
+ App.store.commit();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -114,14 +117,14 @@ App.configGroupsMapper = App.QuickDataMapper.create({
|
|
* @param {string[]} [hostNames=null]
|
|
* @param {string[]} [hostNames=null]
|
|
* @returns {{id: string, config_group_id: string, name: string, service_name: string, description: string, host_names: [string], service_id: string}}
|
|
* @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');
|
|
var displayName = App.StackService.find(serviceName).get('displayName');
|
|
return {
|
|
return {
|
|
id: serviceName + '0',
|
|
id: serviceName + '0',
|
|
config_group_id: '-1',
|
|
config_group_id: '-1',
|
|
name: displayName + ' Default',
|
|
name: displayName + ' Default',
|
|
service_name: serviceName,
|
|
service_name: serviceName,
|
|
- description: 'Default cluster level '+ displayName +' configuration',
|
|
|
|
|
|
+ description: 'Default cluster level ' + displayName + ' configuration',
|
|
host_names: hostNames ? hostNames : App.get('allHostNames'),
|
|
host_names: hostNames ? hostNames : App.get('allHostNames'),
|
|
service_id: serviceName
|
|
service_id: serviceName
|
|
}
|
|
}
|