From 7de7b8687038f53d7587149523485343b52a2086 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Wed, 11 Jul 2012 16:19:47 -0700 Subject: [PATCH] Static NAT UI: Have tier dropdown filter VMs On VM select list view for static NAT, tier selection will filter the VM listing by tier (networkid). By default, VMs for all tiers are shown, until the drop-down is changed. --- ui/scripts/network.js | 58 ++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 28b06cc2404..abde8c1045d 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1252,41 +1252,53 @@ action: { noAdd: true, - custom: cloudStack.uiCustom.enableStaticNAT({ + custom: cloudStack.uiCustom.enableStaticNAT({ tierSelect: function(args) { - if ('vpc' in args.context) { //from VPC section + if ('vpc' in args.context) { //from VPC section args.$tierSelect.show(); //show tier dropdown - - $.ajax({ //populate tier dropdown - 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 }); - } - }); + + $.ajax({ //populate tier dropdown + url: createURL("listNetworks"), + async: false, + data: { + listAll: true + }, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = [{ id: -1, description: 'All' }]; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({ data: items }); + } + }); } - else { //from Guest Network section - args.$tierSelect.hide(); - } + else { //from Guest Network section + args.$tierSelect.hide(); + } + + args.$tierSelect.change(function() { + args.$tierSelect.closest('.list-view').listView('refresh'); + }); }, listView: $.extend(true, {}, cloudStack.sections.instances, { listView: { dataProvider: function(args) { + var $listView = args.$listView; var data = { page: args.page, pageSize: pageSize, listAll: true }; - + + // See if tier is selected + var $tierSelect = $listView.find('.tier-select select'); + + if ($tierSelect.size() && $tierSelect.val() != '-1') { + data.networkid = $tierSelect.val(); + } + if('vpc' in args.context) { $.extend(data, { vpcid: args.context.vpc[0].id @@ -1304,7 +1316,7 @@ domainid: args.context.ipAddresses[0].domainid }); } - + $.ajax({ url: createURL('listVirtualMachines'), data: data,