forked from KathiraveluLab/DHGWorkflow
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathLogs.jsx
More file actions
51 lines (45 loc) · 1.72 KB
/
Logs.jsx
File metadata and controls
51 lines (45 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useState, useEffect } from 'react';
import './logs.css';
import { actionType as T } from '../reducer';
const Logs = ({ superState, dispatcher }) => {
const [output, setOutput] = useState('');
const clearTerminal = () => {
setOutput('');
dispatcher({ type: T.SET_LOGS_MESSAGE, payload: '' });
};
const closeTerminal = () => {
dispatcher({ type: T.SET_LOGS, payload: false });
};
useEffect(() => {
if (superState.logs) {
document.getElementById('outlay').style.display = 'block';
document.getElementById('terminal').style.display = 'block';
setOutput(superState.logsmessage);
} else {
document.getElementById('terminal').style.display = 'none';
document.getElementById('outlay').style.display = 'none';
setOutput(superState.logsmessage);
}
}, [superState.logs]);
return (
<>
<div className="outlay" id="outlay">
<div className="terminal" id="terminal">
<div className="terminal-header">
Logs
<button type="button" className="clear" onClick={clearTerminal}>Clear</button>
<button type="button" className="closelogs" onClick={closeTerminal}>X</button>
</div>
<div className="terminal-body">
{output.split('\n').map((line) => (
<div className="terminal-line">
{line}
</div>
))}
</div>
</div>
</div>
</>
);
};
export default Logs;