Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b905ee

Browse files
committed
added alertbox
1 parent e689e0f commit 8b905ee

6 files changed

Lines changed: 281 additions & 16 deletions

File tree

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"dependencies": {
33
"express": "^4.18.1",
4+
"react-d3-speedometer": "^1.1.0",
45
"socket.io": "^4.5.2"
56
}
67
}

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@types/react-dom": "^18.0.6",
1717
"react": "^18.2.0",
1818
"react-charts": "^3.0.0-beta.50",
19+
"react-d3-speedometer": "^1.1.0",
1920
"react-dom": "^18.2.0",
2021
"react-router-dom": "^6.4.2",
2122
"react-scripts": "5.0.1",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { AxisOptions, Chart, ChartOptions } from "react-charts";
2+
import {Alert, Box, Paper, Typography } from "@mui/material";
3+
4+
import React from "react";
5+
6+
interface Props {
7+
data: string[];
8+
}
9+
10+
/*
11+
* TODO:
12+
* Add a legend
13+
* Add a focus event to emphasise one line
14+
* Fix the tooltip location somehow
15+
*/
16+
const AlertBox: React.FC<Props> = ({ data}) => {
17+
18+
19+
return (
20+
<Box flex="1 0 0">
21+
<Paper sx={{ p: 2 }} elevation={2}>
22+
<Typography variant="h5" pb={1}>
23+
Motor Fault Alerts
24+
</Typography>
25+
<Box>
26+
{
27+
data.map((alert) => {
28+
return (<Alert severity="warning">{alert}</Alert>);
29+
})
30+
}
31+
</Box>
32+
</Paper>
33+
</Box>
34+
);
35+
};
36+
37+
export default AlertBox;

frontend/src/pages/HeadsUpPage.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import {Box, Paper, Typography} from "@mui/material";
1+
import {Alert, Box, Paper, Typography} from "@mui/material";
22
import React, {useEffect, useState} from "react";
33
import VideoFeed from "../components/VideoFeed";
44
import OnePedalDrive from "../components/OnePedalDrive";
55
import {io} from "socket.io-client";
6+
import ReactSpeedometer from "react-d3-speedometer";
7+
import AlertBox from "../components/AlertBox";
68

79
const socket = io("http://localhost:5050");
810
const MAX_LENGTH = 50;
@@ -118,10 +120,24 @@ const HeadsUpPage = () => {
118120
</Paper>
119121
</Box>
120122
<Box>
123+
{/*<ReactSpeedometer />*/}
124+
<Box>
125+
{/* Replace this paper component with mph */}
126+
<Paper
127+
sx={{
128+
flex: "1 0 0",
129+
display: "flex",
130+
alignItems: "center",
131+
justifyContent: "center",
132+
}}
133+
>
134+
<AlertBox data={["low bat", "sldkfj"]}/>
135+
</Paper>
136+
</Box>
121137
<VideoFeed />
122138
</Box>
123139
</Box>
124-
<OnePedalDrive value={ data.pedal_value.length != 0 ? data.pedal_value[data.pedal_value.length - 1].value : 50 } />
140+
<OnePedalDrive value={ data.pedal_value.length !== 0 ? data.pedal_value[data.pedal_value.length - 1].value : 50 } />
125141
</Box>
126142
);
127143
};

frontend/src/pages/InteractivePage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
44
import OnePedalDrive from "../components/OnePedalDrive";
55
import { io } from "socket.io-client";
66
import ToggleButtons from "../components/ToggleButtons";
7+
import AlertBox from "../components/AlertBox";
78

89
const socket = io("http://localhost:5050");
910
const MAX_LENGTH = 50;
@@ -221,7 +222,7 @@ const InteractivePage = () => {
221222
height: "calc(25vh - 8px)",
222223
}}
223224
>
224-
<Typography>Motor Faults</Typography>
225+
<AlertBox data={["Alert 1", "Alert2"]}/>
225226
</Paper>
226227
{/* Replace this paper component with fifa chart */}
227228
<Paper

0 commit comments

Comments
 (0)