new UI - add zone wizard - implement CreateZone.

This commit is contained in:
Jessica Wang 2010-11-10 13:37:08 -08:00
parent b074f99c8d
commit 8af7b2473b
2 changed files with 139 additions and 24 deletions

View File

@ -359,7 +359,7 @@
<p> Adding Zone to Physical Resources</p>
</div>
<div id="confirmation_message" class="zonepoup_msgbox"> Confirmation msg will appear here</div>
<div id="after_action_message" class="zonepoup_msgbox"></div>
</div>
<div class="zonepopup_navigationpanel">
<div class="vmpop_nextbutton" id="close_button">

View File

@ -303,8 +303,10 @@ function resourceCountTotal() {
}
function refreshAddZoneWizard() {
$("#add_zone_wizard").find("#step2, #step3, #after_submit_screen").hide();
$("#add_zone_wizard").find("#step1").show();
var $addZoneWizard = $("#add_zone_wizard");
$addZoneWizard.find("#step2, #step3, #after_submit_screen").hide();
$addZoneWizard.find("#step1").show();
$addZoneWizard.find("#basic_mode").click();
}
function openAddZoneWizard() {
@ -318,16 +320,46 @@ function closeAddZoneWizard() {
$("#wizard_overlay").hide();
}
function initAddZoneShortcut() {
$("#add_zone_shortcut").unbind("click").bind("click", function(event) {
openAddZoneWizard();
function initAddZoneShortcut() {
var $addZoneWizard = $("#add_zone_wizard");
$addZoneWizard.find("#add_zone_public").unbind("change").bind("change", function(event) {
if($(this).val() == "true") { //public zone
$addZoneWizard.find("#domain_dropdown_container").hide();
}
else { //private zone
$addZoneWizard.find("#domain_dropdown_container").show();
}
return false;
});
var domainDropdown = $addZoneWizard.find("#domain_dropdown").empty();
$.ajax({
data: createURL("command=listDomains"+maxPageSize),
dataType: "json",
async: false,
success: function(json) {
var domains = json.listdomainsresponse.domain;
if (domains != null && domains.length > 0) {
for (var i = 0; i < domains.length; i++) {
domainDropdown.append("<option value='" + domains[i].id + "'>" + fromdb(domains[i].name) + "</option>");
}
}
}
});
$("#add_zone_shortcut").unbind("click").bind("click", function(event) {
if($("#leftmenu_physical_resource").find("#physical_resource_arrow").hasClass("expanded_close") == true)
$("#leftmenu_physical_resource").click(); //if Physical Resource arrow shows closed (i.e. zonetree is hidden), expand and show zonetree.
//$addZoneWizard.find("#info_container").hide();
openAddZoneWizard();
return false;
});
$("#add_zone_wizard").unbind("click").bind("click", function(event) {
$addZoneWizard.unbind("click").bind("click", function(event) {
var $thisWizard = $(this);
var $target = $(event.target);
switch($target.attr("id")) {
case "close_button":
closeAddZoneWizard();
@ -350,11 +382,6 @@ function initAddZoneShortcut() {
$thisWizard.find("#step2").hide();
$thisWizard.find("#step3").show();
break;
case "submit_button": //step 3 => spinning wheel
$thisWizard.find("#step3").hide();
$thisWizard.find("#after_submit_screen").show();
break;
case "back_to_step_2": //step 3 => step 2
$thisWizard.find("#step3").hide();
@ -364,13 +391,99 @@ function initAddZoneShortcut() {
case "back_to_step_1": //step 2 => step 1
$thisWizard.find("#step2").hide();
$thisWizard.find("#step1").show();
break;
break;
case "submit_button": //step 3 => spinning wheel
$thisWizard.find("#step3").hide();
$thisWizard.find("#after_submit_screen").show();
AddZoneWizardSubmit($thisWizard);
break;
}
return false;
});
}
function AddZoneWizardSubmit($thisWizard) {
// validate values
var isValid = true;
isValid &= validateString("Name", $thisWizard.find("#add_zone_name"), $thisWizard.find("#add_zone_name_errormsg"));
isValid &= validateIp("DNS 1", $thisWizard.find("#add_zone_dns1"), $thisWizard.find("#add_zone_dns1_errormsg"), false); //required
isValid &= validateIp("DNS 2", $thisWizard.find("#add_zone_dns2"), $thisWizard.find("#add_zone_dns2_errormsg"), true); //optional
isValid &= validateIp("Internal DNS 1", $thisWizard.find("#add_zone_internaldns1"), $thisWizard.find("#add_zone_internaldns1_errormsg"), false); //required
isValid &= validateIp("Internal DNS 2", $thisWizard.find("#add_zone_internaldns2"), $thisWizard.find("#add_zone_internaldns2_errormsg"), true); //optional
if (getNetworkType() != "vnet") {
isValid &= validateString("Zone - Start VLAN Range", $thisWizard.find("#add_zone_startvlan"), $thisWizard.find("#add_zone_startvlan_errormsg"), false); //required
isValid &= validateString("Zone - End VLAN Range", $thisWizard.find("#add_zone_endvlan"), $thisWizard.find("#add_zone_endvlan_errormsg"), true); //optional
}
isValid &= validateCIDR("Guest CIDR", $thisWizard.find("#add_zone_guestcidraddress"), $thisWizard.find("#add_zone_guestcidraddress_errormsg"), false); //required
if (!isValid)
return;
$thisWizard.find("#spinning_wheel").show();
var moreCriteria = [];
var name = trim($thisWizard.find("#add_zone_name").val());
moreCriteria.push("&name="+todb(name));
var dns1 = trim($thisWizard.find("#add_zone_dns1").val());
moreCriteria.push("&dns1="+encodeURIComponent(dns1));
var dns2 = trim($thisWizard.find("#add_zone_dns2").val());
if (dns2 != null && dns2.length > 0)
moreCriteria.push("&dns2="+encodeURIComponent(dns2));
var internaldns1 = trim($thisWizard.find("#add_zone_internaldns1").val());
moreCriteria.push("&internaldns1="+encodeURIComponent(internaldns1));
var internaldns2 = trim($thisWizard.find("#add_zone_internaldns2").val());
if (internaldns2 != null && internaldns2.length > 0)
moreCriteria.push("&internaldns2="+encodeURIComponent(internaldns2));
if (getNetworkType() != "vnet") {
var vlanStart = trim($thisWizard.find("#add_zone_startvlan").val());
var vlanEnd = trim($thisWizard.find("#add_zone_endvlan").val());
if (vlanEnd != null && vlanEnd.length > 0)
moreCriteria.push("&vlan=" + encodeURIComponent(vlanStart + "-" + vlanEnd));
else
moreCriteria.push("&vlan=" + encodeURIComponent(vlanStart));
}
var guestcidraddress = trim($thisWizard.find("#add_zone_guestcidraddress").val());
moreCriteria.push("&guestcidraddress="+encodeURIComponent(guestcidraddress));
if($thisWizard.find("#domain_dropdown_container").css("display") != "none") {
var domainId = trim($thisWizard.find("#domain_dropdown").val());
moreCriteria.push("&domainid="+domainId);
}
$.ajax({
data: createURL("command=createZone"+moreCriteria.join("")),
dataType: "json",
success: function(json) {
$thisWizard.find("#spinning_wheel").hide();
//$thisWizard.dialog("close");
var template = $("#leftmenu_zone_node_template").clone(true);
var $zoneTree = $("#leftmenu_zone_tree").find("#tree_container");
$zoneTree.prepend(template);
template.fadeIn("slow");
var item = json.createzoneresponse.zone;
zoneJSONToTreeNode(item, template);
$thisWizard.find("#after_action_message").text("Zone was added successfully");
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
handleErrorInDialog(XMLHttpResponse, $thisWizard);
});
}
});
}
function initUpdateConsoleCertButton($midMenuAddLink2) {
$midMenuAddLink2.find("#label").text("Update SSL Certificate");
$midMenuAddLink2.show();
@ -448,20 +561,22 @@ function initUpdateConsoleCertButton($midMenuAddLink2) {
function initAddZoneButton($midmenuAddLink1) {
$midmenuAddLink1.find("#label").text("Add Zone");
$midmenuAddLink1.show();
var $dialogAddZone = $("#dialog_add_zone");
$dialogAddZone.find("#add_zone_public").unbind("change").bind("change", function(event) {
$midmenuAddLink1.show();
initAddZoneDialog($("#dialog_add_zone"), $midmenuAddLink1);
}
function initAddZoneDialog($addZoneDialog, $addZoneLink) {
$addZoneDialog.find("#add_zone_public").unbind("change").bind("change", function(event) {
if($(this).val() == "true") { //public zone
$dialogAddZone.find("#domain_dropdown_container").hide();
$addZoneDialog.find("#domain_dropdown_container").hide();
}
else { //private zone
$dialogAddZone.find("#domain_dropdown_container").show();
$addZoneDialog.find("#domain_dropdown_container").show();
}
return false;
});
var domainDropdown = $dialogAddZone.find("#domain_dropdown").empty();
var domainDropdown = $addZoneDialog.find("#domain_dropdown").empty();
$.ajax({
data: createURL("command=listDomains"+maxPageSize),
dataType: "json",
@ -476,13 +591,13 @@ function initAddZoneButton($midmenuAddLink1) {
}
});
$midmenuAddLink1.unbind("click").bind("click", function(event) {
$addZoneLink.unbind("click").bind("click", function(event) {
if($("#leftmenu_physical_resource").find("#physical_resource_arrow").hasClass("expanded_close") == true)
$("#leftmenu_physical_resource").click(); //if Physical Resource arrow shows closed (i.e. zonetree is hidden), expand and show zonetree.
$("#dialog_add_zone").find("#info_container").hide();
$addZoneDialog.find("#info_container").hide();
$("#dialog_add_zone")
$addZoneDialog
.dialog('option', 'buttons', {
"Add": function() {
var $thisDialog = $(this);