X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0f5b0542513b572959e39400bae42e69aeb1a7b6..a6b9fb8166440eef3144150024a875c858db9bb6:/services/workbench2/src/common/formatters.ts diff --git a/services/workbench2/src/common/formatters.ts b/services/workbench2/src/common/formatters.ts index a38609a678..e44a21e026 100644 --- a/services/workbench2/src/common/formatters.ts +++ b/services/workbench2/src/common/formatters.ts @@ -41,6 +41,10 @@ export const formatFileSize = (size?: number | string) => { return '0 B'; }; +export const formatCWLResourceSize = (size: number) => { + return `${(size / CWL_SIZE.base).toFixed(0)} ${CWL_SIZE.unit}`; +}; + export const formatTime = (time: number, seconds?: boolean) => { const minutes = Math.floor((time / (1000 * 60)) % 60).toFixed(0); const hours = Math.floor(time / (1000 * 60 * 60)).toFixed(0); @@ -78,15 +82,15 @@ export function formatUploadSpeed( const FILE_SIZES = [ { - base: 1099511627776, + base: 1024 ** 4, unit: 'TiB', }, { - base: 1073741824, + base: 1024 ** 3, unit: 'GiB', }, { - base: 1048576, + base: 1024 ** 2, unit: 'MiB', }, { @@ -99,6 +103,11 @@ const FILE_SIZES = [ }, ]; +const CWL_SIZE = { + base: 1024 ** 2, + unit: 'MiB', +}; + export const formatPropertyValue = ( pv: PropertyValue, vocabulary?: Vocabulary @@ -116,7 +125,7 @@ export const formatPropertyValue = ( return ''; }; -export const formatContainerCost = (cost: number): string => { +export const formatCost = (cost: number): string => { const decimalPlaces = 3; const factor = Math.pow(10, decimalPlaces);