mirror of https://github.com/apache/cloudstack.git
Extend shared function doActionToTab() to support details tab action on pages that don't have middle menu (e.g. Domain page, Zone page, Pod page).
This commit is contained in:
parent
4fb3beed76
commit
20ae6c8f97
|
|
@ -682,80 +682,8 @@ function doDeleteDomain($actionLink, $detailsTab, $midmenuItem1) {
|
|||
.dialog('option', 'buttons', {
|
||||
"Confirm": function() {
|
||||
$(this).dialog("close");
|
||||
|
||||
var $spinningWheel = $("#right_panel_content").find("#tab_content_details").find("#spinning_wheel");
|
||||
$spinningWheel.find("#description").text(dictionary["label.action.delete.domain.processing"]);
|
||||
$spinningWheel.show();
|
||||
|
||||
var $afterActionInfoContainer = $("#right_panel_content #after_action_info_container_on_top");
|
||||
$afterActionInfoContainer.removeClass("errorbox").hide();
|
||||
|
||||
var label2 = dictionary["label.action.delete.domain"];
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=deleteDomain&id="+id),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var jobId = json.deletedomainresponse.jobid;
|
||||
var timerKey = "asyncJob_" + jobId;
|
||||
$("body").everyTime(
|
||||
10000,
|
||||
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);
|
||||
$spinningWheel.hide();
|
||||
|
||||
if (result.jobstatus == 1) { // Succeeded
|
||||
showAfterActionInfoOnTop(true, (label2 + " - " + g_dictionary["label.succeeded"]));
|
||||
$midmenuItem1.slideUp(function() {
|
||||
var jsonObj = $(this).data("jsonObj");
|
||||
$(this).remove();
|
||||
if(jsonObj.id.toString() == $("#right_panel_content").find("#tab_content_details").find("#id").text()) {
|
||||
clearRightPanel();
|
||||
domainJsonClearRightPanel();
|
||||
}
|
||||
});
|
||||
} else if (result.jobstatus == 2) { // Failed
|
||||
var errorMsg = label2 + " - " + g_dictionary["label.failed"] + " - " + fromdb(result.jobresult.errortext);
|
||||
showAfterActionInfoOnTop(false, errorMsg);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
$("body").stopTime(timerKey);
|
||||
$spinningWheel.hide();
|
||||
handleError(XMLHttpResponse, function() {
|
||||
var errorMsg = label2 + " - " + g_dictionary["label.failed"] + " - ";
|
||||
if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) {
|
||||
errorMsg += parseXMLHttpResponse(XMLHttpResponse);
|
||||
}
|
||||
showAfterActionInfoOnTop(false, errorMsg);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
0
|
||||
);
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
$spinningWheel.hide();
|
||||
handleError(XMLHttpResponse, function() {
|
||||
var errorMsg = label2 + " - " + g_dictionary["label.failed"] + " - ";
|
||||
if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) {
|
||||
errorMsg += parseXMLHttpResponse(XMLHttpResponse);
|
||||
}
|
||||
showAfterActionInfoOnTop(false, errorMsg);
|
||||
});
|
||||
}
|
||||
});
|
||||
var apiCommand = "command=deleteDomain&id="+id;
|
||||
doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $detailsTab);
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
|
|
@ -768,6 +696,18 @@ var domainActionMap = {
|
|||
dialogBeforeActionFn: doEditDomain
|
||||
},
|
||||
"label.action.delete.domain": {
|
||||
dialogBeforeActionFn : doDeleteDomain
|
||||
isAsyncJob: true,
|
||||
dialogBeforeActionFn : doDeleteDomain,
|
||||
asyncJobResponse: "deletedomainresponse",
|
||||
inProcessText: "label.action.delete.domain.processing",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
$midmenuItem1.slideUp(function() {
|
||||
$(this).remove();
|
||||
if(id.toString() == $("#right_panel_content").find("#tab_content_details").find("#id").text()) {
|
||||
clearRightPanel();
|
||||
domainJsonClearRightPanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,16 +110,24 @@ function doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $thisTab) {
|
|||
|
||||
if (result.jobstatus == 1) { // Succeeded
|
||||
var afterActionInfo = afterActionSeccessFn(json, $midmenuItem1, id); //afterActionSeccessFn() will update $midmenuItem1.data("jsonObj")
|
||||
|
||||
//handleMidMenuItemAfterDetailsTabAction() will used updated $midmenuItem1.data("jsonObj")
|
||||
if(afterActionInfo == null)
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, (label2 + " - " + g_dictionary["label.succeeded"]));
|
||||
else
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, afterActionInfo);
|
||||
if($("#middle_menu").css("display") != "none") {
|
||||
if(afterActionInfo == null)
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, (label2 + " - " + g_dictionary["label.succeeded"]));
|
||||
else
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, afterActionInfo);
|
||||
}
|
||||
else {
|
||||
if(afterActionInfo == null)
|
||||
showAfterActionInfoOnTop(true, (label2 + " - " + g_dictionary["label.succeeded"]));
|
||||
else
|
||||
showAfterActionInfoOnTop(true, afterActionInfo);
|
||||
}
|
||||
} else if (result.jobstatus == 2) { // Failed
|
||||
//var errorMsg = label2 + " - " + g_dictionary["label.failed"] + " - " + g_dictionary["label.error.code"] + " " + fromdb(result.jobresult.errorcode);
|
||||
var errorMsg = label2 + " - " + g_dictionary["label.failed"] + " - " + fromdb(result.jobresult.errortext);
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, false, errorMsg);
|
||||
if($("#middle_menu").css("display") != "none")
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, false, errorMsg);
|
||||
else
|
||||
showAfterActionInfoOnTop(false, errorMsg);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -152,10 +160,18 @@ function doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $thisTab) {
|
|||
success: function(json) {
|
||||
$spinningWheel.hide();
|
||||
var afterActionInfo = afterActionSeccessFn(json, $midmenuItem1, id); //afterActionSeccessFn() will update $midmenuItem1.data("jsonObj")
|
||||
if(afterActionInfo == null)
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, (label2 + " - " + g_dictionary["label.succeeded"])); //handleMidMenuItemAfterDetailsTabAction() will used updated $midmenuItem1.data("jsonObj")
|
||||
else
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, afterActionInfo);
|
||||
if($("#middle_menu").css("display") != "none") {
|
||||
if(afterActionInfo == null)
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, (label2 + " - " + g_dictionary["label.succeeded"])); //handleMidMenuItemAfterDetailsTabAction() will used updated $midmenuItem1.data("jsonObj")
|
||||
else
|
||||
handleMidMenuItemAfterDetailsTabAction($midmenuItem1, true, afterActionInfo);
|
||||
}
|
||||
else {
|
||||
if(afterActionInfo == null)
|
||||
showAfterActionInfoOnTop(true, (label2 + " - " + g_dictionary["label.succeeded"]));
|
||||
else
|
||||
showAfterActionInfoOnTop(true, afterActionInfo);
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue