Skip to content

Commit

Permalink
fix: separate used/allocated units
Browse files Browse the repository at this point in the history
Signed-off-by: andy.lee <andy.lee@suse.com>
  • Loading branch information
a110605 committed Dec 11, 2024
1 parent a3cf2fa commit 329e05e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pkg/harvester/formatters/HarvesterStorageUsed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,23 @@ export default {
return stats;
},
units() {
allocatedUnits() {
const exponent = exponentNeeded(this.storageStats.total, 1024);
return `${ UNITS[exponent] }iB`;
},
usedUnits() {
const exponent = exponentNeeded(this.storageStats.maximum, 1024);
return `${ UNITS[exponent] }iB`;
},
used() {
formatUsed() {
let out = this.formatter(this.storageStats.used);
if (!Number.parseFloat(out) > 0) {
out = this.formatter(this.storageStats.used, { canRoundToZero: false });
out = this.formatter(this.storageStats.used, { canRoundToZero: true });
}
return out;
Expand All @@ -92,25 +98,25 @@ export default {
let out = this.formatter(this.storageStats.scheduled);
if (!Number.parseFloat(out) > 0) {
out = this.formatter(this.storageStats.scheduled, { canRoundToZero: false });
out = this.formatter(this.storageStats.scheduled, { canRoundToZero: true });
}
return out;
},
usedAmountTemplateValues() {
return {
used: this.used,
used: this.formatUsed,
total: this.formatter(this.storageStats.maximum),
unit: this.units,
unit: this.usedUnits,
};
},
allocatedAmountTemplateValues() {
return {
used: this.formatAllocated,
total: this.formatter(this.storageStats.total),
unit: this.units,
unit: this.allocatedUnits,
};
},
},
Expand Down Expand Up @@ -141,7 +147,7 @@ export default {
<ConsumptionGauge
:capacity="storageStats.total"
:used="storageStats.scheduled"
:units="units"
:units="allocatedUnits"
:number-formatter="formatter"
:resource-name="resourceName"
>
Expand All @@ -161,7 +167,7 @@ export default {
<ConsumptionGauge
:capacity="storageStats.maximum"
:used="storageStats.used"
:units="units"
:units="usedUnits"
:number-formatter="formatter"
:resource-name="showAllocated ? '' : resourceName"
:class="{
Expand Down

0 comments on commit 329e05e

Please sign in to comment.