Skip to content

Commit

Permalink
B #3858: Update CPU model VM (#3895)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
  • Loading branch information
jloboescalona2 authored and Tino Vázquez committed Oct 31, 2019
1 parent 1cd286d commit 936df07
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,15 @@ define(function(require) {
function _retrieve(context) {
var templateJSON = {};
var osJSON = {};
$.extend(osJSON, WizardFields.retrieve(".bootTab", context));
$.extend(osJSON, WizardFields.retrieve(".kernelTab", context));
$.extend(osJSON, WizardFields.retrieve(".ramdiskTab", context));
$.extend(osJSON, WizardFields.retrieve(
$(".bootTab", context)
));
$.extend(osJSON, WizardFields.retrieve(
$(".kernelTab", context)
));
$.extend(osJSON, WizardFields.retrieve(
$(".ramdiskTab", context)
));

var boot = _retrieveBootValue(context);

Expand All @@ -334,13 +340,24 @@ define(function(require) {
osJSON["BOOT"] = "";
}

if (!$.isEmptyObject(osJSON)) { templateJSON["OS"] = osJSON; };
if (!$.isEmptyObject(osJSON)) {
templateJSON["OS"] = osJSON;
}

var featuresJSON = WizardFields.retrieve(
$(".featuresTab", context)
);
if (!$.isEmptyObject(featuresJSON)) {
templateJSON["FEATURES"] = featuresJSON;
}

var featuresJSON = WizardFields.retrieve(".featuresTab", context);
if (!$.isEmptyObject(featuresJSON)) { templateJSON["FEATURES"] = featuresJSON; };
var cpuModelJSON = WizardFields.retrieve(
$(".cpuTab", context)
);

var cpuModelJSON = WizardFields.retrieve(".cpuTab", context);
if (!$.isEmptyObject(cpuModelJSON)) { templateJSON["CPU_MODEL"] = cpuModelJSON; };
if (!$.isEmptyObject(cpuModelJSON)) {
templateJSON["CPU_MODEL"] = cpuModelJSON;
}

return templateJSON;
}
Expand Down
14 changes: 10 additions & 4 deletions src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,18 @@ define(function(require) {
});
}

function _submitWizard(context) {
var templateJSON = {}
function _submitWizard() {
var context = ".sunstone-content > #vms-tab #vms-tab-wizardForms.is-active";
var templateJSON = {};
$.each(this.wizardTabs, function(index, wizardTab) {
$.extend(true, templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context)));
$.extend(
true,
templateJSON,
wizardTab.retrieve(
$('#' + wizardTab.wizardTabId, context)
)
);
});

Sunstone.runAction("VM.updateconf", this.resourceId, TemplateUtils.templateToString(templateJSON));
return false;

Expand Down
13 changes: 6 additions & 7 deletions src/sunstone/public/app/utils/wizard-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ define(function(require) {

fields.each(function() {
var field = $(this);

if (field.prop('wizard_field_disabled') != true &&
field.val() != null && field.val().length &&
(field.attr("type") != "checkbox" || field.prop("checked")) &&
(field.attr("type") != "radio" || field.prop("checked"))) {
if(
field.prop('wizard_field_disabled') != true &&
field.val() != null && field.val().length &&
(field.attr("type") != "checkbox" || field.prop("checked")) &&
(field.attr("type") != "radio" || field.prop("checked"))
) {
var field_name = field.attr('wizard_field');

if (field.attr('wizard_field_64') == "true"){
templateJSON[field_name] = btoa(field.val());
} else {
templateJSON[field_name] = _retrieveInput(field);
}
}
});

return templateJSON;
}

Expand Down

0 comments on commit 936df07

Please sign in to comment.