cloudstack 3.0 UI: create site-to-site VPN action - when any of the 3 createXXXXXXX API fails, remove the row from listView.

This commit is contained in:
Jessica Wang 2012-07-03 12:03:15 -07:00
parent 2742c50484
commit d0ed346b49
2 changed files with 33 additions and 21 deletions

View File

@ -3378,18 +3378,22 @@
return; //Job has not completed
}
else {
clearInterval(createvpnconnectionIntervalID);
if (result.jobstatus == 1) {
var obj = result.jobresult.vpnconnection;
clearInterval(createvpnconnectionIntervalID);
if (result.jobstatus == 1) {
//var obj = result.jobresult.vpnconnection;
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: "site-to-site VPN is created successfully." });
}
else if (result.jobstatus == 2) {
alert("Failed to create VPN connection. Error: " + _s(result.jobresult.errortext));
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("Failed to create VPN connection. Error: " + errorMsg);
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
@ -3397,27 +3401,29 @@
});
}
else if (result.jobstatus == 2) {
alert("Failed to create VPN customer gateway. Error: " + _s(result.jobresult.errortext));
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("Failed to create VPN customer gateway. Error: " + errorMsg);
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
}
});
}
else if (result.jobstatus == 2) {
alert("Failed to create VPN gateway. Error: " + _s(result.jobresult.errortext));
else if (result.jobstatus == 2) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("Failed to create VPN gateway. Error: " + errorMsg);
error: function(XMLHttpResponse) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
@ -3476,7 +3482,6 @@
}
},
action: function(args) {
debugger;
$.ajax({
url: createURL("deleteVpnConnection"),
dataType: "json",
@ -3484,8 +3489,7 @@
id: args.context.siteToSiteVpn[0].id
},
async: true,
success: function(json) {
debugger;
success: function(json) {
var jid = json.deletevpnconnectionresponse.jobid;
var deleteVpnConnectionIntervalID = setInterval(function() {
$.ajax({
@ -3521,8 +3525,7 @@
}
else {
clearInterval(deleteVpnGatewayIntervalID);
if (result.jobstatus == 1) {
//debugger;
if (result.jobstatus == 1) {
$.ajax({
url: createURL("deleteVpnCustomerGateway"),
dataType: "json",
@ -3530,8 +3533,7 @@
id: args.context.siteToSiteVpn[0].s2scustomergatewayid
},
async: true,
success: function(json) {
debugger;
success: function(json) {
var jid = json.deletecustomergatewayresponse.jobid;
var deleteVpnCustomerGatewayIntervalID = setInterval(function() {
$.ajax({

View File

@ -55,6 +55,7 @@ var pollAsyncJobResult = function(args) {
}
else {
if (result.jobstatus == 1) { // Succeeded
debugger;
if(args._custom.getUpdatedItem != null && args._custom.getActionFilter != null) {
args.complete({
data: args._custom.getUpdatedItem(json),
@ -276,6 +277,15 @@ cloudStack.actionFilter = {
}
}
$.removeTableRowInAction = function() { //remove table row that has loading image on top of it (i.e. table row that is in action)
var $listviewTable = $("div.list-view div.data-table table.body tbody");
var $tr1 = $listviewTable.find("tr.loading").removeClass("loading");
$tr1.find("td div.loading").removeClass("loading");
$tr1.remove();
if($listviewTable.find("tr").length == 0)
$listviewTable.append($("<tr>").addClass("empty even").append($("<td>").text("No data to show")));
}
var roleTypeUser = "0";
var roleTypeAdmin = "1";
var roleTypeDomainAdmin = "2";