From b6ebbc93e7375977593e2abd16418a266ec8bbd3 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 9 Jul 2012 15:36:29 -0700 Subject: [PATCH] cloudstack 3.0 UI - VPC - IP addresses - implement acquire new IP dialog box with tier dropdown. --- ui/scripts/network.js | 88 +++++++++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7cfa3f97516..cd87c60a082 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -984,18 +984,75 @@ actions: { add: { label: 'label.acquire.new.ip', - addRow: 'true', - action: function(args) { - var apiCmd = "associateIpAddress"; - if(args.context.networks[0].type == "Shared" && !args.context.projects) - apiCmd += "&domainid=" + g_domainid + "&account=" + g_account; + addRow: 'true', + messages: { + notification: function(args) { + return 'label.acquire.new.ip'; + } + }, + createForm: { + title: 'label.acquire.new.ip', + desc: 'Please confirm that you want to acquire a new IP', + preFilter: function(args) { + if('vpc' in args.context) { + args.$form.find('.form-item[rel=networkid]').css('display', 'inline-block'); //shown + } + else { + args.$form.find('.form-item[rel=networkid]').hide(); //hidden + } + }, + fields: { + networkid: { + label: 'tier', + select: function(args) { + if('vpc' in args.context) { + $.ajax({ + url: createURL("listNetworks"), + data: { + vpcid: args.context.vpc[0].id, + listAll: true + }, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = []; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({data: items}); + } + }); + } + else { + args.response.success({data: []}); + } + } + } + } + }, + action: function(args) { + var dataObj = {}; + if('vpc' in args.context) { //from VPC section + $.extend(dataObj, { + vpcid: args.context.vpc[0].id, + networkid: args.data.networkid + }); + } + else if('networks' in args.context) { //from Guest Network section + $.extend(dataObj, { + networkid: args.context.networks[0].id + }); + + if(args.context.networks[0].type == "Shared" && !args.context.projects) { + $.extend(dataObj, { + domainid: g_domainid, + account: g_account + }); + } + } + $.ajax({ - url: createURL(apiCmd), - data: { - networkId: args.context.networks[0].id - }, - dataType: 'json', - async: true, + url: createURL('associateIpAddress'), + data: dataObj, success: function(data) { args.response.success({ _custom: { @@ -1019,15 +1076,6 @@ }); }, - messages: { - confirm: function(args) { - return 'message.acquire.new.ip'; - }, - notification: function(args) { - return 'label.acquire.new.ip'; - } - }, - notification: { poll: pollAsyncJobResult }