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:
Jake Yip 2021-03-02 11:06:58 +11:00 committed by Jake Yip
parent c9555d0e2a
commit 335fb71a58
2 changed files with 8 additions and 6 deletions

View File

@ -75,11 +75,13 @@
// set data for clusters chart
var sum = dataClusters[0].value;
var max = dataClusters[1].value;
if (response.data.hard_limit) {
max = response.data.hard_limit;
dataClusters[1].value = max - sum;
}
max = response.data.hard_limit;
dataClusters[1].value = max - sum;
var percent = Math.round(sum / max * 100);
// shows 100% used if max = 0
if (max === 0) {
percent = 100;
}
var overMax = percent > 100;
ctrl.chartDataClusters = {
title: gettext("Clusters"),

View File

@ -61,9 +61,9 @@
expect(magnum.getQuota).toHaveBeenCalled();
});
it('should load stats and default quotas', function() {
it('should load stats and zero quota', function() {
deferredQuota = $q.defer();
deferredQuota.resolve({data: {hard_limit: null}});
deferredQuota.resolve({data: {hard_limit: 0}});
spyOn(magnum, 'getQuota').and.returnValue(deferredQuota.promise);
$scope.$apply();