Add Dashboard page

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-10-23 17:00:46 +02:00
parent 9b5bdeb85c
commit f8408469f7
27 changed files with 2680 additions and 3 deletions
@@ -0,0 +1,38 @@
import { formatSi, parseSi } from '@shell/utils/units';
export function dataVolumeSize(storage, getters, errors, validatorArgs) {
const t = getters['i18n/t'];
if (!storage || storage === '') {
const key = t('harvester.volume.size');
errors.push(t('validation.required', { key }));
return errors;
}
const size = getSize(storage);
const max = 999999;
const integerRegex = /^[1-9]\d*$/;
if (!integerRegex.test(size) || size > max) {
errors.push(t('harvester.validation.volume.sizeRange'));
}
return errors;
}
function getSize(storage) {
if (!storage) {
return null;
}
const kibUnitSize = parseSi(storage);
return formatSi(kibUnitSize, {
addSuffix: false,
increment: 1024,
minExponent: 3,
maxExponent: 3
});
}