|
@@ -132,31 +132,18 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- /**
|
|
|
|
- * disable saving recommended value for current config
|
|
|
|
- * @param config
|
|
|
|
- * @param {boolean} saveRecommended
|
|
|
|
- * @method removeCurrentFromDependentList
|
|
|
|
- */
|
|
|
|
- removeCurrentFromDependentList: function (config, saveRecommended) {
|
|
|
|
- var current = this.getRecommendation(config.get('name'), config.get('filename'), config.get('group.name'));
|
|
|
|
- if (current) {
|
|
|
|
- Em.setProperties(current, {
|
|
|
|
- 'saveRecommended': !!saveRecommended,
|
|
|
|
- 'saveRecommendedDefault': !!saveRecommended
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ clearRecommendationsInfo: function() {
|
|
|
|
+ this.set('recommendationsConfigs', null);
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* sends request to get values for dependent configs
|
|
* sends request to get values for dependent configs
|
|
* @param {{type: string, name: string}[]} changedConfigs - list of changed configs to track recommendations
|
|
* @param {{type: string, name: string}[]} changedConfigs - list of changed configs to track recommendations
|
|
- * @param {Boolean} initial
|
|
|
|
* @param {Function} onComplete
|
|
* @param {Function} onComplete
|
|
* @returns {$.ajax|null}
|
|
* @returns {$.ajax|null}
|
|
*/
|
|
*/
|
|
- getRecommendationsForDependencies: function(changedConfigs, initial, onComplete) {
|
|
|
|
- if (Em.isArray(changedConfigs) && changedConfigs.length > 0 || initial) {
|
|
|
|
|
|
+ getRecommendationsForDependencies: function(changedConfigs, onComplete) {
|
|
|
|
+ if ((Em.isArray(changedConfigs) && changedConfigs.length > 0) || Em.isNone(this.get('recommendationsConfigs'))) {
|
|
var configGroup = this.get('selectedConfigGroup');
|
|
var configGroup = this.get('selectedConfigGroup');
|
|
var recommendations = this.get('hostGroups');
|
|
var recommendations = this.get('hostGroups');
|
|
delete recommendations.config_groups;
|
|
delete recommendations.config_groups;
|
|
@@ -168,7 +155,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
};
|
|
};
|
|
|
|
|
|
var clearConfigsOnAddService = configGroup.get('isDefault') && this.isConfigHasInitialState();
|
|
var clearConfigsOnAddService = configGroup.get('isDefault') && this.isConfigHasInitialState();
|
|
- if (clearConfigsOnAddService) {
|
|
|
|
|
|
+ if (clearConfigsOnAddService && !Em.isNone(this.get('initialConfigValues'))) {
|
|
recommendations.blueprint.configurations = this.get('initialConfigValues');
|
|
recommendations.blueprint.configurations = this.get('initialConfigValues');
|
|
} else {
|
|
} else {
|
|
recommendations.blueprint.configurations = blueprintUtils.buildConfigsJSON(this.get('services'), this.get('stepConfigs'));
|
|
recommendations.blueprint.configurations = blueprintUtils.buildConfigsJSON(this.get('services'), this.get('stepConfigs'));
|
|
@@ -182,24 +169,28 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
recommendations.config_groups = [configGroups];
|
|
recommendations.config_groups = [configGroups];
|
|
}
|
|
}
|
|
dataToSend.recommendations = recommendations;
|
|
dataToSend.recommendations = recommendations;
|
|
|
|
+ var self = this;
|
|
return App.ajax.send({
|
|
return App.ajax.send({
|
|
name: 'config.recommendations',
|
|
name: 'config.recommendations',
|
|
sender: this,
|
|
sender: this,
|
|
data: {
|
|
data: {
|
|
stackVersionUrl: App.get('stackVersionURL'),
|
|
stackVersionUrl: App.get('stackVersionURL'),
|
|
dataToSend: dataToSend,
|
|
dataToSend: dataToSend,
|
|
- notDefaultGroup: configGroup && !configGroup.get('isDefault'),
|
|
|
|
clearConfigsOnAddService: clearConfigsOnAddService
|
|
clearConfigsOnAddService: clearConfigsOnAddService
|
|
},
|
|
},
|
|
- success: 'dependenciesSuccess',
|
|
|
|
- error: 'dependenciesError',
|
|
|
|
|
|
+ success: 'loadRecommendationsSuccess',
|
|
|
|
+ error: 'loadRecommendationsError',
|
|
callback: function() {
|
|
callback: function() {
|
|
|
|
+ self.set('recommendationTimeStamp', (new Date).getTime());
|
|
if (onComplete) {
|
|
if (onComplete) {
|
|
onComplete()
|
|
onComplete()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
|
|
+ if (onComplete) {
|
|
|
|
+ onComplete()
|
|
|
|
+ }
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -277,14 +268,54 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
* @param params
|
|
* @param params
|
|
* @method dependenciesSuccess
|
|
* @method dependenciesSuccess
|
|
*/
|
|
*/
|
|
- dependenciesSuccess: function (data, opt, params) {
|
|
|
|
- this._saveRecommendedValues(data, params.dataToSend.changed_configurations, params.notDefaultGroup);
|
|
|
|
|
|
+ loadRecommendationsSuccess: function (data, opt, params) {
|
|
|
|
+ this._saveRecommendedValues(data, params.dataToSend.changed_configurations);
|
|
this.set("recommendationsConfigs", Em.get(data.resources[0] , "recommendations.blueprint.configurations"));
|
|
this.set("recommendationsConfigs", Em.get(data.resources[0] , "recommendations.blueprint.configurations"));
|
|
if (params.clearConfigsOnAddService) {
|
|
if (params.clearConfigsOnAddService) {
|
|
this.clearConfigValues();
|
|
this.clearConfigValues();
|
|
this.clearAllRecommendations();
|
|
this.clearAllRecommendations();
|
|
}
|
|
}
|
|
- this.set('recommendationTimeStamp', (new Date).getTime());
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ loadRecommendationsError: Em.K,
|
|
|
|
+
|
|
|
|
+ changedDependentGroup: function() {
|
|
|
|
+ var dependentServices = this.get('stepConfigs').filter(function(stepConfig) {
|
|
|
|
+ return this.get('selectedService.dependentServiceNames').contains(stepConfig.get('serviceName'));
|
|
|
|
+ }, this);
|
|
|
|
+ App.showSelectGroupsPopup(this.get('selectedService.serviceName'),
|
|
|
|
+ this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name')),
|
|
|
|
+ dependentServices, this.get('recommendations'))
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * saves values from response for dependent config properties to <code>recommendations<code>
|
|
|
|
+ * @param data
|
|
|
|
+ * @param [changedConfigs=null]
|
|
|
|
+ * @method saveRecommendedValues
|
|
|
|
+ * @private
|
|
|
|
+ */
|
|
|
|
+ _saveRecommendedValues: function(data, changedConfigs) {
|
|
|
|
+ Em.assert('invalid data - `data.resources[0].recommendations.blueprint.configurations` not defined ', data && data.resources[0] && Em.get(data.resources[0], 'recommendations.blueprint.configurations'));
|
|
|
|
+ var recommendations = data.resources[0].recommendations;
|
|
|
|
+ if (recommendations['config-groups'] && this.get('selectedConfigGroup') && !this.get('selectedConfigGroup.isDefault')) {
|
|
|
|
+ var configFroGroup = recommendations['config-groups'][0];
|
|
|
|
+ this.get('stepConfigs').forEach(function(stepConfig) {
|
|
|
|
+ var configGroup = this.getGroupForService(stepConfig.get('serviceName'));
|
|
|
|
+ if (configGroup) {
|
|
|
|
+ this.updateOverridesByRecommendations(configFroGroup.configurations, stepConfig.get('configs'), changedConfigs, configGroup);
|
|
|
|
+ this.updateOverridesByRecommendations(configFroGroup.dependent_configurations, stepConfig.get('configs'), changedConfigs, configGroup);
|
|
|
|
+ this.toggleProperty('forceUpdateBoundaries');
|
|
|
|
+ }
|
|
|
|
+ }, this);
|
|
|
|
+ } else {
|
|
|
|
+ var configObject = recommendations.blueprint.configurations;
|
|
|
|
+ this.get('stepConfigs').forEach(function(stepConfig) {
|
|
|
|
+ this.updateConfigsByRecommendations(configObject, stepConfig.get('configs'), changedConfigs);
|
|
|
|
+ }, this);
|
|
|
|
+ this.addByRecommendations(configObject, changedConfigs);
|
|
|
|
+ }
|
|
|
|
+ this.cleanUpRecommendations();
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -292,15 +323,33 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
* @method showChangedDependentConfigs
|
|
* @method showChangedDependentConfigs
|
|
*/
|
|
*/
|
|
showChangedDependentConfigs: function(event, callback, secondary) {
|
|
showChangedDependentConfigs: function(event, callback, secondary) {
|
|
- if (this.get('recommendations.length') > 0) {
|
|
|
|
- App.showDependentConfigsPopup(this.get('changedProperties'), this.onSaveRecommendedPopup.bind(this), secondary);
|
|
|
|
|
|
+ var self = this;
|
|
|
|
+ var recommendations = event ? this.get('changedProperties') : this.get('recommendations');
|
|
|
|
+ if (recommendations.length > 0) {
|
|
|
|
+ App.showDependentConfigsPopup(recommendations, function() {
|
|
|
|
+ self.onSaveRecommendedPopup(recommendations);
|
|
|
|
+ if (callback) callback();
|
|
|
|
+ }, secondary);
|
|
} else {
|
|
} else {
|
|
- if (callback) {
|
|
|
|
- callback();
|
|
|
|
- }
|
|
|
|
|
|
+ if (callback) callback();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * update configs when toggle checkbox on dependent configs popup
|
|
|
|
+ */
|
|
|
|
+ onSaveRecommendedPopup: function(recommendations) {
|
|
|
|
+ var propertiesToUpdate = recommendations.filter(function(c) {
|
|
|
|
+ return Em.get(c, 'saveRecommendedDefault') != Em.get(c, 'saveRecommended');
|
|
|
|
+ }),
|
|
|
|
+ propertiesToUndo = propertiesToUpdate.filterProperty('saveRecommended', false),
|
|
|
|
+ propertiesToRedo = propertiesToUpdate.filterProperty('saveRecommended', true);
|
|
|
|
+
|
|
|
|
+ this.undoRedoRecommended(propertiesToUndo, false);
|
|
|
|
+ this.undoRedoRecommended(propertiesToRedo, true);
|
|
|
|
+ this.set('recommendationTimeStamp', (new Date).getTime());
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* run through config properties list (form dependent popup)
|
|
* run through config properties list (form dependent popup)
|
|
* and set value to default (undo) or recommended (redo)
|
|
* and set value to default (undo) or recommended (redo)
|
|
@@ -341,92 +390,22 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * update configs when toggle checkbox on dependent configs popup
|
|
|
|
- * @param propertiesToUndo
|
|
|
|
- * @param propertiesToRedo
|
|
|
|
- */
|
|
|
|
- onSaveRecommendedPopup: function(propertiesToUndo, propertiesToRedo) {
|
|
|
|
- this.undoRedoRecommended(propertiesToUndo, false);
|
|
|
|
- this.undoRedoRecommended(propertiesToRedo, true);
|
|
|
|
- this.set('recommendationTimeStamp', (new Date).getTime());
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- changedDependentGroup: function() {
|
|
|
|
- var dependentServices = this.get('stepConfigs').filter(function(stepConfig) {
|
|
|
|
- return this.get('selectedService.dependentServiceNames').contains(stepConfig.get('serviceName'));
|
|
|
|
- }, this);
|
|
|
|
- App.showSelectGroupsPopup(this.get('selectedService.serviceName'),
|
|
|
|
- this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name')),
|
|
|
|
- dependentServices, this.get('recommendations'))
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- * @param jqXHR
|
|
|
|
- * @param ajaxOptions
|
|
|
|
- * @param error
|
|
|
|
- * @param opt
|
|
|
|
- */
|
|
|
|
- dependenciesError: function(jqXHR, ajaxOptions, error, opt) {
|
|
|
|
- this.set('recommendationTimeStamp', (new Date).getTime());
|
|
|
|
- // We do not want to show user dialogs of failed recommendations
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * saves values from response for dependent config properties to <code>recommendations<code>
|
|
|
|
- * @param data
|
|
|
|
- * @param [changedConfigs=null]
|
|
|
|
- * @param notDefaultGroup
|
|
|
|
- * @method saveRecommendedValues
|
|
|
|
- * @private
|
|
|
|
- */
|
|
|
|
- _saveRecommendedValues: function(data, changedConfigs, notDefaultGroup) {
|
|
|
|
- Em.assert('invalid data - `data.resources[0].recommendations.blueprint.configurations` not defined ', data && data.resources[0] && Em.get(data.resources[0], 'recommendations.blueprint.configurations'));
|
|
|
|
- var configObject = data.resources[0].recommendations.blueprint.configurations;
|
|
|
|
- if (!notDefaultGroup) {
|
|
|
|
- this.get('stepConfigs').forEach(function(stepConfig) {
|
|
|
|
- this.updateConfigsByRecommendations(configObject, stepConfig.get('configs'), changedConfigs);
|
|
|
|
- }, this);
|
|
|
|
- this.addByRecommendations(configObject, changedConfigs);
|
|
|
|
- } else if (data.resources[0].recommendations['config-groups']) {
|
|
|
|
- var configFroGroup = data.resources[0].recommendations['config-groups'][0];
|
|
|
|
- this.get('stepConfigs').forEach(function(stepConfig) {
|
|
|
|
- var configGroup = this.getGroupForService(stepConfig.get('serviceName'));
|
|
|
|
- if (configGroup) {
|
|
|
|
- this.updateOverridesByRecommendations(configFroGroup.configurations, stepConfig.get('configs'), changedConfigs, configGroup);
|
|
|
|
- this.updateOverridesByRecommendations(configFroGroup.dependent_configurations, stepConfig.get('configs'), changedConfigs, configGroup);
|
|
|
|
- this.toggleProperty('forceUpdateBoundaries');
|
|
|
|
- }
|
|
|
|
- }, this);
|
|
|
|
- }
|
|
|
|
- this.cleanUpRecommendations();
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- installedServices: function () {
|
|
|
|
- return App.StackService.find().toArray().toMapByCallback('serviceName', function (item) {
|
|
|
|
- return Em.get(item, 'isInstalled');
|
|
|
|
- });
|
|
|
|
- }.property(),
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Helper method to get property from the <code>stepConfigs</code>
|
|
|
|
- *
|
|
|
|
- * @param {String} name - config property name
|
|
|
|
- * @param {String} fileName - config property filename
|
|
|
|
- * @return {App.ServiceConfigProperty|Boolean} - App.ServiceConfigProperty instance or <code>false</code> when property not found
|
|
|
|
|
|
+ * disable saving recommended value for current config
|
|
|
|
+ * @param config
|
|
|
|
+ * @param {boolean} saveRecommended
|
|
|
|
+ * @method removeCurrentFromDependentList
|
|
*/
|
|
*/
|
|
- findConfigProperty: function(name, fileName) {
|
|
|
|
- if (!name && !fileName) return false;
|
|
|
|
- if (this.get('stepConfigs') && this.get('stepConfigs.length')) {
|
|
|
|
- return this.get('stepConfigs').mapProperty('configs').filter(function(item) {
|
|
|
|
- return item.length;
|
|
|
|
- }).reduce(function(p, c) {
|
|
|
|
- if (p) {
|
|
|
|
- return p.concat(c);
|
|
|
|
|
|
+ removeCurrentFromDependentList: function (config, saveRecommended) {
|
|
|
|
+ var recommendation = this.getRecommendation(config.get('name'), config.get('filename'), config.get('group.name'));
|
|
|
|
+ if (recommendation) {
|
|
|
|
+ try {
|
|
|
|
+ if (this.saveRecommendation(recommendation)) {
|
|
|
|
+ this.undoRedoRecommended([recommendation], saveRecommended);
|
|
|
|
+ this.set('recommendationTimeStamp', (new Date).getTime());
|
|
}
|
|
}
|
|
- }).filterProperty('filename', fileName).findProperty('name', name);
|
|
|
|
|
|
+ } catch(e) {
|
|
|
|
+ console.warn(e.message);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
});
|
|
});
|