Updated Branches: refs/heads/ui-vpc-redesign 8d9a8ca15 -> b5acb9034
CLOUDSTACK-747: UI - Internal LB - implement Add Internal LB action. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b5acb903 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b5acb903 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b5acb903 Branch: refs/heads/ui-vpc-redesign Commit: b5acb9034f2463c891fa424cd9deaae17501eebc Parents: 8d9a8ca Author: Jessica Wang <[email protected]> Authored: Thu May 16 11:34:38 2013 -0700 Committer: Jessica Wang <[email protected]> Committed: Thu May 16 11:37:16 2013 -0700 ---------------------------------------------------------------------- ui/scripts/vpc.js | 66 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 54 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b5acb903/ui/scripts/vpc.js ---------------------------------------------------------------------- diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js index 8e39314..7a1c50c 100644 --- a/ui/scripts/vpc.js +++ b/ui/scripts/vpc.js @@ -323,7 +323,7 @@ // Internal load balancers tierLoadBalancers: { listView: { - id: 'ipAddresses', + id: 'internalLb', fields: { ipaddress: { label: 'label.ip.address' }, type: { label: 'label.type' } @@ -339,30 +339,72 @@ }, actions: { add: { - label: 'Add new LB', + label: 'Add Internal LB', createForm: { - title: 'Add new LB', - desc: 'Please specify the type of load balancer you would like to create.', - fields: { - type: { - label: 'label.type', + title: 'Add Internal LB', + fields: { + name: { label: 'label.name', validation: { required: true } }, + description: { label: 'label.description', validation: { required: false } }, + sourceipaddress: { label: 'Source IP Address', validation: { required: false } }, + sourceport: { label: 'sourceport', validation: { required: true } }, + instanceport: { label: 'instanceport', validation: { required: true } }, + algorithm: { + label: 'label.algorithm', + validation: { required: true }, select: function(args) { args.response.success({ data: [ - { id: 'internal', description: 'Internal' }, - { id: 'public', description: 'Public' } + { id: 'source', description: 'source' }, + { id: 'roundrobin', description: 'roundrobin' }, + { id: 'leastconn', description: 'leastconn' } ] }); } - } + } } }, messages: { notification: function(args) { - return 'Add LB to VPC network'; + return 'Add Internal LB'; } }, - action: function(args) { + action: function(args) { + var data = { + name: args.data.name, + sourceport: args.data.sourceport, + instanceport: args.data.instanceport, + algorithm: args.data.algorithm, + networkid: args.context.networks[0].id, + sourceipaddressnetworkid: args.context.networks[0].id, + scheme: 'Internal' + }; + if(args.data.description != null && args.data.description.length > 0){ + $.extend(data, { + description: args.data.description + }); + } + if(args.data.sourceipaddress != null && args.data.sourceipaddress.length > 0){ + $.extend(data, { + sourceipaddress: args.data.sourceipaddress + }); + } + $.ajax({ + url: createURL('createLoadBalancer'), + data: data, + success: function(json){ + var jid = json.createloadbalancerresponse.jobid; + args.response.success( + {_custom: + {jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.loadbalancerrule; + } + } + } + ); + } + }); + args.response.success(); }, notification: {
