new UI - snapshots page - implement delete snapshot action.

This commit is contained in:
Jessica Wang 2010-09-23 16:59:19 -07:00
parent e583473252
commit e8a16e052c
2 changed files with 45 additions and 21 deletions

View File

@ -101,20 +101,23 @@ function doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap) {
if (result.jobstatus == 1) { // Succeeded
$detailsTab.find("#action_message_box #description").text(label + " action succeeded.");
$detailsTab.find("#action_message_box").removeClass("error").show();
//DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041)
//Before Bug 6041 get fixed, use the temporary solution below.
$.ajax({
cache: false,
data: createURL("command="+listAPI+"&id="+id),
dataType: "json",
success: function(json) {
afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]);
}
});
//After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
//afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]);
if(apiCommand.indexOf("command=delete")!=0) {
//DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041)
//Before Bug 6041 get fixed, use the temporary solution below.
$.ajax({
cache: false,
data: createURL("command="+listAPI+"&id="+id),
dataType: "json",
success: function(json) {
afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]);
}
});
//After Bug 6037 is fixed, remove temporary solution above and uncomment the line below
//afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]);
}
else { //apiCommand is deleteXXXXXXX
afterActionSeccessFn(id);
}
} else if (result.jobstatus == 2) { // Failed
$detailsTab.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(result.jobresult));
$detailsTab.find("#action_message_box").addClass("error").show();

View File

@ -24,9 +24,7 @@ function snapshotToRigntPanel($midmenuItem) {
function snapshotJsonToDetailsTab(jsonObj) {
var $detailsTab = $("#right_panel_content #tab_content_details");
$detailsTab.data("jsonObj", jsonObj);
var $detailsTab = $("#right_panel_content #tab_content_details");
$detailsTab.data("jsonObj", jsonObj);
$detailsTab.find("#id").text(jsonObj.id);
$detailsTab.find("#name").text(fromdb(jsonObj.name));
$detailsTab.find("#volume_name").text(fromdb(jsonObj.volumename));
@ -38,7 +36,19 @@ function snapshotJsonToDetailsTab(jsonObj) {
//actions ***
var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu");
$actionMenu.find("#action_list").empty();
buildActionLinkForDetailsTab("Create Volume", snapshotActionMap, $actionMenu, snapshotListAPIMap);
buildActionLinkForDetailsTab("Create Volume", snapshotActionMap, $actionMenu, snapshotListAPIMap);
buildActionLinkForDetailsTab("Delete snapshot", snapshotActionMap, $actionMenu, snapshotListAPIMap);
}
function snapshotClearRightPanel() {
var $detailsTab = $("#right_panel_content #tab_content_details");
$detailsTab.find("#id").text("");
$detailsTab.find("#name").text("");
$detailsTab.find("#volume_name").text("");
$detailsTab.find("#interval_type").text("");
$detailsTab.find("#account").text("");
$detailsTab.find("#domain").text("");
$detailsTab.find("#created").text("");
}
var snapshotActionMap = {
@ -47,10 +57,21 @@ var snapshotActionMap = {
asyncJobResponse: "createvolumeresponse",
dialogBeforeActionFn : doCreateVolumeFromSnapshotInSnapshotPage,
inProcessText: "Creating Volume....",
afterActionSeccessFn: function(jsonObj) {
afterActionSeccessFn: function(jsonObj) {}
}
,
"Delete snapshot": {
api: "deleteSnapshot",
isAsyncJob: true,
asyncJobResponse: "deletesnapshotresponse",
inProcessText: "Deleting snapshot....",
afterActionSeccessFn: function(id) {
var $midmenuItem1 = $("#midmenuItem_"+id);
$midmenuItem1.remove();
clearRightPanel();
snapshotClearRightPanel();
}
}
}
}
var snapshotListAPIMap = {