Skip to content

Commit 158b5e1

Browse files
committed
backport edf info box to sn-editor
sn-webrtc contains a feature to display edf headers in a popup modal, this commit ports that feature to sn-editor
1 parent a42b57f commit 158b5e1

File tree

6 files changed

+698
-35
lines changed

6 files changed

+698
-35
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import _ from 'lodash';
4+
import { formatSize } from '../utils/utils';
5+
6+
const edfHeader = [
7+
'numberOfSignals',
8+
'start',
9+
'end',
10+
'patientIdentification',
11+
'recordIdentification',
12+
'recordHeaderByteSize',
13+
'numberOfDataRecords',
14+
'recordDurationTime',
15+
'recordSize',
16+
'recordSampleSize',
17+
];
18+
19+
const EdfInfoBox = ({ edf, onClose }) => (
20+
<div className="infobox">
21+
<button className="toggleInfobox" onClick={onClose}>
22+
×
23+
</button>
24+
{edf && (
25+
<section>
26+
<h2>EDF file header informationen</h2>
27+
<table>
28+
<thead>
29+
<tr>
30+
<th>EDF Header</th>
31+
<th>Value</th>
32+
</tr>
33+
</thead>
34+
<tbody>
35+
{edfHeader.map(key => (
36+
<tr key={key}>
37+
<td>{key}</td>
38+
<td>{`${edf.header[key]}`}</td>
39+
</tr>
40+
))}
41+
</tbody>
42+
</table>
43+
44+
<table>
45+
<thead>
46+
<tr>
47+
<th>Channel</th>
48+
<th>Label</th>
49+
<th>physical Dimension</th>
50+
<th>Number of Samples</th>
51+
<th>Digital min / max</th>
52+
<th>Physical min / max</th>
53+
</tr>
54+
</thead>
55+
<tbody>
56+
{edf.header.channels.map(channel => (
57+
<tr key={channel.index}>
58+
<td>{channel.index + 1}</td>
59+
<td>{channel.label}</td>
60+
<td>{channel.physicalDimension}</td>
61+
<td>{channel.numberOfSamples}</td>
62+
<td>
63+
{channel.digitalMinimum} / {channel.digitalMaximum}
64+
</td>
65+
<td>
66+
{channel.physicalMinimum} / {channel.physicalMaximum}
67+
</td>
68+
</tr>
69+
))}
70+
</tbody>
71+
</table>
72+
</section>
73+
)}
74+
</div>
75+
);
76+
77+
EdfInfoBox.propTypes = {
78+
edf: PropTypes.object,
79+
onClose: PropTypes.func,
80+
};
81+
82+
EdfInfoBox.defaultProps = {
83+
edf: null,
84+
onClose() {},
85+
};
86+
87+
export default EdfInfoBox;

sn-editor/src/containers/App.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import Dropzone from 'react-dropzone';
33
import queryString from 'query-string';
44
import EDF from 'components/EDF-View';
5+
import EdfInfoBox from 'components/EdfInfoBox';
56
import Controls from 'components/Controls';
67
import Sidebar from 'components/Sidebar';
78
import XNAT from 'components/Xnat';
@@ -15,6 +16,7 @@ export default class App extends Component {
1516
activeBundle: null,
1617
showSidebar: true,
1718
loggedIn: false,
19+
isInfoboxVisible: false,
1820
}
1921

2022
proxy = { onClick() {} }
@@ -100,6 +102,11 @@ export default class App extends Component {
100102
this.setState({ showSidebar });
101103
}
102104

105+
toggleInfobox = () => {
106+
const { isInfoboxVisible } = this.state;
107+
this.setState({ isInfoboxVisible: !isInfoboxVisible });
108+
};
109+
103110
renderEditor() {
104111
const { edf, artifacts } = this.state.activeBundle || {};
105112
const sidebarWidth = this.state.showSidebar ? '20rem' : '0rem';
@@ -135,15 +142,28 @@ export default class App extends Component {
135142
}
136143

137144
render() {
145+
const { edf } = this.state.activeBundle || {};
138146
const hasBundle = this.state.bundles.length > 0;
139147
const hasActiveBundle = !!this.state.activeBundle;
140148
const containerClass = `container ${hasBundle ? 'full-width' : ''}`;
149+
const isInfoboxVisible = this.state.isInfoboxVisible;
141150

142151
return (
143152
<div className={containerClass}>
144153
<header className="site-header dashed-bottom">
145154
<a href="." className="site-title">copla-editor</a>
146-
{hasActiveBundle && <Controls proxy={this.proxy} />}
155+
{hasActiveBundle && (
156+
<nav>
157+
<Controls proxy={this.proxy} />
158+
<button
159+
className="btn btn-default btn-ghost"
160+
onClick={this.toggleInfobox}
161+
title="Zeige Dateiinfos"
162+
>
163+
ℹ️️
164+
</button>
165+
</nav>
166+
)}
147167
{hasBundle && this.renderDropzone('site-nav')}
148168
</header>
149169

@@ -161,6 +181,13 @@ export default class App extends Component {
161181
<footer className="site-footer dashed-top">
162182
Gitlab: <a href="https://git.tools.f4.htw-berlin.de/somnonetz/copla-editor">somnonetz/copla-editor</a>
163183
</footer>
184+
185+
{isInfoboxVisible && (
186+
<EdfInfoBox
187+
edf={edf}
188+
onClose={this.toggleInfobox}
189+
/>
190+
)}
164191
</div>
165192
);
166193
}

sn-editor/src/index.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,44 @@
3434

3535
.select-box select, .select-box input {
3636
width: 100%;
37+
}
38+
39+
.infobox {
40+
z-index: 10;
41+
position: absolute;
42+
top: 6rem;
43+
left: 50%;
44+
transform: translateX(-50%);
45+
width: 60rem;
46+
padding: 1rem;
47+
max-width: calc(100% - 4rem);
48+
min-height: calc(100vh - 8rem);
49+
background: #eee;
50+
}
51+
52+
.infobox .toggleInfobox {
53+
position: absolute;
54+
top: 1px;
55+
right: 0.5rem;
56+
background: none;
57+
font-size: 32px;
58+
color: #333;
59+
}
60+
61+
.infobox table {
62+
width: 100%;
63+
margin-bottom: 1rem;
64+
}
65+
66+
.infobox table.fixed {
67+
table-layout: fixed;
68+
}
69+
70+
.infobox td {
71+
padding: 0.5rem;
72+
word-break: break-all;
73+
}
74+
75+
.infobox tr:nth-child(odd) td {
76+
background: #ddd;
3777
}

0 commit comments

Comments
 (0)