Extract variables to utils/unit

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee
2025-03-03 16:57:25 +08:00
parent 8f76d5ad30
commit 8db4de1c4a
18 changed files with 57 additions and 34 deletions
@@ -2,7 +2,7 @@
import ConsumptionGauge from '@shell/components/ConsumptionGauge';
import { METRIC, NODE } from '@shell/config/types';
import { formatSi, exponentNeeded, UNITS, parseSi } from '@shell/utils/units';
import { UNIT_SUFFIX } from '../utils/unit';
export default {
name: 'HarvesterMemoryUsed',
components: { ConsumptionGauge },
@@ -51,7 +51,7 @@ export default {
memoryUnits() {
const exponent = exponentNeeded(this.memoryTotal, 1024);
return `${ UNITS[exponent] }i`;
return `${ UNITS[exponent] }${ UNIT_SUFFIX }`;
},
node() {
@@ -2,6 +2,7 @@
import ConsumptionGauge from '@shell/components/ConsumptionGauge';
import { LONGHORN } from '@shell/config/types';
import { formatSi, exponentNeeded, UNITS } from '@shell/utils/units';
import { UNIT_SUFFIX } from '../utils/unit';
export default {
name: 'HarvesterStorageUsed',
@@ -75,13 +76,13 @@ export default {
allocatedUnits() {
const exponent = exponentNeeded(this.storageStats.total, 1024);
return `${ UNITS[exponent] }i`;
return `${ UNITS[exponent] }${ UNIT_SUFFIX }`;
},
usedUnits() {
const exponent = exponentNeeded(this.storageStats.maximum, 1024);
return `${ UNITS[exponent] }i`;
return `${ UNITS[exponent] }${ UNIT_SUFFIX }`;
},
formatUsed() {