new UI - implement reset password for VM

This commit is contained in:
jessica 2010-08-27 19:08:05 -07:00 committed by unknown
parent 29451b8da7
commit 6f14b406ce
2 changed files with 39 additions and 2 deletions

View File

@ -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");

View File

@ -65,6 +65,14 @@ function clickInstanceGroupHeader($arrowIcon) {
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("<p>Please confirm you want to change the ROOT password for your virtual machine(s)</p>")
.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");