From a804b1283fdd29fc528a3b90d6ea04bb88045228 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 6 Jan 2011 10:33:06 -0800 Subject: [PATCH] Add Zone Wizard - basic mode - move Add Guest IP Range section from step3(createPod) to step4(AddIPRange). --- ui/jsp/resource.jsp | 69 ++++++++--------- ui/scripts/cloud.core.resource.js | 124 ++++++++++++++---------------- 2 files changed, 93 insertions(+), 100 deletions(-) diff --git a/ui/jsp/resource.jsp b/ui/jsp/resource.jsp index 9c4b8c8651c..ac3b31f1ae9 100644 --- a/ui/jsp/resource.jsp +++ b/ui/jsp/resource.jsp @@ -361,31 +361,7 @@ - -
  • - - - - - - -
  • -
  • - - - -
  • -
  • - - - -
  • + @@ -394,11 +370,8 @@
    Back
    - -
    - Submit -
    +
    + Go to Step 4
    @@ -427,14 +400,40 @@

    - Step 4: Add an IP range to public network in zone

    + Step 4: Add an IP range

    -
      +
        +
      1. + + - + + + +
      2. +
      3. + + + +
      4. +
      5. + + + +
      6. +
      +
    diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 4f1d9efb91d..ec1591c94f2 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -1065,18 +1065,20 @@ function initAddZoneWizard() { case "Basic": //create VLAN in pod-level //hide Zone VLAN Range in Add Zone(step 2), show Guest IP Range in Add Pod(step3) $thisWizard.find("#step2").find("#add_zone_vlan_container, #add_zone_guestcidraddress_container").hide(); - $thisWizard.find("#step3").find("#guestip_container, #guestnetmask_container, #guestgateway_container, #submit_in_step3").show(); - $thisWizard.find("#step3").find("#go_to_step_4").hide(); + + //$thisWizard.find("#step3").find("#guestip_container, #guestnetmask_container, #guestgateway_container").show(); + $thisWizard.find("#step4").find("#guestip_list").show(); + $thisWizard.find("#step4").find("#publicip_list").hide(); return true; break; case "Advanced": //create VLAN in zone-level //show Zone VLAN Range in Add Zone(step 2), hide Guest IP Range in Add Pod(step3) $thisWizard.find("#step2").find("#add_zone_vlan_container, #add_zone_guestcidraddress_container").show(); - $thisWizard.find("#step3").find("#guestip_container, #guestnetmask_container, #guestgateway_container, #submit_in_step3").hide(); - $thisWizard.find("#step3").find("#go_to_step_4").show(); - - // default value of "#add_publicip_vlan_scope" is "zone-wide". Calling change() will hide "#add_publicip_vlan_domain_container", "#add_publicip_vlan_account_container". + + //$thisWizard.find("#step3").find("#guestip_container, #guestnetmask_container, #guestgateway_container").hide(); + $thisWizard.find("#step4").find("#guestip_list").hide(); + $thisWizard.find("#step4").find("#publicip_list").show(); $addZoneWizard.find("#step4").find("#add_publicip_vlan_scope").change(); return true; @@ -1135,9 +1137,7 @@ function initAddZoneWizard() { break; case "go_to_step_4": //step 3 => step 4 - var isValid = addZoneWizardValidatePod($thisWizard); - if($thisWizard.find("#step3").find("#guestip_container").css("display") != "none") - isValid &= addZoneWizardValidateGuestIPRange($thisWizard); + var isValid = addZoneWizardValidatePod($thisWizard); if (!isValid) return; @@ -1159,28 +1159,20 @@ function initAddZoneWizard() { $thisWizard.find("#step2").hide(); $thisWizard.find("#step1").show(); break; - - case "submit_in_step3": //step 3 => make API call - var isValid = addZoneWizardValidatePod($thisWizard); - if($thisWizard.find("#step3").find("#guestip_container").css("display") != "none") - isValid &= addZoneWizardValidateGuestIPRange($thisWizard); - if (!isValid) - return; - - $thisWizard.find("#step3").hide(); - $thisWizard.find("#after_submit_screen").show(); - addZoneWizardSubmit($thisWizard); - break; - - case "submit_in_step4": //step 4 => make API call - var isValid = addZoneWizardValidatePublicIPRange($thisWizard); + + case "submit": //step 4 => make API call + var isValid = true; + if($thisWizard.find("#step4").find("#guestip_list").css("display") != "none") + isValid = addZoneWizardValidateGuestIPRange($thisWizard); + if($thisWizard.find("#step4").find("#publicip_list").css("display") != "none") + isValid &= addZoneWizardValidatePublicIPRange($thisWizard); if (!isValid) return; $thisWizard.find("#step4").hide(); $thisWizard.find("#after_submit_screen").show(); addZoneWizardSubmit($thisWizard); - break; + break; } return false; }); @@ -1368,8 +1360,47 @@ function addZoneWizardSubmit($thisWizard) { }); // create pod (end) - // add IP range to public network in zone (begin) - if(networktype == "Advanced") { + // add guest IP range to basic zone (begin) + if($thisWizard.find("#step4").find("#guestip_list").css("display") != "none") { + var netmask = $thisWizard.find("#step4").find("#guestip_list").find("#guestnetmask").val(); + var startip = $thisWizard.find("#step4").find("#guestip_list").find("#startguestip").val(); + var endip = $thisWizard.find("#step4").find("#guestip_list").find("#endguestip").val(); + var guestgateway = $thisWizard.find("#step4").find("#guestip_list").find("#guestgateway").val(); + + var array1 = []; + array1.push("&vlan=untagged"); + array1.push("&zoneid=" + zoneId); + array1.push("&podId=" + podId); + array1.push("&forVirtualNetwork=false"); //direct VLAN + array1.push("&gateway="+todb(guestgateway)); + array1.push("&netmask="+todb(netmask)); + array1.push("&startip="+todb(startip)); + if(endip != null && endip.length > 0) + array1.push("&endip="+todb(endip)); + + $.ajax({ + data: createURL("command=createVlanIpRange" + array1.join("")), + dataType: "json", + async: false, + success: function(json) { + $thisWizard.find("#after_submit_screen").find("#add_iprange_tick_cross").removeClass().addClass("zonepopup_reviewtick"); + $thisWizard.find("#after_submit_screen").find("#add_iprange_message").removeClass().text("Guest IP range was created successfully"); + + var item = json.createvlaniprangeresponse.vlan; + vlanId = item.id; + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + $thisWizard.find("#after_submit_screen").find("#add_iprange_tick_cross").removeClass().addClass("zonepopup_reviewcross"); + $thisWizard.find("#after_submit_screen").find("#add_iprange_message").removeClass().addClass("error").text(("Failed to create Guest IP range: " + parseXMLHttpResponse(XMLHttpResponse))); + }); + } + }); + } + // add guest IP range to basic zone (end) + + // add public IP range to basic zone (begin) + if($thisWizard.find("#step4").find("#publicip_list").css("display") != "none") { var isDirect = false; var isTagged = $thisWizard.find("#step4").find("#add_publicip_vlan_tagged").val() == "tagged"; @@ -1419,46 +1450,9 @@ function addZoneWizardSubmit($thisWizard) { } }); } - // add IP range to public network in zone (end) + // add public IP range to basic zone (end) } - - if(podId != null && $thisWizard.find("#step3").find("#guestip_container").css("display") != "none") { - var netmask = $thisWizard.find("#step3").find("#guestnetmask").val(); - var startip = $thisWizard.find("#step3").find("#startguestip").val(); - var endip = $thisWizard.find("#step3").find("#endguestip").val(); - var guestgateway = $thisWizard.find("#step3").find("#guestgateway").val(); - - var array1 = []; - array1.push("&vlan=untagged"); - array1.push("&zoneid=" + zoneId); - array1.push("&podId=" + podId); - array1.push("&forVirtualNetwork=false"); //direct VLAN - array1.push("&gateway="+todb(guestgateway)); - array1.push("&netmask="+todb(netmask)); - array1.push("&startip="+todb(startip)); - if(endip != null && endip.length > 0) - array1.push("&endip="+todb(endip)); - $.ajax({ - data: createURL("command=createVlanIpRange" + array1.join("")), - dataType: "json", - async: false, - success: function(json) { - $thisWizard.find("#after_submit_screen").find("#add_iprange_tick_cross").removeClass().addClass("zonepopup_reviewtick"); - $thisWizard.find("#after_submit_screen").find("#add_iprange_message").removeClass().text("Guest IP range was created successfully"); - - var item = json.createvlaniprangeresponse.vlan; - vlanId = item.id; - }, - error: function(XMLHttpResponse) { - handleError(XMLHttpResponse, function() { - $thisWizard.find("#after_submit_screen").find("#add_iprange_tick_cross").removeClass().addClass("zonepopup_reviewcross"); - $thisWizard.find("#after_submit_screen").find("#add_iprange_message").removeClass().addClass("error").text(("Failed to create Guest IP range: " + parseXMLHttpResponse(XMLHttpResponse))); - }); - } - }); - } - $thisWizard.find("#after_submit_screen").find("#spinning_wheel").hide(); }