From c66e3cbddcf661f1bb88e9a3ec149ee2c4dda88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 13 Mar 2014 17:41:00 +0100 Subject: [PATCH] Feature #2746: fix nic advanced section --- .../public/js/plugins/templates-tab.js | 47 +++++++++++-------- src/sunstone/public/js/plugins/vms-tab.js | 6 +-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 90b4610634..3e9c4dd2e6 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -332,7 +332,8 @@ var template_actions = { type: "single", call: OpenNebula.Template.update, callback: function(request, response){ - $create_template_dialog.foundation('reveal', 'close') + $create_template_dialog.foundation('reveal', 'close'); + templateShow(request); notifyMessage(tr("Template updated correctly")); }, error: onError @@ -1649,8 +1650,10 @@ function generate_nic_tab_content(str_nic_tab_id, str_datatable_id){ ''+tr("ICMP")+''+ '
'+ '
'+ - ''+ - ''+ + ''+ '
'+ '
'+ ''+ @@ -1665,6 +1668,27 @@ function generate_nic_tab_content(str_nic_tab_id, str_datatable_id){ return html; } +function retrieve_nic_tab_data(context){ + var data = {}; + addSectionJSON(data, context); + + var tcp = $("input.tcp_type:checked", context).val(); + if (tcp) { + data[tcp] = $("#TCP_PORTS", context).val(); + } + + var udp = $("input.udp_type:checked", context).val(); + if (udp) { + data[udp] = $("#UDP_PORTS", context).val(); + } + + if ($("#icmp_type", context).is(":checked")) { + data["ICMP"] = "drop" + } + + return data +} + function setup_nic_tab_content(nic_section, str_nic_tab_id, str_datatable_id) { var dataTable_template_networks = $('#'+str_datatable_id, nic_section).dataTable({ "bAutoWidth":false, @@ -3606,22 +3630,7 @@ function initialize_create_template_dialog(dialog) { vm_json["NIC"] = []; $('.nic',dialog).each(function(){ - var hash = {}; - addSectionJSON(hash, this); - - var tcp = $("input.tcp_type:checked").val(); - if (tcp) { - hash[tcp] = $("#TCP_PORTS", this).val(); - } - - var udp = $("input.udp_type:checked").val(); - if (udp) { - hash[udp] = $("#UDP_PORTS", this).val(); - } - - if ($("#icmp_type", this).is(":checked")) { - hash["ICMP"] = "drop" - } + hash = retrieve_nic_tab_data(this); if (!$.isEmptyObject(hash)) { vm_json["NIC"].push(hash); diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 23f569a5c2..544b1e82a9 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -241,7 +241,7 @@ var deploy_vm_tmpl ='\
\
\ \ -
\ @@ -2447,9 +2447,7 @@ function setupAttachNicDialog(){ $('#attach_nic_form',dialog).submit(function(){ var vm_id = $('#vm_id', this).text(); - - var data = {}; - addSectionJSON(data, this); + var data = retrieve_nic_tab_data(this); var obj = {NIC: data} Sunstone.runAction('VM.attachnic', vm_id, obj);