-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathViewLogs.jsx
More file actions
executable file
·82 lines (75 loc) · 2.4 KB
/
ViewLogs.jsx
File metadata and controls
executable file
·82 lines (75 loc) · 2.4 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { Component } from 'react';
import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
import CommunicationsList from './CommunicationsListFull';
import Button from '@material-ui/core/Button';
import RefreshIcon from '@material-ui/icons/Refresh';
class Logs extends Component {
constructor(){
super();
this.state = {
messages: [],
is_empty: false,
error_message: ''
}
}
handleRefresh(){
fetch('/api/communications?newest-first=true')
.then( response => {
return response.json();
}).then(data => {
if (data.status == 'success'){
this.setState({
messages: data.data.messages,
is_empty: false
})
} else{
console.log('get failed')
this.setState({
is_empty: true,
error_message: 'error fetching messages: ' + data.message
})
}
});
}
componentDidMount(){
this.handleRefresh();
}
handleError(){
if (!(this.state.error_message === '')){
return (
<div>
<Typography style={{color: 'red'}}>
{this.state.error_message}
</Typography>
</div>
);
}
}
render(){
// const { classes } = this.props;
return (
<div>
{this.handleError()}
<div>
<Button
style={{
marginBottom:"1%"
}}
color="primary"
onClick={ () => this.handleRefresh()}
variant="outlined">
<RefreshIcon></RefreshIcon>
Refresh
</Button>
</div>
<div>
<Paper style={{paddingTop:"1%", paddingBottom:"2%"}}>
<CommunicationsList autoScroll={false} showQueueButton={true} displayLog={this.state.messages} isEmpty={this.state.is_empty}/>
</Paper>
</div>
</div>
);
}
}
export default Logs;