From 603f0448ad75d0d12deb4d98ff64c007bb1a96ff Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 28 Feb 2013 19:01:25 +0100 Subject: [PATCH] feature #1664: Update vnet extended info and wizard --- src/sunstone/public/css/app.css | 5 + .../public/js/plugins/clusters-tab.js | 2 +- .../public/js/plugins/datastores-tab.js | 4 +- src/sunstone/public/js/plugins/images-tab.js | 4 +- src/sunstone/public/js/plugins/vnets-tab.js | 513 ++++++++++++------ src/sunstone/public/js/sunstone.js | 14 +- src/sunstone/public/sass/app.scss | 4 + .../public/vendor/4.0/foundation/app.js | 5 +- 8 files changed, 378 insertions(+), 173 deletions(-) diff --git a/src/sunstone/public/css/app.css b/src/sunstone/public/css/app.css index eb47f03afb..dfbe1ad700 100644 --- a/src/sunstone/public/css/app.css +++ b/src/sunstone/public/css/app.css @@ -6548,3 +6548,8 @@ form.creation { overflow-x: hidden; padding: 5px; } + +/* line 574, ../sass/app.scss */ +#dialog input { + margin: 0px; +} diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index ca4527c1a7..e45e5d7f0c 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -1387,7 +1387,7 @@ function updateClusterInfo(request,cluster){ var info_tab = { title : tr("Information"), content : - '
\ + '
\
\ \ \ diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index ee8186a996..184baa7367 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -68,7 +68,7 @@ var datastores_tab_content = '\ var create_datastore_tmpl = '
\
\ -

\ +

\ '+tr("Create Datastore")+'\

