|
28 | 28 | user: { |
29 | 29 | dataProvider: function(args) { |
30 | 30 | var dataFns = { |
31 | | - instances: function(data) { |
32 | | - $.ajax({ |
33 | | - url: createURL('listVirtualMachines'), |
| 31 | + instances: function(data) { |
| 32 | + var totalInstanceCount = 0; |
| 33 | + $.ajax({ |
| 34 | + url: createURL("listVirtualMachines"), |
34 | 35 | data: { |
35 | | - listAll: true |
| 36 | + listAll: true, |
| 37 | + page: 1, |
| 38 | + pageSize: 1 |
36 | 39 | }, |
37 | | - success: function(json) { |
38 | | - var instances = json.listvirtualmachinesresponse.virtualmachine ? |
39 | | - json.listvirtualmachinesresponse.virtualmachine : []; |
40 | | - |
41 | | - dataFns.account($.extend(data, { |
42 | | - runningInstances: $.grep(instances, function(instance) { |
43 | | - return instance.state == 'Running'; |
44 | | - }).length, |
45 | | - stoppedInstances: $.grep(instances, function(instance) { |
46 | | - return instance.state == 'Stopped'; |
47 | | - }).length, |
48 | | - totalInstances: instances.length |
49 | | - })); |
| 40 | + async: false, |
| 41 | + success: function(json) { |
| 42 | + if (json.listvirtualmachinesresponse.count != undefined) { |
| 43 | + totalInstanceCount = json.listvirtualmachinesresponse.count; |
| 44 | + } |
50 | 45 | } |
51 | 46 | }); |
| 47 | + |
| 48 | + var RunningInstanceCount = 0; |
| 49 | + $.ajax({ |
| 50 | + url: createURL("listVirtualMachines"), |
| 51 | + data: { |
| 52 | + listAll: true, |
| 53 | + page: 1, |
| 54 | + pageSize: 1, |
| 55 | + state: "Running" |
| 56 | + }, |
| 57 | + async: false, |
| 58 | + success: function(json) { |
| 59 | + if (json.listvirtualmachinesresponse.count != undefined) { |
| 60 | + RunningInstanceCount = json.listvirtualmachinesresponse.count; |
| 61 | + } |
| 62 | + } |
| 63 | + }); |
| 64 | + |
| 65 | + var stoppedInstanceCount = 0; |
| 66 | + $.ajax({ |
| 67 | + url: createURL("listVirtualMachines"), |
| 68 | + data: { |
| 69 | + listAll: true, |
| 70 | + page: 1, |
| 71 | + pageSize: 1, |
| 72 | + state: "Stopped" |
| 73 | + }, |
| 74 | + async: false, |
| 75 | + success: function(json) { |
| 76 | + if (json.listvirtualmachinesresponse.count != undefined) { |
| 77 | + stoppedInstanceCount = json.listvirtualmachinesresponse.count; |
| 78 | + } |
| 79 | + } |
| 80 | + }); |
| 81 | + |
| 82 | + dataFns.account($.extend(data, { |
| 83 | + runningInstances: RunningInstanceCount, |
| 84 | + stoppedInstances: stoppedInstanceCount, |
| 85 | + totalInstances: totalInstanceCount |
| 86 | + })); |
52 | 87 | }, |
53 | 88 |
|
54 | 89 | account: function(data) { |
|
68 | 103 | data: { |
69 | 104 | listAll: true, |
70 | 105 | page: 1, |
71 | | - pageSize: 4 |
| 106 | + pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited) |
| 107 | + //pageSize: 1 //for testing only |
72 | 108 | }, |
73 | 109 | success: function(json) { |
74 | 110 | dataFns.ipAddresses($.extend(data, { |
|
83 | 119 | url: createURL('listNetworks'), |
84 | 120 | data: { |
85 | 121 | listAll: true, |
| 122 | + page: 1, |
| 123 | + pageSize: 1, |
86 | 124 | type: 'isolated', |
87 | 125 | supportedServices: 'SourceNat' |
88 | 126 | }, |
|
92 | 130 |
|
93 | 131 | $.ajax({ |
94 | 132 | url: createURL('listPublicIpAddresses'), |
| 133 | + data: { |
| 134 | + page: 1, |
| 135 | + pageSize: 1 |
| 136 | + }, |
95 | 137 | success: function(json) { |
96 | 138 | var ipTotal = json.listpublicipaddressesresponse.count ? |
97 | 139 | json.listpublicipaddressesresponse.count : 0; |
|
163 | 205 | url: createURL('listAlerts'), |
164 | 206 | data: { |
165 | 207 | page: 1, |
166 | | - pageSize: 4 |
| 208 | + pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited) |
167 | 209 | }, |
168 | 210 | success: function(json) { |
169 | 211 | var alerts = json.listalertsresponse.alert ? |
|
188 | 230 | data: { |
189 | 231 | state: 'Alert', |
190 | 232 | page: 1, |
191 | | - pageSize: 4 |
| 233 | + pageSize: (pageSize > 4? 4: pageSize) //if default.page.size > 4, show 4 items only (since space on dashboard is limited) |
192 | 234 | }, |
193 | 235 | success: function(json) { |
194 | 236 | var hosts = json.listhostsresponse.host ? |
|
213 | 255 | fetchLatest: false, |
214 | 256 | sortBy: 'usage', |
215 | 257 | page: 0, |
216 | | - pagesize: 8 |
| 258 | + pageSize: (pageSize > 8? 8: pageSize) |
217 | 259 | }, |
218 | 260 | success: function(json) { |
219 | 261 | var capacities = json.listcapacityresponse.capacity ? |
|
0 commit comments