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

Feature #3175: Add advanced section to SG wizard

This commit is contained in:
Carlos Martín 2014-10-16 11:15:31 +02:00
parent 264e956c62
commit 39fe2580ef
2 changed files with 43 additions and 9 deletions

View File

@ -27,9 +27,14 @@ module OpenNebulaJSON
return secgroup_hash
end
template = template_to_str(secgroup_hash)
if secgroup_hash['security_group_raw']
template = secgroup_hash['security_group_raw']
else
template = template_to_str(secgroup_hash)
end
self.allocate(template)
end
def perform_action(template_json)

View File

@ -82,13 +82,6 @@ function initialize_create_security_group_dialog(dialog){
rule["ICMP_TYPE"] = $(".security_group_rule_icmp_type", dialog).val();
// TODO: create generic method to show rules table
function td(attr){
return '<td>'+ (attr ? attr : '') +'</td>';
}
var text = rule_to_st(rule);
$(".security_group_rules tbody").append(
@ -139,6 +132,27 @@ function initialize_create_security_group_dialog(dialog){
return false;
}
});
$('#create_security_group_form_advanced',dialog).on('invalid.fndtn.abide', function () {
notifyError(tr("One or more required fields are missing or malformed."));
popFormDialog("create_security_group_form", $("#secgroup-tab"));
}).on('valid.fndtn.abide', function() {
if ($('#create_security_group_form_advanced',dialog).attr("action") == "create") {
var template = $('textarea#template',dialog).val();
var security_group_json = {security_group: {security_group_raw: template}};
Sunstone.runAction("SecurityGroup.create",security_group_json);
return false;
} else if ($('#create_security_group_form_advanced',dialog).attr("action") == "update") {
// TODO
//var template_raw = $('textarea#template',dialog).val();
//Sunstone.runAction("SecurityGroup.update",sg_to_update_id,template_raw);
return false;
}
});
}
function generate_json_security_group_from_form(dialog) {
@ -481,6 +495,21 @@ var create_security_group_wizard_html =
</div>\
</form>';
var create_security_group_advanced_html =
'<form data-abide="ajax" id="create_security_group_form_advanced" class="custom creation">' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<p>'+tr("Write the Security Group template here")+'</p>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="large-12 columns">' +
'<textarea id="template" rows="15" required></textarea>' +
'</div>' +
'</div>' +
'</form>';
var dataTable_security_groups;
var $create_security_group_dialog;
@ -690,7 +719,7 @@ var security_groups_tab = {
}
},
wizard_html: create_security_group_wizard_html,
// advanced_html: create_security_group_advanced_html,
advanced_html: create_security_group_advanced_html,
setup: initialize_create_security_group_dialog
}
}