You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2014/08/27 23:21:06 UTC
git commit: updated refs/heads/master to 21ff99b
Repository: cloudstack
Updated Branches:
refs/heads/master 718fd5f39 -> 21ff99b0a
CLOUDSTACK-7450: UI - dashboard - pass &pageSize=1&page=1 to listXXX API calls that are for getting total number of items.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/21ff99b0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/21ff99b0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/21ff99b0
Branch: refs/heads/master
Commit: 21ff99b0aedf3f8d369ad94b98d7c116fa6cdf7d
Parents: 718fd5f
Author: Jessica Wang <je...@apache.org>
Authored: Wed Aug 27 14:20:41 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Wed Aug 27 14:20:51 2014 -0700
----------------------------------------------------------------------
ui/scripts/dashboard.js | 84 +++++++++++++++++++++++++++++++++-----------
1 file changed, 63 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21ff99b0/ui/scripts/dashboard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js
index 249e769..15e5e52 100644
--- a/ui/scripts/dashboard.js
+++ b/ui/scripts/dashboard.js
@@ -28,27 +28,62 @@
user: {
dataProvider: function(args) {
var dataFns = {
- instances: function(data) {
- $.ajax({
- url: createURL('listVirtualMachines'),
+ instances: function(data) {
+ var totalInstanceCount = 0;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
data: {
- listAll: true
+ listAll: true,
+ page: 1,
+ pageSize: 1
},
- success: function(json) {
- var instances = json.listvirtualmachinesresponse.virtualmachine ?
- json.listvirtualmachinesresponse.virtualmachine : [];
-
- dataFns.account($.extend(data, {
- runningInstances: $.grep(instances, function(instance) {
- return instance.state == 'Running';
- }).length,
- stoppedInstances: $.grep(instances, function(instance) {
- return instance.state == 'Stopped';
- }).length,
- totalInstances: instances.length
- }));
+ async: false,
+ success: function(json) {
+ if (json.listvirtualmachinesresponse.count != undefined) {
+ totalInstanceCount = json.listvirtualmachinesresponse.count;
+ }
}
});
+
+ var RunningInstanceCount = 0;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
+ data: {
+ listAll: true,
+ page: 1,
+ pageSize: 1,
+ state: "Running"
+ },
+ async: false,
+ success: function(json) {
+ if (json.listvirtualmachinesresponse.count != undefined) {
+ RunningInstanceCount = json.listvirtualmachinesresponse.count;
+ }
+ }
+ });
+
+ var stoppedInstanceCount = 0;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
+ data: {
+ listAll: true,
+ page: 1,
+ pageSize: 1,
+ state: "Stopped"
+ },
+ async: false,
+ success: function(json) {
+ if (json.listvirtualmachinesresponse.count != undefined) {
+ stoppedInstanceCount = json.listvirtualmachinesresponse.count;
+ }
+ }
+ });
+
+ dataFns.account($.extend(data, {
+ runningInstances: RunningInstanceCount,
+ stoppedInstances: stoppedInstanceCount,
+ totalInstances: totalInstanceCount
+ }));
},
account: function(data) {
@@ -68,7 +103,8 @@
data: {
listAll: true,
page: 1,
- pageSize: 4
+ pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited)
+ //pageSize: 1 //for testing only
},
success: function(json) {
dataFns.ipAddresses($.extend(data, {
@@ -83,6 +119,8 @@
url: createURL('listNetworks'),
data: {
listAll: true,
+ page: 1,
+ pageSize: 1,
type: 'isolated',
supportedServices: 'SourceNat'
},
@@ -92,6 +130,10 @@
$.ajax({
url: createURL('listPublicIpAddresses'),
+ data: {
+ page: 1,
+ pageSize: 1
+ },
success: function(json) {
var ipTotal = json.listpublicipaddressesresponse.count ?
json.listpublicipaddressesresponse.count : 0;
@@ -163,7 +205,7 @@
url: createURL('listAlerts'),
data: {
page: 1,
- pageSize: 4
+ pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited)
},
success: function(json) {
var alerts = json.listalertsresponse.alert ?
@@ -188,7 +230,7 @@
data: {
state: 'Alert',
page: 1,
- pageSize: 4
+ pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited)
},
success: function(json) {
var hosts = json.listhostsresponse.host ?
@@ -213,7 +255,7 @@
fetchLatest: false,
sortBy: 'usage',
page: 0,
- pagesize: 8
+ pageSize: (pageSize > 8? 8: pageSize)
},
success: function(json) {
var capacities = json.listcapacityresponse.capacity ?