From ad811df23e1daaf39f95364f2fb91a57d014afed Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 20 Dec 2011 16:40:26 -0800 Subject: [PATCH] cloudstack 3.0 new UI - instance page - reset password - check whether the instance is password enabled and its state before popping up confirmation box. --- ui/scripts/instances.js | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index b74d00477fc..0a49fff2216 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -1081,29 +1081,8 @@ resetPassword: { label: 'Reset password', messages: { - confirm: function(args) { - /* - if (jsonObj.passwordenabled == false) { - $("#dialog_info") - .text(dictionary["message.action.reset.password.off"]) - .dialog('option', 'buttons', { - "OK": function() { - $(this).dialog("close"); - } - }).dialog("open"); - return; - } else if (jsonObj.state != 'Stopped') { - $("#dialog_info") - .text(dictionary["message.action.reset.password.warning"]) - .dialog('option', 'buttons', { - "OK": function() { - $(this).dialog("close"); - } - }).dialog("open"); - return; - } - */ - return 'Are you sure you want to reset password?'; + confirm: function(args) { + return 'Please confirm that you want to reset password.'; }, success: function(args) { return 'Password is being reset.'; @@ -1115,6 +1094,19 @@ return 'Password has been reset to ' + args.password; } }, + + preAction: function(args) { + var jsonObj = args.context.instances[0]; + if (jsonObj.passwordenabled == false) { + cloudStack.dialog.notice({ message: 'The template this instance was created with is not password enabled' }); + return false; + } + else if (jsonObj.state != 'Stopped') { + cloudStack.dialog.notice({ message: 'Your instance must be stopped before attempting to change its current password' }); + return false; + } + }, + action: function(args) { $.ajax({ url: createURL("resetPasswordForVirtualMachine&id=" + args.data.id),