-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
single run annotation metadata (#155)
#111 - Refactors code to use [remix-typedjson](https://github.com/kiliman/remix-typedjson) for better typing when using loader data - Add state for active annotation data - Implements new components for the annotation drawer ## Demo <img width="274" alt="image" src="https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/473115bc-fbd6-45ae-b995-0cd25a2b7518">
- Loading branch information
1 parent
0747e76
commit ed7b04e
Showing
31 changed files
with
385 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
frontend/packages/data-portal/app/components/Dataset/SampleAndExperimentConditionsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
frontend/packages/data-portal/app/components/Run/AnnotationConfidenceTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { AccordionMetadataTable } from 'app/components/AccordionMetadataTable' | ||
import { i18n } from 'app/i18n' | ||
import { useAnnotation } from 'app/state/annotation' | ||
|
||
export function AnnotationConfidenceTable() { | ||
const { activeAnnotation: annotation } = useAnnotation() | ||
|
||
if (!annotation) { | ||
return null | ||
} | ||
|
||
const isGroundTruth = annotation.ground_truth_status | ||
|
||
return ( | ||
<AccordionMetadataTable | ||
id="annotation-confidence" | ||
header={i18n.annotationConfidence} | ||
data={[ | ||
{ | ||
label: i18n.groundTruthStatus, | ||
values: [isGroundTruth ? i18n.true : i18n.false], | ||
}, | ||
{ | ||
label: i18n.curatorRecommended, | ||
values: ['TBD'], | ||
}, | ||
{ | ||
label: i18n.groundTruthUsed, | ||
values: [ | ||
isGroundTruth | ||
? i18n.notApplicable | ||
: annotation.ground_truth_used ?? '--', | ||
], | ||
}, | ||
{ | ||
label: i18n.precision, | ||
values: [ | ||
isGroundTruth | ||
? i18n.notApplicable | ||
: annotation.confidence_precision ?? '--', | ||
], | ||
}, | ||
{ | ||
label: i18n.recall, | ||
values: [ | ||
isGroundTruth | ||
? i18n.notApplicable | ||
: annotation.confidence_recall ?? '--', | ||
], | ||
}, | ||
]} | ||
/> | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
frontend/packages/data-portal/app/components/Run/AnnotationDrawer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { MetadataDrawer } from 'app/components/MetadataDrawer' | ||
import { i18n } from 'app/i18n' | ||
import { useAnnotation } from 'app/state/annotation' | ||
import { getAnnotationTitle } from 'app/utils/annotation' | ||
|
||
import { AnnotationConfidenceTable } from './AnnotationConfidenceTable' | ||
import { AnnotationObjectTable } from './AnnotationObjectTable' | ||
import { AnnotationOverviewTable } from './AnnotationOveriewTable' | ||
|
||
export function AnnotationDrawer() { | ||
const { activeAnnotation, setActiveAnnotation } = useAnnotation() | ||
|
||
return ( | ||
<MetadataDrawer | ||
disabled={!activeAnnotation} | ||
drawerId="annotation-metadata" | ||
label={i18n.annotationDetails} | ||
title={getAnnotationTitle(activeAnnotation)} | ||
onClose={() => setActiveAnnotation(null)} | ||
> | ||
<AnnotationOverviewTable /> | ||
<AnnotationObjectTable /> | ||
<AnnotationConfidenceTable /> | ||
</MetadataDrawer> | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
frontend/packages/data-portal/app/components/Run/AnnotationObjectTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { AccordionMetadataTable } from 'app/components/AccordionMetadataTable' | ||
import { i18n } from 'app/i18n' | ||
import { useAnnotation } from 'app/state/annotation' | ||
|
||
export function AnnotationObjectTable() { | ||
const { activeAnnotation: annotation } = useAnnotation() | ||
|
||
if (!annotation) { | ||
return null | ||
} | ||
|
||
return ( | ||
<AccordionMetadataTable | ||
id="annotation-object" | ||
header={i18n.annotationObject} | ||
data={[ | ||
{ | ||
label: i18n.objectName, | ||
values: [annotation.object_name], | ||
}, | ||
{ | ||
label: i18n.goId, | ||
values: ['TBD'], | ||
}, | ||
{ | ||
label: i18n.objectShapeType, | ||
values: [annotation.shape_type], | ||
}, | ||
{ | ||
label: i18n.objectState, | ||
values: [annotation.object_state ?? '--'], | ||
}, | ||
{ | ||
label: i18n.objectDescription, | ||
values: [annotation.object_description ?? '--'], | ||
}, | ||
]} | ||
/> | ||
) | ||
} |
64 changes: 64 additions & 0 deletions
64
frontend/packages/data-portal/app/components/Run/AnnotationOveriewTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { AccordionMetadataTable } from 'app/components/AccordionMetadataTable' | ||
import { i18n } from 'app/i18n' | ||
import { useAnnotation } from 'app/state/annotation' | ||
|
||
export function AnnotationOverviewTable() { | ||
const { activeAnnotation: annotation } = useAnnotation() | ||
|
||
if (!annotation) { | ||
return null | ||
} | ||
|
||
return ( | ||
<AccordionMetadataTable | ||
id="annotation-overview" | ||
header={i18n.annotationOverview} | ||
data={[ | ||
{ | ||
label: i18n.depositionDate, | ||
values: [annotation.deposition_date], | ||
}, | ||
{ | ||
label: i18n.releaseDateBlank, | ||
values: [annotation.release_date], | ||
}, | ||
{ | ||
label: i18n.lastModifiedBlank, | ||
values: [annotation.last_modified_date ?? '--'], | ||
}, | ||
{ | ||
label: i18n.authorsMaybePlural, | ||
// TODO render author emails | ||
// TODO render bold primary author | ||
values: annotation.authors.map((author) => author.name), | ||
}, | ||
{ | ||
label: i18n.lastModifiedBlank, | ||
values: [annotation.last_modified_date ?? '--'], | ||
}, | ||
{ | ||
label: i18n.affiliationNames, | ||
values: Array.from( | ||
new Set( | ||
annotation.author_affiliations | ||
.flatMap((author) => author.affiliation_name) | ||
.filter((value): value is string => !!value), | ||
), | ||
), | ||
}, | ||
{ | ||
label: i18n.publications, | ||
values: [annotation.annotation_publication ?? '--'], | ||
}, | ||
{ | ||
label: i18n.annotationMethod, | ||
values: [annotation.annotation_method], | ||
}, | ||
{ | ||
label: i18n.annotationSoftware, | ||
values: [annotation.annotation_software ?? '--'], | ||
}, | ||
]} | ||
/> | ||
) | ||
} |
Oops, something went wrong.