Updated Branches: refs/heads/4.2 3953cbe35 -> e03ea2702
CLOUDSTACK-3207: UI > domain page > get total number of instances, volumes by both listAccounts API and listProjects API. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e03ea270 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e03ea270 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e03ea270 Branch: refs/heads/4.2 Commit: e03ea2702fb38c379ad71995463d262778c41745 Parents: 3953cbe Author: Jessica Wang <[email protected]> Authored: Wed Jul 3 15:22:19 2013 -0700 Committer: Jessica Wang <[email protected]> Committed: Mon Jul 8 11:59:21 2013 -0700 ---------------------------------------------------------------------- ui/scripts/domains.js | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e03ea270/ui/scripts/domains.js ---------------------------------------------------------------------- diff --git a/ui/scripts/domains.js b/ui/scripts/domains.js index e82f8ff..01f4236 100644 --- a/ui/scripts/domains.js +++ b/ui/scripts/domains.js @@ -435,6 +435,9 @@ ], dataProvider: function(args) { var domainObj = args.context.domains[0]; + var totalVMs=0; + var totalVolumes=0; + $.ajax({ url: createURL("listAccounts&domainid=" + domainObj.id), async: false, @@ -443,26 +446,39 @@ }, success: function(json) { var items = json.listaccountsresponse.account; - var total; - if (items != null) - total = items.length; - else - total = 0; - domainObj["accountTotal"] = total; - var itemsAcc; - var totalVMs=0; - var totalVolumes=0; - for(var i=0;i<total;i++) { - itemsAcc = json.listaccountsresponse.account[i]; - totalVMs = totalVMs + itemsAcc.vmtotal; - totalVolumes = totalVolumes + itemsAcc.volumetotal; + if(items != null) { + domainObj["accountTotal"] = items.length; + for(var i = 0; i < items.length; i++) { + totalVMs += items[i].vmtotal; + totalVolumes += items[i].volumetotal; + } } - domainObj["vmTotal"] = totalVMs; - domainObj["volumeTotal"] = totalVolumes; - + else { + domainObj["accountTotal"] = 0; + } } }); + $.ajax({ + url: createURL("listProjects&domainid=" + domainObj.id), + async: false, + data: { + details: 'min' + }, + success: function(json) { + var items = json.listprojectsresponse.project; + if(items != null) { + for(var i = 0; i < items.length; i++) { + totalVMs += items[i].vmtotal; + totalVolumes += items[i].volumetotal; + } + } + } + }); + + domainObj["vmTotal"] = totalVMs; + domainObj["volumeTotal"] = totalVolumes; + /* $.ajax({ url: createURL("listVirtualMachines&details=min&domainid=" + domainObj.id), async: false,
