From ffdea8fd4b49e3a27cda3ed92c88d0dc3c623b57 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 28 Dec 2011 15:45:55 -0800 Subject: [PATCH] bug 11546: cloudstack 3.0 new UI - Stop Instance action - add "Force Stop" option. --- ui/scripts/instances.js | 79 +++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index ad65426a0c9..a7b4e5b1032 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -533,10 +533,23 @@ } }, stop: { - label: 'Stop instance', - action: function(args) { + label: 'Stop instance', + createForm: { + title: 'Stop instance', + desc: 'Please confirm that you want to stop this instance', + fields: { + forced: { + label: 'Force stop', + isBoolean: true, + isChecked: false + } + } + }, + action: function(args) { + var array1 = []; + array1.push("&forced=" + (args.data.forced == "on")); $.ajax({ - url: createURL("stopVirtualMachine&id=" + args.data.id), + url: createURL("stopVirtualMachine&id=" + args.context.instances[0].id + array1.join("")), dataType: "json", async: true, success: function(json) { @@ -570,8 +583,7 @@ return args.name + ' has been stopped.'; } }, - notification: { - //poll: testData.notifications.testPoll + notification: { poll: pollAsyncJobResult } }, @@ -793,28 +805,41 @@ }, stop: { label: 'Stop instance', - action: function(args) { - $.ajax({ - url: createURL("stopVirtualMachine&id=" + args.data.id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.stopvirtualmachineresponse.jobid; - args.response.success( - {_custom: - {jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.virtualmachine; - }, - getActionFilter: function() { - return vmActionfilter; - } - } - } - ); - } - }); - }, + createForm: { + title: 'Stop instance', + desc: 'Please confirm that you want to stop this instance', + fields: { + forced: { + label: 'Force stop', + isBoolean: true, + isChecked: false + } + } + }, + action: function(args) { + var array1 = []; + array1.push("&forced=" + (args.data.forced == "on")); + $.ajax({ + url: createURL("stopVirtualMachine&id=" + args.context.instances[0].id + array1.join("")), + dataType: "json", + async: true, + success: function(json) { + var jid = json.stopvirtualmachineresponse.jobid; + args.response.success( + {_custom: + {jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.virtualmachine; + }, + getActionFilter: function() { + return vmActionfilter; + } + } + } + ); + } + }); + }, messages: { confirm: function(args) { return 'Are you sure you want to stop ' + args.name + '?';