Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): gs-sequences-by-location: add button to download the data #625

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions components/src/preact/map/sequences-by-location.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import z from 'zod';

import { SequencesByLocationMap } from './sequences-by-location-map';
import { SequencesByLocationTable } from './sequences-by-location-table';
import { type MapLocationData, MapLocationDataType } from '../../query/computeMapLocationData';
import {
type EnhancedLocationsTableData,
type MapLocationData,
MapLocationDataType,
} from '../../query/computeMapLocationData';
import { type AggregateData } from '../../query/queryAggregateData';
import { querySequencesByLocationData } from '../../query/querySequencesByLocationData';
import { LapisUrlContext } from '../LapisUrlContext';
import { CsvDownloadButton } from '../components/csv-download-button';
import { ErrorBoundary } from '../components/error-boundary';
import { Fullscreen } from '../components/fullscreen';
import Info, { InfoComponentCode, InfoHeadline1, InfoParagraph } from '../components/info';
Expand Down Expand Up @@ -120,16 +126,27 @@ const SequencesByLocationMapTabs: FunctionComponent<SequencesByLocationMapTabsPr

const tabs = originalComponentProps.views.map((view) => getTab(view));

return <Tabs tabs={tabs} toolbar={<Toolbar originalComponentProps={originalComponentProps} />} />;
return (
<Tabs
tabs={tabs}
toolbar={<Toolbar originalComponentProps={originalComponentProps} tableData={data.tableData} />}
/>
);
};

type ToolbarProps = {
originalComponentProps: SequencesByLocationProps;
tableData: AggregateData | EnhancedLocationsTableData;
};

const Toolbar: FunctionComponent<ToolbarProps> = ({ originalComponentProps }) => {
const Toolbar: FunctionComponent<ToolbarProps> = ({ originalComponentProps, tableData }) => {
return (
<div class='flex flex-row'>
<CsvDownloadButton
className='mx-1 btn btn-xs'
getData={() => tableData}
filename='sequences_by_location.csv'
/>
<SequencesByLocationMapInfo originalComponentProps={originalComponentProps} />
<Fullscreen />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
count,division,proportion
109799,,0.33325037407543423
50650,Baden-Wuerttemberg,0.15372755168007673
50102,North Rhine Westphalia,0.15206431972902673
28546,Bavaria,0.08663981619465884
25459,Saxony,0.0772704785433973
10343,Rheinland-Pfalz,0.03139198552866799
9832,Schleswig-Holstein,0.029841052085261884
9633,Hamburg,0.029237068219825846
6198,Niedersachsen,0.01881151757775154
4969,Hesse,0.015081386067093805
4911,Saarland,0.014905350568625011
4747,Saxony-Anhalt,0.014407595021230488
3846,Berlin,0.011672974605361798
3778,Brandenburg,0.011466588158881142
3238,Thuringia,0.00982763696624064
1748,Mecklenburg-Vorpommern,0.005305345712473329
1672,Bremen,0.005074678507583185
7,Germany,0.000021245663608302804
1,Baden-Württemberg,0.0000030350948011861152
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
count,division,proportion
109799,,0.33325037407543423
50650,Baden-Wuerttemberg,0.15372755168007673
50102,North Rhine Westphalia,0.15206431972902673
28546,Bavaria,0.08663981619465884
25459,Saxony,0.0772704785433973
10343,Rheinland-Pfalz,0.03139198552866799
9832,Schleswig-Holstein,0.029841052085261884
9633,Hamburg,0.029237068219825846
6198,Niedersachsen,0.01881151757775154
4969,Hesse,0.015081386067093805
4911,Saarland,0.014905350568625011
4747,Saxony-Anhalt,0.014407595021230488
3846,Berlin,0.011672974605361798
3778,Brandenburg,0.011466588158881142
3238,Thuringia,0.00982763696624064
1748,Mecklenburg-Vorpommern,0.005305345712473329
1672,Bremen,0.005074678507583185
7,Germany,0.000021245663608302804
1,Baden-Württemberg,0.0000030350948011861152
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
count,division,proportion,isShownOnMap
fengelniederhammer marked this conversation as resolved.
Show resolved Hide resolved
109799,,0.33325037407543423,false
50650,Baden-Wuerttemberg,0.15372755168007673,true
50102,North Rhine Westphalia,0.15206431972902673,true
28546,Bavaria,0.08663981619465884,true
25459,Saxony,0.0772704785433973,true
10343,Rheinland-Pfalz,0.03139198552866799,true
9832,Schleswig-Holstein,0.029841052085261884,true
9633,Hamburg,0.029237068219825846,true
6198,Niedersachsen,0.01881151757775154,true
4969,Hesse,0.015081386067093805,true
4911,Saarland,0.014905350568625011,true
4747,Saxony-Anhalt,0.014407595021230488,true
3846,Berlin,0.011672974605361798,true
3778,Brandenburg,0.011466588158881142,true
3238,Thuringia,0.00982763696624064,true
1748,Mecklenburg-Vorpommern,0.005305345712473329,true
1672,Bremen,0.005074678507583185,true
7,Germany,0.000021245663608302804,false
1,Baden-Württemberg,0.0000030350948011861152,false
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
count,division,proportion,isShownOnMap
109799,,0.33325037407543423,false
50650,Baden-Wuerttemberg,0.15372755168007673,true
50102,North Rhine Westphalia,0.15206431972902673,true
28546,Bavaria,0.08663981619465884,true
25459,Saxony,0.0772704785433973,true
10343,Rheinland-Pfalz,0.03139198552866799,true
9832,Schleswig-Holstein,0.029841052085261884,true
9633,Hamburg,0.029237068219825846,true
6198,Niedersachsen,0.01881151757775154,true
4969,Hesse,0.015081386067093805,true
4911,Saarland,0.014905350568625011,true
4747,Saxony-Anhalt,0.014407595021230488,true
3846,Berlin,0.011672974605361798,true
3778,Brandenburg,0.011466588158881142,true
3238,Thuringia,0.00982763696624064,true
1748,Mecklenburg-Vorpommern,0.005305345712473329,true
1672,Bremen,0.005074678507583185,true
7,Germany,0.000021245663608302804,false
1,Baden-Württemberg,0.0000030350948011861152,false
2 changes: 2 additions & 0 deletions components/tests/visualizationStories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const visualizationStories = [
id: 'visualization-sequences-by-location--germany',
title: 'Sequences by location',
loadingIsDoneIndicator: 'Leaflet',
testDownloadWithFilename: 'sequences_by_location.csv',
},
{
id: 'visualization-sequences-by-location--germany-on-table-tab',
Expand All @@ -137,5 +138,6 @@ export const visualizationStories = [
id: 'visualization-sequences-by-location--germany-table-only',
title: 'Sequences by location',
loadingIsDoneIndicator: 'division',
testDownloadWithFilename: 'sequences_by_location.csv',
},
];
Loading