cloudStack - Elastic Load Balancer - createLoadBalancer API has been changed from sync to async. This is another UI change (create load balancer rule with IP) for it.

This commit is contained in:
Jessica Wang 2011-07-28 19:50:16 -07:00
parent 7e8393e6da
commit ca9fb52ba6
1 changed files with 55 additions and 18 deletions

View File

@ -565,26 +565,63 @@ function afterLoadIpJSP() {
array1.push("&publicport="+publicPort);
array1.push("&privateport="+privatePort);
array1.push("&algorithm="+algorithm);
$.ajax({
data: createURL("command=createLoadBalancerRule"+array1.join("")),
dataType: "json",
success: function(json) {
var item = json.createloadbalancerruleresponse.loadbalancer;
loadBalancerJsonToTemplate(item, $template);
$spinningWheel.hide();
refreshCreateLoadBalancerRow();
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
$template.slideUp("slow", function() {
$(this).remove();
$.ajax({
data: createURL("command=createLoadBalancerRule"+array1.join("")),
dataType: "json",
success: function(json) {
var jobId = json.createloadbalancerruleresponse.jobid;
var timerKey = "addLbJob_"+jobId;
$("body").everyTime(2000, timerKey, function() {
$.ajax({
data: createURL("command=queryAsyncJobResult&jobId="+jobId),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
} else {
$("body").stopTime(timerKey);
if (result.jobstatus == 1) {
// Succeeded
var item = result.jobresult.loadbalancer;
loadBalancerJsonToTemplate(item, $template);
$spinningWheel.hide();
refreshCreateLoadBalancerRow();
} else if (result.jobstatus == 2) {
$template.slideUp("slow", function() {
$(this).remove();
});
var errorMsg = fromdb(result.jobresult.errortext);
$("#dialog_error").text(fromdb(errorMsg)).dialog("open");
}
}
},
error: function(XMLHttpResponse) {
$("body").stopTime(timerKey);
handleError(XMLHttpResponse, function() {
$template.slideUp("slow", function() {
$(this).remove();
});
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
$("#dialog_error").text(fromdb(errorMsg)).dialog("open");
});
}
});
}, 0);
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
$template.slideUp("slow", function() {
$(this).remove();
});
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
$("#dialog_error").text(fromdb(errorMsg)).dialog("open");
});
}
});
$("#dialog_error").text(fromdb(errorMsg)).dialog("open");
});
}
});
return false;
});
//*** Load Balancer tab (end) ***