From 5ec9cf30812ad1b1294f7ea5f321c4aff2f05f89 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 6 Aug 2012 15:38:28 -0700 Subject: [PATCH] cloudstack 3.0 UI - infrastructure - zone detail - network service providers - VPC Virtual Router - Instances tab - detailView - add ChangeService action. --- ui/scripts/system.js | 68 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index c12aa1023f5..3eb6ab46475 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -2540,7 +2540,64 @@ poll: pollAsyncJobResult } }, - + + changeService: { + label: 'label.change.service.offering', + createForm: { + title: 'label.change.service.offering', + desc: '', + fields: { + serviceOfferingId: { + label: 'label.compute.offering', + select: function(args) { + $.ajax({ + url: createURL('listServiceOfferings'), + data: { + issystem: true, + systemvmtype: 'domainrouter' + }, + success: function(json) { + var serviceofferings = json.listserviceofferingsresponse.serviceoffering; + var items = []; + $(serviceofferings).each(function() { + if(this.id != args.context.routers[0].serviceofferingid) { + items.push({id: this.id, description: this.name}); //default one (i.e. "System Offering For Software Router") doesn't have displaytext property. So, got to use name property instead. + } + }); + args.response.success({data: items}); + } + }); + } + } + } + }, + messages: { + notification: function(args) { + return 'label.change.service.offering'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("changeServiceForRouter&id=" + args.context.routers[0].id + "&serviceofferingid=" + args.data.serviceOfferingId), + dataType: "json", + async: true, + success: function(json) { + var jsonObj = json.changeserviceforrouterresponse.domainrouter; + 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.destroy.router', messages: { @@ -9512,7 +9569,10 @@ if (jsonObj.state == 'Running') { allowedActions.push("stop"); allowedActions.push("restart"); - //allowedActions.push("changeService"); + + if(jsonObj.vpcid != null) + allowedActions.push("changeService"); + allowedActions.push("viewConsole"); if (isAdmin()) allowedActions.push("migrate"); @@ -9520,7 +9580,9 @@ else if (jsonObj.state == 'Stopped') { allowedActions.push("start"); allowedActions.push("remove"); - //allowedActions.push("changeService"); + + if(jsonObj.vpcid != null) + allowedActions.push("changeService"); } return allowedActions; }