-
Notifications
You must be signed in to change notification settings - Fork 210
/
SystemLog.js
105 lines (92 loc) · 2.55 KB
/
SystemLog.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React from 'react';
import {SystemLogContext} from './Contexts/SystemLogContext'
import {Toast, Container, Row, Col, Button, Card} from 'react-bootstrap'
/*
@name SystemLogStatus
@ddescription consumer for system log status
*/
//class SystemLogStatus extends React.Component {
const SystemLogStatus = (props) => {
const [show, setShow] = React.useState(false);
return (
<SystemLogContext.Consumer>
{({system_log_status}) => (
<>
<p className="systemlogp">
System Status From Server: {system_log_status}
</p>
</>
)}
</SystemLogContext.Consumer>
)
}
/*
@name SystemLog
@description component as provider for system log status
*/
class SystemLog extends React.Component {
constructor(props) {
super(props);
this.API_SERVER = "http://localhost:5000"
this.state = {
system_log_status: 1
}
}
async loadSystemStatus() {
try{
let complete_endpoint = this.API_SERVER+"/display/get_all_entities"
const res = await fetch(complete_endpoint)
const json_response = await res.json()
this.setState({
system_log_status: this.state.system_log_status + 1
});
}catch(e){
console.log(e);
this.setState({
system_log_status: this.state.system_log_status + 1
});
}
}
async componentDidMount() {
/*
let complete_endpoint = this.API_SERVER+"/display/get_all_entities"
let complete_endpoint = this.API_SERVER+"/display/get_all_users"
let complete_endpoint = this.API_SERVER+"/display/get_system_log"
*/
try {
setInterval(async () => {
// async call to load system status
//this.loadSystemStatus()
}, 1000);
} catch(e) {
console.log(e);
}
}
render(){
console.log("rendering system log")
return (
<SystemLogContext.Provider value={this.state}>
<Container className="systemLogContainer">
<Row>
<Col lg={{span: 12, offset: 0}} className="system_log">
<Card lg={{span: 12, offset: 1}}>
<Card.Body>
<Card.Text>
<Container>
<Row>
<Col lg={{span: 12, offset: 0}}>
<SystemLogStatus/>
</Col>
</Row>
</Container>
</Card.Text>
</Card.Body>
</Card>
</Col>
</Row>
</Container>
</SystemLogContext.Provider>
)
}
}
export default SystemLog;