mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
fix: align all memory / storage / quota units to Gi/Mi
Signed-off-by: Andy Lee <andy.lee@suse.com> (cherry picked from commit 8f76d5ad30b34778d38eddc5fdb7532699cde11c)
This commit is contained in:
parent
9fa9b3837b
commit
a8f8f0d288
@ -121,7 +121,7 @@ export default {
|
|||||||
memoryUnits() {
|
memoryUnits() {
|
||||||
const exponent = exponentNeeded(this.memoryTotal, 1024);
|
const exponent = exponentNeeded(this.memoryTotal, 1024);
|
||||||
|
|
||||||
return `${ UNITS[exponent] }iB`;
|
return `${ UNITS[exponent] }i`;
|
||||||
},
|
},
|
||||||
|
|
||||||
nodeType() {
|
nodeType() {
|
||||||
|
|||||||
@ -178,7 +178,7 @@ export default {
|
|||||||
minExponent: 3,
|
minExponent: 3,
|
||||||
maxExponent: 3,
|
maxExponent: 3,
|
||||||
maxPrecision: 2,
|
maxPrecision: 2,
|
||||||
suffix: 'iB',
|
suffix: 'i',
|
||||||
};
|
};
|
||||||
|
|
||||||
const longhornDisks = Object.keys(diskStatus).map((key) => {
|
const longhornDisks = Object.keys(diskStatus).map((key) => {
|
||||||
|
|||||||
@ -92,7 +92,7 @@ export default {
|
|||||||
:input-exponent="3"
|
:input-exponent="3"
|
||||||
:increment="1024"
|
:increment="1024"
|
||||||
:output-modifier="true"
|
:output-modifier="true"
|
||||||
suffix="GiB"
|
suffix="Gi"
|
||||||
class="mb-20"
|
class="mb-20"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -185,7 +185,7 @@ export default {
|
|||||||
minExponent: 3,
|
minExponent: 3,
|
||||||
maxExponent: 3,
|
maxExponent: 3,
|
||||||
maxPrecision: 2,
|
maxPrecision: 2,
|
||||||
suffix: 'iB',
|
suffix: 'i',
|
||||||
};
|
};
|
||||||
|
|
||||||
const longhornDisks = Object.keys(diskStatus).map((key) => {
|
const longhornDisks = Object.keys(diskStatus).map((key) => {
|
||||||
@ -457,7 +457,7 @@ export default {
|
|||||||
const devPath = d.spec?.devPath;
|
const devPath = d.spec?.devPath;
|
||||||
const deviceType = d.status?.deviceStatus?.details?.deviceType;
|
const deviceType = d.status?.deviceStatus?.details?.deviceType;
|
||||||
const sizeBytes = d.status?.deviceStatus?.capacity?.sizeBytes;
|
const sizeBytes = d.status?.deviceStatus?.capacity?.sizeBytes;
|
||||||
const size = formatSi(sizeBytes, { increment: 1024 });
|
const size = formatSi(sizeBytes, { increment: 1024, suffix: 'i' });
|
||||||
const parentDevice = d.status?.deviceStatus?.parentDevice;
|
const parentDevice = d.status?.deviceStatus?.parentDevice;
|
||||||
const isChildAdded = this.newDisks.find((newDisk) => newDisk.blockDevice?.status?.deviceStatus?.parentDevice === devPath);
|
const isChildAdded = this.newDisks.find((newDisk) => newDisk.blockDevice?.status?.deviceStatus?.parentDevice === devPath);
|
||||||
const name = d.displayName;
|
const name = d.displayName;
|
||||||
|
|||||||
@ -377,6 +377,7 @@ export default {
|
|||||||
:disabled="value?.isLonghornV2 && isEdit"
|
:disabled="value?.isLonghornV2 && isEdit"
|
||||||
required
|
required
|
||||||
class="mb-20"
|
class="mb-20"
|
||||||
|
suffix="Gi"
|
||||||
@update:value="update"
|
@update:value="update"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@ -113,6 +113,7 @@ export default {
|
|||||||
:output-modifier="true"
|
:output-modifier="true"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
required
|
required
|
||||||
|
suffix="Gi"
|
||||||
class="mb-20"
|
class="mb-20"
|
||||||
@update:value="change"
|
@update:value="change"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -47,6 +47,7 @@ export default {
|
|||||||
:input-exponent="2"
|
:input-exponent="2"
|
||||||
:increment="1024"
|
:increment="1024"
|
||||||
:output-modifier="true"
|
:output-modifier="true"
|
||||||
|
suffix="Mi"
|
||||||
@update:value="change"
|
@update:value="change"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -254,6 +254,7 @@ export default {
|
|||||||
:label="t('harvester.fields.size')"
|
:label="t('harvester.fields.size')"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
:disabled="true"
|
:disabled="true"
|
||||||
|
suffix="Gi"
|
||||||
@update:value="update"
|
@update:value="update"
|
||||||
/>
|
/>
|
||||||
</InputOrDisplay>
|
</InputOrDisplay>
|
||||||
|
|||||||
@ -129,13 +129,17 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
imageVirtualSize() {
|
imageVirtualSize() {
|
||||||
return this.selectedImage?.virtualSize;
|
if (this.selectedImage?.virtualSize) {
|
||||||
|
return this.selectedImage.virtualSize.replace(' ', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '0';
|
||||||
},
|
},
|
||||||
|
|
||||||
diskSize() {
|
diskSize() {
|
||||||
const size = this.value?.size || '0';
|
const size = this.value?.size || '0';
|
||||||
|
|
||||||
return `${ size.replace('Gi', '') } GB`;
|
return size;
|
||||||
},
|
},
|
||||||
|
|
||||||
imageVirtualSizeInByte() {
|
imageVirtualSizeInByte() {
|
||||||
@ -332,7 +336,7 @@ export default {
|
|||||||
:mode="mode"
|
:mode="mode"
|
||||||
:required="validateRequired"
|
:required="validateRequired"
|
||||||
:disable="isLonghornV2"
|
:disable="isLonghornV2"
|
||||||
suffix="GiB"
|
suffix="Gi"
|
||||||
@update:value="update"
|
@update:value="update"
|
||||||
/>
|
/>
|
||||||
</InputOrDisplay>
|
</InputOrDisplay>
|
||||||
|
|||||||
@ -258,6 +258,7 @@ export default {
|
|||||||
:required="validateRequired"
|
:required="validateRequired"
|
||||||
:label="t('harvester.fields.size')"
|
:label="t('harvester.fields.size')"
|
||||||
:disabled="isLonghornV2"
|
:disabled="isLonghornV2"
|
||||||
|
suffix="Gi"
|
||||||
@update:value="update"
|
@update:value="update"
|
||||||
/>
|
/>
|
||||||
</InputOrDisplay>
|
</InputOrDisplay>
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export default {
|
|||||||
memoryUnits() {
|
memoryUnits() {
|
||||||
const exponent = exponentNeeded(this.memoryTotal, 1024);
|
const exponent = exponentNeeded(this.memoryTotal, 1024);
|
||||||
|
|
||||||
return `${ UNITS[exponent] }iB`;
|
return `${ UNITS[exponent] }i`;
|
||||||
},
|
},
|
||||||
|
|
||||||
node() {
|
node() {
|
||||||
|
|||||||
@ -75,13 +75,13 @@ export default {
|
|||||||
allocatedUnits() {
|
allocatedUnits() {
|
||||||
const exponent = exponentNeeded(this.storageStats.total, 1024);
|
const exponent = exponentNeeded(this.storageStats.total, 1024);
|
||||||
|
|
||||||
return `${ UNITS[exponent] }iB`;
|
return `${ UNITS[exponent] }i`;
|
||||||
},
|
},
|
||||||
|
|
||||||
usedUnits() {
|
usedUnits() {
|
||||||
const exponent = exponentNeeded(this.storageStats.maximum, 1024);
|
const exponent = exponentNeeded(this.storageStats.maximum, 1024);
|
||||||
|
|
||||||
return `${ UNITS[exponent] }iB`;
|
return `${ UNITS[exponent] }i`;
|
||||||
},
|
},
|
||||||
|
|
||||||
formatUsed() {
|
formatUsed() {
|
||||||
|
|||||||
@ -8,9 +8,7 @@ import Banner from '@components/Banner/Banner.vue';
|
|||||||
import MessageLink from '@shell/components/MessageLink';
|
import MessageLink from '@shell/components/MessageLink';
|
||||||
import SortableTable from '@shell/components/SortableTable';
|
import SortableTable from '@shell/components/SortableTable';
|
||||||
import { allHash, setPromiseResult } from '@shell/utils/promise';
|
import { allHash, setPromiseResult } from '@shell/utils/promise';
|
||||||
import {
|
import { parseSi, formatSi, exponentNeeded, UNITS } from '@shell/utils/units';
|
||||||
parseSi, formatSi, exponentNeeded, UNITS, createMemoryValues
|
|
||||||
} from '@shell/utils/units';
|
|
||||||
import { REASON } from '@shell/config/table-headers';
|
import { REASON } from '@shell/config/table-headers';
|
||||||
import {
|
import {
|
||||||
EVENT, METRIC, NODE, SERVICE, PVC, LONGHORN, POD, COUNT, NETWORK_ATTACHMENT
|
EVENT, METRIC, NODE, SERVICE, PVC, LONGHORN, POD, COUNT, NETWORK_ATTACHMENT
|
||||||
@ -32,7 +30,6 @@ dayjs.extend(utc);
|
|||||||
dayjs.extend(minMax);
|
dayjs.extend(minMax);
|
||||||
|
|
||||||
const PARSE_RULES = {
|
const PARSE_RULES = {
|
||||||
memory: {
|
|
||||||
format: {
|
format: {
|
||||||
addSuffix: true,
|
addSuffix: true,
|
||||||
firstSuffix: 'B',
|
firstSuffix: 'B',
|
||||||
@ -41,8 +38,7 @@ const PARSE_RULES = {
|
|||||||
maxPrecision: 2,
|
maxPrecision: 2,
|
||||||
minExponent: 0,
|
minExponent: 0,
|
||||||
startingExponent: 0,
|
startingExponent: 0,
|
||||||
suffix: 'iB',
|
suffix: 'i',
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -402,13 +398,13 @@ export default {
|
|||||||
storageUsed() {
|
storageUsed() {
|
||||||
const stats = this.storageStats;
|
const stats = this.storageStats;
|
||||||
|
|
||||||
return this.createMemoryValues(stats.maximum, stats.used);
|
return this.createDisplayValues(stats.maximum, stats.used);
|
||||||
},
|
},
|
||||||
|
|
||||||
storageAllocated() {
|
storageAllocated() {
|
||||||
const stats = this.storageStats;
|
const stats = this.storageStats;
|
||||||
|
|
||||||
return this.createMemoryValues(stats.total, stats.scheduled);
|
return this.createDisplayValues(stats.total, stats.scheduled);
|
||||||
},
|
},
|
||||||
|
|
||||||
vmEvents() {
|
vmEvents() {
|
||||||
@ -454,7 +450,7 @@ export default {
|
|||||||
return total + node.memoryReserved;
|
return total + node.memoryReserved;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
return createMemoryValues(this.memoryTotal, useful);
|
return this.createDisplayValues(this.memoryTotal, useful);
|
||||||
},
|
},
|
||||||
|
|
||||||
availableNodes() {
|
availableNodes() {
|
||||||
@ -494,7 +490,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
ramUsed() {
|
ramUsed() {
|
||||||
return createMemoryValues(this.memoryTotal, this.metricAggregations?.memory);
|
return this.createDisplayValues(this.memoryTotal, this.metricAggregations?.memory);
|
||||||
},
|
},
|
||||||
|
|
||||||
hasMetricNodeSchema() {
|
hasMetricNodeSchema() {
|
||||||
@ -516,10 +512,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
createMemoryValues(total, useful) {
|
createDisplayValues(total, useful) {
|
||||||
const parsedTotal = parseSi((total || '0').toString());
|
const parsedTotal = parseSi((total || '0').toString());
|
||||||
|
|
||||||
const parsedUseful = parseSi((useful || '0').toString());
|
const parsedUseful = parseSi((useful || '0').toString());
|
||||||
const format = this.createMemoryFormat(parsedTotal);
|
const format = this.createFormat(parsedTotal);
|
||||||
|
|
||||||
const formattedTotal = formatSi(parsedTotal, format);
|
const formattedTotal = formatSi(parsedTotal, format);
|
||||||
let formattedUseful = formatSi(parsedUseful, {
|
let formattedUseful = formatSi(parsedUseful, {
|
||||||
...format,
|
...format,
|
||||||
@ -538,24 +536,24 @@ export default {
|
|||||||
useful: Number(parsedUseful),
|
useful: Number(parsedUseful),
|
||||||
formattedTotal,
|
formattedTotal,
|
||||||
formattedUseful,
|
formattedUseful,
|
||||||
units: this.createMemoryUnits(parsedTotal),
|
units: this.createUnits(parsedTotal),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
createMemoryFormat(n) {
|
createFormat(n) {
|
||||||
const exponent = exponentNeeded(n, PARSE_RULES.memory.format.increment);
|
const exponent = exponentNeeded(n, PARSE_RULES.format.increment);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...PARSE_RULES.memory.format,
|
...PARSE_RULES.format,
|
||||||
maxExponent: exponent,
|
maxExponent: exponent,
|
||||||
minExponent: exponent,
|
minExponent: exponent,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
createMemoryUnits(n) {
|
createUnits(n) {
|
||||||
const exponent = exponentNeeded(n, PARSE_RULES.memory.format.increment);
|
const exponent = exponentNeeded(n, PARSE_RULES.format.increment);
|
||||||
|
|
||||||
return `${ UNITS[exponent] }${ PARSE_RULES.memory.format.suffix }`;
|
return `${ UNITS[exponent] }${ PARSE_RULES.format.suffix }`;
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchClusterResources(type, opt = {}, store) {
|
async fetchClusterResources(type, opt = {}, store) {
|
||||||
|
|||||||
@ -243,8 +243,8 @@ export default class HciVmImage extends HarvesterResource {
|
|||||||
return formatSi(size, {
|
return formatSi(size, {
|
||||||
increment: 1024,
|
increment: 1024,
|
||||||
maxPrecision: 2,
|
maxPrecision: 2,
|
||||||
suffix: 'B',
|
suffix: 'i',
|
||||||
firstSuffix: 'B',
|
firstSuffix: 'i',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,8 +258,8 @@ export default class HciVmImage extends HarvesterResource {
|
|||||||
return formatSi(virtualSize, {
|
return formatSi(virtualSize, {
|
||||||
increment: 1024,
|
increment: 1024,
|
||||||
maxPrecision: 2,
|
maxPrecision: 2,
|
||||||
suffix: 'B',
|
suffix: 'i',
|
||||||
firstSuffix: 'B',
|
firstSuffix: 'i',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export function vmDisks(spec, getters, errors, validatorArgs, displayKey, value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeValue?.spec?.resources?.requests?.storage && !/^([0-9][0-9]{0,8})[a-zA-Z]+$/.test(typeValue?.spec?.resources?.requests?.storage)) {
|
if (typeValue?.spec?.resources?.requests?.storage && !/^([0-9][0-9]{0,8})[a-zA-Z]+$/.test(typeValue?.spec?.resources?.requests?.storage)) {
|
||||||
const message = getters['i18n/t']('harvester.validation.generic.maximumSize', { max: '999999999 GiB' });
|
const message = getters['i18n/t']('harvester.validation.generic.maximumSize', { max: '999999999 Gi' });
|
||||||
|
|
||||||
errors.push(getters['i18n/t']('harvester.validation.generic.tabError', { prefix, message }));
|
errors.push(getters['i18n/t']('harvester.validation.generic.tabError', { prefix, message }));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export function volumeSize(size, getters, errors, validatorArgs, displayKey, val
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size && !/^([0-9][0-9]{0,8})[a-zA-Z]+$/.test(size)) {
|
if (size && !/^([0-9][0-9]{0,8})[a-zA-Z]+$/.test(size)) {
|
||||||
const message = getters['i18n/t']('harvester.validation.generic.maximumSize', { max: '999999999 GiB' });
|
const message = getters['i18n/t']('harvester.validation.generic.maximumSize', { max: '999999999 Gi' });
|
||||||
|
|
||||||
errors.push(message);
|
errors.push(message);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user