Skip to content

Commit

Permalink
Add redux for predicted route
Browse files Browse the repository at this point in the history
  • Loading branch information
Norukh committed Dec 2, 2023
1 parent 8ca91dc commit 9fc5763
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 195 deletions.
8 changes: 6 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 4 additions & 66 deletions predictor-app/src/components/GlassCollectionMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,68 +26,10 @@ const GlassCollectionMap = ({ key }) => {
}, [key]);

const sensors = useSelector((state) => state.sensor.sensors);
//const predictedRoute = useSelector((state) => state.predictedRoute.predictedRoute);

const predictedRoute = [
[
47.4156038,
9.3325804
],
{
"date": "Sat, 21 May 2022 00:00:00 GMT",
"lat": "47.4351834416",
"level": 0.1217434210526317,
"lng": "9.3918149135",
"sensor_id": "107132 | 255E",
"type": "Glas / Grün,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.412065012904804",
"level": 0.6643749999999999,
"lng": "9.335980774191682",
"sensor_id": "107026 | 67BE",
"type": "YMATRON,Glas / Braun"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41208",
"level": 0.4225,
"lng": "9.33586",
"sensor_id": "107068 | 4455",
"type": "YMATRON,Glas / Grün"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41209608066285",
"level": 0.40874999999999995,
"lng": "9.33591068841119",
"sensor_id": "107072 | F389",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40792974774064",
"level": 0.67225,
"lng": "9.33352525794038",
"sensor_id": "107065 | 4A3D",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40798",
"level": 0.6775,
"lng": "9.33388",
"sensor_id": "107077 | 2CC4",
"type": "YMATRON,Glas / Grün"
},
[
47.4156038,
9.3325804
]
];
const predictedRoute = useSelector((state) => state.predictedRoute.predictedRoute);

console.log(sensors);
console.log(predictedRoute);

const { isLoaded, loadError } = useLoadScript({
googleMapsApiKey: process.env.REACT_APP_GOOGLE_MAPS_API_KEY,
Expand Down Expand Up @@ -118,11 +60,7 @@ const GlassCollectionMap = ({ key }) => {
stopover: true,
};
});

//console.log(waypoints);
console.log(origin);
console.log(destination);


directionsService.route(
{
origin: new window.google.maps.LatLng(origin.lat, origin.lng),
Expand All @@ -139,7 +77,7 @@ const GlassCollectionMap = ({ key }) => {
}
);
}
}, [isLoaded, travelMode,]);
}, [isLoaded, travelMode, predictedRoute]);

if (loadError) {
return <div>Error loading maps</div>;
Expand Down
10 changes: 2 additions & 8 deletions predictor-app/src/components/GlassMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ const GlassMarker = (props) => {
<TableContainer style={{ marginTop: '1em' }} component={Paper}>
<Table sx={{ minWidth: 200 }} aria-label="simple table">
<TableBody>
<TableRow key={1} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">
prediction (datum)
</TableCell>
<TableCell align="right">{props.prediction ? props.prediction : 0}</TableCell>

</TableRow>


<TableRow key={2} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">
fill level
last fill level
</TableCell>
<TableCell align="right">{parseFloat(props.level.toFixed(4)) * 100}%</TableCell>

Expand Down
66 changes: 5 additions & 61 deletions predictor-app/src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ListItemAvatar from '@mui/material/ListItemAvatar';
import Avatar from '@mui/material/Avatar';
import RoomIcon from '@mui/icons-material/Room';
import RecyclingIcon from '@mui/icons-material/Recycling';
import { useSelector } from "react-redux";

const marks = [
{
Expand Down Expand Up @@ -66,67 +67,10 @@ const durationMarks = [
},
];

const predictedRoute = [
[
47.4156038,
9.3325804
],
{
"date": "Sat, 21 May 2022 00:00:00 GMT",
"lat": "47.4351834416",
"level": 0.1217434210526317,
"lng": "9.3918149135",
"sensor_id": "107132 | 255E",
"type": "Glas / Grün,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.412065012904804",
"level": 0.6643749999999999,
"lng": "9.335980774191682",
"sensor_id": "107026 | 67BE",
"type": "YMATRON,Glas / Braun"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41208",
"level": 0.4225,
"lng": "9.33586",
"sensor_id": "107068 | 4455",
"type": "YMATRON,Glas / Grün"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41209608066285",
"level": 0.40874999999999995,
"lng": "9.33591068841119",
"sensor_id": "107072 | F389",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40792974774064",
"level": 0.67225,
"lng": "9.33352525794038",
"sensor_id": "107065 | 4A3D",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40798",
"level": 0.6775,
"lng": "9.33388",
"sensor_id": "107077 | 2CC4",
"type": "YMATRON,Glas / Grün"
},
[
47.4156038,
9.3325804
]
];


const Sidebar = () => {


const predictedRoute = useSelector((state) => state.predictedRoute.predictedRoute);

const [state, setState] = React.useState({
brown: true,
Expand Down Expand Up @@ -238,7 +182,7 @@ const Sidebar = () => {
</Card>
</Grid> : null}

{predictedRoute ?
{predictedRoute !== undefined ?

<Grid item xs={12}>
<b>Tour</b>
Expand Down
59 changes: 1 addition & 58 deletions predictor-app/src/redux/predictedRouteSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,7 @@ import { createSlice } from '@reduxjs/toolkit';
export const predictedRouteSlice = createSlice({
name: 'predictedRoute',
initialState: {
predictedRoute : [
[
47.4156038,
9.3325804
],
{
"date": "Sat, 21 May 2022 00:00:00 GMT",
"lat": "47.4351834416",
"level": 0.1217434210526317,
"lng": "9.3918149135",
"sensor_id": "107132 | 255E",
"type": "Glas / Grün,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.412065012904804",
"level": 0.6643749999999999,
"lng": "9.335980774191682",
"sensor_id": "107026 | 67BE",
"type": "YMATRON,Glas / Braun"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41208",
"level": 0.4225,
"lng": "9.33586",
"sensor_id": "107068 | 4455",
"type": "YMATRON,Glas / Grün"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.41209608066285",
"level": 0.40874999999999995,
"lng": "9.33591068841119",
"sensor_id": "107072 | F389",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40792974774064",
"level": 0.67225,
"lng": "9.33352525794038",
"sensor_id": "107065 | 4A3D",
"type": "Glas / Weiss,YMATRON"
},
{
"date": "Mon, 10 Oct 2022 00:00:00 GMT",
"lat": "47.40798",
"level": 0.6775,
"lng": "9.33388",
"sensor_id": "107077 | 2CC4",
"type": "YMATRON,Glas / Grün"
},
[
47.4156038,
9.3325804
]
],
predictedRoute : undefined,
},
reducers: {
setPredictedRoute: (state, action) => {
Expand Down
2 changes: 2 additions & 0 deletions predictor-app/src/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {configureStore} from "@reduxjs/toolkit";
import {sensorReducer} from "./sensorSlice";
import {predictedRouteReducer} from "./predictedRouteSlice";

const store = configureStore({
reducer: {
sensor: sensorReducer,
predictedRoute: predictedRouteReducer,
},
});

Expand Down

0 comments on commit 9fc5763

Please sign in to comment.