diff --git a/ui/new/jsp/tab_instance.jsp b/ui/new/jsp/tab_instance.jsp index 79afb8044fe..a5419a2c4a9 100755 --- a/ui/new/jsp/tab_instance.jsp +++ b/ui/new/jsp/tab_instance.jsp @@ -597,8 +597,8 @@
+ + + \ No newline at end of file diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index b17ecdbae68..3c620c7cb82 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -22,56 +22,57 @@ function clickInstanceGroupHeader($arrowIcon) { }; var actionMap = { - stopVirtualMachine: { - label: "Stop Instance", + "Stop Instance": { + api: "stopVirtualMachine", isAsyncJob: true, asyncJobResponse: "stopvirtualmachineresponse", afterActionSeccessFn: setMidmenuItemVm }, - startVirtualMachine: { - label: "Start Instance", + "Start Instance": { + api: "startVirtualMachine", isAsyncJob: true, asyncJobResponse: "startvirtualmachineresponse", afterActionSeccessFn: setMidmenuItemVm }, - rebootVirtualMachine: { - label: "Reboot Instance", + "Reboot Instance": { + api: "rebootVirtualMachine", isAsyncJob: true, asyncJobResponse: "rebootvirtualmachineresponse", afterActionSeccessFn: setMidmenuItemVm }, - destroyVirtualMachine: { - label: "Destroy Instance", + "Destroy Instance": { + api: "destroyVirtualMachine", isAsyncJob: true, asyncJobResponse: "destroyvirtualmachineresponse", afterActionSeccessFn: setMidmenuItemVm }, - recoverVirtualMachine: { - label: "Restore Instance", + "Restore Instance": { + api: "recoverVirtualMachine", isAsyncJob: false, afterActionSeccessFn: setMidmenuItemVm }, - attachIso: { - label: "Attach ISO", + "Attach ISO": { isAsyncJob: true, - asyncJobResponse: "attachisoresponse", - afterActionSeccessFn: setMidmenuItemVm, - dialogBeforeActionFn : doAttachISO + asyncJobResponse: "attachisoresponse", + dialogBeforeActionFn : doAttachISO, + afterActionSeccessFn: setMidmenuItemVm }, - detachIso: { - label: "Detach ISO", + "Detach ISO": { isAsyncJob: true, - asyncJobResponse: "detachisoresponse", - afterActionSeccessFn: setMidmenuItemVm, - dialogBeforeActionFn : doDetachISO - } - , - resetPasswordForVirtualMachine: { - label: "Reset Password", + asyncJobResponse: "detachisoresponse", + dialogBeforeActionFn : doDetachISO, + afterActionSeccessFn: setMidmenuItemVm + }, + "Reset Password": { isAsyncJob: true, - asyncJobResponse: "resetpasswordforvirtualmachineresponse", - afterActionSeccessFn: function(){}, - dialogBeforeActionFn : doResetPassword + asyncJobResponse: "resetpasswordforvirtualmachineresponse", + dialogBeforeActionFn : doResetPassword, + afterActionSeccessFn: function(){} + }, + "Change Name": { + isAsyncJob: false, + dialogBeforeActionFn : doChangeName, + afterActionSeccessFn: setMidmenuItemVm } } @@ -159,6 +160,33 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } + function doChangeName($t, selectedItemIds, listAPIMap) { + $("#dialog_change_name") + .dialog('option', 'buttons', { + "Confirm": function() { + var thisDialog = $(this); + thisDialog.dialog("close"); + + // validate values + var isValid = true; + isValid &= validateString("Name", thisDialog.find("#change_instance_name"), thisDialog.find("#change_instance_name_errormsg")); + if (!isValid) return; + + var name = trim(thisDialog.find("#change_instance_name").val()); + + for(var id in selectedItemIds) { + var apiCommand = "command=updateVirtualMachine&id="+id+"&displayName="+encodeURIComponent(escape(name)); + doAction(id, $t, apiCommand, listAPIMap); + } + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); + } + + + function updateVirtualMachineStateInRightPanel(state) { if(state == "Running") $rightPanelContent.find("#state").text(state).removeClass("red gray").addClass("green"); @@ -308,13 +336,13 @@ function clickInstanceGroupHeader($arrowIcon) { //action menu $("#action_link").show(); $actionList.empty(); - for(var api in actionMap) { - var apiInfo = actionMap[api]; + for(var label in actionMap) { + var apiInfo = actionMap[label]; var $listItem = $("#action_list_item").clone(); $actionList.append($listItem.show()); - var $link = $listItem.find("#link").text(apiInfo.label); - $link.data("api", api); - $link.data("label", apiInfo.label); + var $link = $listItem.find("#link").text(label); + $link.data("label", label); + $link.data("api", apiInfo.api); $link.data("isAsyncJob", apiInfo.isAsyncJob); $link.data("asyncJobResponse", apiInfo.asyncJobResponse); $link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn); @@ -355,6 +383,12 @@ function clickInstanceGroupHeader($arrowIcon) { zIndex: 2000 })); + activateDialog($("#dialog_change_name").dialog({ + autoOpen: false, + modal: true, + zIndex: 2000 + })); + //***** VM Wizard (begin) ****************************************************************************** $vmPopup = $("#vm_popup"); var $serviceOfferingTemplate = $("#vm_popup_service_offering_template"); diff --git a/ui/new/scripts/cloud.core.js b/ui/new/scripts/cloud.core.js index 7c0bcc02660..8702a733baa 100755 --- a/ui/new/scripts/cloud.core.js +++ b/ui/new/scripts/cloud.core.js @@ -21,8 +21,7 @@ // Version: @VERSION@ //var jobIdMap; -function doAction(id, $t, apiCommand, listAPIMap) { - var api = $t.data("api"); +function doAction(id, $t, apiCommand, listAPIMap) { var label = $t.data("label"); var isAsyncJob = $t.data("isAsyncJob"); var asyncJobResponse = $t.data("asyncJobResponse"); @@ -109,7 +108,7 @@ function doAction(id, $t, apiCommand, listAPIMap) { //Sync job (begin) ***** else { $.ajax({ - data: createURL("command="+api+"&id="+id), + data: createURL(apiCommand), dataType: "json", async: false, success: function(json) {