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

Feature #4082: New user input type in sunstone, text64

This commit is contained in:
Carlos Martín 2015-10-30 10:57:41 +01:00
parent 440fdf4299
commit c7e76eebdf
3 changed files with 33 additions and 13 deletions

View File

@ -171,6 +171,7 @@ define(function(require) {
'<td>' +
'<select class="user_input_type" >' +
'<option value="text">' + Locale.tr("text") + '</option>' +
'<option value="text64">' + Locale.tr("text (base64)") + '</option>' +
'<option value="password">' + Locale.tr("password") + '</option>' +
'</select>' +
'</td>' +

View File

@ -87,8 +87,7 @@ define(function(require) {
network_attrs.push(attrs)
break;
case "text":
text_attrs.push(attrs)
break;
case "text64":
case "password":
text_attrs.push(attrs)
break;
@ -154,16 +153,30 @@ define(function(require) {
div.append('<div class="instantiate_user_inputs"/>');
$.each(text_attrs, function(index, custom_attr) {
$(".instantiate_user_inputs", div).append(
'<div class="row">' +
'<div class="large-12 large-centered columns">' +
'<label>' +
TemplateUtils.htmlDecode(custom_attr.description) +
'<input type="' + custom_attr.type + '" wizard_field="' + custom_attr.name + '" required/>' +
'</label>' +
'</div>' +
'</div>');
});
var input;
switch (custom_attr.type) {
case "text":
input = '<textarea type="text" rows="1" wizard_field="' + custom_attr.name + '" required/>';
break;
case "text64":
input = '<textarea type="text" rows="1" wizard_field_64="true" wizard_field="' + custom_attr.name + '" required/>';
break;
case "password":
input = '<input type="password" wizard_field="' + custom_attr.name + '" required/>';
break;
}
$(".instantiate_user_inputs", div).append(
'<div class="row">' +
'<div class="large-12 large-centered columns">' +
'<label>' +
TemplateUtils.htmlDecode(custom_attr.description) +
input +
'</label>' +
'</div>' +
'</div>');
});
}
return (network_attrs.length > 0 || text_attrs.length > 0);

View File

@ -39,13 +39,19 @@ define(function(require) {
(field.attr("type") != "checkbox" || field.prop("checked")) &&
(field.attr("type") != "radio" || field.prop("checked"))) {
var field_name = field.attr('wizard_field');
templateJSON[field_name] = field.val();
if (field.attr('wizard_field_64') == "true"){
templateJSON[field_name] = btoa(field.val());
} else {
templateJSON[field_name] = field.val();
}
}
});
return templateJSON;
}
// TODO: wizard_field_64 for fill method
function _fillWizardFields(context, templateJSON) {
var fields = $('[wizard_field]', context);