Update VPC tier dashboard - Remove 'Port forwarders' -- Getting IPs by PF is not supported by API
- Split Public + Internal LB into separate items - Use API response 'count' for count number, instead of array '.length' to fix issues with larger results Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0eb73e9d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0eb73e9d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0eb73e9d Branch: refs/heads/master Commit: 0eb73e9dec3ac47bbce4349430598c7b8d640c59 Parents: ea440f2 Author: Brian Federle <brian.fede...@citrix.com> Authored: Wed May 22 16:28:09 2013 -0700 Committer: Brian Federle <brian.fede...@citrix.com> Committed: Wed May 22 16:28:09 2013 -0700 ---------------------------------------------------------------------- ui/modules/vpc/vpc.js | 4 +- ui/scripts/vpc.js | 240 +++++++++++++++++++++++--------------------- 2 files changed, 126 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb73e9d/ui/modules/vpc/vpc.js ---------------------------------------------------------------------- diff --git a/ui/modules/vpc/vpc.js b/ui/modules/vpc/vpc.js index cc0273f..e313b8a 100644 --- a/ui/modules/vpc/vpc.js +++ b/ui/modules/vpc/vpc.js @@ -168,7 +168,7 @@ $total.find('span').html(dashboardItem.totalMultiLine); $total.addClass('multiline'); } else { - $total.find('span').html(dashboardItem.total); + $total.find('span').html(dashboardItem.total ? dashboardItem.total : 0); } $dashboardItem.append($total, $name); @@ -183,7 +183,7 @@ var $section = $('<div>'); if ($.isFunction(section)) { - section = cloudStack.vpc.sections[id]() + section = cloudStack.vpc.sections[id](); } if (section.listView) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb73e9d/ui/scripts/vpc.js ---------------------------------------------------------------------- diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js index d27e1fc..2445adc 100644 --- a/ui/scripts/vpc.js +++ b/ui/scripts/vpc.js @@ -341,7 +341,7 @@ }, tierStaticNATs: function() { - return cloudStack.vpc.ipAddresses.listView(); + return cloudStack.vpc.staticNatIpAddresses.listView(); }, // Internal load balancers @@ -1185,7 +1185,7 @@ ipAddresses: { listView: function() { var listView = $.extend(true, {}, cloudStack.sections.network.sections.ipAddresses); - + listView.listView.fields = { ipaddress: listView.listView.fields.ipaddress, zonename: listView.listView.fields.zonename, @@ -1196,6 +1196,35 @@ return listView; } }, + staticNatIpAddresses: { + listView: function() { + var listView = $.extend(true, {}, cloudStack.sections.network.sections.ipAddresses); + + listView.listView.fields = { + ipaddress: listView.listView.fields.ipaddress, + zonename: listView.listView.fields.zonename, + associatednetworkname: { label: 'label.network.name' }, + state: listView.listView.fields.state + }; + + listView.listView.dataProvider = function(args) { + $.ajax({ + url: createURL('listPublicIpAddresses'), + data: { networkid: args.context.networks[0].id, isstaticnat: true }, + success: function(json) { + args.response.success({ + data: json.listpublicipaddressesresponse.publicipaddress + }); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + }; + + return listView; + } + }, acl: { multiEdit: aclMultiEdit, @@ -3171,29 +3200,16 @@ async: true, success: function(json) { var networks = json.listnetworksresponse.network; - var loadBalancers, networkACLLists, publicIpAddresses, privateGateways, vpnGateways, portForwardingRules; + var networkACLLists, publicIpAddresses, privateGateways, vpnGateways; var error = false; - // Get load balancers - $.ajax({ - url: createURL('listLoadBalancers'), - data: { vpcid: args.context.vpc[0].id }, - success: function(json) { - loadBalancers = json.listloadbalancerssresponse.loadbalancer ? - json.listloadbalancerssresponse.loadbalancer : []; - }, - error: function(json) { - error = true; - } - }); - // Get network ACL lists $.ajax({ url: createURL('listNetworkACLLists'), data: { 'vpc_id': args.context.vpc[0].id }, + async: false, success: function(json) { - networkACLLists = json.listnetworkacllistsresponse.networkacllist ? - json.listnetworkacllistsresponse.networkacllist : []; + networkACLLists = json.listnetworkacllistsresponse; }, error: function(json) { error = true; @@ -3203,23 +3219,10 @@ // Get public IPs $.ajax({ url: createURL('listPublicIpAddresses'), + async: false, data: { 'vpcid': args.context.vpc[0].id }, success: function(json) { - publicIpAddresses = json.listpublicipaddressesresponse.publicipaddress ? - json.listpublicipaddressesresponse.publicipaddress : []; - }, - error: function(json) { - error = true; - } - }); - - // Get port forwarding rules - $.ajax({ - url: createURL('listPortForwardingRules'), - data: { 'vpcid': args.context.vpc[0].id }, - success: function(json) { - portForwardingRules = json.listportforwardingrulesresponse.portforwardingrule ? - json.listportforwardingrulesresponse.portforwardingrule : []; + publicIpAddresses = json.listpublicipaddressesresponse; }, error: function(json) { error = true; @@ -3229,10 +3232,10 @@ // Get private gateways $.ajax({ url: createURL('listPrivateGateways'), + async: false, data: { 'vpcid': args.context.vpc[0].id }, success: function(json) { - privateGateways = json.listprivategatewaysresponse.privategateway ? - json.listprivategatewaysresponse.privategateway : []; + privateGateways = json.listprivategatewaysresponse; }, error: function(json) { error = true; @@ -3242,106 +3245,111 @@ // Get VPN gateways $.ajax({ url: createURL('listVpnGateways'), + async: false, data: { 'vpcid': args.context.vpc[0].id }, success: function(json) { - vpnGateways = json.listvpngatewaysresponse.vpngateway ? - json.listvpngatewaysresponse.vpngateway : []; + vpnGateways = json.listvpngatewaysresponse; }, error: function(json) { error = true; } }); - var dataTimer = setInterval(function() { - var complete = loadBalancers && networkACLLists && publicIpAddresses && privateGateways && vpnGateways; - - if (complete) { - clearInterval(dataTimer); + args.response.success({ + routerDashboard: [ + { + id: 'privateGateways', + name: 'Private gateways', + total: privateGateways.count + }, + { + id: 'publicIPs', + name: 'Public IP addresses', + total: publicIpAddresses.count + }, + { + id: 'siteToSiteVPNs', + name: 'Site-to-site VPNs', + total: vpnGateways.count + }, + { + id: 'networkACLLists', + name: 'Network ACL lists', + total: networkACLLists.count + } + ], + tiers: $(networks).map(function(index, tier) { + var internalLoadBalancers, publicLoadBalancers, virtualMachines, staticNatIps; - if(networks != null && networks.length > 0) { - for(var i = 0; i < networks.length; i++) { - $.ajax({ - url: createURL("listVirtualMachines"), - dataType: "json", - data: { - networkid: networks[i].id, - listAll: true - }, - async: false, - success: function(json) { - networks[i].virtualMachines = json.listvirtualmachinesresponse.virtualmachine; - } - }); + // Get internal load balancers + $.ajax({ + url: createURL('listLoadBalancers'), + async: false, + data: { networkid: tier.id }, + success: function(json) { + internalLoadBalancers = json.listloadbalancerssresponse; + }, + error: function(json) { + error = true; } - } - args.response.success({ - routerDashboard: [ + }); + + // Get VMs + $.ajax({ + url: createURL('listVirtualMachines'), + async: false, + data: { networkid: tier.id }, + success: function(json) { + virtualMachines = json.listvirtualmachinesresponse; + }, + error: function(json) { + error = true; + } + }); + + // Get static NAT IPs + $.ajax({ + url: createURL('listPublicIpAddresses'), + async: false, + data: { networkid: tier.id, isstaticnat: true }, + success: function(json) { + staticNatIps = json.listpublicipaddressesresponse; + }, + error: function(json) { + error = true; + } + }); + + return $.extend(tier, { + _dashboardItems: [ { - id: 'privateGateways', - name: 'Private gateways', - total: privateGateways.length + id: 'tierLoadBalancers', + name: 'Internal LB', + total: internalLoadBalancers.count }, { - id: 'publicIPs', - name: 'Public IP addresses', - total: publicIpAddresses.length + id: 'tierLoadBalancers', + name: 'Public LB', + total: 0 }, { - id: 'siteToSiteVPNs', - name: 'Site-to-site VPNs', - total: vpnGateways.length + id: 'tierStaticNATs', + name: 'Static NATs', + total: staticNatIps.count }, { - id: 'networkACLLists', - name: 'Network ACL lists', - total: networkACLLists.length + id: 'tierVMs', + name: 'Virtual Machines', + total: virtualMachines.count } - ], - tiers: $(networks).map(function(index, tier) { - var internalLoadBalancers = $.grep(loadBalancers, function(lb) { - return lb.networkid == tier.id; - }); - - return $.extend(tier, { - _dashboardItems: [ - { - id: 'tierLoadBalancers', - name: 'Load balancers', - totalMultiLine: internalLoadBalancers.length + ' Internal<br/>0 Public' - }, - { - id: 'tierPortForwarders', - name: 'Port forwarders', - total: $.grep(publicIpAddresses, function(ip) { - return $.grep( - portForwardingRules, - function(pf) { - return pf.ipaddressid == ip.id; - } - ).length ? true : false; - }).length - }, - { - id: 'tierStaticNATs', - name: 'Static NATs', - total: $.grep(publicIpAddresses, function(ip) { - return ip.associatednetworkid == tier.id && ip.isstaticnat; - }).length - }, - { - id: 'tierVMs', - name: 'Virtual Machines', - total: $.isArray(tier.virtualMachines) ? tier.virtualMachines.length : 0 - } - ] - }); - }) + ] }); - } else if (error) { - clearInterval(dataTimer); - cloudStack.dialog.notice({ message: 'Error loading dashboard data.' }); - } - }, 500); + }) + }); + + if (error) { + cloudStack.dialog.notice({ message: 'Error loading dashboard data.' }); + } } }); }