1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

B #5578: Fix user inputs on service form (#1593)

This commit is contained in:
Sergio Betanzos 2021-11-19 14:58:08 +01:00 committed by GitHub
parent 71b92d8724
commit 20e45c5798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 18 deletions

View File

@ -289,26 +289,32 @@ define(function(require) {
});
extra_info.merge_template.custom_attrs_values = $.extend({}, optionalCustomAttrs, extra_info.merge_template.custom_attrs_values);
}
if(that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles){
if (that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles) {
var charters = "";
var scheduleActionsList = ScheduleActions.retrieve(context, true)
$.each(scheduleActionsList, function(_,sched_action){
charters += TemplateUtils.templateToString(sched_action);
});
$.each(that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles, function(index, role){
var temp_role = {};
$.extend( temp_role, role);
vm_template_contents = TemplateUtils.stringToTemplate(role.vm_template_contents);
var div_id = "user_input_role_"+index;
var tmp_json = {};
$.extend( tmp_json, WizardFields.retrieve($("#"+div_id, context)) );
$.each(tmp_json, function(key, value){
if (Array.isArray(value)){
delete vm_template_contents[key];
vm_template_contents[key] = value.join(",");
var temp_role = $.extend({}, role);
var temp_inputs = $.extend({}, WizardFields.retrieve($("#user_input_role_"+index, context)));
var vm_template_contents = TemplateUtils.stringToTemplate(role.vm_template_contents);
$.each(temp_inputs, function(inputName, inputValue) {
if (Array.isArray(inputValue)) {
delete temp_inputs[inputName];
temp_inputs[inputName] = inputValue.join(",");
}
// removes duplicated inputs in context
delete vm_template_contents[inputName];
});
temp_role.user_inputs_values = temp_inputs;
temp_role.vm_template_contents = TemplateUtils.templateToString(vm_template_contents);
var stringCustomValues = TemplateUtils.templateToString(customAttrsValues);
if (stringCustomValues) {
(temp_role.vm_template_contents)

View File

@ -1572,20 +1572,30 @@ define(function(require) {
var extra_info = ServiceUtils.getExtraInfo(context, Config.isFeatureEnabled("show_vnet_instantiate_flow"));
$(".provision_create_flow_role", context).each(function(){
var user_inputs_values = WizardFields.retrieve($(".provision_custom_attributes_selector", $(this)));
var role_template = $(this).data("opennebula");
var cardinality = WizardFields.retrieve( $(".provision_cardinality_selector", $(this)) )["cardinality"];
var temp_inputs = WizardFields.retrieve($(".provision_custom_attributes_selector", $(this)));
var vm_template_contents = TemplateUtils.stringToTemplate(role_template.vm_template_contents);
$.each(temp_inputs, function(inputName, inputValue) {
if (Array.isArray(inputValue)) {
delete temp_inputs[inputName];
temp_inputs[inputName] = inputValue.join(",");
}
// removes duplicated inputs in context
delete vm_template_contents[inputName];
});
extra_info.merge_template.roles.push($.extend(role_template, {
"cardinality": cardinality,
"user_inputs_values": user_inputs_values
cardinality: cardinality,
user_inputs_values: temp_inputs,
vm_template_contents: TemplateUtils.templateToString(vm_template_contents),
}));
});
if (flow_name){
extra_info["merge_template"]["name"] = flow_name;
if (flow_name) {
extra_info.merge_template.name = flow_name;
}
Sunstone.runAction("Provision.Flow.instantiate", template_id, extra_info);