From e8fe7e782b563206065da10f98c0bfb85831894b Mon Sep 17 00:00:00 2001 From: "andy.lee" Date: Mon, 9 Dec 2024 14:12:40 +0800 Subject: [PATCH] fix: separate used/allocated units Signed-off-by: andy.lee (cherry picked from commit b5455bcb9aed4decb636239dd85e52611693bed6) --- .../formatters/HarvesterStorageUsed.vue | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/harvester/formatters/HarvesterStorageUsed.vue b/pkg/harvester/formatters/HarvesterStorageUsed.vue index e37f27c98b9..d41b20d10aa 100644 --- a/pkg/harvester/formatters/HarvesterStorageUsed.vue +++ b/pkg/harvester/formatters/HarvesterStorageUsed.vue @@ -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; @@ -92,7 +98,7 @@ 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; @@ -100,9 +106,9 @@ export default { usedAmountTemplateValues() { return { - used: this.used, + used: this.formatUsed, total: this.formatter(this.storageStats.maximum), - unit: this.units, + unit: this.usedUnits, }; }, @@ -110,7 +116,7 @@ export default { return { used: this.formatAllocated, total: this.formatter(this.storageStats.total), - unit: this.units, + unit: this.allocatedUnits, }; }, }, @@ -141,7 +147,7 @@ export default { @@ -161,7 +167,7 @@ export default {