From 424c784a4c64753afb959b2b6b2fa39a413a4138 Mon Sep 17 00:00:00 2001 From: "Anna (Anya) Parker" <50943381+anna-parker@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:37:36 +0100 Subject: [PATCH] feat(website): add option to search by clade/subtype on sequencing efforts page (#423) --- .../SequencingEffortsPageStateSelector.tsx | 15 ++++- .../pageStateSelectors/VariantSelector.tsx | 30 +++++---- .../analyzeSingleVariant/CollectionsList.tsx | 4 +- .../GenericCompareSideBySidePage.astro | 11 +++- .../GenericSequencingEffortsPage.astro | 23 +++++-- website/src/views/BaseView.ts | 18 +++--- website/src/views/OrganismConstants.ts | 5 +- website/src/views/covid.ts | 63 ++++++++++++------- website/src/views/h5n1.ts | 4 +- website/src/views/mpox.ts | 4 +- .../CompareSideBySidePageStateHandler.ts | 4 +- .../CompareToBaselinePageStateHandler.spec.ts | 4 +- .../CompareToBaselinePageStateHandler.ts | 4 +- .../CompareVariantsPageStateHandler.spec.ts | 4 +- .../CompareVariantsPageStateHandler.ts | 4 +- .../pageStateHandlers/PageStateHandler.ts | 4 +- .../SequencingEffortsPageStateHandler.ts | 36 +++++++---- .../SingleVariantPageStateHandler.ts | 4 +- website/src/views/rsvA.ts | 4 +- website/src/views/rsvB.ts | 4 +- website/src/views/westNile.ts | 4 +- 21 files changed, 161 insertions(+), 92 deletions(-) diff --git a/website/src/components/pageStateSelectors/SequencingEffortsPageStateSelector.tsx b/website/src/components/pageStateSelectors/SequencingEffortsPageStateSelector.tsx index 5a22f253..54daf887 100644 --- a/website/src/components/pageStateSelectors/SequencingEffortsPageStateSelector.tsx +++ b/website/src/components/pageStateSelectors/SequencingEffortsPageStateSelector.tsx @@ -4,6 +4,8 @@ import { useMemo, useState } from 'react'; import { ApplyFilterButton } from './ApplyFilterButton.tsx'; import { BaselineSelector, type DateRangeFilterConfig, type LocationFilterConfig } from './BaselineSelector.tsx'; import { SelectorHeadline } from './SelectorHeadline.tsx'; +import { toVariantFilter, type VariantFilterConfig } from './VariantFilterConfig.ts'; +import { VariantSelector } from './VariantSelector.tsx'; import type { OrganismsConfig } from '../../config.ts'; import type { LapisLocation } from '../../views/helpers.ts'; import { type OrganismViewKey, Routing } from '../../views/routing.ts'; @@ -12,15 +14,18 @@ import type { sequencingEffortsViewKey } from '../../views/viewKeys.ts'; export function SequencingEffortsPageStateSelector({ locationFilterConfig, dateRangeFilterConfig, + variantFilterConfig, organismViewKey, organismsConfig, }: { locationFilterConfig: LocationFilterConfig; dateRangeFilterConfig: DateRangeFilterConfig; + variantFilterConfig: VariantFilterConfig; organismViewKey: OrganismViewKey & `${string}.${typeof sequencingEffortsViewKey}`; organismsConfig: OrganismsConfig; }) { const [location, setLocation] = useState(locationFilterConfig.initialLocation); + const [variantFilterConfigState, setVariantFilterConfigState] = useState(variantFilterConfig); const [dateRange, setDateRange] = useState(dateRangeFilterConfig.initialDateRange); const view = useMemo(() => new Routing(organismsConfig), [organismsConfig]).getOrganismView(organismViewKey); @@ -30,8 +35,9 @@ export function SequencingEffortsPageStateSelector({ location, dateRange, }, + variantFilter: toVariantFilter(variantFilterConfigState), }), - [location, dateRange], + [location, dateRange, variantFilterConfigState], ); return ( @@ -45,6 +51,13 @@ export function SequencingEffortsPageStateSelector({ dateRangeFilterConfig={dateRangeFilterConfig} /> +
+ +
); diff --git a/website/src/components/pageStateSelectors/VariantSelector.tsx b/website/src/components/pageStateSelectors/VariantSelector.tsx index 4cbe1a60..42f80121 100644 --- a/website/src/components/pageStateSelectors/VariantSelector.tsx +++ b/website/src/components/pageStateSelectors/VariantSelector.tsx @@ -6,9 +6,11 @@ import { GsMutationFilter } from '../genspectrum/GsMutationFilter.tsx'; export function VariantSelector({ onVariantFilterChange, variantFilterConfig, + hideMutationFilter, }: { variantFilterConfig: VariantFilterConfig; onVariantFilterChange: (variantFilter: VariantFilterConfig) => void; + hideMutationFilter?: boolean | undefined; }) { return (
@@ -29,19 +31,21 @@ export function VariantSelector({ key={lineageFilterConfig.lapisField} /> ))} - { - if (mutation === undefined) { - return; - } - const newVariantFilterConfig = { - ...variantFilterConfig, - mutationFilterConfig: mutation, - }; - onVariantFilterChange(newVariantFilterConfig); - }} - /> + {!hideMutationFilter && ( + { + if (mutation === undefined) { + return; + } + const newVariantFilterConfig = { + ...variantFilterConfig, + mutationFilterConfig: mutation, + }; + onVariantFilterChange(newVariantFilterConfig); + }} + /> + )}
); } diff --git a/website/src/components/views/analyzeSingleVariant/CollectionsList.tsx b/website/src/components/views/analyzeSingleVariant/CollectionsList.tsx index 8cb66659..8c6048c6 100644 --- a/website/src/components/views/analyzeSingleVariant/CollectionsList.tsx +++ b/website/src/components/views/analyzeSingleVariant/CollectionsList.tsx @@ -3,7 +3,7 @@ import { useMemo, useState } from 'react'; import { z } from 'zod'; import type { OrganismsConfig } from '../../../config.ts'; -import { type CovidAnalyzeSingleVariantData } from '../../../views/covid.ts'; +import { type CovidVariantData } from '../../../views/covid.ts'; import { Routing } from '../../../views/routing.ts'; import { withQueryProvider } from '../../subscriptions/backendApi/withQueryProvider.tsx'; @@ -104,7 +104,7 @@ function CollectionVariantList({ collection, organismsConfig }: CollectionVarian const currentPageState = routing .getOrganismView('covid.singleVariantView') .pageStateHandler.parsePageStateFromUrl(new URL(window.location.href)); - let newPageState: CovidAnalyzeSingleVariantData; + let newPageState: CovidVariantData; const query = querySchema.parse(JSON.parse(variant.query)); if (query.variantQuery !== undefined) { newPageState = { diff --git a/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro b/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro index 2fd525a4..784df55b 100644 --- a/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro +++ b/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro @@ -15,9 +15,10 @@ import { CompareSideBySideSelectorFallback } from '../../pageStateSelectors/Fall type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { organism: OrganismViewCompareVariant; + hideMutationFilter?: boolean; } -const { organism } = Astro.props; +const { organism, hideMutationFilter } = Astro.props; const organismViewKey = `${organism}.${compareSideBySideViewKey}` satisfies OrganismViewKey; const view = ServerSide.routing.getOrganismView(organismViewKey); @@ -97,8 +98,12 @@ const pageState = view.pageStateHandler.parsePageStateFromUrl(Astro.url); lapisDateField={view.organismConstants.mainDateField} granularity={timeGranularity} /> - - + {!hideMutationFilter && ( + <> + + + + )} @@ -54,6 +59,7 @@ const { organismViewKey={organismViewKey} organismsConfig={getDashboardsConfig().dashboards.organisms} client:only='react' + variantFilterConfig={{ mutationFilterConfig: pageState.variantFilter.mutations, lineageFilterConfigs }} > @@ -63,7 +69,7 @@ const { lapisFilters={[ { displayName: '', - lapisFilter: datasetLapisFilter, + lapisFilter: variantLapisFilter, }, ]} lapisDateField={view.organismConstants.mainDateField} @@ -75,7 +81,7 @@ const { title={locationLabel} height={ComponentHeight.large} lapisLocationField={locationField} - lapisFilter={datasetLapisFilter} + lapisFilter={variantLapisFilter} mapName={mapName} /> ) @@ -84,11 +90,16 @@ const { title='Hosts' height={ComponentHeight.large} fields={[view.organismConstants.hostField]} - lapisFilter={datasetLapisFilter} + lapisFilter={variantLapisFilter} + /> + { view.organismConstants.additionalSequencingEffortsFields.map(({ label, fields, height }) => ( - + )) } diff --git a/website/src/views/BaseView.ts b/website/src/views/BaseView.ts index c8bf328c..0d04cb2e 100644 --- a/website/src/views/BaseView.ts +++ b/website/src/views/BaseView.ts @@ -1,5 +1,5 @@ -import type { OrganismConstants, SequencingEffortsConstants, SingleVariantConstants } from './OrganismConstants.ts'; -import type { CompareToBaselineData, CompareVariantsData, Dataset, DatasetAndVariantData, View } from './View.ts'; +import type { OrganismConstants, ExtendedConstants } from './OrganismConstants.ts'; +import type { CompareToBaselineData, CompareVariantsData, DatasetAndVariantData, View } from './View.ts'; import { compareToBaselineViewConstants, compareVariantsViewConstants, @@ -40,7 +40,7 @@ export abstract class BaseView< } } -export class GenericSingleVariantView extends BaseView< +export class GenericSingleVariantView extends BaseView< DatasetAndVariantData, Constants, SingleVariantPageStateHandler @@ -67,8 +67,8 @@ export class GenericSingleVariantView } } -export class GenericSequencingEffortsView extends BaseView< - Dataset, +export class GenericSequencingEffortsView extends BaseView< + DatasetAndVariantData, Constants, SequencingEffortsStateHandler > { @@ -82,6 +82,10 @@ export class GenericSequencingEffortsView extends BaseView< +export class GenericCompareVariantsView extends BaseView< CompareVariantsData, Constants, CompareVariantsPageStateHandler @@ -114,7 +118,7 @@ export class GenericCompareVariantsView extends BaseView< +export class GenericCompareToBaselineView extends BaseView< CompareToBaselineData, Constants, CompareToBaselineStateHandler diff --git a/website/src/views/OrganismConstants.ts b/website/src/views/OrganismConstants.ts index af1794e2..e12408f4 100644 --- a/website/src/views/OrganismConstants.ts +++ b/website/src/views/OrganismConstants.ts @@ -21,16 +21,13 @@ export interface AdditionalSequencingEffortsField { readonly height: (typeof ComponentHeight)[keyof typeof ComponentHeight]; } -export interface SequencingEffortsConstants extends OrganismConstants { +export interface ExtendedConstants extends OrganismConstants { readonly locationFields: string[]; readonly mainDateField: string; readonly dateRangeOptions: DateRangeOption[]; readonly defaultDateRange: DateRangeOption; readonly additionalFilters: Record | undefined; readonly additionalSequencingEffortsFields: AdditionalSequencingEffortsField[]; -} - -export interface SingleVariantConstants extends SequencingEffortsConstants { readonly lineageFilters: LineageFilterConfig[]; } diff --git a/website/src/views/covid.ts b/website/src/views/covid.ts index f0dba635..67d8d738 100644 --- a/website/src/views/covid.ts +++ b/website/src/views/covid.ts @@ -1,6 +1,12 @@ import { type DateRangeOption, dateRangeOptionPresets } from '@genspectrum/dashboard-components/util'; -import { type CompareSideBySideData, type Dataset, getLineageFilterFields, type Id, type VariantData } from './View.ts'; +import { + type CompareSideBySideData, + type DatasetAndVariantData, + getLineageFilterFields, + type Id, + type VariantData, +} from './View.ts'; import { getDateRangeFromSearch, getIntegerFromSearch, @@ -13,7 +19,7 @@ import { } from './helpers.ts'; import { type OrganismsConfig } from '../config.ts'; import { BaseView, GenericCompareToBaselineView, GenericCompareVariantsView } from './BaseView.ts'; -import { ComponentHeight, type SingleVariantConstants } from './OrganismConstants.ts'; +import { ComponentHeight, type ExtendedConstants } from './OrganismConstants.ts'; import { compareSideBySideViewConstants, sequencingEffortsViewConstants, @@ -29,7 +35,7 @@ import { SingleVariantPageStateHandler } from './pageStateHandlers/SingleVariant const earliestDate = '2020-01-06'; -class CovidConstants implements SingleVariantConstants { +class CovidConstants implements ExtendedConstants { public readonly organism = Organisms.covid; public readonly defaultDateRange = dateRangeOptionPresets.lastYear; public readonly earliestDate = '2020-01-06'; @@ -84,13 +90,13 @@ class CovidConstants implements SingleVariantConstants { } } -export type CovidAnalyzeSingleVariantData = Dataset & +export type CovidVariantData = DatasetAndVariantData & VariantData & { collectionId?: number; }; export class CovidAnalyzeSingleVariantView extends BaseView< - CovidAnalyzeSingleVariantData, + CovidVariantData, CovidConstants, CovidSingleVariantStateHandler > { @@ -120,17 +126,17 @@ export class CovidAnalyzeSingleVariantView extends BaseView< class CovidSingleVariantStateHandler extends SingleVariantPageStateHandler - implements PageStateHandler + implements PageStateHandler { constructor( protected readonly constants: CovidConstants, - defaultPageState: CovidAnalyzeSingleVariantData, + defaultPageState: CovidVariantData, pathname: string, ) { super(constants, defaultPageState, pathname); } - public override parsePageStateFromUrl(url: URL): CovidAnalyzeSingleVariantData { + public override parsePageStateFromUrl(url: URL): CovidVariantData { const search = url.searchParams; const baselineFilter = super.parsePageStateFromUrl(url).datasetFilter; return { @@ -140,7 +146,7 @@ class CovidSingleVariantStateHandler }; } - public override toUrl(pageState: CovidAnalyzeSingleVariantData): string { + public override toUrl(pageState: CovidVariantData): string { const search = new URLSearchParams(); setSearchFromLocation(search, pageState.datasetFilter.location); @@ -159,7 +165,7 @@ class CovidSingleVariantStateHandler return `${this.pathname}?${search}`; } - public override toLapisFilter(pageState: CovidAnalyzeSingleVariantData) { + public override toLapisFilter(pageState: CovidVariantData) { return { ...super.toLapisFilter(pageState), variantQuery: pageState.variantFilter.variantQuery, @@ -167,7 +173,7 @@ class CovidSingleVariantStateHandler } } -type CovidCompareSideBySideFilter = Dataset & VariantData; +type CovidCompareSideBySideFilter = DatasetAndVariantData & VariantData; export type CovidCompareSideBySideData = CompareSideBySideData; export class CovidCompareSideBySideView extends BaseView< @@ -274,12 +280,8 @@ class CovidCompareSideBySideStateHandler extends CompareSideBySideStateHandler { @@ -294,6 +296,10 @@ export class CovidSequencingEffortsView extends BaseView< location: {}, dateRange: constants.defaultDateRange, }, + variantFilter: { + lineages: {}, + mutations: {}, + }, }, organismConfig[constants.organism].pathFragment, ), @@ -304,26 +310,41 @@ export class CovidSequencingEffortsView extends BaseView< class CovidSequencingEffortsStateHandler extends SequencingEffortsStateHandler - implements PageStateHandler + implements PageStateHandler { - public override parsePageStateFromUrl(url: URL): CovidSequencingEffortsData { + public override parsePageStateFromUrl(url: URL): CovidVariantData { + const search = url.searchParams; + const baselineFilter = super.parsePageStateFromUrl(url).datasetFilter; return { - ...super.parsePageStateFromUrl(url), - collectionId: getIntegerFromSearch(url.searchParams, 'collectionId'), + datasetFilter: baselineFilter, + variantFilter: getLapisCovidVariantQuery(search, getLineageFilterFields(this.constants.lineageFilters)), + collectionId: getIntegerFromSearch(search, 'collectionId'), }; } - public override toUrl(pageState: CovidSequencingEffortsData): string { + public override toUrl(pageState: CovidVariantData): string { const search = new URLSearchParams(); setSearchFromLocation(search, pageState.datasetFilter.location); if (pageState.datasetFilter.dateRange !== this.constants.defaultDateRange) { setSearchFromDateRange(search, this.constants.mainDateField, pageState.datasetFilter.dateRange); } + setSearchFromLapisCovidVariantQuery( + search, + pageState.variantFilter, + getLineageFilterFields(this.constants.lineageFilters), + ); if (pageState.collectionId !== undefined) { search.set('collectionId', pageState.collectionId.toString()); } return `${this.pathname}?${search}`; } + + public override toLapisFilter(pageState: CovidVariantData) { + return { + ...super.toLapisFilter(pageState), + variantQuery: pageState.variantFilter.variantQuery, + }; + } } export class CovidCompareVariantsView extends GenericCompareVariantsView { diff --git a/website/src/views/h5n1.ts b/website/src/views/h5n1.ts index 32e94344..89fc7f0d 100644 --- a/website/src/views/h5n1.ts +++ b/website/src/views/h5n1.ts @@ -9,7 +9,7 @@ import { GenericSequencingEffortsView, GenericSingleVariantView, } from './BaseView.ts'; -import { getAuthorRelatedSequencingEffortsFields, type SingleVariantConstants } from './OrganismConstants.ts'; +import { getAuthorRelatedSequencingEffortsFields, type ExtendedConstants } from './OrganismConstants.ts'; import { compareSideBySideViewConstants } from './ViewConstants.ts'; import type { LineageFilterConfig } from '../components/pageStateSelectors/LineageFilterInput.tsx'; import { organismConfig, Organisms } from '../types/Organism.ts'; @@ -18,7 +18,7 @@ import { GenericCompareSideBySideStateHandler } from './pageStateHandlers/Compar const earliestDate = '1905-01-01'; -class H5n1Constants implements SingleVariantConstants { +class H5n1Constants implements ExtendedConstants { public readonly organism = Organisms.h5n1; public readonly earliestDate = '1905-01-01'; public readonly defaultDateRange = dateRangeOptionPresets.lastYear; diff --git a/website/src/views/mpox.ts b/website/src/views/mpox.ts index 3c341c47..5b2f6e74 100644 --- a/website/src/views/mpox.ts +++ b/website/src/views/mpox.ts @@ -9,14 +9,14 @@ import { GenericSequencingEffortsView, GenericSingleVariantView, } from './BaseView.ts'; -import { getPathoplexusAdditionalSequencingEffortsFields, type SingleVariantConstants } from './OrganismConstants.ts'; +import { getPathoplexusAdditionalSequencingEffortsFields, type ExtendedConstants } from './OrganismConstants.ts'; import { compareSideBySideViewConstants } from './ViewConstants.ts'; import type { LineageFilterConfig } from '../components/pageStateSelectors/LineageFilterInput.tsx'; import { organismConfig, Organisms } from '../types/Organism.ts'; import { type DataOrigin, dataOrigins } from '../types/dataOrigins.ts'; import { GenericCompareSideBySideStateHandler } from './pageStateHandlers/CompareSideBySidePageStateHandler.ts'; -class MpoxConstants implements SingleVariantConstants { +class MpoxConstants implements ExtendedConstants { public readonly organism = Organisms.mpox; public readonly earliestDate = '1960-01-01'; public readonly defaultDateRange = dateRangeOptionPresets.lastYear; diff --git a/website/src/views/pageStateHandlers/CompareSideBySidePageStateHandler.ts b/website/src/views/pageStateHandlers/CompareSideBySidePageStateHandler.ts index fe9f4168..276b2c59 100644 --- a/website/src/views/pageStateHandlers/CompareSideBySidePageStateHandler.ts +++ b/website/src/views/pageStateHandlers/CompareSideBySidePageStateHandler.ts @@ -1,6 +1,6 @@ import type { LapisFilter } from '@genspectrum/dashboard-components/util'; -import type { SingleVariantConstants } from '../OrganismConstants.ts'; +import type { ExtendedConstants } from '../OrganismConstants.ts'; import { type CompareSideBySideData, type DatasetAndVariantData, getLineageFilterFields, type Id } from '../View.ts'; import { compareSideBySideViewConstants } from '../ViewConstants.ts'; import type { CovidCompareSideBySideData } from '../covid.ts'; @@ -25,7 +25,7 @@ export abstract class CompareSideBySideStateHandler, pathFragment: string, ) { diff --git a/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.spec.ts b/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.spec.ts index 86764248..48a5cca2 100644 --- a/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.spec.ts +++ b/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from 'vitest'; import { Organisms } from '../../types/Organism.ts'; -import type { SingleVariantConstants } from '../OrganismConstants.ts'; +import type { ExtendedConstants } from '../OrganismConstants.ts'; import type { CompareToBaselineData } from '../View.ts'; import { CompareToBaselineStateHandler } from './CompareToBaselinePageStateHandler.ts'; -const mockConstants: SingleVariantConstants = { +const mockConstants: ExtendedConstants = { organism: Organisms.covid, dataOrigins: [], locationFields: ['country', 'region'], diff --git a/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.ts b/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.ts index 536f500a..9d541dc0 100644 --- a/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.ts +++ b/website/src/views/pageStateHandlers/CompareToBaselinePageStateHandler.ts @@ -1,6 +1,6 @@ import type { LapisFilter, NamedLapisFilter } from '@genspectrum/dashboard-components/util'; -import type { SingleVariantConstants } from '../OrganismConstants.ts'; +import type { ExtendedConstants } from '../OrganismConstants.ts'; import { type CompareToBaselineData, type DatasetFilter, @@ -31,7 +31,7 @@ export class CompareToBaselineStateHandler implements PageStateHandler { export function toLapisFilterWithoutVariant( pageState: Dataset, - constants: SequencingEffortsConstants, + constants: ExtendedConstants, ): LapisFilter & LapisLocation { return { ...pageState.datasetFilter.location, diff --git a/website/src/views/pageStateHandlers/SequencingEffortsPageStateHandler.ts b/website/src/views/pageStateHandlers/SequencingEffortsPageStateHandler.ts index 8e28be21..6331afd3 100644 --- a/website/src/views/pageStateHandlers/SequencingEffortsPageStateHandler.ts +++ b/website/src/views/pageStateHandlers/SequencingEffortsPageStateHandler.ts @@ -1,26 +1,30 @@ -import type { SequencingEffortsConstants } from '../OrganismConstants.ts'; -import type { Dataset } from '../View.ts'; +import type { ExtendedConstants } from '../OrganismConstants.ts'; +import { getLineageFilterFields, type DatasetAndVariantData } from '../View.ts'; import { sequencingEffortsViewConstants } from '../ViewConstants.ts'; import { getDateRangeFromSearch, getLapisLocationFromSearch, + getLapisVariantQuery, setSearchFromDateRange, + setSearchFromLapisVariantQuery, setSearchFromLocation, } from '../helpers.ts'; import { type PageStateHandler, toLapisFilterWithoutVariant } from './PageStateHandler.ts'; -export class SequencingEffortsStateHandler implements PageStateHandler { +export class SequencingEffortsStateHandler + implements PageStateHandler +{ protected readonly pathname; constructor( - protected readonly constants: SequencingEffortsConstants, - protected readonly defaultPageState: Dataset, + protected readonly constants: ExtendedConstants, + protected readonly defaultPageState: PageState, pathFragment: string, ) { this.pathname = `/${pathFragment}/${sequencingEffortsViewConstants.pathFragment}`; } - public parsePageStateFromUrl(url: URL): Dataset { + public parsePageStateFromUrl(url: URL): DatasetAndVariantData { const search = url.searchParams; return { datasetFilter: { @@ -29,23 +33,33 @@ export class SequencingEffortsStateHandler implements PageStateHandler getDateRangeFromSearch(search, this.constants.mainDateField, this.constants.dateRangeOptions) ?? this.constants.defaultDateRange, }, + variantFilter: getLapisVariantQuery(search, getLineageFilterFields(this.constants.lineageFilters)), }; } - public toUrl(pageState: Dataset): string { + public toUrl(pageState: DatasetAndVariantData): string { const search = new URLSearchParams(); setSearchFromLocation(search, pageState.datasetFilter.location); if (pageState.datasetFilter.dateRange !== this.constants.defaultDateRange) { setSearchFromDateRange(search, this.constants.mainDateField, pageState.datasetFilter.dateRange); } + setSearchFromLapisVariantQuery( + search, + pageState.variantFilter, + getLineageFilterFields(this.constants.lineageFilters), + ); return `${this.pathname}?${search}`; } - public getDefaultPageUrl(): string { - return this.toUrl(this.defaultPageState); + public toLapisFilter(pageState: DatasetAndVariantData) { + return { + ...toLapisFilterWithoutVariant(pageState, this.constants), + ...pageState.variantFilter.lineages, + ...pageState.variantFilter.mutations, + }; } - public toLapisFilter(pageState: Dataset) { - return toLapisFilterWithoutVariant(pageState, this.constants); + public getDefaultPageUrl(): string { + return this.toUrl(this.defaultPageState); } } diff --git a/website/src/views/pageStateHandlers/SingleVariantPageStateHandler.ts b/website/src/views/pageStateHandlers/SingleVariantPageStateHandler.ts index 4db5b6eb..ee184a16 100644 --- a/website/src/views/pageStateHandlers/SingleVariantPageStateHandler.ts +++ b/website/src/views/pageStateHandlers/SingleVariantPageStateHandler.ts @@ -1,6 +1,6 @@ import type { LapisFilter } from '@genspectrum/dashboard-components/util'; -import type { SingleVariantConstants } from '../OrganismConstants.ts'; +import type { ExtendedConstants } from '../OrganismConstants.ts'; import { type Dataset, type DatasetAndVariantData, getLineageFilterFields } from '../View.ts'; import { singleVariantViewConstants } from '../ViewConstants.ts'; import { @@ -20,7 +20,7 @@ export class SingleVariantPageStateHandler