|
@@ -62,21 +62,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
*/
|
|
*/
|
|
originalConfigGroups: [],
|
|
originalConfigGroups: [],
|
|
|
|
|
|
- /**
|
|
|
|
- * map of <code>originalConfigGroups</code>
|
|
|
|
- * @type {object}
|
|
|
|
- */
|
|
|
|
- originalConfigGroupsMap: function() {
|
|
|
|
- var map = {};
|
|
|
|
-
|
|
|
|
- this.get('originalConfigGroups').forEach(function (item) {
|
|
|
|
- if (!item.get('isDefault')) {
|
|
|
|
- map[item.get('id')] = item;
|
|
|
|
- }
|
|
|
|
- }, this);
|
|
|
|
- return map;
|
|
|
|
- }.property('originalConfigGroups'),
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @type {App.ConfigGroup}
|
|
* @type {App.ConfigGroup}
|
|
*/
|
|
*/
|
|
@@ -169,40 +154,55 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
var groupsToSetHosts = [];
|
|
var groupsToSetHosts = [];
|
|
var groupsToCreate = [];
|
|
var groupsToCreate = [];
|
|
var groups = this.get('configGroups');
|
|
var groups = this.get('configGroups');
|
|
- var originalGroups = this.get('originalConfigGroups');
|
|
|
|
- var originalGroupsMap = this.get('originalConfigGroupsMap');
|
|
|
|
-
|
|
|
|
- // remove default group
|
|
|
|
- var originalGroupsCopy = originalGroups.without(originalGroups.findProperty('isDefault'));
|
|
|
|
- var originalGroupsIds = originalGroupsCopy.mapProperty('id');
|
|
|
|
- groups.forEach(function (group) {
|
|
|
|
- if (!group.get('isDefault')) {
|
|
|
|
- var originalGroup = originalGroupsMap[group.get('id')];
|
|
|
|
|
|
+ var originalGroups = [];
|
|
|
|
+ var originalGroupsMap = {};
|
|
|
|
+
|
|
|
|
+ this.get('originalConfigGroups').forEach(function(item){
|
|
|
|
+ if (!item.is_default) {
|
|
|
|
+ originalGroupsMap[item.id] = item;
|
|
|
|
+ originalGroups.push(item);
|
|
|
|
+ }
|
|
|
|
+ }, this);
|
|
|
|
+
|
|
|
|
+ groups.forEach(function (groupRecord) {
|
|
|
|
+ if (!groupRecord.get('isDefault')) {
|
|
|
|
+ var originalGroup = originalGroupsMap[groupRecord.get('id')];
|
|
if (originalGroup) {
|
|
if (originalGroup) {
|
|
- if (!(JSON.stringify(group.get('hosts').slice().sort()) === JSON.stringify(originalGroup.get('hosts').sort()))) {
|
|
|
|
- groupsToClearHosts.push(group.set('id', originalGroup.get('id')));
|
|
|
|
- if (group.get('hosts').length) {
|
|
|
|
- groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
|
|
|
|
|
|
+ if (!(JSON.stringify(groupRecord.get('hosts').slice().sort()) === JSON.stringify(originalGroup.hosts.sort()))) {
|
|
|
|
+ groupsToClearHosts.push(groupRecord);
|
|
|
|
+ if (groupRecord.get('hosts').length) {
|
|
|
|
+ groupsToSetHosts.push(groupRecord);
|
|
}
|
|
}
|
|
// should update name or description
|
|
// should update name or description
|
|
- } else if (group.get('description') !== originalGroup.get('description') || group.get('name') !== originalGroup.get('name') ) {
|
|
|
|
- groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
|
|
|
|
|
|
+ } else if (groupRecord.get('description') !== originalGroup.description || groupRecord.get('name') !== originalGroup.name) {
|
|
|
|
+ groupsToSetHosts.push(groupRecord);
|
|
}
|
|
}
|
|
- originalGroupsIds = originalGroupsIds.without(group.get('id'));
|
|
|
|
|
|
+ delete originalGroupsMap[groupRecord.get('id')];
|
|
} else {
|
|
} else {
|
|
- groupsToCreate.push(group);
|
|
|
|
|
|
+ groupsToCreate.push({
|
|
|
|
+ id: groupRecord.get('id'),
|
|
|
|
+ config_group_id: groupRecord.get('configGroupId'),
|
|
|
|
+ name: groupRecord.get('name'),
|
|
|
|
+ description: groupRecord.get('description'),
|
|
|
|
+ hosts: groupRecord.get('hosts').slice(0),
|
|
|
|
+ service_id: groupRecord.get('serviceName'),
|
|
|
|
+ desired_configs: groupRecord.get('desiredConfigs')
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- originalGroupsIds.forEach(function (id) {
|
|
|
|
- groupsToDelete.push(originalGroupsMap[id]);
|
|
|
|
- }, this);
|
|
|
|
|
|
+
|
|
|
|
+ //groups to delete
|
|
|
|
+ for (var id in originalGroupsMap) {
|
|
|
|
+ groupsToDelete.push(App.ServiceConfigGroup.find(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
this.set('hostsModifiedConfigGroups', {
|
|
this.set('hostsModifiedConfigGroups', {
|
|
toClearHosts: groupsToClearHosts,
|
|
toClearHosts: groupsToClearHosts,
|
|
toDelete: groupsToDelete,
|
|
toDelete: groupsToDelete,
|
|
toSetHosts: groupsToSetHosts,
|
|
toSetHosts: groupsToSetHosts,
|
|
toCreate: groupsToCreate,
|
|
toCreate: groupsToCreate,
|
|
- initialGroups: originalGroupsCopy
|
|
|
|
|
|
+ initialGroups: originalGroups
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
@@ -340,9 +340,8 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
*/
|
|
*/
|
|
loadConfigGroups: function (serviceName) {
|
|
loadConfigGroups: function (serviceName) {
|
|
if (this.get('isInstaller')) {
|
|
if (this.get('isInstaller')) {
|
|
- this.set('serviceName', serviceName);
|
|
|
|
- var configGroups = this.copyConfigGroups(App.router.get('wizardStep7Controller.selectedService.configGroups'));
|
|
|
|
- var originalConfigGroups = this.copyConfigGroups(configGroups);
|
|
|
|
|
|
+ var configGroups = App.router.get('wizardStep7Controller.selectedService.configGroups').slice(0);
|
|
|
|
+ var originalConfigGroups = this.generateOriginalConfigGroups(configGroups);
|
|
this.setProperties({
|
|
this.setProperties({
|
|
configGroups: configGroups,
|
|
configGroups: configGroups,
|
|
originalConfigGroups: originalConfigGroups,
|
|
originalConfigGroups: originalConfigGroups,
|
|
@@ -369,63 +368,53 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
* @method _onLoadConfigGroupsSuccess
|
|
* @method _onLoadConfigGroupsSuccess
|
|
*/
|
|
*/
|
|
_onLoadConfigGroupsSuccess: function (data) {
|
|
_onLoadConfigGroupsSuccess: function (data) {
|
|
- var usedHosts = [];
|
|
|
|
- var unusedHosts = [];
|
|
|
|
var serviceName = this.get('serviceName');
|
|
var serviceName = this.get('serviceName');
|
|
- var defaultConfigGroup = App.ConfigGroup.create({
|
|
|
|
- name: App.format.role(serviceName) + " Default",
|
|
|
|
- description: "Default cluster level " + serviceName + " configuration",
|
|
|
|
- isDefault: true,
|
|
|
|
- parentConfigGroup: null,
|
|
|
|
- service: this.get('content'),
|
|
|
|
- configSiteTags: [],
|
|
|
|
- serviceName: serviceName
|
|
|
|
- });
|
|
|
|
|
|
|
|
- if (data && data.items) {
|
|
|
|
- var groupToTypeToTagMap = {};
|
|
|
|
- var configGroups = [];
|
|
|
|
- data.items.forEach(function (configGroup) {
|
|
|
|
- configGroup = configGroup.ConfigGroup;
|
|
|
|
- var hostNames = configGroup.hosts.mapProperty('host_name');
|
|
|
|
- var newConfigGroup = App.ConfigGroup.create({
|
|
|
|
- id: configGroup.id,
|
|
|
|
- name: configGroup.group_name,
|
|
|
|
- description: configGroup.description,
|
|
|
|
- isDefault: false,
|
|
|
|
- parentConfigGroup: defaultConfigGroup,
|
|
|
|
- service: App.Service.find(configGroup.tag),
|
|
|
|
- hosts: hostNames,
|
|
|
|
- configSiteTags: configGroup.desired_configs.map(function (config) {
|
|
|
|
- if (!groupToTypeToTagMap[configGroup.group_name]) {
|
|
|
|
- groupToTypeToTagMap[configGroup.group_name] = {}
|
|
|
|
- }
|
|
|
|
- groupToTypeToTagMap[configGroup.group_name][config.type] = config.tag;
|
|
|
|
|
|
+ App.configGroupsMapper.map(data, false, [serviceName]);
|
|
|
|
|
|
- return App.ConfigSiteTag.create({
|
|
|
|
- site: config.type,
|
|
|
|
- tag: config.tag
|
|
|
|
- });
|
|
|
|
- }),
|
|
|
|
- properties: [],
|
|
|
|
- apiResponse: configGroup
|
|
|
|
|
|
+ var configGroups = App.ServiceConfigGroup.find().filterProperty('serviceName', serviceName);
|
|
|
|
+ var rawConfigGroups = this.generateOriginalConfigGroups(configGroups);
|
|
|
|
+ var groupToTypeToTagMap = {};
|
|
|
|
+
|
|
|
|
+ rawConfigGroups.forEach(function (item) {
|
|
|
|
+ if (Array.isArray(item.desired_configs)) {
|
|
|
|
+ item.desired_configs.forEach(function (config) {
|
|
|
|
+ if (!groupToTypeToTagMap[item.name]) {
|
|
|
|
+ groupToTypeToTagMap[item.name] = {};
|
|
|
|
+ }
|
|
|
|
+ groupToTypeToTagMap[item.name][config.type] = config.tag;
|
|
});
|
|
});
|
|
- usedHosts = usedHosts.concat(hostNames);
|
|
|
|
- configGroups.push(newConfigGroup);
|
|
|
|
- }, this);
|
|
|
|
- unusedHosts = App.get('allHostNames').slice(0);
|
|
|
|
- usedHosts.uniq().forEach(function (host) {
|
|
|
|
- unusedHosts = unusedHosts.without(host);
|
|
|
|
- }, this);
|
|
|
|
- defaultConfigGroup.set('childConfigGroups', configGroups);
|
|
|
|
- defaultConfigGroup.set('hosts', unusedHosts);
|
|
|
|
- var allGroups = [defaultConfigGroup].concat(configGroups);
|
|
|
|
- this.set('configGroups', allGroups);
|
|
|
|
- var originalGroups = this.copyConfigGroups(allGroups);
|
|
|
|
- this.set('originalConfigGroups', originalGroups);
|
|
|
|
- this.loadProperties(groupToTypeToTagMap);
|
|
|
|
- this.set('isLoaded', true);
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.set('configGroups', configGroups);
|
|
|
|
+ this.set('originalConfigGroups', rawConfigGroups);
|
|
|
|
+ this.loadProperties(groupToTypeToTagMap);
|
|
|
|
+ this.set('isLoaded', true);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param {Array} configGroups
|
|
|
|
+ * @returns {Array}
|
|
|
|
+ */
|
|
|
|
+ generateOriginalConfigGroups: function(configGroups) {
|
|
|
|
+ return configGroups.map(function (item) {
|
|
|
|
+ return {
|
|
|
|
+ id: item.get('id'),
|
|
|
|
+ config_group_id: item.get('configGroupId'),
|
|
|
|
+ name: item.get('name'),
|
|
|
|
+ service_name: item.get('serviceName'),
|
|
|
|
+ description: item.get('description'),
|
|
|
|
+ hosts: item.get('hosts').slice(0),
|
|
|
|
+ service_id: item.get('serviceName'),
|
|
|
|
+ desired_configs: item.get('desiredConfigs'),
|
|
|
|
+ is_default: item.get('isDefault'),
|
|
|
|
+ child_config_groups: item.get('childConfigGroups') ? item.get('childConfigGroups').mapProperty('id') : [],
|
|
|
|
+ parent_config_group_id: item.get('parentConfigGroup.id'),
|
|
|
|
+ properties: item.get('properties')
|
|
|
|
+ };
|
|
|
|
+ });
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -471,12 +460,12 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
var typeTagConfigs = [];
|
|
var typeTagConfigs = [];
|
|
var group = params.typeTagToGroupMap[configs.type + "///" + configs.tag];
|
|
var group = params.typeTagToGroupMap[configs.type + "///" + configs.tag];
|
|
for (var config in configs.properties) {
|
|
for (var config in configs.properties) {
|
|
- typeTagConfigs.push(Em.Object.create({
|
|
|
|
|
|
+ typeTagConfigs.push({
|
|
name: config,
|
|
name: config,
|
|
value: configs.properties[config]
|
|
value: configs.properties[config]
|
|
- }));
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- this.get('configGroups').findProperty('name', group).get('properties').pushObjects(typeTagConfigs);
|
|
|
|
|
|
+ this.get('configGroups').findProperty('name', group).set('properties', typeTagConfigs);
|
|
}, this);
|
|
}, this);
|
|
},
|
|
},
|
|
|
|
|
|
@@ -628,9 +617,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
onPrimary: function () {
|
|
onPrimary: function () {
|
|
self.set('selectedConfigGroup.name', this.get('configGroupName'));
|
|
self.set('selectedConfigGroup.name', this.get('configGroupName'));
|
|
self.set('selectedConfigGroup.description', this.get('configGroupDesc'));
|
|
self.set('selectedConfigGroup.description', this.get('configGroupDesc'));
|
|
- self.get('selectedConfigGroup.properties').forEach(function(property){
|
|
|
|
- property.set('group', self.get('selectedConfigGroup'));
|
|
|
|
- });
|
|
|
|
this.hide();
|
|
this.hide();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -684,29 +670,36 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
onPrimary: function () {
|
|
onPrimary: function () {
|
|
var defaultConfigGroup = self.get('configGroups').findProperty('isDefault');
|
|
var defaultConfigGroup = self.get('configGroups').findProperty('isDefault');
|
|
var properties = [];
|
|
var properties = [];
|
|
- var newConfigGroupData = App.ConfigGroup.create({
|
|
|
|
- id: null,
|
|
|
|
|
|
+ var serviceName = self.get('serviceName');
|
|
|
|
+ //temporarily id until real assigned by server
|
|
|
|
+ var newGroupId = serviceName + "_NEW_" + self.get('configGroups.length');
|
|
|
|
+
|
|
|
|
+ App.store.load(App.ServiceConfigGroup, {
|
|
|
|
+ id: newGroupId,
|
|
name: this.get('configGroupName').trim(),
|
|
name: this.get('configGroupName').trim(),
|
|
description: this.get('configGroupDesc'),
|
|
description: this.get('configGroupDesc'),
|
|
isDefault: false,
|
|
isDefault: false,
|
|
- parentConfigGroup: defaultConfigGroup,
|
|
|
|
- service: Em.Object.create({id: self.get('serviceName')}),
|
|
|
|
|
|
+ parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
|
|
|
|
+ service_id: serviceName,
|
|
|
|
+ service_name: serviceName,
|
|
hosts: [],
|
|
hosts: [],
|
|
configSiteTags: [],
|
|
configSiteTags: [],
|
|
properties: []
|
|
properties: []
|
|
});
|
|
});
|
|
|
|
+ App.store.commit();
|
|
|
|
+ var childConfigGroups = defaultConfigGroup.get('childConfigGroups').mapProperty('id');
|
|
|
|
+ childConfigGroups.push(newGroupId);
|
|
|
|
+ App.store.load(App.ServiceConfigGroup, App.configGroupsMapper.generateDefaultGroup(self.get('serviceName'), defaultConfigGroup.get('hosts'), childConfigGroups));
|
|
|
|
+ App.store.commit();
|
|
if (duplicated) {
|
|
if (duplicated) {
|
|
- self.get('selectedConfigGroup.properties').forEach(function(property) {
|
|
|
|
- var property = App.ServiceConfigProperty.create($.extend(false, {}, property));
|
|
|
|
- property.set('group', newConfigGroupData);
|
|
|
|
|
|
+ self.get('selectedConfigGroup.properties').forEach(function(item) {
|
|
|
|
+ var property = App.ServiceConfigProperty.create($.extend(false, {}, item));
|
|
|
|
+ property.set('group', App.ServiceConfigGroup.find(newGroupId));
|
|
properties.push(property);
|
|
properties.push(property);
|
|
});
|
|
});
|
|
- newConfigGroupData.set('properties', properties);
|
|
|
|
- } else {
|
|
|
|
- newConfigGroupData.set('properties', []);
|
|
|
|
|
|
+ App.ServiceConfigGroup.find(newGroupId).set('properties', properties);
|
|
}
|
|
}
|
|
- self.get('configGroups').pushObject(newConfigGroupData);
|
|
|
|
- defaultConfigGroup.get('childConfigGroups').pushObject(newConfigGroupData);
|
|
|
|
|
|
+ self.get('configGroups').pushObject(App.ServiceConfigGroup.find(newGroupId));
|
|
this.hide();
|
|
this.hide();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -721,40 +714,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
this.addConfigGroup(true);
|
|
this.addConfigGroup(true);
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * copy config groups to manage popup to give user choice whether or not save changes
|
|
|
|
- * @param originGroups
|
|
|
|
- * @return {Array}
|
|
|
|
- * @method copyConfigGroups
|
|
|
|
- */
|
|
|
|
- copyConfigGroups: function (originGroups) {
|
|
|
|
- var configGroups = [];
|
|
|
|
- var result = [];
|
|
|
|
- var defaultConfigGroup = App.ConfigGroup.create($.extend(true, {}, originGroups.findProperty('isDefault')));
|
|
|
|
- originGroups.forEach(function (configGroup) {
|
|
|
|
- if (!configGroup.get('isDefault')) {
|
|
|
|
- var copiedGroup = App.ConfigGroup.create($.extend(true, {}, configGroup));
|
|
|
|
- copiedGroup.set('parentConfigGroup', defaultConfigGroup);
|
|
|
|
- configGroups.pushObject(copiedGroup);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- defaultConfigGroup.set('childConfigGroups', configGroups.slice());
|
|
|
|
- configGroups.pushObject(defaultConfigGroup);
|
|
|
|
- configGroups.forEach(function (group) {
|
|
|
|
- var groupCopy = {};
|
|
|
|
- for (var prop in group) {
|
|
|
|
- if (group.hasOwnProperty(prop)) {
|
|
|
|
- groupCopy[prop] = group[prop];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- groupCopy.properties.forEach(function(property){
|
|
|
|
- property.set('group', group);
|
|
|
|
- });
|
|
|
|
- result.push(App.ConfigGroup.create(groupCopy));
|
|
|
|
- }, this);
|
|
|
|
- return result;
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Show popup with config groups
|
|
* Show popup with config groups
|
|
* User may edit/create/delete them
|
|
* User may edit/create/delete them
|
|
@@ -809,6 +768,25 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
this.hide();
|
|
this.hide();
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ onClose: function () {
|
|
|
|
+ this.resetGroupChanges();
|
|
|
|
+ this._super();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ onSecondary: function () {
|
|
|
|
+ this.resetGroupChanges();
|
|
|
|
+ this._super();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ resetGroupChanges: function () {
|
|
|
|
+ if (this.get('subViewController.isHostsModified')) {
|
|
|
|
+ App.ServiceConfigGroup.find().clear();
|
|
|
|
+ App.store.commit();
|
|
|
|
+ App.store.loadMany(App.ServiceConfigGroup, this.get('subViewController.originalConfigGroups'));
|
|
|
|
+ App.store.commit();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* run requests which delete config group and clear its hosts
|
|
* run requests which delete config group and clear its hosts
|
|
* @param {Function} finishFunction
|
|
* @param {Function} finishFunction
|
|
@@ -825,8 +803,7 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
|
|
|
|
|
|
modifiedConfigGroups.toClearHosts.forEach(function (cg) {
|
|
modifiedConfigGroups.toClearHosts.forEach(function (cg) {
|
|
counter++;
|
|
counter++;
|
|
- var initialGroupState = modifiedConfigGroups.initialGroups.findProperty('id', cg.get('id'));
|
|
|
|
- configsController.clearConfigurationGroupHosts(cg, initialGroupState, doneFunction, doneFunction);
|
|
|
|
|
|
+ configsController.updateConfigurationGroup(cg, doneFunction, doneFunction)
|
|
}, this);
|
|
}, this);
|
|
modifiedConfigGroups.toDelete.forEach(function (cg) {
|
|
modifiedConfigGroups.toDelete.forEach(function (cg) {
|
|
counter++;
|
|
counter++;
|