Remove hard_limit check in dashboard
This erroneously displays a quota of 20 if quota is 0. Since Change I1b278d221d0f15d92d67869cd3ac897d041eaf90, API always returns a quota, so this check is no longer necessary. Also fixed to show 100% if quota = 0; without this dashboard will show NaN% when 0/0 . Change-Id: Id59e63639667e2ec5fa01b57ef4a7ff5cd0db37d
This commit is contained in:
parent
c9555d0e2a
commit
335fb71a58
@ -75,11 +75,13 @@
|
|||||||
// set data for clusters chart
|
// set data for clusters chart
|
||||||
var sum = dataClusters[0].value;
|
var sum = dataClusters[0].value;
|
||||||
var max = dataClusters[1].value;
|
var max = dataClusters[1].value;
|
||||||
if (response.data.hard_limit) {
|
|
||||||
max = response.data.hard_limit;
|
max = response.data.hard_limit;
|
||||||
dataClusters[1].value = max - sum;
|
dataClusters[1].value = max - sum;
|
||||||
}
|
|
||||||
var percent = Math.round(sum / max * 100);
|
var percent = Math.round(sum / max * 100);
|
||||||
|
// shows 100% used if max = 0
|
||||||
|
if (max === 0) {
|
||||||
|
percent = 100;
|
||||||
|
}
|
||||||
var overMax = percent > 100;
|
var overMax = percent > 100;
|
||||||
ctrl.chartDataClusters = {
|
ctrl.chartDataClusters = {
|
||||||
title: gettext("Clusters"),
|
title: gettext("Clusters"),
|
||||||
|
@ -61,9 +61,9 @@
|
|||||||
expect(magnum.getQuota).toHaveBeenCalled();
|
expect(magnum.getQuota).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load stats and default quotas', function() {
|
it('should load stats and zero quota', function() {
|
||||||
deferredQuota = $q.defer();
|
deferredQuota = $q.defer();
|
||||||
deferredQuota.resolve({data: {hard_limit: null}});
|
deferredQuota.resolve({data: {hard_limit: 0}});
|
||||||
spyOn(magnum, 'getQuota').and.returnValue(deferredQuota.promise);
|
spyOn(magnum, 'getQuota').and.returnValue(deferredQuota.promise);
|
||||||
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user