Updated Branches: refs/heads/master 5c6017e2e -> 404c7e0df
CLOUDSTACK-747: UI - Internal LB detailView - Assigned VMs tab - implement AssignVMs action. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/404c7e0d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/404c7e0d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/404c7e0d Branch: refs/heads/master Commit: 404c7e0dfddb61a49f0b051510b9eb43eca6d0ef Parents: 5c6017e Author: Jessica Wang <[email protected]> Authored: Wed Jun 5 14:06:41 2013 -0700 Committer: Jessica Wang <[email protected]> Committed: Wed Jun 5 14:06:59 2013 -0700 ---------------------------------------------------------------------- ui/scripts/vpc.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404c7e0d/ui/scripts/vpc.js ---------------------------------------------------------------------- diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js index 9d7b058..18fb5c1 100644 --- a/ui/scripts/vpc.js +++ b/ui/scripts/vpc.js @@ -625,6 +625,71 @@ }); }, actions: { + add: { + label: 'Assign VMs', + messages: { + notification: function(args) { return 'Assign VMs'; } + }, + listView: $.extend(true, {}, cloudStack.sections.instances.listView, { + type: 'checkbox', + filters: false, + dataProvider: function(args) { + $.ajax({ + url: createURL('listVirtualMachines'), + data: { + networkid: args.context.networks[0].id, + listAll: true + }, + success: function(json) { + var instances = json.listvirtualmachinesresponse.virtualmachine; + + // Pre-select existing instances in LB rule + $(instances).map(function(index, instance) { + instance._isSelected = $.grep( + args.context.internalLoadBalancers[0].loadbalancerinstance, + + function(lbInstance) { + return lbInstance.id == instance.id; + } + ).length ? true : false; + }); + + args.response.success({ + data: instances + }); + } + }); + } + }), + action: function(args) { + var vms = args.context.instances; + var array1 = []; + for(var i = 0; i < vms.length; i++) { + array1.push(vms[i].id); + } + var virtualmachineids = array1.join(','); + + $.ajax({ + url: createURL('assignToLoadBalancerRule'), + data: { + id: args.context.internalLoadBalancers[0].id, + virtualmachineids: virtualmachineids + }, + dataType: 'json', + async: true, + success: function(data) { + var jid = data.assigntoloadbalancerruleresponse.jobid; + args.response.success({ + _custom: { jobId: jid } + }); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + }, + remove: { label: 'remove VM from load balancer', addRow: 'false',
