From 641c7e617f7eaef620ce21cd1647cc9f6f14a593 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 25 Oct 2010 11:46:28 -0700 Subject: [PATCH] new UI - instance page - implement multiple-selection Reboot VM action. --- ui/new/scripts/cloud.core2.instance.js | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index 509e3a2456d..9ec283338c3 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -141,6 +141,45 @@ function afterLoadInstanceJSP() { return false; }); + //Reboot VM button + $("#midmenu_rebootvm_link").show(); + $("#midmenu_rebootvm_link").bind("click", function(event) { + var itemCounts = 0; + for(var id in selectedItemsInMidMenu) { + itemCounts ++; + } + if(itemCounts == 0) { + $("#dialog_info_please_select_one_item_in_middle_menu").dialog("open"); + return false; + } + + for(var id in selectedItemsInMidMenu) { + var apiCommand = "command=rebootVirtualMachine&id="+id; + var apiInfo = { + label: "Reboot Instance", + isAsyncJob: true, + asyncJobResponse: "rebootvirtualmachineresponse", + afterActionSeccessFn: function(json, $midmenuItem1, id) { + //call listVirtualMachine to get embedded object until Bug 6751("rebootVirtualMachine API should return an embedded object") is fixed. + var jsonObj; + $.ajax({ + data: createURL("command=listVirtualMachines&id="+id), + dataType: "json", + async: false, + success: function(json) { + jsonObj = json.listvirtualmachinesresponse.virtualmachine[0]; + } + }); + vmToMidmenu(jsonObj, $midmenuItem1); + } + } + doActionForMidMenu(id, apiInfo, apiCommand); + } + + selectedItemsInMidMenu = {}; //clear selected items for action + return false; + }); + // switch between different tabs var tabArray = [$("#tab_details"), $("#tab_volume"), $("#tab_statistics"), $("#tab_router")]; var tabContentArray = [$("#tab_content_details"), $("#tab_content_volume"), $("#tab_content_statistics"), $("#tab_content_router")];