From da762b01db97af0d6480fb285cb7d8eea263ed3b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 19 Oct 2010 10:51:30 -0700 Subject: [PATCH] new UI - implement delete primary storage action. --- .../classes/resources/resource.properties | 1 + ui/new/jsp/resource.jsp | 22 ++++++ ui/new/scripts/cloud.core2.resource.js | 68 ++++++++++++++++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/client/WEB-INF/classes/resources/resource.properties b/client/WEB-INF/classes/resources/resource.properties index 9d678edd428..725a639a93c 100644 --- a/client/WEB-INF/classes/resources/resource.properties +++ b/client/WEB-INF/classes/resources/resource.properties @@ -128,3 +128,4 @@ please.confirm.you.want.to.cancel.maintenance.for.the.host = Please confirm you please.confirm.you.want.to.force.a.reconnection.for.the.host = Please confirm you want to force a reconnection for the host please.confirm.you.want.to.remove.the.host.from.the.management.server = Please confirm you want to remove the host from the management server Please.choose.a.OS.preference.for.this.host..Virtual.machines.will.always.be.allocated.to.hosts.with.an.OS.preference.that.matches.with.the.OS.type.of.the.template.chosen.for.the.virtual.machine.before.choosing.other.hosts. = Please choose a OS preference for this host. Virtual machines will always be allocated to hosts with an OS preference that matches with the OS type of the template chosen for the virtual machine before choosing other hosts. +please.confirm.you.want.to.delete_the_primary_storage = Please confirm you want to delete the primary storage \ No newline at end of file diff --git a/ui/new/jsp/resource.jsp b/ui/new/jsp/resource.jsp index 69d74e1d4a5..550bd484b23 100644 --- a/ui/new/jsp/resource.jsp +++ b/ui/new/jsp/resource.jsp @@ -401,6 +401,22 @@
+
+ +
+
+
+

+ Waiting …

+
+
@@ -1126,3 +1142,9 @@
+ + diff --git a/ui/new/scripts/cloud.core2.resource.js b/ui/new/scripts/cloud.core2.resource.js index 94abfbae419..d055b585689 100644 --- a/ui/new/scripts/cloud.core2.resource.js +++ b/ui/new/scripts/cloud.core2.resource.js @@ -511,7 +511,41 @@ function primarystorageJsonToDetailsTab(jsonObj) { $detailsTab.find("#path").text(fromdb(jsonObj.path)); $detailsTab.find("#disksizetotal").text(convertBytes(jsonObj.disksizetotal)); $detailsTab.find("#disksizeallocated").text(convertBytes(jsonObj.disksizeallocated)); - $detailsTab.find("#tags").text(fromdb(jsonObj.tags)); + $detailsTab.find("#tags").text(fromdb(jsonObj.tags)); + + //actions *** + var $actionLink = $detailsTab.find("#action_link"); + $actionLink.bind("mouseover", function(event) { + $(this).find("#action_menu").show(); + return false; + }); + $actionLink.bind("mouseout", function(event) { + $(this).find("#action_menu").hide(); + return false; + }); + var $actionMenu = $detailsTab.find("#action_link #action_menu"); + $actionMenu.find("#action_list").empty(); + var midmenuItemId = primarystorageGetMidmenuId(jsonObj); + buildActionLinkForDetailsTab("Delete Primary Storage", primarystorageActionMap, $actionMenu, midmenuItemId, $detailsTab); +} + +function primarystorageClearRigntPanel() { + primarystorageJsonClearDetailsTab(jsonObj); +} + +function primarystorageJsonClearDetailsTab() { + var $detailsTab = $("#primarystorage_page").find("#tab_content_details"); + $detailsTab.find("#id").text(""); + $detailsTab.find("#name").text(""); + $detailsTab.find("#zonename").text(""); + $detailsTab.find("#podname").text(""); + $detailsTab.find("#clustername").text(""); + $detailsTab.find("#type").text(""); + $detailsTab.find("#ipaddress").text(""); + $detailsTab.find("#path").text(""); + $detailsTab.find("#disksizetotal").text(""); + $detailsTab.find("#disksizeallocated").text(""); + $detailsTab.find("#tags").text(""); } //***** primary storage page (end) ********************************************************************************************* @@ -757,6 +791,7 @@ function afterLoadResourceJSP() { initDialog("dialog_confirmation_force_reconnect"); initDialog("dialog_confirmation_remove_host"); initDialog("dialog_update_os"); + initDialog("dialog_confirmation_delete_primarystorage"); // if hypervisor is KVM, limit the server option to NFS for now if (getHypervisorType() == 'kvm') @@ -1448,4 +1483,35 @@ function doUpdateOSPreference($actionLink, $detailsTab, midmenuItemId){ $(this).dialog("close"); } }).dialog("open"); +} + +var primarystorageActionMap = { + "Delete Primary Storage": { + isAsyncJob: false, + dialogBeforeActionFn : doDeletePrimaryStorage, + inProcessText: "Deleting Primary Storage....", + afterActionSeccessFn: function(json, id, midmenuItemId) { + var $midmenuItem1 = $("#"+midmenuItemId); + $midmenuItem1.remove(); + clearRightPanel(); + primarystorageClearRightPanel(); + } + } +} + +function doDeletePrimaryStorage($actionLink, $detailsTab, midmenuItemId){ + var jsonObj = $detailsTab.data("jsonObj"); + + $("#dialog_confirmation_delete_primarystorage") + .dialog("option", "buttons", { + "OK": function() { + $(this).dialog("close"); + var id = jsonObj.id; + var apiCommand = "command=deleteStoragePool&id="+id; + doActionToDetailsTab(id, $actionLink, apiCommand, midmenuItemId); + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); } \ No newline at end of file