diff --git a/ui/new/scripts/cloud.core.init.js b/ui/new/scripts/cloud.core.init.js index 902a7acfe79..b25fcd2c601 100755 --- a/ui/new/scripts/cloud.core.init.js +++ b/ui/new/scripts/cloud.core.init.js @@ -20,7 +20,7 @@ $(document).ready(function() { var $t = $("#"+ui.selecting.id); if($t.find("#content").hasClass("inaction") == false) { //only items not in action are allowed to be selected var id =$t.data("id"); - selectedItemIds[id] = null; + selectedItemIds[id] = $t; $t.find("#content").addClass("selected"); } var toRightPanelFn = $t.data("toRightPanelFn"); diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index c1ac1dc173f..b17ecdbae68 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -64,7 +64,15 @@ function clickInstanceGroupHeader($arrowIcon) { asyncJobResponse: "detachisoresponse", afterActionSeccessFn: setMidmenuItemVm, dialogBeforeActionFn : doDetachISO - } + } + , + resetPasswordForVirtualMachine: { + label: "Reset Password", + isAsyncJob: true, + asyncJobResponse: "resetpasswordforvirtualmachineresponse", + afterActionSeccessFn: function(){}, + dialogBeforeActionFn : doResetPassword + } } function doAttachISO($t, selectedItemIds, listAPIMap) { @@ -122,6 +130,35 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } + function doResetPassword($t, selectedItemIds, listAPIMap) { + $("#dialog_confirmation") + .html("

Please confirm you want to change the ROOT password for your virtual machine(s)

") + .dialog('option', 'buttons', { + "Confirm": function() { + $(this).dialog("close"); + for(var id in selectedItemIds) { + var $midMenuItem = selectedItemIds[id]; + var jsonObj = $midMenuItem.data("jsonObj"); + if(jsonObj.state != "Stopped") { + $midMenuItem.find("#info_icon").addClass("error").show(); + $midMenuItem.data("afterActionInfo", ($t.data("label") + " action failed. Reason: This instance needs to be stopped before you can reset password")); + continue; + } + if(jsonObj.passwordEnabled != "true") { + $midMenuItem.find("#info_icon").addClass("error").show(); + $midMenuItem.data("afterActionInfo", ($t.data("label") + " action failed. Reason: This instance is not using a template that has the password reset feature enabled. If you have forgotten your root password, please contact support.")); + continue; + } + var apiCommand = "command=resetPasswordForVirtualMachine&id="+id; + 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");