From abaf82b30b8d23cca445c48935cc3d5402d51129 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 10 Nov 2010 20:20:25 -0800 Subject: [PATCH] new UI - add zone and pod wizard - implement error handling. --- ui/scripts/cloud.core.js | 7 +++++ ui/scripts/cloud.core.resource.js | 43 ++++++++++--------------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 0b218fb42ce..3b1a8defcfe 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -1013,6 +1013,13 @@ function handleErrorInDialog(XMLHttpResponse, $thisDialog) { $infoContainer.show(); } +function parseXMLHttpResponse(XMLHttpResponse) { + var start = XMLHttpResponse.responseText.indexOf("h1") + 3; + var end = XMLHttpResponse.responseText.indexOf(""); + $thisWizard.find("#spinning_wheel").hide(); }); } }); @@ -542,8 +543,8 @@ function addZoneWizardSubmit($thisWizard) { data: createURL("command=createPod"+array1.join("")), dataType: "json", async: false, - success: function(json) { - createPodSuccessful = true; + success: function(json) { + afterActionMsg += "Pod was created successfully
"; $thisWizard.find("#spinning_wheel").hide(); var item = json.createpodresponse.pod; @@ -568,7 +569,8 @@ function addZoneWizardSubmit($thisWizard) { }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse, function() { - handleErrorInDialog(XMLHttpResponse, $thisWizard); + afterActionMsg += ("Failed to create Pod. " + parseXMLHttpResponse(XMLHttpResponse) + "
"); + $thisWizard.find("#spinning_wheel").hide(); }); } }); @@ -593,37 +595,20 @@ function addZoneWizardSubmit($thisWizard) { $.ajax({ data: createURL("command=createVlanIpRange" + array1.join("")), dataType: "json", - success: function(json) { - createVLANSuccessful = true; + success: function(json) { + afterActionMsg += "Guest IP range was created successfully
"; var item = json.createvlaniprangeresponse.vlan; vlanId = item.id; }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse, function() { - handleErrorInDialog(XMLHttpResponse, $thisWizard); + afterActionMsg += ("Failed to create Guest IP range. " + parseXMLHttpResponse(XMLHttpResponse) + "
"); + $thisWizard.find("#spinning_wheel").hide(); }); } }); } - - var afterActionMsg = ""; - if(createZoneSuccessful) - afterActionMsg += "Zone was created successfully
"; - else - afterActionMsg += "failed to create zone
"; - if(createPodSuccessful) - afterActionMsg += "Pod was created successfully
"; - else - afterActionMsg += "failed to create pod
"; - - if($thisWizard.find("#step3").find("#guestip_container").css("display") != "none") { - if(createVLANSuccessful) - afterActionMsg += "Guest IP range was created successfully
"; - else - afterActionMsg += "failed to create Guest IP range
"; - } - $thisWizard.find("#after_action_message").html(afterActionMsg); }