Skip to content
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
16 changes: 11 additions & 5 deletions src/features/collections/CollectionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import { useModalControls } from '../layout/Modal';
import { Loader } from '../../common/components/Loader';
import { CollectionSidebar } from './CollectionSidebar';
import { CollectionSidebar, dataProductsMeta } from './CollectionSidebar';
import {
clearFilter,
clearFiltersAndColumnMeta,
Expand Down Expand Up @@ -62,6 +62,15 @@ export const CollectionDetail = () => {
collection?.data_products.find(
(dp) => dp.product === params.data_product
) || collection?.data_products[0];
const currDataProductMeta = dataProductsMeta.find((d) => {
return d.product === currDataProduct?.product;
});
// Set page title to data product display name or human-readbale
const dataProductTitle =
currDataProductMeta?.displayName ||
(currDataProduct
? snakeCaseToHumanReadable(currDataProduct.product)
: null);

// Redirect if the data_product specified by the url DNE
useEffect(() => {
Expand Down Expand Up @@ -113,10 +122,7 @@ export const CollectionDetail = () => {
<main className={styles['collection_main']}>
<div className={styles['detail_header']}>
<h2>
{showOverview
? 'Overview'
: currDataProduct &&
snakeCaseToHumanReadable(currDataProduct.product)}
{showOverview ? 'Overview' : currDataProduct && dataProductTitle}
</h2>
{!showOverview && (
<>
Expand Down
77 changes: 55 additions & 22 deletions src/features/collections/CollectionOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ export const CollectionOverview: FC<{
<Grid container spacing={2}>
<Grid item xs={3}>
<Card sx={{ height: '100%' }}>
<CardHeader
title={
<Typography variant="h6" fontWeight="bold">
Details
</Typography>
}
sx={{ paddingBottom: 0 }}
/>
<CardContent>
<h3>Details</h3>
<Typography
sx={{ fontSize: 12 }}
color="text.secondary"
Expand Down Expand Up @@ -102,12 +109,21 @@ export const CollectionOverview: FC<{
</Grid>
<Grid item xs={9}>
<Card sx={{ height: '100%' }}>
<CardHeader
title={
<Typography variant="h6" fontWeight="bold">
Description
</Typography>
}
sx={{ paddingBottom: 0 }}
/>
<CardContent>
<h3>Description</h3>
<div>{collection.desc}</div>
{collection.attribution && (
<>
<h4>Attribution</h4>
<Typography fontWeight="bold" sx={{ marginTop: 2 }}>
Attribution
</Typography>
<div
dangerouslySetInnerHTML={{
__html: marked(purify.sanitize(collection.attribution)),
Expand All @@ -120,19 +136,19 @@ export const CollectionOverview: FC<{
</Grid>
<Grid item xs={6}>
<Card sx={{ height: '100%' }}>
<CardHeader
title={
<Typography variant="h6" fontWeight="bold">
In this Collection
</Typography>
}
sx={{ paddingBottom: 0 }}
/>
<CardContent>
<h3>In this Collection</h3>
<Stack direction={'row'} spacing={2}>
{hasGenomes ? (
<Card>
<CardContent>
<Typography
sx={{ fontSize: 12 }}
color="text.secondary"
gutterBottom
>
Primary Data
</Typography>
<Button
variant="text"
href={`/collections/${collection_id}/genome_attribs`}
Expand All @@ -158,13 +174,6 @@ export const CollectionOverview: FC<{
{hasSamples ? (
<Card>
<CardContent>
<Typography
sx={{ fontSize: 12 }}
color="text.secondary"
gutterBottom
>
Secondary Data
</Typography>
<Button
variant="text"
href={`/collections/${collection_id}/samples`}
Expand Down Expand Up @@ -192,8 +201,15 @@ export const CollectionOverview: FC<{
</Grid>
<Grid item xs={6}>
<Card sx={{ height: '100%' }}>
<CardHeader
title={
<Typography variant="h6" fontWeight="bold">
Actions
</Typography>
}
sx={{ paddingBottom: 0 }}
/>
<CardContent>
<h3>Actions</h3>
<Stack direction={'row'} spacing={2}>
<Card
onClick={() => {
Expand Down Expand Up @@ -246,11 +262,24 @@ export const CollectionOverview: FC<{
</Grid>
{taxa_count ? (
<Grid item xs={6}>
<Card sx={{ height: '100%' }}>
<Card sx={{ height: '100%', overflow: 'visible' }}>
<CardHeader
title={<Typography variant="h6">Taxa Counts</Typography>}
title={
<Typography variant="h6" fontWeight="bold">
Taxa Counts
</Typography>
}
sx={{ paddingBottom: 0 }}
/>
<TaxaCount collection_id={collection_id}></TaxaCount>
<CardContent>
<TaxaCount
collection_id={collection_id}
paperProps={{
variant: 'elevation',
elevation: 0,
}}
/>
</CardContent>
</Card>
</Grid>
) : (
Expand All @@ -265,6 +294,10 @@ export const CollectionOverview: FC<{
<SampleAttribs
mapOnly={true}
collection_id={collection_id}
paperProps={{
variant: 'elevation',
elevation: 0,
}}
></SampleAttribs>
</Card>
</Grid>
Expand Down
9 changes: 5 additions & 4 deletions src/features/collections/data_products/SampleAttribs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import {
useSelectionId,
} from '../collectionsSlice';
import classes from './../Collections.module.scss';
import { Grid, Paper, Stack } from '@mui/material';
import { Grid, Paper, PaperProps, Stack } from '@mui/material';
import { formatNumber } from '../../../common/utils/stringUtils';

export const SampleAttribs: FC<{
collection_id: string;
mapOnly?: boolean;
}> = ({ collection_id, mapOnly }) => {
paperProps?: PaperProps;
}> = ({ collection_id, mapOnly, paperProps }) => {
// Context
const dispatch = useAppDispatch();

Expand Down Expand Up @@ -235,7 +236,7 @@ export const SampleAttribs: FC<{
}, [L, leafletMap, markers]);

const map = (
<Paper variant="outlined">
<Paper variant="outlined" {...paperProps}>
<LeafletMap height={'800px'} map={leaflet} />
</Paper>
);
Expand All @@ -244,7 +245,7 @@ export const SampleAttribs: FC<{
return (
<Grid container columnSpacing={1}>
<Grid item md={6}>
<Paper variant="outlined">
<Paper variant="outlined" {...paperProps}>
<Stack
className={classes['table-toolbar']}
direction="row"
Expand Down
9 changes: 5 additions & 4 deletions src/features/collections/data_products/TaxaCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { useBackoffPolling } from '../../../common/hooks';
import { snakeCaseToHumanReadable } from '../../../common/utils/stringUtils';
import { useMatchId, useSelectionId } from '../collectionsSlice';
import classes from './TaxaCount.module.scss';
import { Paper, Stack } from '@mui/material';
import { Paper, PaperProps, Stack } from '@mui/material';

export const TaxaCount: FC<{
collection_id: string;
}> = ({ collection_id }) => {
paperProps?: PaperProps;
}> = ({ collection_id, paperProps }) => {
// Ranks
const ranksParams = useMemo(() => ({ collection_id }), [collection_id]);
const ranksQuery = listTaxaCountRanks.useQuery(ranksParams);
Expand All @@ -24,7 +25,7 @@ export const TaxaCount: FC<{
value: rank,
label: snakeCaseToHumanReadable(rank),
})) || [];
setRank(opts?.[0]);
setRank(opts?.[opts.length - 1]);
return opts;
}, [ranksQuery.data]);

Expand Down Expand Up @@ -58,7 +59,7 @@ export const TaxaCount: FC<{
if (ranksQuery.isLoading || countsQuery.isLoading) return <Loader />;

return (
<Paper variant="outlined">
<Paper variant="outlined" {...paperProps}>
<Stack spacing={1}>
<div className={classes['chart-toolbar']}>
<Select
Expand Down