Skip to content

Commit bd5ad3f

Browse files
Merge pull request #498 from bento-platform/feat/display_instrument_ontology
feat(explorer): display instrument device / ontology
2 parents 9594a9e + a2999c6 commit bd5ad3f

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

src/components/explorer/IndividualExperiments.js

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { Button, Descriptions, Popover, Table, Tooltip, Typography } from "antd"
66
import { BarsOutlined, EyeOutlined, FileTextOutlined, ProfileOutlined } from "@ant-design/icons";
77

88
import { EM_DASH } from "@/constants";
9-
import { experimentPropTypesShape, experimentResultPropTypesShape, individualPropTypesShape } from "@/propTypes";
9+
import {
10+
experimentPropTypesShape,
11+
experimentResultPropTypesShape,
12+
individualPropTypesShape,
13+
ontologyShape,
14+
} from "@/propTypes";
1015
import { getFileDownloadUrlsFromDrs } from "@/modules/drs/actions";
1116
import { useAppDispatch, useAppSelector } from "@/store";
1217
import { guessFileType } from "@/utils/files";
@@ -136,6 +141,35 @@ const EXPERIMENT_RESULTS_COLUMNS = [
136141
},
137142
];
138143

144+
const Device = ({ device, deviceOntology }) => {
145+
if (device && deviceOntology) {
146+
return (
147+
<div>
148+
<strong>Device:</strong>&nbsp;{device} (<OntologyTerm term={deviceOntology} />)
149+
</div>
150+
);
151+
} else if (!device && deviceOntology) {
152+
return (
153+
<div>
154+
<strong>Device:</strong>&nbsp;
155+
<OntologyTerm term={deviceOntology} />
156+
</div>
157+
);
158+
} else if (device && !deviceOntology) {
159+
return (
160+
<div>
161+
<strong>Device:</strong>&nbsp;{device}
162+
</div>
163+
);
164+
} else {
165+
return null;
166+
}
167+
};
168+
Device.propTypes = {
169+
device: PropTypes.string,
170+
deviceOntology: ontologyShape,
171+
};
172+
139173
export const ExperimentDetail = ({ experiment }) => {
140174
const {
141175
id,
@@ -208,12 +242,15 @@ export const ExperimentDetail = ({ experiment }) => {
208242
</Descriptions.Item>
209243
<Descriptions.Item span={2} label="Instrument">
210244
<div style={{ display: "flex", gap: 16 }}>
211-
<div>
212-
<strong>Platform:</strong>&nbsp;{instrument.platform}
213-
</div>
214-
<div>
215-
<strong>ID:</strong>&nbsp;<MonospaceText>{instrument.identifier}</MonospaceText>
216-
</div>
245+
<Device device={instrument.device} deviceOntology={instrument.device_ontology} />
246+
{instrument.description && (
247+
<div>
248+
<strong>Description:</strong>&nbsp;{instrument.description}
249+
</div>
250+
)}
251+
{Object.keys(instrument.extra_properties ?? {}).length ? (
252+
<ExtraProperties extraProperties={extraProperties} />
253+
) : null}
217254
</div>
218255
</Descriptions.Item>
219256
<Descriptions.Item span={2} label="Extra Properties">

src/propTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ export const experimentPropTypesShape = PropTypes.shape({
311311
platform: PropTypes.string,
312312
description: PropTypes.string,
313313
model: PropTypes.string,
314+
device: PropTypes.string,
315+
device_ontology: ontologyShape,
314316
}),
315317

316318
experiment_results: PropTypes.arrayOf(experimentResultPropTypesShape),

0 commit comments

Comments
 (0)