From f1283f7bb1ca893c8d372e0a4eccebe8e352456c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 12 Jul 2012 14:28:47 -0700 Subject: [PATCH] cloudstack 3.0 UI - VPC - IP Addresses - Load Balancer - tier dropdown - if the IP is already associated with a tier, only populate that tier in the dropdown and hide the dropdown whose value will still be used later in listing VM dialog. --- ui/scripts/network.js | 61 ++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 51d49e72a11..56f78237540 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -851,29 +851,37 @@ }, add: { label: 'label.add.vms', - action: function(args) { - var openFirewall = false; + action: function(args) { var data = { algorithm: args.data.algorithm, name: args.data.name, privateport: args.data.privateport, - publicport: args.data.publicport + publicport: args.data.publicport, + openfirewall: false, + domainid: g_domainid, + account: g_account }; + + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + args.response.error('Tier is required'); + return; + } + $.extend(data, { + networkid: args.data.tier + }); + } + else { //from Guest Network section + $.extend(data, { + networkid: args.context.networks[0].id + }); + } + var stickyData = $.extend(true, {}, args.data.sticky); - - var apiCmd = "createLoadBalancerRule"; - //if(args.context.networks[0].type == "Shared") - apiCmd += "&domainid=" + g_domainid + "&account=" + g_account; - //else //args.context.networks[0].type == "Isolated" - //apiCmd += "&account=" + args.context.users[0].account; - //apiCmd += '&domainid=' + args.context.users[0].domainid; - + $.ajax({ - url: createURL(apiCmd), - data: $.extend(data, { - openfirewall: openFirewall, - networkid: args.context.networks[0].id - }), + url: createURL('createLoadBalancerRule'), + data: data, dataType: 'json', async: true, success: function(data) { @@ -2096,13 +2104,24 @@ tier: { label: 'Tier', select: function(args) { - if('vpc' in args.context) { + if('vpc' in args.context) { + var data = { + listAll: true + }; + if(args.context.ipAddresses[0].associatednetworkid == null) { + $.extend(data, { + vpcid: args.context.vpc[0].id + }); + } + else { + $.extend(data, { + id: args.context.ipAddresses[0].associatednetworkid + }); + } //??? + $.ajax({ url: createURL("listNetworks"), - data: { - vpcid: args.context.vpc[0].id, - listAll: true - }, + data: data, success: function(json) { var networks = json.listnetworksresponse.network; var items = [];