From 97d9862de7fb89f95dd5809e6758d858526cd01a Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 6 Apr 2012 15:47:04 -0700 Subject: [PATCH] bug 14539: cloudstack 3.0 UI - system VM page - add "change service offering" action which shows when systemVM state is Stopped. --- ui/scripts/system.js | 65 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 74c4fb141cd..9a95c284970 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -3698,7 +3698,67 @@ poll: pollAsyncJobResult } }, - + + changeService: { + label: 'label.change.service.offering', + createForm: { + title: 'label.change.service.offering', + desc: '', + fields: { + serviceOfferingId: { + label: 'label.compute.offering', + select: function(args) { + var apiCmd = "listServiceOfferings&issystem=true"; + if(args.context.systemVMs[0].systemvmtype == "secondarystoragevm") + apiCmd += "&systemvmtype=secondarystoragevm"; + else if(args.context.systemVMs[0].systemvmtype == "consoleproxy") + apiCmd += "&systemvmtype=consoleproxy"; + $.ajax({ + url: createURL(apiCmd), + dataType: "json", + async: true, + success: function(json) { + var serviceofferings = json.listserviceofferingsresponse.serviceoffering; + var items = []; + $(serviceofferings).each(function() { + if(this.id != args.context.systemVMs[0].serviceofferingid) { + items.push({id: this.id, description: this.displaytext}); + } + }); + args.response.success({data: items}); + } + }); + } + } + } + }, + messages: { + notification: function(args) { + return 'label.change.service.offering'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("changeServiceForSystemVm&id=" + args.context.systemVMs[0].id + "&serviceofferingid=" + args.data.serviceOfferingId), + dataType: "json", + async: true, + success: function(json) { + var jsonObj = json.changeserviceforsystemvmresponse.systemvm; + args.response.success({data: jsonObj}); + }, + error: function(XMLHttpResponse) { + var errorMsg = parseXMLHttpResponse(XMLHttpResponse); + args.response.error(errorMsg); + } + }); + }, + notification: { + poll: function(args) { + args.complete(); + } + } + }, + remove: { label: 'label.action.destroy.systemvm', messages: { @@ -7448,13 +7508,14 @@ if (jsonObj.state == 'Running') { allowedActions.push("stop"); allowedActions.push("restart"); - allowedActions.push("remove"); + allowedActions.push("remove"); allowedActions.push("viewConsole"); if (isAdmin()) allowedActions.push("migrate"); } else if (jsonObj.state == 'Stopped') { allowedActions.push("start"); + allowedActions.push("changeService"); allowedActions.push("remove"); } else if (jsonObj.state == 'Error') {