Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions frontend/providers/dbprovider/src/utils/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,7 @@ export const memoryFormatToGi = (memory: string | number = '0'): string => {
* @deprecated We need to migrate all resource representations to Quantity (in the near future).
*/
export const storageFormatToNum = (storage = '0') => {
return (
Math.round(
(Number(Quantity.fromJSON(storage).withFormat('BinarySI').scaledValue(Scale.Mega)) / 1024) *
100
) / 100
);
return Math.round((Number(Quantity.fromJSON(storage).value()) / 1024 / 1024 / 1024) * 100) / 100;
};

/**
Expand All @@ -161,11 +156,11 @@ export const storageFormatToNum = (storage = '0') => {
* @deprecated We need to migrate all resource representations to Quantity (in the near future).
*/
export const storageFormatToGi = (value: string | undefined, defaultValue: number = 0): number => {
return (
Math.round(
(Number(Quantity.fromJSON(value).withFormat('BinarySI').scaledValue(Scale.Mega)) / 1024) * 100
) / 100
);
try {
return Math.round((Number(Quantity.fromJSON(value).value()) / 1024 / 1024 / 1024) * 100) / 100;
} catch {
return defaultValue;
}
};

/**
Expand Down
Loading