diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js index 8323a6d0f4..298df139ec 100644 --- a/src/sunstone/public/js/plugins/acls-tab.js +++ b/src/sunstone/public/js/plugins/acls-tab.js @@ -152,6 +152,10 @@ var acl_actions = { type: "create", call: OpenNebula.Acl.create, callback: function(){ + $create_acl_dialog.foundation('reveal', 'close'); + $create_acl_dialog.empty(); + setupCreateAclDialog(); + Sunstone.runAction("Acl.list"); }, error: onError, @@ -590,7 +594,6 @@ function setupCreateAclDialog(){ var acl_json = { "acl" : acl_string }; Sunstone.runAction("Acl.create",acl_json); - $create_acl_dialog.foundation('reveal', 'close'); return false; }); } diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index 5b36283bf0..5057b4c13a 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -183,6 +183,11 @@ datastore_row_hash = {}; // Prepares the cluster creation dialog function setupCreateClusterDialog(){ + reset_counters(); + + $("#create_cluster_dialog").remove(); + dialogs_context.append('
'); + $create_cluster_dialog = $('div#create_cluster_dialog'); var dialog = $create_cluster_dialog; @@ -451,10 +456,7 @@ function setupCreateClusterDialog(){ }; // Create the OpenNebula.Cluster. - // If it is successfull we refresh the list. Sunstone.runAction("Cluster.create",cluster_json); - - $create_cluster_dialog.foundation('reveal', 'close') return false; }); } @@ -475,18 +477,11 @@ function reset_counters(){ // Open creation dialogs function popUpCreateClusterDialog(){ - - filter_expr = "-" ; - - if ($("#create_cluster_dialog")) - { - $("#create_cluster_dialog").remove(); - dialogs_context.append('
'); + if (!$create_cluster_dialog || $create_cluster_dialog.html() == "") { + setupCreateClusterDialog(); } - reset_counters(); - - setupCreateClusterDialog(); + $create_cluster_dialog.die(); // Activate create button $('#create_cluster_submit',$create_cluster_dialog).show(); @@ -508,15 +503,6 @@ function popUpCreateClusterDialog(){ // Open update dialog function popUpUpdateClusterDialog(){ - var dialog = $create_cluster_dialog; - - if ($("#create_cluster_dialog")) { - $("#create_cluster_dialog").remove(); - dialogs_context.append('
'); - } - - reset_counters(); - var selected_nodes = getSelectedNodes(dataTable_clusters); if ( selected_nodes.length != 1 ) @@ -525,6 +511,12 @@ function popUpUpdateClusterDialog(){ return false; } + var dialog = $create_cluster_dialog; + + if ($("#create_cluster_dialog")) { + dialog.html(""); + } + setupCreateClusterDialog(); // Activate update button @@ -535,6 +527,12 @@ function popUpUpdateClusterDialog(){ Sunstone.runAction("Cluster.show_to_update", selected_nodes[0]); + $create_cluster_dialog.die(); + $create_cluster_dialog.live('closed', function () { + $("#create_cluster_dialog").html(""); + setupCreateClusterDialog(); + }); + $create_cluster_dialog.foundation().foundation('reveal', 'open'); return false; @@ -886,7 +884,13 @@ var cluster_actions = { type: "create", call: OpenNebula.Cluster.create, callback: function(request, response){ - Sunstone.runAction('Cluster.list'); + // Reset the create wizard + $create_cluster_dialog.foundation('reveal', 'close'); + $create_cluster_dialog.empty(); + setupCreateClusterDialog(); + + addImageElement(request, response); +// Sunstone.runAction('Cluster.list'); for (var host in request.request.data[0].cluster.hosts) if (request.request.data[0].cluster.hosts[host]) @@ -1433,7 +1437,7 @@ $(document).ready(function(){ Sunstone.runAction("Cluster.list"); - dialogs_context.append('
'); + setupCreateClusterDialog(); setClusterAutorefresh(); clusterResourceViewListeners(); diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index 8e35d3d454..8238e592d5 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -292,8 +292,13 @@ var datastore_actions = { type: "create", call : OpenNebula.Datastore.create, callback : function(request, response) { - addDatastoreElement(request, response); - notifyCustom(tr("Datastore created"), " ID: " + response.DATASTORE.ID, false); + // Reset the create wizard + $create_datastore_dialog.foundation('reveal', 'close'); + $create_datastore_dialog.empty(); + setupCreateDatastoreDialog(); + + addDatastoreElement(request, response); + notifyCustom(tr("Datastore created"), " ID: " + response.DATASTORE.ID, false); }, error : onError }, @@ -960,8 +965,6 @@ function setupCreateDatastoreDialog(){ $('#tm_use_ssh').prop('checked', false); Sunstone.runAction("Datastore.create",ds_obj); - - $create_datastore_dialog.foundation('reveal', 'close') return false; }); @@ -981,7 +984,6 @@ function setupCreateDatastoreDialog(){ "cluster_id" : cluster_id }; Sunstone.runAction("Datastore.create",ds_obj); - $create_datastore_dialog.foundation('reveal', 'close') return false; }); @@ -989,8 +991,6 @@ function setupCreateDatastoreDialog(){ $create_datastore_dialog.html(""); setupCreateDatastoreDialog(); - window.ds_wizard_is_not_first="false"; - popUpCreateDatastoreDialog(); }); @@ -998,8 +998,6 @@ function setupCreateDatastoreDialog(){ $create_datastore_dialog.html(""); setupCreateDatastoreDialog(); - window.ds_wizard_is_not_first="false"; - popUpCreateDatastoreDialog(); $("a[href='#datastore_manual']").click(); }); @@ -1007,6 +1005,8 @@ function setupCreateDatastoreDialog(){ // Hide disk_type $('select#disk_type').parent().hide(); + hide_all($create_datastore_dialog); + select_filesystem(); } function select_filesystem(){ @@ -1110,12 +1110,6 @@ function popUpCreateDatastoreDialog(){ $('select#datastore_cluster_raw',$create_datastore_dialog).html(clusters_sel()); $create_datastore_dialog.foundation().foundation('reveal', 'open'); $("input#name",$create_datastore_dialog).focus(); - if(window.ds_wizard_is_not_first != "true") - { - hide_all($create_datastore_dialog); - select_filesystem(); - window.ds_wizard_is_not_first="true"; - } } //Prepares autorefresh diff --git a/src/sunstone/public/js/plugins/files-tab.js b/src/sunstone/public/js/plugins/files-tab.js index b26bb5d7bd..6297410f8a 100644 --- a/src/sunstone/public/js/plugins/files-tab.js +++ b/src/sunstone/public/js/plugins/files-tab.js @@ -138,8 +138,13 @@ var file_actions = { type: "create", call: OpenNebula.Image.create, callback: function(request, response) { - addFileElement(request, response); - notifyCustom(tr("File created"), " ID: " + response.IMAGE.ID, false); + // Reset the create wizard + $create_file_dialog.foundation('reveal', 'close'); + $create_file_dialog.empty(); + setupCreateFileDialog(); + + addFileElement(request, response); + notifyCustom(tr("File created"), " ID: " + response.IMAGE.ID, false); }, error: onError }, @@ -736,7 +741,6 @@ function setupCreateFileDialog(){ Sunstone.runAction("File.create", file_obj); }; - $create_file_dialog.foundation('reveal', 'close') return false; }); @@ -756,7 +760,6 @@ function setupCreateFileDialog(){ "ds_id" : ds_id }; Sunstone.runAction("File.create",file_obj); - $create_file_dialog.foundation('reveal', 'close') return false; }); diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index f617e77813..0948db23b8 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -202,12 +202,13 @@ var group_actions = { type: "create", call : OpenNebula.Group.create, callback : function(request, response) { - // Reset the create wizard - $create_group_dialog.empty(); - setupCreateGroupDialog(); + // Reset the create wizard + $create_group_dialog.foundation('reveal', 'close'); + $create_group_dialog.empty(); + setupCreateGroupDialog(); - Sunstone.runAction("Group.list"); - notifyCustom(tr("Group created"), " ID: " + response.GROUP.ID, false); + Sunstone.runAction("Group.list"); + notifyCustom(tr("Group created"), " ID: " + response.GROUP.ID, false); }, error : onError }, @@ -1294,7 +1295,6 @@ function setupCreateGroupDialog(){ Sunstone.runAction("Group.create",group_json); - $create_group_dialog.foundation('reveal', 'close'); return false; }); } diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index e5b4d05bdc..016dc76fc8 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -120,8 +120,13 @@ var host_actions = { type: "create", call : OpenNebula.Host.create, callback : function(request, response) { - addHostElement(request, response); - notifyCustom(tr("Host created"), " ID: " + response.HOST.ID, false); + // Reset the create wizard + $create_host_dialog.foundation('reveal', 'close'); + $create_host_dialog.empty(); + setupCreateHostDialog(); + + addHostElement(request, response); + notifyCustom(tr("Host created"), " ID: " + response.HOST.ID, false); }, error : onError }, @@ -813,33 +818,36 @@ function updateHostInfo(request,host){ //Prepares the host creation dialog function setupCreateHostDialog(){ - dialogs_context.append('
'); - $('div#create_host_dialog').html(create_host_tmpl); - var dialog = $('div#create_host_dialog'); + if ($('#create_host_dialog').length == 0) { + dialogs_context.append('
'); + } - dialog.addClass("reveal-modal medium").attr("data-reveal", ""); - dialog.foundation() + $('div#create_host_dialog').html(create_host_tmpl); + $create_host_dialog = $('#create_host_dialog'); + + $create_host_dialog.addClass("reveal-modal medium").attr("data-reveal", ""); + $create_host_dialog.foundation() // Show custom driver input only when custom is selected in selects $('input[name="custom_vmm_mad"],'+ 'input[name="custom_im_mad"],'+ - 'input[name="custom_vnm_mad"]',dialog).parent().hide(); + 'input[name="custom_vnm_mad"]',$create_host_dialog).parent().hide(); - $('select#vmm_mad',dialog).change(function(){ + $('select#vmm_mad',$create_host_dialog).change(function(){ if ($(this).val()=="custom") $('input[name="custom_vmm_mad"]').parent().show(); else $('input[name="custom_vmm_mad"]').parent().hide(); }); - $('select#im_mad',dialog).change(function(){ + $('select#im_mad',$create_host_dialog).change(function(){ if ($(this).val()=="custom") $('input[name="custom_im_mad"]').parent().show(); else $('input[name="custom_im_mad"]').parent().hide(); }); - $('select#vnm_mad',dialog).change(function(){ + $('select#vnm_mad',$create_host_dialog).change(function(){ if ($(this).val()=="custom") $('input[name="custom_vnm_mad"]').parent().show(); else @@ -847,7 +855,7 @@ function setupCreateHostDialog(){ }); //Handle the form submission - $('#create_host_form',dialog).submit(function(){ + $('#create_host_form',$create_host_dialog).submit(function(){ var name = $('#name',this).val(); if (!name){ notifyError(tr("Host name missing!")); @@ -877,14 +885,18 @@ function setupCreateHostDialog(){ //Create the OpenNebula.Host. //If it is successfull we refresh the list. Sunstone.runAction("Host.create",host_json); - $('div#create_host_dialog').foundation('reveal', 'close') return false; }); } //Open creation dialogs function popUpCreateHostDialog(){ + var cluster_id = $('#host_cluster_id',$('div#create_host_dialog')).val(); + if (!cluster_id) cluster_id = "-1"; + $('#host_cluster_id',$('div#create_host_dialog')).html(clusters_sel()); + $('#host_cluster_id',$('div#create_host_dialog')).val(cluster_id); + $('div#create_host_dialog').foundation('reveal', 'open'); $("input#name",$('div#create_host_dialog')).focus(); return false; diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index ec8bb7c54d..96dc7628fd 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -244,9 +244,13 @@ var image_actions = { type: "create", call: OpenNebula.Image.create, callback: function(request, response){ - addImageElement(request, response); - $create_image_dialog.foundation('reveal', 'close') - notifyCustom(tr("Image created"), " ID: " + response.IMAGE.ID, false) + // Reset the create wizard + $create_image_dialog.foundation('reveal', 'close'); + $create_image_dialog.empty(); + setupCreateImageDialog(); + + addImageElement(request, response); + notifyCustom(tr("Image created"), " ID: " + response.IMAGE.ID, false); }, error: onError }, diff --git a/src/sunstone/public/js/plugins/oneflow-templates.js b/src/sunstone/public/js/plugins/oneflow-templates.js index b3c36eb2b4..13ec753e46 100644 --- a/src/sunstone/public/js/plugins/oneflow-templates.js +++ b/src/sunstone/public/js/plugins/oneflow-templates.js @@ -312,9 +312,15 @@ var service_template_actions = { call: ServiceTemplate.create, callback: function(request, response) { //empty creation dialog roles after successful creation +/* var dialog = $create_service_template_dialog; $('table#current_roles tbody', dialog).empty(); $('select[name="parents"]', dialog).empty(); + dialog.foundation('reveal', 'close'); +*/ + $create_service_template_dialog.foundation('reveal', 'close') + $create_service_template_dialog.empty(); + addServiceTemplateElement(request, response); notifyCustom(tr("Service Template created"), " ID: " + response.DOCUMENT.ID, false); }, @@ -343,7 +349,10 @@ var service_template_actions = { type: "single", call: ServiceTemplate.update, callback: function(request,response){ - notifyMessage(tr("ServiceTemplate updated correctly")); + $create_service_template_dialog.foundation('reveal', 'close'); + Sunstone.runAction("ServiceTemplate.show",request.request.data[0][0]); + + notifyMessage(tr("ServiceTemplate updated correctly")); }, error: onError }, @@ -1101,14 +1110,12 @@ function setupCreateServiceTemplateDialog(){ $('#create_service_template_submit',dialog).click(function(){ var json_template = generate_json_service_template_from_form(); Sunstone.runAction("ServiceTemplate.create", json_template ); - dialog.foundation('reveal', 'close'); return false; }); $('#update_service_template_submit',dialog).click(function(){ var json_template = generate_json_service_template_from_form(); Sunstone.runAction("ServiceTemplate.update",service_template_to_update_id, JSON.stringify(json_template)); - dialog.foundation('reveal', 'close'); return false; }); @@ -1260,16 +1267,19 @@ function generate_json_service_template_from_form() { } function popUpCreateServiceTemplateDialog(){ - if (!$create_service_template_dialog) { + if (!$create_service_template_dialog || $create_service_template_dialog.html() == "") { setupCreateServiceTemplateDialog(); } var dialog = $create_service_template_dialog; + dialog.die(); + $("#create_service_template_header", dialog).show(); $("#update_service_template_header", dialog).hide(); $("#create_service_template_submit", dialog).show(); $("#update_service_template_submit", dialog).hide(); + $("#create_service_template_reset", dialog).show(); $("#service_name", dialog).removeAttr("disabled"); @@ -1292,7 +1302,6 @@ function popUpUpdateServiceTemplateDialog() { setupCreateServiceTemplateDialog(); } - // Get proper cluster_id var template_id = ""+selected_nodes[0]; Sunstone.runAction("ServiceTemplate.show_to_update", template_id); } @@ -1305,6 +1314,7 @@ function fillUpUpdateServiceTemplateDialog(request, response){ $("#update_service_template_header", dialog).show(); $("#create_service_template_submit", dialog).hide(); $("#update_service_template_submit", dialog).show(); + $("#create_service_template_reset", dialog).hide(); var service_template = response[ServiceTemplate.resource] $("#service_name", dialog).attr("disabled", "disabled"); @@ -1394,6 +1404,11 @@ function fillUpUpdateServiceTemplateDialog(request, response){ service_template_to_update_id = service_template.ID; + dialog.die(); + dialog.live('closed', function () { + $create_service_template_dialog.html(""); + }); + dialog.foundation('reveal', 'open'); } diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 22034436f5..e43c1ae8ab 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -3830,7 +3830,6 @@ function popUpUpdateTemplateDialog(){ $create_template_dialog.html(""); } - // TODO do not recreate if it exists setupCreateTemplateDialog(); $('button#create_template_form_easy', $create_template_dialog).hide(); @@ -3846,15 +3845,20 @@ function popUpUpdateTemplateDialog(){ $('#template_name_form', $create_template_dialog).hide(); $('#NAME').attr("disabled", "disabled");; + $create_template_dialog.die(); + $create_template_dialog.live('closed', function () { + $create_template_dialog.html(""); + }); + $create_template_dialog.foundation().foundation('reveal', 'open'); }; function popUpCreateTemplateDialog(){ - if ($create_template_dialog) { - $create_template_dialog.html(""); + if (!$create_template_dialog || $create_template_dialog.html() == "") { + setupCreateTemplateDialog(); } - // TODO do not recreate if it exists - setupCreateTemplateDialog(); + + $create_template_dialog.die(); $('button#create_template_form_easy', $create_template_dialog).show(); $('button#template_template_update_button', $create_template_dialog).hide(); diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 567b071e83..aa0aeed103 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -272,8 +272,12 @@ var user_actions = { type: "create", call: OpenNebula.User.create, callback: function(request, response) { - addUserElement(request, response); - notifyCustom(tr("User created"), " ID: " + response.USER.ID, false); + $create_user_dialog.foundation('reveal', 'close'); + $create_user_dialog.empty(); + setupCreateUserDialog(); + + addUserElement(request, response); + notifyCustom(tr("User created"), " ID: " + response.USER.ID, false); }, error: onError }, @@ -795,7 +799,6 @@ function setupCreateUserDialog(){ } Sunstone.runAction("User.create",user_json); - $create_user_dialog.foundation('reveal', 'close'); return false; }); } diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 05661027ae..ca3dd55c6c 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -325,8 +325,13 @@ var vnet_actions = { type: "create", call: OpenNebula.Network.create, callback: function(request, response) { - addVNetworkElement(request, response); - notifyCustom(tr("Virtual Network created"), " ID: " + response.VNET.ID, false); + // Reset the create wizard + $create_vn_dialog.foundation('reveal', 'close'); + $create_vn_dialog.empty(); + setupCreateVNetDialog(); + + addVNetworkElement(request, response); + notifyCustom(tr("Virtual Network created"), " ID: " + response.VNET.ID, false); }, error: onError }, @@ -1246,7 +1251,6 @@ function setupCreateVNetDialog() { }; Sunstone.runAction("Network.create",network_json); - $create_vn_dialog.foundation('reveal', 'close') return false; }); @@ -1254,7 +1258,6 @@ function setupCreateVNetDialog() { var template=$('#template',dialog).val(); var vnet_json = {vnet: {vnet_raw: template}}; Sunstone.runAction("Network.create",vnet_json); - $create_vn_dialog.foundation('reveal', 'close') return false; }); diff --git a/src/sunstone/public/js/plugins/zones-tab.js b/src/sunstone/public/js/plugins/zones-tab.js index a60191c41d..d027790eaa 100644 --- a/src/sunstone/public/js/plugins/zones-tab.js +++ b/src/sunstone/public/js/plugins/zones-tab.js @@ -19,9 +19,10 @@ //Prepares the dialog to create function setupCreateZoneDialog(){ - // TODO + if ($('#create_zone_dialog').length == 0) { + dialogs_context.append('
'); + } - dialogs_context.append('
'); $create_zone_dialog = $('#create_zone_dialog',dialogs_context); var dialog = $create_zone_dialog; @@ -33,7 +34,6 @@ function setupCreateZoneDialog(){ var endpoint=$("#endpoint",this).val(); var zone_json = { "zone" : { "name" : name, "endpoint" : endpoint}}; Sunstone.runAction("Zone.create",zone_json); - $create_zone_dialog.foundation('reveal', 'close'); return false; }); @@ -87,6 +87,9 @@ var zone_actions = { type: "create", call: OpenNebula.Zone.create, callback: function(request, response){ + $create_zone_dialog.foundation('reveal', 'close'); + $("form", $create_zone_dialog)[0].reset(); + Sunstone.runAction('Zone.list'); }, error: onError,