diff --git a/ui/new/jsp/snapshot.jsp b/ui/new/jsp/snapshot.jsp index eada1550537..5b53579b6a8 100644 --- a/ui/new/jsp/snapshot.jsp +++ b/ui/new/jsp/snapshot.jsp @@ -125,3 +125,19 @@ + + + + diff --git a/ui/new/scripts/cloud.core2.snapshot.js b/ui/new/scripts/cloud.core2.snapshot.js index 8204def8f12..598ceaac4a2 100644 --- a/ui/new/scripts/cloud.core2.snapshot.js +++ b/ui/new/scripts/cloud.core2.snapshot.js @@ -1,5 +1,9 @@ function afterLoadSnapshotJSP() { - + activateDialog($("#dialog_add_volume_from_snapshot").dialog({ + autoOpen: false, + modal: true, + zIndex: 2000 + })); } function snapshotToMidmenu(jsonObj, $midmenuItem1) { @@ -13,15 +17,70 @@ function snapshotToMidmenu(jsonObj, $midmenuItem1) { $midmenuItem1.find("#second_row").text(fromdb(jsonObj.volumename).substring(0,25)); } -function snapshotToRigntPanel($midmenuItem) { +function snapshotToRigntPanel($midmenuItem) { var jsonObj = $midmenuItem.data("jsonObj"); + snapshotJsonToDetailsTab(jsonObj); +} + +function snapshotJsonToDetailsTab(jsonObj) { + var $detailsTab = $("#right_panel_content #tab_content_details"); + $detailsTab.data("jsonObj", jsonObj); - var $rightPanelContent = $("#right_panel_content"); - $rightPanelContent.find("#id").text(jsonObj.id); - $rightPanelContent.find("#name").text(fromdb(jsonObj.name)); - $rightPanelContent.find("#volume_name").text(fromdb(jsonObj.volumename)); - $rightPanelContent.find("#interval_type").text(jsonObj.intervaltype); - $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); - $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); - setDateField(jsonObj.created, $rightPanelContent.find("#created")); + var $detailsTab = $("#right_panel_content #tab_content_details"); + $detailsTab.find("#id").text(jsonObj.id); + $detailsTab.find("#name").text(fromdb(jsonObj.name)); + $detailsTab.find("#volume_name").text(fromdb(jsonObj.volumename)); + $detailsTab.find("#interval_type").text(jsonObj.intervaltype); + $detailsTab.find("#account").text(fromdb(jsonObj.account)); + $detailsTab.find("#domain").text(fromdb(jsonObj.domain)); + setDateField(jsonObj.created, $detailsTab.find("#created")); + + //actions *** + var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu"); + $actionMenu.find("#action_list").empty(); + buildActionLinkForDetailsTab("Create Volume", snapshotActionMap, $actionMenu, snapshotListAPIMap); +} + +var snapshotActionMap = { + "Create Volume": { + isAsyncJob: true, + asyncJobResponse: "createvolumeresponse", + dialogBeforeActionFn : doCreateVolumeFromSnapshotInSnapshotPage, + inProcessText: "Creating Volume....", + afterActionSeccessFn: function(jsonObj) { + + } + } +} + +var snapshotListAPIMap = { + listAPI: "listSnapshots", + listAPIResponse: "listsnapshotsresponse", + listAPIResponseObj: "snapshot" +}; + +function doCreateVolumeFromSnapshotInSnapshotPage($actionLink, listAPIMap, $detailsTab) { + var jsonObj = $detailsTab.data("jsonObj"); + + $("#dialog_add_volume_from_snapshot") + .dialog("option", "buttons", { + "Add": function() { + var thisDialog = $(this); + + var isValid = true; + isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg")); + if (!isValid) return; + + thisDialog.dialog("close"); + + var name = thisDialog.find("#name").val(); + + var id = jsonObj.id; + var apiCommand = "command=createVolume&snapshotid="+id+"&name="+name; + doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap); + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); } \ No newline at end of file