Skip to content

Commit 8ce31fb

Browse files
committed
chore: include mass_spectrometry_data_processing, mass_spectrometry_focused_ion and acquisition_chromatography in RecordView.tsx; close #82
1 parent b35b22f commit 8ce31fb

File tree

3 files changed

+125
-1
lines changed

3 files changed

+125
-1
lines changed

web-frontend/src/elements/record/AcquisitionTable.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ function AcquisitionTable({ acquisition, width, height }: InputProps) {
126126
key: 'key-ion-mode',
127127
});
128128

129+
if (acquisition.chromatography) {
130+
acquisition.chromatography.forEach((c, i) => {
131+
const split = splitStringAndCapitaliseFirstLetter(c.subtag, '_', ' ');
132+
dataSource.push({
133+
Parameter: split,
134+
Value: (
135+
<ExportableContent
136+
mode="copy"
137+
title={`Copy '${split}' to clipboard`}
138+
component={c.value}
139+
onClick={() => copyTextToClipboard(split, c.value)}
140+
/>
141+
),
142+
key: `key-chromatography-${i}`,
143+
});
144+
});
145+
}
146+
129147
if (acquisition.mass_spectrometry.subtags) {
130148
acquisition.mass_spectrometry.subtags.forEach((s, i) => {
131149
const split = splitStringAndCapitaliseFirstLetter(s.subtag, '_', ' ');
@@ -134,7 +152,7 @@ function AcquisitionTable({ acquisition, width, height }: InputProps) {
134152
Value: (
135153
<ExportableContent
136154
mode="copy"
137-
title={"Copy '${split}' to clipboard"}
155+
title={`Copy '${split}' to clipboard`}
138156
component={s.value}
139157
onClick={() => copyTextToClipboard(split, s.value)}
140158
/>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import './Table.scss';
2+
3+
import { Table } from 'antd';
4+
import { CSSProperties, useMemo } from 'react';
5+
import { splitStringAndCapitaliseFirstLetter } from '../../utils/stringUtils';
6+
import ExportableContent from '../common/ExportableContent';
7+
import copyTextToClipboard from '../../utils/copyTextToClipboard';
8+
import MassSpectrometry from '../../types/record/MassSpectrometry';
9+
10+
type InputProps = {
11+
massSpectrometry: MassSpectrometry | undefined;
12+
width: CSSProperties['width'];
13+
height: CSSProperties['height'];
14+
};
15+
16+
function MassSpectrometryTable({
17+
massSpectrometry,
18+
width,
19+
height,
20+
}: InputProps) {
21+
return useMemo(() => {
22+
if (!massSpectrometry) {
23+
return null;
24+
}
25+
26+
const columns = [
27+
{
28+
title: 'Parameter',
29+
dataIndex: 'Parameter',
30+
key: 'parameter',
31+
align: 'center' as const,
32+
},
33+
{
34+
title: 'Value',
35+
dataIndex: 'Value',
36+
key: 'value',
37+
align: 'center' as const,
38+
},
39+
];
40+
41+
const dataSource: { [key: string]: string | JSX.Element }[] = [];
42+
43+
if (massSpectrometry.focused_ion) {
44+
massSpectrometry.focused_ion.forEach((c, i) => {
45+
const split = splitStringAndCapitaliseFirstLetter(c.subtag, '_', ' ');
46+
dataSource.push({
47+
Parameter: split,
48+
Value: (
49+
<ExportableContent
50+
mode="copy"
51+
title={`Copy '${split}' to clipboard`}
52+
component={c.value}
53+
onClick={() => copyTextToClipboard(split, c.value)}
54+
/>
55+
),
56+
key: `key-chromatography-${i}`,
57+
});
58+
});
59+
}
60+
61+
if (massSpectrometry.data_processing) {
62+
massSpectrometry.data_processing.forEach((s, i) => {
63+
const split = splitStringAndCapitaliseFirstLetter(s.subtag, '_', ' ');
64+
dataSource.push({
65+
Parameter: split,
66+
Value: (
67+
<ExportableContent
68+
mode="copy"
69+
title={`Copy '${split}' to clipboard`}
70+
component={s.value}
71+
onClick={() => copyTextToClipboard(split, s.value)}
72+
/>
73+
),
74+
key: `key-subtag-${i}`,
75+
});
76+
});
77+
}
78+
79+
return (
80+
<Table
81+
className="table"
82+
style={{ width, height }}
83+
sticky
84+
columns={columns}
85+
dataSource={dataSource}
86+
pagination={false}
87+
/>
88+
);
89+
}, [height, massSpectrometry, width]);
90+
}
91+
92+
export default MassSpectrometryTable;

web-frontend/src/elements/record/RecordView.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import InformationTable from './InformationTable';
1212
import SectionDivider from '../basic/SectionDivider';
1313
import Segmented from '../basic/Segmented';
1414
import segmentedWidth from '../../constants/segmentedWidth';
15+
import MassSpectrometryTable from './MassSpectrometryTable';
1516

1617
type inputProps = {
1718
record: Record;
@@ -89,6 +90,19 @@ function RecordView({ record, width, height }: inputProps) {
8990
elementLabels.push('Peak Annotation');
9091
}
9192

93+
const massSpectrometry = (
94+
<Content>
95+
{buildDivider('Mass Spectrometry')}
96+
<MassSpectrometryTable
97+
massSpectrometry={record.mass_spectrometry}
98+
width="100%"
99+
height="auto"
100+
/>
101+
</Content>
102+
);
103+
elements.push(massSpectrometry);
104+
elementLabels.push('Mass Spectrometry');
105+
92106
const acquisition = (
93107
<Content>
94108
{buildDivider('Acquisition')}

0 commit comments

Comments
 (0)