Merge branch '21388-arvados-3.0-distros-docs'
[arvados.git] / services / workbench2 / src / common / formatters.ts
index a38609a678661c420d5b88a23197540feb859dca..e44a21e026c7c6fda90490a42e020f5bdb53f25b 100644 (file)
@@ -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);