Skip to content

Commit 9c7abbc

Browse files
committed
Admin dashboard update
Use new API call to list capacities, ordered by usage and limited to the top 5 capacites. --Note that, due to API limitations, the UI cannot display what particular pod/cluster the capacity belongs to anymore, as that information is not returned in the response. This can be added again if relevant API changes are made.
1 parent 81e878e commit 9c7abbc

1 file changed

Lines changed: 9 additions & 61 deletions

File tree

ui/scripts/dashboard.js

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -223,73 +223,21 @@
223223

224224
zoneCapacity: function(data) {
225225
$.ajax({
226-
url: createURL('listZones'),
226+
url: createURL('listCapacity'),
227227
data: {
228-
showCapacities: true
228+
sortBy: 'usage',
229+
page: 1,
230+
pageSize: 5
229231
},
230232
success: function(json) {
231-
var zones = json.listzonesresponse.zone ?
232-
json.listzonesresponse.zone : [];
233-
234-
var zoneCapacities = [];
235-
236-
$(zones).each(function() {
237-
var zone = this;
238-
var clusters;
239-
240-
// Get cluster-level data
241-
$.ajax({
242-
url: createURL('listClusters'),
243-
data: {
244-
zoneId: zone.id,
245-
showCapacities: true
246-
},
247-
async: false,
248-
success: function(json) {
249-
var cluster = json.listclustersresponse.cluster;
250-
251-
// Get cluster-level data
252-
$(cluster).each(function() {
253-
var cluster = this;
254-
255-
$(cluster.capacity).each(function() {
256-
var capacity = this;
257-
258-
zoneCapacities.push($.extend(capacity, {
259-
zoneName: zone.name +
260-
'<br/>Pod: ' + cluster.podname +
261-
'<br/>Cluster: ' + cluster.name
262-
}));
263-
});
264-
});
265-
266-
// Get zone-level data
267-
$(zone.capacity).each(function() {
268-
var capacity = this;
269-
var existingCapacityTypes = $.map(zoneCapacities, function(capacity) {
270-
return capacity.type;
271-
});
272-
var isExistingCapacity = $.inArray(capacity.type, existingCapacityTypes) > -1;
273-
274-
if (!isExistingCapacity) {
275-
zoneCapacities.push($.extend(capacity, {
276-
zoneName: zone.name
277-
}));
278-
}
279-
});
280-
}
281-
});
282-
});
283-
284-
var sortFn = function(a, b) {
285-
return parseInt(a.percentused) < parseInt(b.percentused);
286-
};
233+
var capacities = json.listcapacityresponse.capacity ?
234+
json.listcapacityresponse.capacity : [];
287235

288236
complete($.extend(data, {
289-
zoneCapacities: $.map(zoneCapacities.sort(sortFn), function(capacity) {
237+
zoneCapacities: $.map(capacities, function(capacity) {
290238
return {
291-
zoneID: zones[0].id, // Temporary fix for dashboard
292-
zoneName: capacity.zoneName,
239+
zoneID: capacity.zoneid, // Temporary fix for dashboard
240+
zoneName: capacity.zonename,
293241
type: cloudStack.converters.toAlertType(capacity.type),
294242
percent: parseInt(capacity.percentused),
295243
used: cloudStack.converters.convertByType(capacity.type, capacity.capacityused),

0 commit comments

Comments
 (0)