\
\ @@ -631,7 +631,7 @@ function updateDatastoreInfo(request,ds){ images_str=getImageName(info.IMAGES.ID); }; - var info_tab_content = '
\ + var info_tab_content = '
\
\
\ \ diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 5ba32836de..f8219fbb58 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -76,7 +76,7 @@ var create_image_tmpl = \
    \
  • \ - \ + \
    \
    \
    \ @@ -623,7 +623,7 @@ function updateImageInfo(request,img){ var info_tab = { title: tr("Information"), content: - '
    \ + '
    \
    \
\ \ diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index f1388fe46d..ae2cf6319f 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -63,122 +63,276 @@ var vnets_tab_content = '\ var create_vn_tmpl = '
\ +
\ +

\ + '+tr("Create Virtual Network")+'\ +

\ +
\
\ -
'+tr("Wizard")+'
\ +
'+tr("Wizard")+'
\
'+tr("Advanced mode")+'
\
\
    \ -
  • \ - \ -
    \ - \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ - \ -
    \ - \ - \ - \ -
    \ - \ -
    \ -
    \ -
    \ - \ - '+tr("Fixed network")+'
    \ - '+tr("Ranged network")+'
    \ -
    \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ - \ - \ -
    \ - \ - \ - \ -
    \ -
    \ +
  • \ + \ +
    \ +
    \ + \
    \ -
    \ -
    \ - \ -
    \ - \ -
    \ - \ -
    \ - \ -
    \ - \ - \ -
    \ +
    \ + \ +
    \ +
    \
    \
    \ -
    \ - \ -
    \ -
    \ - \ -
    \ - \ -
    \ - \ - \ -
    \ - \ - \ +
    \ +
    \ + ' + tr("Type") + '\ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \
    \ -
    \ -
    \ -
    \ - \ - \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + ' + tr("Custom attributes") + '\ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ +
    \ +
    \
    \ -
    \ \ +
    \ +
    \ + \ + \ + \ +
    \
  • \
  • \
    \ -

    '+tr("Write the Virtual Network template here")+'

    \ -
    \ +

    '+tr("Write the Virtual Network template here")+'

    \ \ -
    \ -
    \ -
    \ + \
    \ - \ - \ -
    \ -
    \ - \ + \ + \ +
\ \ \ ×\ @@ -572,20 +726,23 @@ function updateVNetworksView(request, network_list){ function updateVNetworkInfo(request,vn){ var vn_info = vn.VNET; var info_tab_content = - '
\ + '
\ +
\ +
\ \ - \ \ \ \ \ + \ \ \ \ \ \ \ @@ -595,31 +752,37 @@ function updateVNetworkInfo(request,vn){ \ \ \ + \ \ \ \ \ + \ \ \ \ \ + \ \ \ \ \ + \ \ -
'+tr("Information for Virtual Network")+' - '+vn_info.NAME+' '+ +
'+tr("Virtual Network")+' - '+vn_info.NAME+' '+ '
'+tr("ID")+''+vn_info.ID+'
'+tr("Name")+''+vn_info.NAME+'
\ - e\ + \
\
'+tr("Bridge")+''+ (typeof(vn_info.BRIDGE) == "object" ? "--": vn_info.BRIDGE) +'
'+tr("VLAN")+''+ (vn_info.VLAN == "0" ? "no" : "yes") +'
'+tr("Physical device")+''+ (typeof(vn_info.PHYDEV) == "object" ? "--": vn_info.PHYDEV) +'
'+tr("VLAN ID")+''+ (typeof(vn_info.VLAN_ID) == "object" ? "--": vn_info.VLAN_ID) +'
'; - - info_tab_content += insert_extended_template_table(vn_info.TEMPLATE, - "Network", - vn_info.ID); - - info_tab_content += insert_permissions_table("Network", + \ +
\ +
' + + insert_permissions_table("Network", vn_info.ID, vn_info.UNAME, vn_info.GNAME, vn_info.UID, - vn_info.GID); + vn_info.GID) + + insert_extended_template_table(vn_info.TEMPLATE, + "Network", + vn_info.ID) + + '
\ +
'; var info_tab = { title: tr("Information"), @@ -664,33 +827,43 @@ function updateVNetworkInfo(request,vn){ // It adds the "add lease", "hold lease" fields, and each lease comes with // hold, release buttons etc. Listeners in setupLeasesOps() function printLeases(vn_info){ - var html ='
\ + var html ='
\ +
\ \ - \ + \ '; if (vn_info.TYPE == "0"){ html += '\ - \ + \ \ + \ + \ \ \ - \ + \ \ + \ + \ \ \ - \ + \ \ + \ + \ \ - '; + \ + \ + \ + \ + '; } else { - html += ''; + html += '\ + \ + \ + \ + \ + '; }; var leases = vn_info.LEASES.LEASE; @@ -702,7 +875,7 @@ function printLeases(vn_info){ \ '; - html += '
'+tr("Leases information")+'
'+tr("Leases information")+'
'+tr("IP Start")+''+tr("IP Start")+''+vn_info.RANGE.IP_START+'
'+tr("IP End")+''+tr("IP End")+''+vn_info.RANGE.IP_END+'
'+tr("Network mask")+''+tr("Network mask")+''+( vn_info.TEMPLATE.NETWORK_MASK ? vn_info.TEMPLATE.NETWORK_MASK : "--" )+'
\ - \ - \ -
\ - \ - \ -
\
'; + html += '
'; return html; } else if (leases.constructor != Array) //>1 lease @@ -723,40 +896,43 @@ function printLeases(vn_info){ }; - html+=''; - html+='' + + html += ''; switch (state){ case 0: //free - html += 'src="images/green_bullet.png" />'; + html += ' ' break; case 1: //used - html += 'src="images/red_bullet.png" />'; + html += ' ' break; case 2: //hold - html += 'src="images/yellow_bullet.png" />'; + html += ' ' break; }; + html += '' - html += lease.IP + ''; + html += ''+ lease.IP + ''; html += '\ - '+lease.MAC+'   '; + '+lease.MAC+''; switch (state){ case 0: - html += ''+tr("hold")+' | '+tr("delete")+''; + html += ''; break; case 1: - html += tr("Used by VM")+' '+lease.VID; + html += '' + tr("VM:") + lease.VID+'' break; case 2: - html += ''+tr("release")+''; + html += ''; break; }; - html += ''; + html += '' + html += ''; }; - html += ''; + html += ''; return html; } @@ -777,18 +953,21 @@ function setupCreateVNetDialog() { // width: 475, // height: height //}); - dialog.addClass("reveal-modal"); + dialog.addClass("reveal-modal large"); //Make the tabs look nice for the creation mode //$('#vn_tabs',dialog).tabs(); $('div#ranged',dialog).hide(); - $('#fixed_check',dialog).click(function(){ + $('input[name="fixed_ranged"]',dialog).change(function(){ + console.log("pepe") + if (this.id == 'fixed_check') { $('div#fixed',$create_vn_dialog).show(); $('div#ranged',$create_vn_dialog).hide(); - }); - $('#ranged_check',dialog).click(function(){ - $('div#fixed',$create_vn_dialog).hide(); - $('div#ranged',$create_vn_dialog).show(); + } + else { + $('div#fixed',$create_vn_dialog).hide(); + $('div#ranged',$create_vn_dialog).show(); + } }); $('#network_mode',dialog).change(function(){ @@ -797,9 +976,12 @@ function setupCreateVNetDialog() { switch ($(this).val()) { case "default": $('input#bridge,label[for="bridge"]',$create_vn_dialog).show(); - $('input#phydev,label[for="phydev"]',$create_vn_dialog).show(); + $('input#phydev,label[for="phydev"]',$create_vn_dialog).hide(); + $('select#vlan,label[for="vlan"]',$create_vn_dialog).hide(); + $('input#vlan_id,label[for="vlan_id"]',$create_vn_dialog).hide(); break; case "802.1Q": + // TODO add warning use PHY_DEV unless... BRIDGE $('input#bridge,label[for="bridge"]',$create_vn_dialog).show(); $('input#phydev,label[for="phydev"]',$create_vn_dialog).show(); $('select#vlan,label[for="vlan"]',$create_vn_dialog).show(); @@ -807,11 +989,18 @@ function setupCreateVNetDialog() { break; case "ebtables": $('input#bridge,label[for="bridge"]',$create_vn_dialog).show(); + $('input#phydev,label[for="phydev"]',$create_vn_dialog).show(); $('select#vlan,label[for="vlan"]',$create_vn_dialog).show(); + $('input#vlan_id,label[for="vlan_id"]',$create_vn_dialog).hide(); break; case "openvswitch": + $('input#bridge,label[for="bridge"]',$create_vn_dialog).show(); + $('input#phydev,label[for="phydev"]',$create_vn_dialog).hide(); + $('select#vlan,label[for="vlan"]',$create_vn_dialog).show(); + $('input#vlan_id,label[for="vlan_id"]',$create_vn_dialog).show(); case "vmware": $('input#bridge,label[for="bridge"]',$create_vn_dialog).show(); + $('input#phydev,label[for="phydev"]',$create_vn_dialog).hide(); $('select#vlan,label[for="vlan"]',$create_vn_dialog).show(); $('input#vlan_id,label[for="vlan_id"]',$create_vn_dialog).show(); break; @@ -899,9 +1088,9 @@ function setupCreateVNetDialog() { //Handle submission of the easy mode - $('#create_vn_form_easy',dialog).submit(function(){ + $('#create_vn_submit_easy',dialog).click(function(){ //Fetch values - var name = $('#name',this).val(); + var name = $('#name',dialog).val(); if (!name.length){ notifyError(tr("Virtual Network name missing!")); return false; @@ -909,11 +1098,11 @@ function setupCreateVNetDialog() { var network_json = {"name" : name}; - var network_mode = $('select#network_mode',this).val(); - var bridge = $('#bridge',this).val(); - var phydev = $('#phydev',this).val(); - var vlan = $('#vlan',this).val(); - var vlan_id = $('#vlan_id',this).val(); + var network_mode = $('select#network_mode',dialog).val(); + var bridge = $('#bridge',dialog).val(); + var phydev = $('#phydev',dialog).val(); + var vlan = $('#vlan',dialog).val(); + var vlan_id = $('#vlan_id',dialog).val(); //Depending on network mode we include certain params in the //template @@ -960,17 +1149,17 @@ function setupCreateVNetDialog() { break; }; - var type = $('input:checked',this).val(); + var type = $('input:checked',dialog).val(); network_json['type']=type; //TODO: Name and bridge provided?! if (type == "fixed") { - var leases = $('#leases option', this); + var leases = $('#leases option', dialog); var leases_obj=[]; //for each specified lease we prepare the JSON object $.each(leases,function(){ - var lease_str = $(this).val().split(","); + var lease_str = $(dialog).val().split(","); if (lease_str[1]) leases_obj.push({"ip": lease_str[0], "mac": lease_str[1]}); @@ -983,11 +1172,11 @@ function setupCreateVNetDialog() { } else { //type ranged - var network_addr = $('#net_address',this).val(); - var network_mask = $('#net_mask',this).val(); - var custom = $('#custom_pool',this).is(':checked'); - var ip_start = $('#ip_start',this).val(); - var ip_end = $('#ip_end',this).val(); + var network_addr = $('#net_address',dialog).val(); + var network_mask = $('#net_mask',dialog).val(); + var custom = $('#custom_pool',dialog).is(':checked'); + var ip_start = $('#ip_start',dialog).val(); + var ip_end = $('#ip_end',dialog).val(); if (!(ip_start.length && ip_end.length) && !network_addr.length){ notifyError(tr("There are missing network parameters")); @@ -1010,8 +1199,8 @@ function setupCreateVNetDialog() { //Time to add custom attributes $('#custom_var_vnet_box option',$create_vn_dialog).each(function(){ - var attr_name = $(this).attr('name'); - var attr_value = $(this).val(); + var attr_name = $(dialog).attr('name'); + var attr_value = $(dialog).val(); network_json[attr_name] = attr_value; }); @@ -1026,8 +1215,8 @@ function setupCreateVNetDialog() { return false; }); - $('#create_vn_form_manual',dialog).submit(function(){ - var template=$('#template',this).val(); + $('#create_vn_submit_manual',dialog).click(function(){ + var template=$('#template',dialog).val(); var vnet_json = {vnet: {vnet_raw: template}}; Sunstone.runAction("Network.create",vnet_json); $create_vn_dialog.trigger("reveal:close") diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index fe9398e869..8a3902cb49 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -66,7 +66,7 @@ var Sunstone = { SunstoneCfg["tabs"][tab_id] = tab_obj; if (refresh){ insertTab(tab_id); - $(document).foundationCustomForms(); + //$(document).foundationCustomForms(); } }, @@ -786,16 +786,22 @@ function setupConfirmDialogs(){ //add the HTML with the standard question and buttons. dialog.html( - '
\ + '
\ +

\ + '+tr("Confirm")+'\ +

\ +
\ + \
'+tr("You have to confirm this action.")+'
\
\
'+tr("Do you want to proceed?")+'
\
\
\
\ - \ - \ + \ + \
\ + ×\
'); //prepare the jquery dialog diff --git a/src/sunstone/public/sass/app.scss b/src/sunstone/public/sass/app.scss index 8fddece7aa..1ca5a0aecd 100644 --- a/src/sunstone/public/sass/app.scss +++ b/src/sunstone/public/sass/app.scss @@ -569,4 +569,8 @@ form.creation { overflow-y: auto; overflow-x: hidden; padding: 5px; +} + +#dialog input { + margin: 0px; } \ No newline at end of file diff --git a/src/sunstone/public/vendor/4.0/foundation/app.js b/src/sunstone/public/vendor/4.0/foundation/app.js index f547a68b4b..746ec450c2 100644 --- a/src/sunstone/public/vendor/4.0/foundation/app.js +++ b/src/sunstone/public/vendor/4.0/foundation/app.js @@ -10,9 +10,10 @@ $.fn.foundationAccordion ? $doc.foundationAccordion() : null; $.fn.foundationNavigation ? $doc.foundationNavigation() : null; $.fn.foundationTopBar ? $doc.foundationTopBar() : null; - $.fn.foundationCustomForms ? $doc.foundationCustomForms() : null; + //$.fn.foundationCustomForms ? $doc.foundationCustomForms() : null; $.fn.foundationMediaQueryViewer ? $doc.foundationMediaQueryViewer() : null; - $.fn.foundationTabs ? $doc.foundationTabs({callback : $.foundation.customForms.appendCustomMarkup}) : null; + //$.fn.foundationTabs ? $doc.foundationTabs({callback : $.foundation.customForms.appendCustomMarkup}) : null; + $.fn.foundationTabs ? $doc.foundationTabs() : null; $.fn.foundationTooltips ? $doc.foundationTooltips() : null; $.fn.foundationMagellan ? $doc.foundationMagellan() : null; $.fn.foundationClearing ? $doc.foundationClearing() : null;