diff --git a/website/src/components/SearchPage/DownloadDialog/DownloadDialog.spec.tsx b/website/src/components/SearchPage/DownloadDialog/DownloadDialog.spec.tsx index 12bc6309b..d45bc9767 100644 --- a/website/src/components/SearchPage/DownloadDialog/DownloadDialog.spec.tsx +++ b/website/src/components/SearchPage/DownloadDialog/DownloadDialog.spec.tsx @@ -84,13 +84,15 @@ describe('DownloadDialog', () => { await userEvent.click(screen.getByLabelText(/Yes, include older versions/)); await userEvent.click(screen.getByLabelText(/Raw nucleotide sequences/)); + await userEvent.click(screen.getByLabelText(/Gzip/)); expect(getDownloadHref()).toBe( - `${defaultLapisUrl}/sample/unalignedNucleotideSequences?downloadAsFile=true&dataUseTerms=OPEN&field1=value1`, + `${defaultLapisUrl}/sample/unalignedNucleotideSequences?downloadAsFile=true&dataUseTerms=OPEN&compression=gzip&field1=value1`, ); await userEvent.click(screen.getByLabelText(/include restricted data/)); + await userEvent.click(screen.getByLabelText(/Zstandard/)); expect(getDownloadHref()).toBe( - `${defaultLapisUrl}/sample/unalignedNucleotideSequences?downloadAsFile=true&field1=value1`, + `${defaultLapisUrl}/sample/unalignedNucleotideSequences?downloadAsFile=true&compression=zstd&field1=value1`, ); }); }); diff --git a/website/src/components/SearchPage/DownloadDialog/DownloadForm.tsx b/website/src/components/SearchPage/DownloadDialog/DownloadForm.tsx index 23a9cdb4b..81f9f25a9 100644 --- a/website/src/components/SearchPage/DownloadDialog/DownloadForm.tsx +++ b/website/src/components/SearchPage/DownloadDialog/DownloadForm.tsx @@ -13,6 +13,7 @@ export const DownloadForm: FC = ({ referenceGenomesSequenceNa const [includeRestricted, setIncludeRestricted] = useState(0); const [includeOldData, setIncludeOldData] = useState(0); const [dataType, setDataType] = useState(0); + const [compression, setCompression] = useState(0); const [unalignedNucleotideSequence, setUnalignedNucleotideSequence] = useState(0); const [alignedNucleotideSequence, setAlignedNucleotideSequence] = useState(0); const [alignedAminoAcidSequence, setAlignedAminoAcidSequence] = useState(0); @@ -50,14 +51,17 @@ export const DownloadForm: FC = ({ referenceGenomesSequenceNa default: throw new Error(`Invalid state error: DownloadForm dataType=${dataType}`); } + const compressionOptions = [undefined, 'zstd', 'gzip'] as const; onChange({ dataType: downloadDataType, includeOldData: includeOldData === 1, includeRestricted: includeRestricted === 1, + compression: compressionOptions[compression], }); }, [ includeRestricted, includeOldData, + compression, dataType, unalignedNucleotideSequence, alignedNucleotideSequence, @@ -161,6 +165,13 @@ export const DownloadForm: FC = ({ referenceGenomesSequenceNa selected={dataType} onSelect={setDataType} /> + None }, { label: <>Zstandard }, { label: <>Gzip }]} + selected={compression} + onSelect={setCompression} + /> ); }; diff --git a/website/src/components/SearchPage/DownloadDialog/OptionBlock.tsx b/website/src/components/SearchPage/DownloadDialog/OptionBlock.tsx index 5fe902f3a..89f6b9d02 100644 --- a/website/src/components/SearchPage/DownloadDialog/OptionBlock.tsx +++ b/website/src/components/SearchPage/DownloadDialog/OptionBlock.tsx @@ -21,7 +21,7 @@ export const RadioOptionBlock: FC = ({ disabled = false, }) => { return ( -
+
{title !== undefined &&

{title}

} {options.map((option, index) => (
diff --git a/website/src/components/SearchPage/DownloadDialog/generateDownloadUrl.ts b/website/src/components/SearchPage/DownloadDialog/generateDownloadUrl.ts index d66cb91d0..413d94942 100644 --- a/website/src/components/SearchPage/DownloadDialog/generateDownloadUrl.ts +++ b/website/src/components/SearchPage/DownloadDialog/generateDownloadUrl.ts @@ -8,10 +8,13 @@ export type DownloadDataType = | { type: 'alignedNucleotideSequences'; segment: string | undefined } | { type: 'alignedAminoAcidSequences'; gene: string }; +export type Compression = 'zstd' | 'gzip' | undefined; + export type DownloadOption = { includeOldData: boolean; includeRestricted: boolean; dataType: DownloadDataType; + compression: Compression; }; export const generateDownloadUrl = ( @@ -33,6 +36,9 @@ export const generateDownloadUrl = ( if (option.dataType.type === 'metadata') { params.set('dataFormat', metadataDefaultDownloadDataFormat); } + if (option.compression !== undefined) { + params.set('compression', option.compression); + } for (const { name, filterValue } of metadataFilter) { if (filterValue.trim().length > 0) { params.set(name, filterValue);