Skip to content

Commit cdb7853

Browse files
committed
Event table prototype
1 parent 1817c8a commit cdb7853

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

src/App.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import Box from '@material-ui/core/Box';
88
import IconButton from '@material-ui/core/IconButton';
99
import RefreshIcon from '@material-ui/icons/Refresh';
1010
import DeveloperModeIcon from '@material-ui/icons/DeveloperMode'
11+
import { startOfToday, formatRelative } from 'date-fns'
1112

1213

1314
import './App.css';
1415
import Status from './Status';
16+
import StatusTable from './StatusTable';
1517
import Debug from './Debug';
1618

1719
import { getStatus } from './api';
@@ -31,9 +33,9 @@ class App extends Component {
3133

3234
async newSetStatusInfo() {
3335
try {
34-
this.setState({statusJson: await getStatus()});
36+
this.setState({ statusJson: await getStatus() });
3537
} catch (error) {
36-
this.setState({error: error.message})
38+
this.setState({ error: error.message })
3739
}
3840
}
3941

@@ -67,7 +69,13 @@ class App extends Component {
6769
</Toolbar>
6870
</AppBar>
6971
<Box mx={2}>
72+
{ this.state.statusJson ? (
73+
<Typography>
74+
Last event collection &amp; analysis time {' was '.concat(formatRelative(new Date(this.state.statusJson.currentStats.lastAnalysisDate), startOfToday()))}<br />
75+
</Typography>
76+
) : <br />}
7077
<Status statusJson={this.state.statusJson} />
78+
<StatusTable />
7179
{this.state.showDebugInfo ? (
7280
<Debug debugInfo={this.state.statusJson} />
7381
) : (<br />)}
@@ -77,5 +85,4 @@ class App extends Component {
7785
}
7886
}
7987

80-
8188
export default App;

src/Status.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ class Status extends Component {
6161
<ReferenceArea x1={firstYesterday.name} />
6262
</BarChart>
6363
</ResponsiveContainer>
64-
<Typography>
64+
{/* <Typography>
6565
Last event collection &amp; analysis time {' was '.concat(formatRelative(new Date(this.props.statusJson.currentStats.lastAnalysisDate), startOfToday()))}<br />
6666
<br /><u>24 Hour totals:</u><br />
6767
Loss of FEC: {(this.props.statusJson["24HoursAgoToNow"].CMStatus16Count) || 0}<br />
6868
Recovery of FEC: {(this.props.statusJson["24HoursAgoToNow"].CMStatus24Count) || 0}<br />
6969
T3 Timeouts: {(this.props.statusJson["24HoursAgoToNow"].T3TimeoutCount) || 0}<br />
7070
T4 Timeouts: {(this.props.statusJson["24HoursAgoToNow"].T4TimeoutCount) || 0}
71-
</Typography>
71+
</Typography> */}
7272
</div>)
7373
}
7474
}

src/StatusTable.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import { makeStyles } from '@material-ui/core/styles';
3+
import Table from '@material-ui/core/Table';
4+
import TableBody from '@material-ui/core/TableBody';
5+
import TableCell from '@material-ui/core/TableCell';
6+
import TableContainer from '@material-ui/core/TableContainer';
7+
import TableHead from '@material-ui/core/TableHead';
8+
import TableRow from '@material-ui/core/TableRow';
9+
import Paper from '@material-ui/core/Paper';
10+
11+
const useStyles = makeStyles({
12+
table: {
13+
minWidth: 650,
14+
},
15+
tablecell: {
16+
fontSize: '9pt'
17+
},
18+
});
19+
20+
function createData(index, time, priority, description) {
21+
return { index, time, priority, description };
22+
}
23+
24+
const rows = [
25+
createData(0, '2020-05-26, 09:00:33', 'Notice (6)', 'CM-STATUS message sent. Event Type Code: 24; Chan ID: 33 ; DSID: N/A; MAC Addr: N/A; OFDM/OFDMA Profile ID: 1 2 3 .;CM-MAC=3c:37:86:e8:47:20;CMTS-MAC=00:17:10:8d:ef:a4;CM-QOS=1.1;CM-VER=3.1;'),
26+
createData(1, '2020-05-26, 09:00:24', 'Notice (6)', 'CM-STATUS message sent. Event Type Code: 16; Chan ID: 33 ; DSID: N/A; MAC Addr: N/A; OFDM/OFDMA Profile ID: 3 .;CM-MAC=3c:37:86:e8:47:20;CMTS-MAC=00:17:10:8d:ef:a4;CM-QOS=1.1;CM-VER=3.1;'),
27+
createData(2, '2020-05-26, 04:24:51', 'Error (4)', 'DHCP RENEW WARNING - Field invalid in response v4 option;CM-MAC=3c:37:86:e8:47:20;CMTS-MAC=00:17:10:8d:ef:a4;CM-QOS=1.1;CM-VER=3.1;'),
28+
createData(3, '2020-05-26, 04:20:37', 'Notice (6)', 'CM-STATUS message sent. Event Type Code: 24; Chan ID: 33 ; DSID: N/A; MAC Addr: N/A; OFDM/OFDMA Profile ID: 1 2 3 .;CM-MAC=3c:37:86:e8:47:20;CMTS-MAC=00:17:10:8d:ef:a4;CM-QOS=1.1;CM-VER=3.1;'),
29+
createData(4, '2020-05-26, 04:20:25', 'Notice (6)', 'CM-STATUS message sent. Event Type Code: 16; Chan ID: 33 ; DSID: N/A; MAC Addr: N/A; OFDM/OFDMA Profile ID: 3 .;CM-MAC=3c:37:86:e8:47:20;CMTS-MAC=00:17:10:8d:ef:a4;CM-QOS=1.1;CM-VER=3.1;'),
30+
];
31+
32+
export default function DenseTable() {
33+
const classes = useStyles();
34+
35+
return (
36+
<TableContainer component={Paper}>
37+
<Table className={classes.table} size="small" aria-label="a dense table">
38+
<TableHead>
39+
<TableRow>
40+
<TableCell style={{ width: "15%", padding: "6px", fontSize: "9pt" }}>Time</TableCell>
41+
<TableCell style={{ width: "10%", padding: "6px", fontSize: "9pt" }}>Priority</TableCell>
42+
<TableCell style={{ width: "75%", padding: "6px", fontSize: "9pt" }}>Description</TableCell>
43+
</TableRow>
44+
</TableHead>
45+
<TableBody>
46+
{rows.map((row) => (
47+
<TableRow key={row.index}>
48+
<TableCell style={{ width: "15%", padding: "6px", fontSize: "9pt" }} component="th" scope="row">
49+
{row.time}
50+
</TableCell>
51+
<TableCell style={{ width: "10%", padding: "6px", fontSize: "9pt" }}>{row.priority}</TableCell>
52+
<TableCell style={{ width: "75%", padding: "6px", fontSize: "9pt" }}>{row.description}</TableCell>
53+
</TableRow>
54+
))}
55+
</TableBody>
56+
</Table>
57+
</TableContainer>
58+
);
59+
}

0 commit comments

Comments
 (0)