Skip to content

Commit

Permalink
Show more algorithm details in occurrence identification history (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihow authored Apr 18, 2024
1 parent a4e4cec commit a9f6bc1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui/src/data-services/models/algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class Algorithm {
return this._algorithm.name
}

get url(): string {
return this._algorithm.url
}

get updatedAt(): string | undefined {
if (!this._algorithm.updated_at) {
return undefined
Expand Down
4 changes: 4 additions & 0 deletions ui/src/data-services/models/occurrence-details.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash'
import { getFormatedTimeString } from 'utils/date/getFormatedTimeString/getFormatedTimeString'
import { UserPermission } from 'utils/user/types'
import { Algorithm } from './algorithm'
import { Occurrence, ServerOccurrence } from './occurrence'
import { Taxon } from './taxa'

Expand All @@ -12,6 +13,7 @@ export interface Identification {
overridden?: boolean
taxon: Taxon
comment?: string
algorithm?: Algorithm
userPermissions: UserPermission[]
createdAt: string
}
Expand All @@ -26,6 +28,7 @@ export interface HumanIdentification extends Identification {
}

export interface MachinePrediction extends Identification {
algorithm: Algorithm
score: number
}

Expand Down Expand Up @@ -80,6 +83,7 @@ export class OccurrenceDetails extends Occurrence {
overridden,
taxon,
score: p.score,
algorithm: p.algorithm,
userPermissions: p.user_permissions,
createdAt: p.created_at,
}
Expand Down
6 changes: 6 additions & 0 deletions ui/src/design-system/variables/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@
line-height: 15px;
text-transform: uppercase;
}

@mixin mono {
@include paragraph-xx-small();
font-family: monospace;
font-weight: 400;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import 'src/design-system/variables/variables.scss';
@import 'src/design-system/variables/colors.scss';
@import 'src/design-system/variables/typography.scss';

.algorithmDetails {
display: block;
@include mono();
padding-bottom: 2px;
color: $color-neutral-600;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Algorithm } from 'data-services/models/algorithm'
import { Tooltip } from 'design-system/components/tooltip/tooltip'
import styles from './algorithm-details.module.scss'

export const AlgorithmDetails = ({ algorithm }: { algorithm: Algorithm | undefined }) => {
return algorithm ? (
<Tooltip content={`id: ${algorithm.id} created: ${algorithm.description} jobs: `}>
<div className={styles.algorithmDetails}>
{algorithm.name}
</div>
</Tooltip>
) : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.content {
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
position: relative;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { STRING, translate } from 'utils/language'
import { UserInfo, UserPermission } from 'utils/user/types'
import { Agree } from '../agree/agree'
import { userAgreed } from '../agree/userAgreed'
import { AlgorithmDetails } from '../algorithm-details/algorithm-details'
import { StatusLabel } from '../status-label/status-label'
import styles from './identification-card.module.scss'

Expand Down Expand Up @@ -61,6 +62,7 @@ export const IdentificationCard = ({
{identification.applied && (
<StatusLabel label={translate(STRING.ID_APPLIED)} />
)}
<AlgorithmDetails algorithm={identification.algorithm} />
<TaxonInfo
overridden={identification.overridden}
taxon={identification.taxon}
Expand Down

0 comments on commit a9f6bc1

Please sign in to comment.