mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-27 10:50:10 +03:00
Feature #4106: consistent treatment of double quotes
This commit is contained in:
parent
ec9ba2d6e2
commit
8b8faca81f
@ -29,6 +29,7 @@ define(function(require) {
|
||||
var ResourceSelect = require('utils/resource-select');
|
||||
var BrowserInfo = require('utils/browser-info');
|
||||
var OpenNebulaDatastore = require('opennebula/datastore');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./create/wizard');
|
||||
var TemplateAdvancedHTML = require('hbs!./create/advanced');
|
||||
@ -199,20 +200,20 @@ define(function(require) {
|
||||
|
||||
var img_json = {};
|
||||
|
||||
var name = $('#file_name', context).val();
|
||||
var name = WizardFields.retrieveInput($('#file_name', context));
|
||||
img_json["NAME"] = name;
|
||||
|
||||
var desc = $('#file_desc', context).val();
|
||||
var desc = WizardFields.retrieveInput($('#file_desc', context));
|
||||
if (desc.length) {
|
||||
img_json["DESCRIPTION"] = desc;
|
||||
}
|
||||
|
||||
var type = $('#file_type', context).val();
|
||||
var type = WizardFields.retrieveInput($('#file_type', context));
|
||||
img_json["TYPE"] = type;
|
||||
|
||||
switch ($('#src_path_select input:checked', context).val()){
|
||||
case "path":
|
||||
path = $('#file_path', context).val();
|
||||
path = WizardFields.retrieveInput($('#file_path', context));
|
||||
if (path) img_json["PATH"] = path;
|
||||
break;
|
||||
case "upload":
|
||||
|
@ -205,7 +205,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _submitWizard(context) {
|
||||
var name = $('#name', context).val();
|
||||
var name = WizardFields.retrieveInput($('#name', context));
|
||||
if (!name) {
|
||||
Sunstone.hideFormPanelLoading(this.tabId);
|
||||
Notifier.notifyError(Locale.tr("Host name missing!"));
|
||||
@ -216,9 +216,9 @@ define(function(require) {
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
var vmm_mad = $('select#vmm_mad', context).val();
|
||||
vmm_mad = vmm_mad == "custom" ? $('input[name="custom_vmm_mad"]').val() : vmm_mad;
|
||||
vmm_mad = vmm_mad == "custom" ? WizardFields.retrieveInput($('input[name="custom_vmm_mad"]')) : vmm_mad;
|
||||
var im_mad = $('select#im_mad', context).val();
|
||||
im_mad = im_mad == "custom" ? $('input[name="custom_im_mad"]').val() : im_mad;
|
||||
im_mad = im_mad == "custom" ? WizardFields.retrieveInput($('input[name="custom_im_mad"]')) : im_mad;
|
||||
|
||||
var host_json = {
|
||||
"host": {
|
||||
|
@ -31,6 +31,7 @@ define(function(require) {
|
||||
var CustomTagsTable = require('utils/custom-tags-table');
|
||||
var BrowserInfo = require('utils/browser-info');
|
||||
var Config = require('sunstone-config');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./create/wizard');
|
||||
var TemplateAdvancedHTML = require('hbs!./create/advanced');
|
||||
@ -265,48 +266,48 @@ define(function(require) {
|
||||
|
||||
var img_json = {};
|
||||
|
||||
var name = $('#img_name', context).val();
|
||||
var name = WizardFields.retrieveInput($('#img_name', context));
|
||||
img_json["NAME"] = name;
|
||||
|
||||
var desc = $('#img_desc', context).val();
|
||||
var desc = WizardFields.retrieveInput($('#img_desc', context));
|
||||
if (desc.length) {
|
||||
img_json["DESCRIPTION"] = desc;
|
||||
}
|
||||
|
||||
var type = $('#img_type', context).val();
|
||||
var type = WizardFields.retrieveInput($('#img_type', context));
|
||||
img_json["TYPE"] = type;
|
||||
|
||||
img_json["PERSISTENT"] = $('#img_persistent:checked', context).length ? "YES" : "NO";
|
||||
|
||||
var dev_prefix = $('#img_dev_prefix', context).val();
|
||||
var dev_prefix = WizardFields.retrieveInput($('#img_dev_prefix', context));
|
||||
if (dev_prefix.length) {
|
||||
img_json["DEV_PREFIX"] = dev_prefix;
|
||||
}
|
||||
|
||||
var driver = $('#img_driver', context).val();
|
||||
var driver = WizardFields.retrieveInput($('#img_driver', context));
|
||||
if (driver.length)
|
||||
img_json["DRIVER"] = driver;
|
||||
|
||||
var target = $('#img_target', context).val();
|
||||
var target = WizardFields.retrieveInput($('#img_target', context));
|
||||
if (target)
|
||||
img_json["TARGET"] = target;
|
||||
|
||||
var adapter_type = $('#adapter_type', context).val();
|
||||
var adapter_type = WizardFields.retrieveInput($('#adapter_type', context));
|
||||
if (adapter_type)
|
||||
img_json["ADAPTER_TYPE"] = adapter_type;
|
||||
|
||||
var disk_type = $('#disk_type', context).val();
|
||||
var disk_type = WizardFields.retrieveInput($('#disk_type', context));
|
||||
if (disk_type)
|
||||
img_json["DISK_TYPE"] = disk_type;
|
||||
|
||||
switch ($('#src_path_select input:checked', context).val()){
|
||||
case "path":
|
||||
path = $('#img_path', context).val();
|
||||
path = WizardFields.retrieveInput($('#img_path', context));
|
||||
if (path) img_json["PATH"] = path;
|
||||
break;
|
||||
case "datablock":
|
||||
size = $('#img_size', context).val();
|
||||
fstype = $('#img_fstype', context).val();
|
||||
size = WizardFields.retrieveInput($('#img_size', context));
|
||||
fstype = WizardFields.retrieveInput($('#img_fstype', context));
|
||||
if (size) img_json["SIZE"] = size;
|
||||
if (fstype) img_json["FSTYPE"] = fstype;
|
||||
break;
|
||||
|
@ -183,16 +183,6 @@ define(function(require) {
|
||||
var marketPlaceJSON = {};
|
||||
$.extend(marketPlaceJSON, WizardFields.retrieve(context));
|
||||
|
||||
var vmTemplate = $('#VMTEMPLATE', context).val();
|
||||
if (vmTemplate) {
|
||||
marketPlaceJSON['VMTEMPLATE64'] = btoa(vmTemplate);
|
||||
}
|
||||
|
||||
var appTemplate = $('#APPTEMPLATE', context).val();
|
||||
if (appTemplate) {
|
||||
marketPlaceJSON['APPTEMPLATE64'] = btoa(appTemplate);
|
||||
}
|
||||
|
||||
var marketPlaceAppObj = {
|
||||
"marketplaceapp" : marketPlaceJSON,
|
||||
"mp_id" : this.marketPlacesTable.idInput().val()
|
||||
|
@ -69,7 +69,7 @@
|
||||
{{tr "VM Template"}}
|
||||
</span>
|
||||
</label>
|
||||
<textarea id="VMTEMPLATE" rows="2"></textarea>
|
||||
<textarea id="VMTEMPLATE" rows="2" wizard_field="VMTEMPLATE64" wizard_field_64="true"></textarea>
|
||||
</div>
|
||||
<div class="medium-6 columns">
|
||||
<label for="APPTEMPLATE">
|
||||
@ -78,7 +78,7 @@
|
||||
{{tr "App Template"}}
|
||||
</span>
|
||||
</label>
|
||||
<textarea id="APPTEMPLATE" rows="2"></textarea>
|
||||
<textarea id="APPTEMPLATE" rows="2" wizard_field="APPTEMPLATE64" wizard_field_64="true"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -195,11 +195,16 @@ define(function(require) {
|
||||
|
||||
this.resourceId = element.ID;
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(TemplateUtils.templateToEditor(element.TEMPLATE));
|
||||
|
||||
WizardFields.fill(context, element.TEMPLATE);
|
||||
$('#NAME', context).val(element.NAME).
|
||||
prop("disabled", true).
|
||||
prop('wizard_field_disabled', true);;
|
||||
$('#MARKET_MAD', context).val(element.MARKET_MAD).change();
|
||||
|
||||
WizardFields.fillInput($('#NAME', context), element.NAME);
|
||||
$('#NAME', context).prop("disabled", true).prop('wizard_field_disabled', true);
|
||||
|
||||
WizardFields.fillInput($('#MARKET_MAD', context), element.MARKET_MAD);
|
||||
$('#MARKET_MAD', context).change();
|
||||
}
|
||||
|
||||
// Set up the create datastore dialog
|
||||
@ -242,7 +247,7 @@ define(function(require) {
|
||||
};
|
||||
Sunstone.runAction("MarketPlace.create", marketObj);
|
||||
} else if (this.action == "update") {
|
||||
Sunstone.runAction("Network.update", this.resourceId, template);
|
||||
Sunstone.runAction("MarketPlace.update", this.resourceId, template);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -173,14 +173,14 @@ define(function(require) {
|
||||
})
|
||||
.on('formvalid.zf.abide', function(ev, frm) {
|
||||
var rule = {};
|
||||
rule["PROTOCOL"] = $(".security_group_rule_protocol", context).val();
|
||||
rule["RULE_TYPE"] = $(".security_group_rule_type", context).val();
|
||||
rule["PROTOCOL"] = WizardFields.retrieveInput($(".security_group_rule_protocol", context));
|
||||
rule["RULE_TYPE"] = WizardFields.retrieveInput($(".security_group_rule_type", context));
|
||||
|
||||
switch ($('.security_group_rule_range_sel', context).val()) {
|
||||
case "ALL":
|
||||
break;
|
||||
case "RANGE":
|
||||
rule["RANGE"] = $(".security_group_rule_range input", context).val();
|
||||
rule["RANGE"] = WizardFields.retrieveInput($(".security_group_rule_range input", context));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -188,8 +188,8 @@ define(function(require) {
|
||||
case "ANY":
|
||||
break;
|
||||
case "NETWORK":
|
||||
rule["IP"] = $('#security_group_rule_first_ip', context).val();
|
||||
rule["SIZE"] = $('#security_group_rule_size', context).val();
|
||||
rule["IP"] = WizardFields.retrieveInput($('#security_group_rule_first_ip', context));
|
||||
rule["SIZE"] = WizardFields.retrieveInput($('#security_group_rule_size', context));
|
||||
break;
|
||||
case "VNET":
|
||||
rule["NETWORK_ID"] = that.vnetsTable.retrieveResourceTableSelect();
|
||||
@ -197,7 +197,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
if (rule["PROTOCOL"] == "ICMP" ){
|
||||
var icmp_type_val = $(".security_group_rule_icmp_type", context).val();
|
||||
var icmp_type_val = WizardFields.retrieveInput($(".security_group_rule_icmp_type", context));
|
||||
|
||||
if (icmp_type_val != ""){
|
||||
rule["ICMP_TYPE"] = icmp_type_val;
|
||||
@ -254,8 +254,8 @@ define(function(require) {
|
||||
|
||||
function _submitWizard(context) {
|
||||
|
||||
var name = $('#security_group_name', context).val();
|
||||
var description = $('#security_group_description', context).val();
|
||||
var name = WizardFields.retrieveInput($('#security_group_name', context));
|
||||
var description = WizardFields.retrieveInput($('#security_group_description', context));
|
||||
|
||||
var rules = [];
|
||||
|
||||
@ -311,14 +311,12 @@ define(function(require) {
|
||||
this.resourceId = element.ID;
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
|
||||
$('#template', context).val(TemplateUtils.templateToEditor(element.TEMPLATE));
|
||||
|
||||
$('#security_group_name',context).val(
|
||||
TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode( element.NAME ))).
|
||||
prop("disabled", true);
|
||||
WizardFields.fillInput($('#security_group_name',context), element.NAME);
|
||||
$('#security_group_name',context).prop("disabled", true);
|
||||
|
||||
$('#security_group_description', context).val(
|
||||
TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode( element.TEMPLATE.DESCRIPTION )) );
|
||||
WizardFields.fillInput($('#security_group_description', context), element.TEMPLATE.DESCRIPTION );
|
||||
|
||||
var rules = element.TEMPLATE.RULE;
|
||||
|
||||
|
@ -190,8 +190,7 @@ define(function(require) {
|
||||
var templateJSON = element.TEMPLATE;
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(
|
||||
TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, ""));
|
||||
$('#template', context).val(TemplateUtils.templateToEditor(templateJSON));
|
||||
|
||||
$.each(this.wizardTabs, function(index, wizardTab) {
|
||||
wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON);
|
||||
|
@ -187,7 +187,7 @@ define(function(require) {
|
||||
var templateJSON = {};
|
||||
|
||||
if($("input[name='context_type']:checked", context).val() == "context_type_vcenter"){
|
||||
var customization = $('input.vcenter_customizations_value', context).val();
|
||||
var customization = WizardFields.retrieveInput($('input.vcenter_customizations_value', context));
|
||||
|
||||
if (customization) {
|
||||
templateJSON["VCENTER_PUBLIC_CLOUD"] = {
|
||||
@ -199,9 +199,9 @@ define(function(require) {
|
||||
$.extend(contextJSON, CustomTagsTable.retrieve(context));
|
||||
|
||||
if ($(".ssh_context", context).is(":checked")) {
|
||||
var public_key = $("#ssh_public_key", context).val();
|
||||
var public_key = WizardFields.retrieveInput($("#ssh_public_key", context));
|
||||
if (public_key) {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = TemplateUtils.escapeDoubleQuotes(public_key);
|
||||
contextJSON["SSH_PUBLIC_KEY"] = public_key;
|
||||
} else {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = '$USER[SSH_PUBLIC_KEY]';
|
||||
}
|
||||
@ -222,10 +222,10 @@ define(function(require) {
|
||||
contextJSON[name] = "$" + name;
|
||||
});
|
||||
|
||||
var start_script = $(".START_SCRIPT", context).val();
|
||||
var start_script = WizardFields.retrieveInput($(".START_SCRIPT", context));
|
||||
if (start_script != "") {
|
||||
if ($(".ENCODE_START_SCRIPT", context).is(":checked")) {
|
||||
contextJSON["START_SCRIPT_BASE64"] = btoa(start_script);
|
||||
contextJSON["START_SCRIPT_BASE64"] = btoa($(".START_SCRIPT", context).val());
|
||||
} else {
|
||||
contextJSON["START_SCRIPT"] = start_script;
|
||||
}
|
||||
@ -255,7 +255,7 @@ define(function(require) {
|
||||
$("input#context_type_vcenter", context).click();
|
||||
|
||||
if(this["CUSTOMIZATION_SPEC"]){
|
||||
$('input.vcenter_customizations_value', context).val(this["CUSTOMIZATION_SPEC"]).change();
|
||||
WizardFields.fillInput($('input.vcenter_customizations_value', context), this["CUSTOMIZATION_SPEC"]);
|
||||
} else if(userInputsJSON || contextJSON) {
|
||||
$("input#context_type_opennebula", context).click();
|
||||
}
|
||||
@ -296,16 +296,16 @@ define(function(require) {
|
||||
$(".ssh_context", context).prop('checked', 'checked');
|
||||
|
||||
if (!publickey_regexp.test(value)) {
|
||||
$("#ssh_public_key", context).val(TemplateUtils.htmlDecode(value));
|
||||
WizardFields.fillInput($("#ssh_public_key", context), value);
|
||||
}
|
||||
} else if (token_regexp.test(key)) {
|
||||
$(".token_context", context).prop('checked', 'checked');
|
||||
} else if (net_regexp.test(key)) {
|
||||
$(".network_context", context).prop('checked', 'checked');
|
||||
} else if ("INIT_SCRIPTS" == key) {
|
||||
$("input.INIT_SCRIPTS").val(TemplateUtils.htmlDecode(value));
|
||||
WizardFields.fillInput($("input.INIT_SCRIPTS", context), value);
|
||||
} else if ("FILES_DS" == key) {
|
||||
$('.FILES_DS', context).val(TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode(contextJSON["FILES_DS"])))
|
||||
WizardFields.fillInput($('.FILES_DS', context), contextJSON["FILES_DS"]);
|
||||
var files = [];
|
||||
while (match = file_ds_regexp.exec(value)) {
|
||||
files.push(match[1])
|
||||
@ -319,7 +319,7 @@ define(function(require) {
|
||||
$(".ENCODE_START_SCRIPT", context).prop('checked', 'checked');
|
||||
$(".START_SCRIPT", context).val(atob(value));
|
||||
} else if ("START_SCRIPT" == key) {
|
||||
$(".START_SCRIPT", context).val(TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode(value)));
|
||||
WizardFields.fillInput($(".START_SCRIPT", context), value);
|
||||
} else {
|
||||
customTagsJSON[key] = value;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ define(function(require) {
|
||||
var Config = require('sunstone-config');
|
||||
var UserInputs = require('utils/user-inputs');
|
||||
var UniqueId = require('utils/unique-id');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -93,7 +94,7 @@ define(function(require) {
|
||||
context.on("change", "#LOGO", function() {
|
||||
$("#template_create_logo", context).show();
|
||||
$("#template_create_logo", context).html('<span class="">' +
|
||||
'<img src="' + $(this).val() + '">' +
|
||||
'<img src="' + TemplateUtils.htmlDecode($(this).val()) + '">' +
|
||||
'</span>');
|
||||
});
|
||||
|
||||
@ -114,7 +115,7 @@ define(function(require) {
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter') {
|
||||
templateJSON["VCENTER_PUBLIC_CLOUD"] = {
|
||||
'TYPE': 'vcenter',
|
||||
'VM_TEMPLATE': $("#vcenter_template_uuid", context).val()
|
||||
'VM_TEMPLATE': WizardFields.retrieveInput($("#vcenter_template_uuid", context))
|
||||
};
|
||||
|
||||
templateJSON["KEEP_DISKS_ON_DONE"] = $("#KEEP_DISKS", context).is(':checked')?"YES":"NO"
|
||||
@ -135,9 +136,9 @@ define(function(require) {
|
||||
// Retrieve Datastore Attribute
|
||||
var dsInput = $(".vcenter_datastore_input", context);
|
||||
if (dsInput.length > 0) {
|
||||
var dsModify = $('.modify_datastore', dsInput).val();
|
||||
var dsInitial = $('.initial_datastore', dsInput).val();
|
||||
var dsParams = $('.available_datastores', dsInput).val();
|
||||
var dsModify = WizardFields.retrieveInput($('.modify_datastore', dsInput));
|
||||
var dsInitial = WizardFields.retrieveInput($('.initial_datastore', dsInput));
|
||||
var dsParams = WizardFields.retrieveInput($('.available_datastores', dsInput));
|
||||
|
||||
if (dsModify === 'fixed' && dsInitial !== '') {
|
||||
templateJSON['VCENTER_DATASTORE'] = dsInitial;
|
||||
@ -156,9 +157,9 @@ define(function(require) {
|
||||
// Retrieve Resource Pool Attribute
|
||||
var rpInput = $(".vcenter_rp_input", context);
|
||||
if (rpInput.length > 0) {
|
||||
var rpModify = $('.modify_rp', rpInput).val();
|
||||
var rpInitial = $('.initial_rp', rpInput).val();
|
||||
var rpParams = $('.available_rps', rpInput).val();
|
||||
var rpModify = WizardFields.retrieveInput($('.modify_rp', rpInput));
|
||||
var rpInitial = WizardFields.retrieveInput($('.initial_rp', rpInput));
|
||||
var rpParams = WizardFields.retrieveInput($('.available_rps', rpInput));
|
||||
|
||||
if (rpModify === 'fixed' && rpInitial !== '') {
|
||||
templateJSON['RESOURCE_POOL'] = rpInitial;
|
||||
@ -167,7 +168,7 @@ define(function(require) {
|
||||
type: 'list',
|
||||
description: Locale.tr("Which resource pool you want this VM to run in?"),
|
||||
initial: rpInitial,
|
||||
params: $('.available_rps', rpInput).val()
|
||||
params: WizardFields.retrieveInput($('.available_rps', rpInput))
|
||||
});
|
||||
|
||||
userInputs['RESOURCE_POOL'] = rpUserInputs;
|
||||
@ -213,7 +214,7 @@ define(function(require) {
|
||||
|
||||
$.each(publicClouds, function(){
|
||||
if(this["TYPE"] == "vcenter"){
|
||||
$("#vcenter_template_uuid", context).val(this["VM_TEMPLATE"]);
|
||||
WizardFields.fillInput($("#vcenter_template_uuid", context), this["VM_TEMPLATE"]);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -243,12 +244,12 @@ define(function(require) {
|
||||
|
||||
if (templateJSON["VCENTER_DATASTORE"]) {
|
||||
$('.modify_datastore', context).val('fixed');
|
||||
$('.initial_datastore', context).val(templateJSON["VCENTER_DATASTORE"]);
|
||||
WizardFields.fillInput($('.initial_datastore', context), templateJSON["VCENTER_DATASTORE"]);
|
||||
}
|
||||
|
||||
if (templateJSON["RESOURCE_POOL"]) {
|
||||
$('.modify_rp', context).val('fixed');
|
||||
$('.initial_rp', context).val(templateJSON["RESOURCE_POOL"]);
|
||||
WizardFields.fillInput($('.initial_rp', context), templateJSON["RESOURCE_POOL"]);
|
||||
}
|
||||
|
||||
CapacityCreate.fill($("div.capacityCreate", context), templateJSON);
|
||||
|
@ -74,7 +74,6 @@ define(function(require) {
|
||||
|
||||
function _setup(context) {
|
||||
$("input[name='graphics_type']", context).change(function() {
|
||||
$("#TYPE", context).val($(this).attr("value"));
|
||||
if ($(this).attr("value") !== '') {
|
||||
$('input[wizard_field="LISTEN"]', context).val("0.0.0.0");
|
||||
} else {
|
||||
@ -93,14 +92,14 @@ define(function(require) {
|
||||
var element1 = document.createElement("input");
|
||||
element1.id = "INPUT_TYPE"
|
||||
element1.type = "text";
|
||||
element1.value = $('select#INPUT_TYPE', context).val()
|
||||
element1.value = WizardFields.retrieveInput($('select#INPUT_TYPE', context));
|
||||
cell1.appendChild(element1);
|
||||
|
||||
var cell2 = row.insertCell(1);
|
||||
var element2 = document.createElement("input");
|
||||
element2.id = "INPUT_BUS"
|
||||
element2.type = "text";
|
||||
element2.value = $('select#INPUT_BUS', context).val()
|
||||
element2.value = WizardFields.retrieveInput($('select#INPUT_BUS', context));
|
||||
cell2.appendChild(element2);
|
||||
|
||||
var cell3 = row.insertCell(2);
|
||||
@ -127,8 +126,8 @@ define(function(require) {
|
||||
$('#input_table tr', context).each(function() {
|
||||
if ($('#INPUT_TYPE', $(this)).val()) {
|
||||
inputsJSON.push({
|
||||
'TYPE': $('#INPUT_TYPE', $(this)).val(),
|
||||
'BUS': $('#INPUT_BUS', $(this)).val()
|
||||
'TYPE': WizardFields.retrieveInput($('#INPUT_TYPE', $(this))),
|
||||
'BUS': WizardFields.retrieveInput($('#INPUT_BUS', $(this)))
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -20,19 +20,18 @@
|
||||
<legend>{{tr "Graphics"}}</legend>
|
||||
<div class="">
|
||||
<div class="large-12 columns text-center">
|
||||
<input type="radio" name="graphics_type" ID="radioNoneType{{uniqueId}}" value="" checked>
|
||||
<input type="radio" wizard_field="TYPE" name="graphics_type" ID="radioNoneType{{uniqueId}}" value="" checked>
|
||||
<label for="radioNoneType{{uniqueId}}">{{tr "None"}}</label>
|
||||
<input type="radio" name="graphics_type" ID="radioVncType{{uniqueId}}" value="VNC">
|
||||
<input type="radio" wizard_field="TYPE" name="graphics_type" ID="radioVncType{{uniqueId}}" value="VNC">
|
||||
<label for="radioVncType{{uniqueId}}">VNC</label>
|
||||
<input type="radio" name="graphics_type" ID="radioSdlType{{uniqueId}}" value="SDL" class="hypervisor only_kvm" >
|
||||
<input type="radio" wizard_field="TYPE" name="graphics_type" ID="radioSdlType{{uniqueId}}" value="SDL" class="hypervisor only_kvm" >
|
||||
<label class="hypervisor only_kvm" for="radioSdlType{{uniqueId}}">SDL</label>
|
||||
<input type="radio" name="graphics_type" ID="radioSpiceType{{uniqueId}}" value="SPICE" class="hypervisor only_kvm" >
|
||||
<input type="radio" wizard_field="TYPE" name="graphics_type" ID="radioSpiceType{{uniqueId}}" value="SPICE" class="hypervisor only_kvm" >
|
||||
<label class="hypervisor only_kvm" for="radioSpiceType{{uniqueId}}">SPICE</label>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="">
|
||||
<input type="hidden" wizard_field="TYPE" name="graphics_type" ID="TYPE">
|
||||
<div class="large-12 columns">
|
||||
<label>
|
||||
{{tr "Listen IP"}}
|
||||
|
@ -121,7 +121,7 @@ define(function(require) {
|
||||
|
||||
if (nicsJSON.length > 0) { templateJSON['NIC'] = nicsJSON; };
|
||||
|
||||
var nicDefault = $('#DEFAULT_MODEL', context).val();
|
||||
var nicDefault = WizardFields.retrieveInput($('#DEFAULT_MODEL', context));
|
||||
if (nicDefault) {
|
||||
templateJSON['NIC_DEFAULT'] = {
|
||||
'MODEL': nicDefault
|
||||
@ -157,7 +157,7 @@ define(function(require) {
|
||||
var nicDefault = templateJSON.NIC_DEFAULT
|
||||
if (nicDefault != undefined) {
|
||||
if (nicDefault.MODEL) {
|
||||
$('#DEFAULT_MODEL', context).val(nicDefault.MODEL);
|
||||
WizardFields.fillInput($('#DEFAULT_MODEL', context), nicDefault.MODEL);
|
||||
}
|
||||
|
||||
delete templateJSON.NIC_DEFAULT;
|
||||
|
@ -105,12 +105,12 @@ define(function(require) {
|
||||
|
||||
var tcp = $("input.tcp_type:checked", context).val();
|
||||
if (tcp) {
|
||||
nicJSON[tcp] = $("#TCP_PORTS", context).val();
|
||||
nicJSON[tcp] = WizardFields.retrieveInput($("#TCP_PORTS", context));
|
||||
}
|
||||
|
||||
var udp = $("input.udp_type:checked", context).val();
|
||||
if (udp) {
|
||||
nicJSON[udp] = $("#UDP_PORTS", context).val();
|
||||
nicJSON[udp] = WizardFields.retrieveInput($("#UDP_PORTS", context));
|
||||
}
|
||||
|
||||
if ($("#icmp_type", context).is(":checked")) {
|
||||
@ -147,24 +147,24 @@ define(function(require) {
|
||||
var field = $("input.tcp_type[value='WHITE_PORTS_TCP']", context);
|
||||
field.click();
|
||||
|
||||
$("#TCP_PORTS", context).val(templateJSON["WHITE_PORTS_TCP"]);
|
||||
WizardFields.fillInput($("#TCP_PORTS", context), templateJSON["WHITE_PORTS_TCP"]);
|
||||
} else if (templateJSON["BLACK_PORTS_TCP"]) {
|
||||
var field = $("input.tcp_type[value='BLACK_PORTS_TCP']", context);
|
||||
field.click();
|
||||
|
||||
$("#TCP_PORTS", context).val(templateJSON["BLACK_PORTS_TCP"]);
|
||||
WizardFields.fillInput($("#TCP_PORTS", context), templateJSON["BLACK_PORTS_TCP"]);
|
||||
}
|
||||
|
||||
if (templateJSON["WHITE_PORTS_UDP"]) {
|
||||
var field = $("input.udp_type[value='WHITE_PORTS_UDP']", context);
|
||||
field.click();
|
||||
|
||||
$("#UDP_PORTS", context).val(templateJSON["WHITE_PORTS_UDP"]);
|
||||
WizardFields.fillInput($("#UDP_PORTS", context), templateJSON["WHITE_PORTS_UDP"]);
|
||||
} else if (templateJSON["BLACK_PORTS_UDP"]) {
|
||||
var field = $("input.udp_type[value='BLACK_PORTS_UDP']", context);
|
||||
field.click();
|
||||
|
||||
$("#UDP_PORTS", context).val(templateJSON["BLACK_PORTS_UDP"]);
|
||||
WizardFields.fillInput($("#UDP_PORTS", context), templateJSON["BLACK_PORTS_UDP"]);
|
||||
}
|
||||
|
||||
if (templateJSON["ICMP"]) {
|
||||
|
@ -147,7 +147,7 @@ define(function(require) {
|
||||
var templateJSON = CustomTagsTable.retrieve(context);
|
||||
|
||||
var rawJSON = {}
|
||||
var rawData = TemplateUtils.escapeDoubleQuotes($('.raw_data', context).val());
|
||||
var rawData = WizardFields.retrieveInput($('.raw_data', context));
|
||||
if (rawData != "") {
|
||||
rawJSON['DATA'] = rawData;
|
||||
|
||||
@ -179,7 +179,7 @@ define(function(require) {
|
||||
if (rawJSON) {
|
||||
$('.raw_type', context).val(rawJSON['TYPE']);
|
||||
$('.raw_type', context).change();
|
||||
$('.raw_data', context).val(TemplateUtils.htmlDecode(rawJSON['DATA']));
|
||||
WizardFields.fillInput($('.raw_data', context), rawJSON['DATA']);
|
||||
|
||||
delete templateJSON.RAW
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ define(function(require) {
|
||||
});
|
||||
|
||||
context.on("change", "input[name='rank_select']", function() {
|
||||
$("#SCHED_RANK", context).val(this.value);
|
||||
WizardFields.fillInput($("#SCHED_RANK", context), this.value);
|
||||
});
|
||||
|
||||
context.on("change", "input[name='ds_rank_select']", function() {
|
||||
$("#SCHED_DS_RANK", context).val(this.value);
|
||||
WizardFields.fillInput($("#SCHED_DS_RANK", context), this.value);
|
||||
});
|
||||
|
||||
var selectOptions = {
|
||||
@ -132,6 +132,8 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _fill(context, templateJSON) {
|
||||
WizardFields.fill(context, templateJSON);
|
||||
|
||||
var reqJSON = templateJSON['SCHED_REQUIREMENTS'];
|
||||
if (reqJSON) {
|
||||
var req = TemplateUtils.escapeDoubleQuotes(reqJSON);
|
||||
@ -162,14 +164,12 @@ define(function(require) {
|
||||
|
||||
this.clustersTable.selectResourceTableSelect(selectedResources);
|
||||
|
||||
$('input#SCHED_REQUIREMENTS', context).val(TemplateUtils.htmlDecode(req));
|
||||
delete templateJSON['SCHED_REQUIREMENTS'];
|
||||
}
|
||||
|
||||
var dsReqJSON = templateJSON['SCHED_DS_REQUIREMENTS'];
|
||||
if (dsReqJSON) {
|
||||
var dsReq = TemplateUtils.escapeDoubleQuotes(dsReqJSON);
|
||||
$('input#SCHED_DS_REQUIREMENTS', context).val(TemplateUtils.htmlDecode(dsReq));
|
||||
delete templateJSON['SCHED_DS_REQUIREMENTS'];
|
||||
}
|
||||
|
||||
@ -190,8 +190,6 @@ define(function(require) {
|
||||
$('input[name="rank_select"]#loadawareRadio', context).click()
|
||||
}
|
||||
|
||||
$('input#SCHED_RANK', context).val(TemplateUtils.htmlDecode(rankJSON));
|
||||
|
||||
delete templateJSON["SCHED_RANK"];
|
||||
}
|
||||
|
||||
@ -207,8 +205,6 @@ define(function(require) {
|
||||
$('input[name="ds_rank_select"]#packingDSRadio', context).click()
|
||||
}
|
||||
|
||||
$('input#SCHED_DS_RANK', context).val(TemplateUtils.htmlDecode(dsRankJSON));
|
||||
|
||||
delete templateJSON["SCHED_DS_RANK"];
|
||||
}
|
||||
}
|
||||
|
@ -319,13 +319,10 @@ define(function(require) {
|
||||
this.resourceId = element.ID;
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
|
||||
$('#template', context).val(TemplateUtils.templateToEditor(element.TEMPLATE));
|
||||
|
||||
|
||||
$('[wizard_field="NAME"]',context).val(
|
||||
TemplateUtils.escapeDoubleQuotes( TemplateUtils.htmlDecode(element.NAME) )).
|
||||
prop("disabled", true).
|
||||
prop('wizard_field_disabled', true);
|
||||
WizardFields.fillInput($('[wizard_field="NAME"]',context), element.NAME);
|
||||
$('[wizard_field="NAME"]',context).prop("disabled", true).prop('wizard_field_disabled', true);
|
||||
|
||||
WizardFields.fill($("#vdcCreateGeneralTab", context), element.TEMPLATE);
|
||||
|
||||
|
@ -148,7 +148,7 @@ define(function(require) {
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(
|
||||
TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, ""));
|
||||
TemplateUtils.templateToEditor(templateJSON));
|
||||
|
||||
$.each(this.wizardTabs, function(index, wizardTab) {
|
||||
wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON);
|
||||
|
@ -349,12 +349,10 @@ define(function(require) {
|
||||
|
||||
$("#default_sg_warning").hide();
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
|
||||
$('#template', context).val(TemplateUtils.templateToEditor(element.TEMPLATE));
|
||||
|
||||
$('[wizard_field="NAME"]', context).val(
|
||||
TemplateUtils.escapeDoubleQuotes( TemplateUtils.htmlDecode(element.NAME) )).
|
||||
prop("disabled", true).
|
||||
prop('wizard_field_disabled', true);
|
||||
WizardFields.fillInput($('[wizard_field="NAME"]', context), element.NAME);
|
||||
$('[wizard_field="NAME"]', context).prop("disabled", true).prop('wizard_field_disabled', true);
|
||||
|
||||
// Show all network mode inputs, and make them not required. This will change
|
||||
// if a different network model is selected
|
||||
@ -365,7 +363,7 @@ define(function(require) {
|
||||
$('input#ip_spoofing,label[for="ip_spoofing"]', context).show().prop('wizard_field_disabled', false);
|
||||
$('input#mac_spoofing,label[for="mac_spoofing"]', context).show().prop('wizard_field_disabled', false);
|
||||
|
||||
$('input#vn_mad', context).val(element.TEMPLATE["VN_MAD"]);
|
||||
WizardFields.fillInput($('input#vn_mad', context), element.TEMPLATE["VN_MAD"]);
|
||||
|
||||
WizardFields.fill($("#vnetCreateGeneralTab", context), element.TEMPLATE);
|
||||
WizardFields.fill($("#vnetCreateBridgeTab", context), element.TEMPLATE);
|
||||
|
@ -22,6 +22,7 @@ define(function(require) {
|
||||
var VectorRowTemplateHTML = require('hbs!./custom-tags-table/vector-row');
|
||||
var VectorAttributeRowTemplateHTML = require('hbs!./custom-tags-table/vector-attribute-row');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
|
||||
function _html(){
|
||||
return TemplateHTML();
|
||||
@ -53,21 +54,23 @@ define(function(require) {
|
||||
|
||||
$('tbody.custom_tags tr', context).each(function(){
|
||||
if ($('.custom_tag_key', $(this)).val()) {
|
||||
template_json[$('.custom_tag_key', $(this)).val()] = $('.custom_tag_value', $(this)).val();
|
||||
var key = WizardFields.retrieveInput($('.custom_tag_key', $(this)));
|
||||
template_json[key] = WizardFields.retrieveInput($('.custom_tag_value', $(this)));
|
||||
}
|
||||
|
||||
if ($('.custom_vector_key', $(this)).val()) {
|
||||
var vectorAttributes = {};
|
||||
|
||||
$('tbody.custom_vector_attributes tr', $(this)).each(function(){
|
||||
var key = $('.custom_vector_attribute_key', $(this)).val();
|
||||
var key = WizardFields.retrieveInput($('.custom_vector_attribute_key', $(this)));
|
||||
if (key) {
|
||||
vectorAttributes[key] = $('.custom_vector_attribute_value', $(this)).val();
|
||||
vectorAttributes[key] = WizardFields.retrieveInput($('.custom_vector_attribute_value', $(this)));
|
||||
}
|
||||
});
|
||||
|
||||
if (!$.isEmptyObject(vectorAttributes)){
|
||||
template_json[$('.custom_vector_key', $(this)).val()] = vectorAttributes;
|
||||
var key = WizardFields.retrieveInput($('.custom_vector_key', $(this)));
|
||||
template_json[key] = vectorAttributes;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -85,10 +88,12 @@ define(function(require) {
|
||||
$("tbody.custom_tags", context).append(
|
||||
VectorRowTemplateHTML({key: key, value: value}));
|
||||
} else {
|
||||
var val = TemplateUtils.escapeDoubleQuotes(TemplateUtils.htmlDecode(value));
|
||||
|
||||
$("tbody.custom_tags", context).append(
|
||||
RowTemplateHTML({
|
||||
key: key,
|
||||
value: TemplateUtils.escapeDoubleQuotes(value)
|
||||
value: val
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -22,7 +22,18 @@ define(function(require) {
|
||||
//Escape doublequote in a string and return it
|
||||
function _escapeDoubleQuotes(string) {
|
||||
if (string != undefined && typeof(string) == "string") {
|
||||
return string.replace(/\\/g, '\\').replace(/"/g, '\\"');
|
||||
// Recursive to deal with strings like: 'aa""b"'
|
||||
// The second " would not match
|
||||
|
||||
var prev;
|
||||
var result = string;
|
||||
|
||||
do {
|
||||
prev = result;
|
||||
result = prev.replace(/([^\\]|^)"/g, '$1\\"');
|
||||
} while (prev != result)
|
||||
|
||||
return result;
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
@ -57,22 +68,27 @@ define(function(require) {
|
||||
template_str += key + " = [\n";
|
||||
|
||||
template_str += Object.keys(element).map(function(k){
|
||||
return " " + k + " = \"" + element[k].toString().replace(/"/g, "\\\"") + "\"";
|
||||
return " " + k + " = \"" + _escapeDoubleQuotes(element[k].toString()) + "\"";
|
||||
}).join(",\n")
|
||||
|
||||
template_str += " ]\n";
|
||||
} else { // or a string
|
||||
template_str += key + " = \"" + element.toString().replace(/"/g, "\\\"") + "\"\n";
|
||||
template_str += key + " = \"" + _escapeDoubleQuotes(element.toString()) + "\"\n";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return _htmlDecode(template_str);
|
||||
return template_str;
|
||||
}
|
||||
|
||||
function _templateToEditor(template_json, unshown_values) {
|
||||
return _htmlDecode(_convert_template_to_string(template_json, unshown_values));
|
||||
}
|
||||
|
||||
return {
|
||||
'templateToString': _convert_template_to_string,
|
||||
'templateToEditor': _templateToEditor,
|
||||
'htmlDecode': _htmlDecode,
|
||||
'escapeDoubleQuotes': _escapeDoubleQuotes
|
||||
};
|
||||
|
@ -24,7 +24,9 @@ define(function(require) {
|
||||
|
||||
return {
|
||||
'retrieve': _retrieveWizardFields,
|
||||
'fill': _fillWizardFields
|
||||
'fill': _fillWizardFields,
|
||||
'retrieveInput': _retrieveInput,
|
||||
'fillInput': _fillInput
|
||||
}
|
||||
|
||||
function _retrieveWizardFields(context) {
|
||||
@ -43,7 +45,7 @@ define(function(require) {
|
||||
if (field.attr('wizard_field_64') == "true"){
|
||||
templateJSON[field_name] = btoa(field.val());
|
||||
} else {
|
||||
templateJSON[field_name] = field.val();
|
||||
templateJSON[field_name] = _retrieveInput(field);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -51,6 +53,10 @@ define(function(require) {
|
||||
return templateJSON;
|
||||
}
|
||||
|
||||
function _retrieveInput(input) {
|
||||
return TemplateUtils.escapeDoubleQuotes(input.val());
|
||||
}
|
||||
|
||||
// TODO: wizard_field_64 for fill method
|
||||
function _fillWizardFields(context, templateJSON) {
|
||||
var fields = $('[wizard_field]', context);
|
||||
@ -88,10 +94,7 @@ define(function(require) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
field.val(
|
||||
TemplateUtils.escapeDoubleQuotes(
|
||||
TemplateUtils.htmlDecode(field_val)));
|
||||
field.change();
|
||||
_fillInput(field, field_val)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,4 +102,13 @@ define(function(require) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _fillInput(input, value) {
|
||||
input.val(
|
||||
TemplateUtils.escapeDoubleQuotes(
|
||||
TemplateUtils.htmlDecode(value)));
|
||||
|
||||
input.change();
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user