From 0435d99247959e7382a1ec0ee98fbff25d6c8f01 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 21 Sep 2010 11:55:12 -0700 Subject: [PATCH] new UI - volume page - implement delete volume action. --- ui/new/scripts/cloud.core2.volume.js | 45 +++++++++++++++++++++----- ui/scripts/cloud.core.storage.js | 47 ++++++++++++++-------------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/ui/new/scripts/cloud.core2.volume.js b/ui/new/scripts/cloud.core2.volume.js index f09468267b2..9e3b329e6de 100644 --- a/ui/new/scripts/cloud.core2.volume.js +++ b/ui/new/scripts/cloud.core2.volume.js @@ -67,13 +67,36 @@ function volumeJsonToDetailsTab(jsonObj){ //actions *** var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu"); $actionMenu.find("#action_list").empty(); - if(jsonObj.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed. - if (jsonObj.vmstate == "Stopped") - buildActionLinkForDetailsTab("Create Template", volumeActionMap, $actionMenu, volumeListAPIMap); - } - else { //jsonObj.type=="DATADISK": "detach disk" is allowed, "create template" is disallowed. - buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap); - } + + //buildActionLinkForDetailsTab("Take Snapshot", volumeActionMap, $actionMenu, volumeListAPIMap); //show take snapshot + //buildActionLinkForDetailsTab("Recurring Snapshot", volumeActionMap, $actionMenu, volumeListAPIMap); //show Recurring Snapshot + + if(jsonObj.type=="ROOT") { + if (jsonObj.vmstate == "Stopped") + buildActionLinkForDetailsTab("Create Template", volumeActionMap, $actionMenu, volumeListAPIMap); //show create template + } + else { + if (jsonObj.virtualmachineid != null) { + if (jsonObj.storagetype == "shared" && (jsonObj.vmstate == "Running" || jsonObj.vmstate == "Stopped")) { + buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap); //show detach disk + } + } else { + // Disk not attached + if (jsonObj.storagetype == "shared") { + buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap); //show attach disk + + if(jsonObj.vmname == null || jsonObj.vmname == "none") + buildActionLinkForDetailsTab("Delete Volume", volumeActionMap, $actionMenu, volumeListAPIMap); //show delete volume + } + } + } + + /* + if(jsonObj.state == "Creating" || jsonObj.state == "Corrupted" || jsonObj.name == "attaching") + template.find("#grid_links_container").hide(); //hide actions panel + else + template.find("#grid_links_container").show(); //show actions panel + */ } var volumeActionMap = { @@ -90,7 +113,13 @@ var volumeActionMap = { dialogBeforeActionFn : doCreateTemplateFromVolume, inProcessText: "Creating template....", afterActionSeccessFn: function(){} - } + }, + "Delete Volume": { + api: "deleteVolume", + isAsyncJob: false, + inProcessText: "Deleting volume....", + afterActionSeccessFn: function(){} + } } var volumeListAPIMap = { diff --git a/ui/scripts/cloud.core.storage.js b/ui/scripts/cloud.core.storage.js index 68e03e0cfff..5cca44dee3f 100644 --- a/ui/scripts/cloud.core.storage.js +++ b/ui/scripts/cloud.core.storage.js @@ -595,28 +595,29 @@ function showStorageTab(domainId, targetTab) { } }); - $("#volume_action_snapshot_grid, #volume_action_take_snapshot_container, #volume_action_recurring_snapshot_container").show(); - $("#submenu_snapshot").show().bind("click", function(event) { - event.preventDefault(); - - currentSubMenu.addClass("submenu_links_off").removeClass("submenu_links_on"); - $(this).addClass("submenu_links_on").removeClass("submenu_links_off"); - currentSubMenu = $(this); - - $("#submenu_content_snapshot").show(); - $("#submenu_content_pool").hide(); - $("#submenu_content_storage").hide(); - $("#submenu_content_volume").hide(); - - var submenuContent = $("#submenu_content_snapshot"); - if (isAdmin) - submenuContent.find("#adv_search_domain_li, #adv_search_account_li").show(); - else //There are no fields in Advanced Search Dialog Box for non-admin user. So, hide Advanced Search Link. - submenuContent.find("#advanced_search_link").hide(); - - currentPage = 1; - listSnapshots(); - }); + $("#volume_action_snapshot_grid, #volume_action_take_snapshot_container, #volume_action_recurring_snapshot_container").show(); + $("#submenu_snapshot").show().bind("click", function(event) { + event.preventDefault(); + + currentSubMenu.addClass("submenu_links_off").removeClass("submenu_links_on"); + $(this).addClass("submenu_links_on").removeClass("submenu_links_off"); + currentSubMenu = $(this); + + $("#submenu_content_snapshot").show(); + $("#submenu_content_pool").hide(); + $("#submenu_content_storage").hide(); + $("#submenu_content_volume").hide(); + + var submenuContent = $("#submenu_content_snapshot"); + if (isAdmin) + submenuContent.find("#adv_search_domain_li, #adv_search_account_li").show(); + else //There are no fields in Advanced Search Dialog Box for non-admin user. So, hide Advanced Search Link. + submenuContent.find("#advanced_search_link").hide(); + + currentPage = 1; + listSnapshots(); + }); + if (getHypervisorType() == "kvm") { $("#dialog_add_pool #pool_cluster_container").hide(); } @@ -982,7 +983,7 @@ function showStorageTab(domainId, targetTab) { rowContainer.hide(); $.ajax({ - data: createURL("command=deleteVolume&id="+volumeId+"&response=json"), + data: createURL("command=deleteVolume&id="+volumeId+"&response=json"), dataType: "json", success: function(json) { volumeTemplate.slideUp("slow", function(){