diff --git a/app/components/Index/common/constants.ts b/app/components/Index/common/constants.ts index bd12237b4..cd97a04d4 100644 --- a/app/components/Index/common/constants.ts +++ b/app/components/Index/common/constants.ts @@ -5,6 +5,8 @@ import { calculateSummaryTotalCellCount, getSummaryCount, } from "./utils"; +import { formatCountSize } from "@databiosphere/findable-ui/lib/utils/formatCountSize"; +import { formatFileSize } from "@databiosphere/findable-ui/lib/utils/formatFileSize"; // Template constants const { @@ -53,24 +55,29 @@ const { FILES, SPECIES, SPECIMENS, + TOTAL_FILE_SIZE, } = SUMMARY; /** * Functions binding summary response API to summary count. */ export const BIND_SUMMARY_RESPONSE = { - [BIOSAMPLES]: (r: AzulSummaryResponse): number => - getSummaryCount(r, SUMMARY_KEY.BIOSAMPLES), - [DONORS]: (r: AzulSummaryResponse): number => - getSummaryCount(r, SUMMARY_KEY.DONORS), - [ESTIMATED_CELLS]: calculateSummaryTotalCellCount, - [FILES]: (r: AzulSummaryResponse): number => - getSummaryCount(r, SUMMARY_KEY.FILES), - [FILE_FORMATS]: calculateSummaryFileFormatsCount, - [SPECIES]: (r: AzulSummaryResponse): number => - getSummaryCount(r, SUMMARY_KEY.SPECIES), - [SPECIMENS]: (r: AzulSummaryResponse): number => - getSummaryCount(r, SUMMARY_KEY.SPECIMENS), + [BIOSAMPLES]: (r: AzulSummaryResponse): string => + formatCountSize(getSummaryCount(r, SUMMARY_KEY.BIOSAMPLES)), + [DONORS]: (r: AzulSummaryResponse): string => + formatCountSize(getSummaryCount(r, SUMMARY_KEY.DONORS)), + [ESTIMATED_CELLS]: (r: AzulSummaryResponse): string => + formatCountSize(calculateSummaryTotalCellCount(r)), + [FILES]: (r: AzulSummaryResponse): string => + formatCountSize(getSummaryCount(r, SUMMARY_KEY.FILES)), + [FILE_FORMATS]: (r: AzulSummaryResponse): string => + formatCountSize(calculateSummaryFileFormatsCount(r)), + [SPECIES]: (r: AzulSummaryResponse): string => + formatCountSize(getSummaryCount(r, SUMMARY_KEY.SPECIES)), + [SPECIMENS]: (r: AzulSummaryResponse): string => + formatCountSize(getSummaryCount(r, SUMMARY_KEY.SPECIMENS)), + [TOTAL_FILE_SIZE]: (r: AzulSummaryResponse): string => + formatFileSize(getSummaryCount(r, SUMMARY_KEY.TOTAL_FILE_SIZE)), }; export const NETWORK_KEYS = [ @@ -162,13 +169,14 @@ export const PLURALIZED_METADATA_LABEL = { /** * Set of possible summary keys. */ -export const SUMMARY_KEY = { +export const SUMMARY_KEY: Record = { [BIOSAMPLES]: "biosampleCount", [DONORS]: "donorCount", [FILES]: "fileCount", [FILE_FORMATS]: "fileFormats", [SPECIES]: "speciesCount", [SPECIMENS]: "specimenCount", + [TOTAL_FILE_SIZE]: "totalFileSize", } as const; /** @@ -182,4 +190,5 @@ export const SUMMARY_LABEL = { [FILE_FORMATS]: "Files", [SPECIES]: "Species", [SPECIMENS]: "Specimens", + [TOTAL_FILE_SIZE]: "", }; diff --git a/app/components/Index/common/entities.ts b/app/components/Index/common/entities.ts index 86cd800da..0989a4e28 100644 --- a/app/components/Index/common/entities.ts +++ b/app/components/Index/common/entities.ts @@ -56,4 +56,5 @@ export enum SUMMARY { FILES = "FILES", SPECIES = "SPECIES", SPECIMENS = "SPECIMENS", + TOTAL_FILE_SIZE = "TOTAL_FILE_SIZE", } diff --git a/app/components/Index/common/indexTransformer.ts b/app/components/Index/common/indexTransformer.ts index eadda09b0..cf3051524 100644 --- a/app/components/Index/common/indexTransformer.ts +++ b/app/components/Index/common/indexTransformer.ts @@ -1,5 +1,4 @@ import { AzulSummaryResponse } from "@databiosphere/findable-ui/lib/apis/azul/common/entities"; -import { formatCountSize } from "@databiosphere/findable-ui/lib/utils/formatCountSize"; import { BIND_SUMMARY_RESPONSE, PLURALIZED_METADATA_LABEL, @@ -30,7 +29,7 @@ export function mapSummary( ): [string, string][] { return summaries.map((summary) => { const summaryBinderFn = BIND_SUMMARY_RESPONSE[summary]; - const count = formatCountSize(summaryBinderFn(summaryResponse)); + const count = summaryBinderFn(summaryResponse); const label = SUMMARY_LABEL[summary]; return [count, label]; }); diff --git a/e2e/anvil/anvil-index-export-button.spec.ts b/e2e/anvil/anvil-index-export-button.spec.ts index fa70eba4f..fff62898c 100644 --- a/e2e/anvil/anvil-index-export-button.spec.ts +++ b/e2e/anvil/anvil-index-export-button.spec.ts @@ -60,6 +60,8 @@ test.describe("AnVIL Data Explorer Export", () => { // Test that each summary item is present in the export summary // with corresponding count. for (const [label, count] of summary) { + // Total file size summary item has no label. + if (!label) continue; const summaryItem = exportSummaryLocator .locator("> div") .filter({ hasText: label }); diff --git a/site-config/anvil-cmg/dev/index/common/constants.ts b/site-config/anvil-cmg/dev/index/common/constants.ts index 8f44257fb..38a086cfa 100644 --- a/site-config/anvil-cmg/dev/index/common/constants.ts +++ b/site-config/anvil-cmg/dev/index/common/constants.ts @@ -1,9 +1,9 @@ import { SUMMARY } from "app/components/Index/common/entities"; // Template constants -const { BIOSAMPLES, DONORS, FILE_FORMATS } = SUMMARY; +const { BIOSAMPLES, DONORS, FILE_FORMATS, TOTAL_FILE_SIZE } = SUMMARY; /** * Summary display order. */ -export const SUMMARIES = [BIOSAMPLES, DONORS, FILE_FORMATS]; +export const SUMMARIES = [BIOSAMPLES, DONORS, FILE_FORMATS, TOTAL_FILE_SIZE];