From 1faee0da2aadbdafc5b7c40f026b7ffe492df068 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 8 Feb 2011 15:24:24 -0800 Subject: [PATCH] bug 8433: Delete Domain action - show action success/fail info on top of right panel after action finishes. --- ui/scripts/cloud.core.domain.js | 94 +++++++++++++++++++++++++++------ ui/scripts/cloud.core.js | 17 ++++++ 2 files changed, 94 insertions(+), 17 deletions(-) diff --git a/ui/scripts/cloud.core.domain.js b/ui/scripts/cloud.core.domain.js index 549358e07b6..c55af0304e9 100644 --- a/ui/scripts/cloud.core.domain.js +++ b/ui/scripts/cloud.core.domain.js @@ -681,9 +681,81 @@ function doDeleteDomain($actionLink, $detailsTab, $midmenuItem1) { .text(dictionary["message.action.delete.domain"]) .dialog('option', 'buttons', { "Confirm": function() { - $(this).dialog("close"); - var apiCommand = "command=deleteDomain&id="+id; - doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $detailsTab); + $(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); + }); + } + }); }, "Cancel": function() { $(this).dialog("close"); @@ -695,19 +767,7 @@ var domainActionMap = { "label.action.edit.domain": { dialogBeforeActionFn: doEditDomain }, - "label.action.delete.domain": { - 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(); - } - }); - } + "label.action.delete.domain": { + dialogBeforeActionFn : doDeleteDomain } } \ No newline at end of file diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 93c1bd8c586..9b1a9c88b46 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -1254,6 +1254,23 @@ function cancelEditMode($tab) { $tab.find("#save_button, #cancel_button").hide(); } +function showAfterActionInfoOnTop(isSuccessful, afterActionInfo) { + var $afterActionInfoContainer = $("#right_panel_content #after_action_info_container_on_top"); + + if(isSuccessful) + $afterActionInfoContainer.removeClass("errorbox"); + else + $afterActionInfoContainer.addClass("errorbox"); + + $afterActionInfoContainer.find("#after_action_info").text(afterActionInfo); + + $afterActionInfoContainer.show(); +} + + + + +