Skip to content

Commit

Permalink
chore: change file summary location (#701)
Browse files Browse the repository at this point in the history
#595 
- changes file summary location + style
- changes style of subtitles in run overview
- fetches frame data
  • Loading branch information
kne42 authored May 8, 2024
1 parent 948c8f2 commit 2ab75e8
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 33 deletions.
67 changes: 67 additions & 0 deletions frontend/packages/data-portal/app/components/InlineMetadata.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { cns } from 'app/utils/cns'

export interface Metadata {
key: string
value: string
uppercase?: boolean
}

export function InlineMetadata({
label,
fields,
subheader = false,
}: {
label?: string
fields: Metadata[]
subheader?: boolean
}) {
const fieldsRender = (
<ul className="list-none flex gap-sds-l items-baseline">
{fields.map(({ key, value, uppercase }) => (
<li
className={cns(
'flex flex-row items-baseline justify-left gap-sds-xxs',
subheader && 'text-sds-gray-500',
)}
key={key + value}
>
<span
className={cns(
'font-semibold',
subheader
? 'text-sds-gray-600 tracking-sds-caps text-sds-caps-xxs leading-sds-caps-xxs'
: 'text-sds-body-xxs leading-sds-body-xxs',
uppercase && 'uppercase',
subheader && uppercase && 'tracking-sds-caps',
)}
>
{key}:
</span>

<span
className={
subheader
? 'text-sds-body-s leading-sds-body-s'
: 'text-sds-body-xxs leading-sds-body-xxs'
}
>
{value}
</span>
</li>
))}
</ul>
)

if (label) {
return (
<div className="flex flex-row gap-sds-xl text-sds-gray-black items-baseline">
<span className="text-sds-caps-xxxs leading-sds-caps-xxxs font-semibold uppercase tracking-sds-caps">
{label}
</span>
{fieldsRender}
</div>
)
}

return fieldsRender
}
32 changes: 3 additions & 29 deletions frontend/packages/data-portal/app/components/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { Button, Icon } from '@czi-sds/components'
import { useSearchParams } from '@remix-run/react'
import { ReactNode } from 'react'

import { InlineMetadata, Metadata } from 'app/components/InlineMetadata'
import { Link } from 'app/components/Link'
import { useI18n } from 'app/hooks/useI18n'
import { cns } from 'app/utils/cns'

interface PageHeaderMetadata {
key: string
value: string
uppercase?: boolean
}

export function PageHeader({
actions,
backToResultsLabel,
Expand All @@ -25,7 +20,7 @@ export function PageHeader({
actions?: ReactNode
backToResultsLabel?: string
lastModifiedDate?: string
metadata?: PageHeaderMetadata[]
metadata?: Metadata[]
onMoreInfoClick?(): void
releaseDate?: string
renderHeader?({ moreInfo }: { moreInfo?: ReactNode }): ReactNode
Expand Down Expand Up @@ -86,29 +81,8 @@ export function PageHeader({
{title}
</h1>

{/* metadata */}
{metadata.length > 0 && (
<ul className="list-none flex gap-sds-l">
{metadata.map(({ key, value, uppercase }) => (
<li
className="flex flex-row items-center justify-left gap-sds-xxs text-sds-gray-500"
key={key + value}
>
<span
className={cns(
'font-semibold text-sds-caps-xxs leading-sds-caps-xxs tracking-[0.3px]',
uppercase && 'uppercase',
)}
>
{key}:
</span>

<span className="text-sds-body-s leading-sds-body-s">
{value}
</span>
</li>
))}
</ul>
<InlineMetadata fields={metadata} subheader />
)}
</div>

Expand Down
53 changes: 52 additions & 1 deletion frontend/packages/data-portal/app/components/Run/RunHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Button, Icon } from '@czi-sds/components'
import { sum } from 'lodash-es'

import { I18n } from 'app/components/I18n'
import { InlineMetadata } from 'app/components/InlineMetadata'
import { KeyPhoto } from 'app/components/KeyPhoto'
import { Link } from 'app/components/Link'
import { PageHeader } from 'app/components/PageHeader'
Expand All @@ -18,6 +20,24 @@ import { useRunById } from 'app/hooks/useRunById'
import { i18n } from 'app/i18n'
import { getTiltRangeLabel } from 'app/utils/tiltSeries'

interface FileSummaryData {
key: string
value: number
}

function FileSummary({ data }: { data: FileSummaryData[] }) {
const { t } = useI18n()
return (
<InlineMetadata
label={t('fileSummary')}
fields={data.map(({ key, value }) => ({
key,
value: t('fileCount', { count: value }),
}))}
/>
)
}

export function RunHeader() {
const { run } = useRunById()
const { toggleDrawer } = useMetadataDrawer()
Expand Down Expand Up @@ -67,7 +87,6 @@ export function RunHeader() {
</>
}
backToResultsLabel={run.dataset.title}
lastModifiedDate="2023-12-16"
metadata={[{ key: t('runId'), value: `${run.id}` }]}
onMoreInfoClick={() => toggleDrawer(MetadataDrawerId.Run)}
title={run.name}
Expand All @@ -86,6 +105,38 @@ export function RunHeader() {
<div className="flex flex-col gap-sds-xl flex-auto pt-sds-l">
<PageHeaderSubtitle>{t('runOverview')}</PageHeaderSubtitle>

<FileSummary
data={[
{
key: t('frames'),
value:
run.tiltseries_aggregate.aggregate?.sum?.frames_count ?? 0,
},
{
key: t('tiltSeries'),
value: run.tiltseries_aggregate.aggregate?.count ?? 0,
},
{
key: t('tomograms'),
value: sum(
run.tomogram_stats.flatMap(
(stats) =>
stats.tomograms_aggregate.aggregate?.count ?? 0,
),
),
},
{
key: t('annotations'),
value: sum(
run.tomogram_stats.flatMap(
(stats) =>
stats.annotations_aggregate.aggregate?.count ?? 0,
),
),
},
]}
/>

<div className="flex gap-sds-xxl flex-col lg:flex-row">
<MetadataTable
title={i18n.tiltSeries}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function MetadataTable({
return (
<div className="flex flex-col gap-sds-m">
{title && (
<p className="text-sds-header-m leading-sds-header-m font-semibold">
<p className="text-sds-caps-xxxs leading-sds-caps-xxxs tracking-sds-caps uppercase font-semibold">
{title}
</p>
)}
Expand Down
12 changes: 12 additions & 0 deletions frontend/packages/data-portal/app/graphql/getRunById.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ const GET_RUN_BY_ID_QUERY = gql(`
}
}
tomograms_aggregate {
aggregate {
count
}
}
tomogram_processing: tomograms(distinct_on: processing) {
processing
}
Expand All @@ -201,6 +207,12 @@ const GET_RUN_BY_ID_QUERY = gql(`
avg {
tilt_series_quality
}
sum {
frames_count
}
count
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@
"false": "False",
"faq": "FAQ",
"fiducialAlignmentStatus": "Fiducial Alignment Status",
"fileCount_one": "{{count}} File",
"fileCount_other": "{{count}} Files",
"fileCount_one": "{{count}} file",
"fileCount_other": "{{count}} files",
"fileFormat": "File Format",
"fileFormatTooltipMrc": "<url to='$t(mrcLink)'>MRC</url>: standard format for CryoET data",
"fileFormatTooltipNdJson": "<url to='$t(ndJsonLink)'>Newline Delimited JSON</url>: format used for point annotations where each point is a JSON on its own line",
"fileFormatTooltipZarr": "<url to='$t(zarrLink)'>OME-Zarr</url>: optimized format for large data",
"fileMrc": "MRC (.mrc)",
"fileNdJson": "Newline Delimited JSON (.ndjson)",
"fileOmeZarr": "OME-ZARR (.zarr)",
"fileSummary": "File Summary",
"filterBy": "Filter by",
"filterByAnyOfTheFollowing": "Filter by any of the following",
"filterCountOfMaxType": "{{count}} of {{max}} {{type}}",
Expand Down

0 comments on commit 2ab75e8

Please sign in to comment.