Skip to content

Commit

Permalink
initial CarEventReenactment
Browse files Browse the repository at this point in the history
  • Loading branch information
sarem-h committed Jun 9, 2024
1 parent 43e3377 commit f6ad8a2
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 9 deletions.
21 changes: 16 additions & 5 deletions src/components/AppDrawer/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useCallback, useEffect, useRef } from 'react';
import { connect } from 'react-redux';
import Obstruction from 'obstruction';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';

import Drawer from '@material-ui/core/Drawer';

import DeviceList from '../Dashboard/DeviceList';
import CarEventReenactment from '../CarEventReenactment';

import { selectDevice } from '../../actions';

Expand Down Expand Up @@ -33,6 +34,11 @@ const AppDrawer = ({
toggleDrawerOff();
}, [dispatch, toggleDrawerOff]);

const location = useLocation();
const currentPage = location.pathname;

const isReplayPage = currentPage.split('/').length === 4 ? true : false;

return (
<Drawer
open={isPermanent || drawerIsOpen}
Expand All @@ -48,10 +54,15 @@ const AppDrawer = ({
<span className="text-xl font-extrabold">connect</span>
</Link>
)}
<DeviceList
selectedDevice={selectedDongleId}
handleDeviceSelected={handleDeviceSelected}
/>
{!isReplayPage && (
<DeviceList
selectedDevice={selectedDongleId}
handleDeviceSelected={handleDeviceSelected}
/>
)}
{isReplayPage && (
<CarEventReenactment />
)}
</div>
</Drawer>
);
Expand Down
12 changes: 8 additions & 4 deletions src/components/AppHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ const AppHeader = ({
</a>
</div>
<div className="flex order-4 w-full justify-center sm:order-none sm:w-auto">
{Boolean(!primeNav && !annotating && dongleId) && <TimeFilter />}
<div className={classes.toggleDashboardView} onClick={toggleDashboardView}>
{showRouteVisualizer ? 'View List' : 'View Map'}
</div>
{Boolean(!primeNav && !annotating && dongleId) && (
<>
<TimeFilter />
<div className={classes.toggleDashboardView} onClick={toggleDashboardView}>
{showRouteVisualizer ? 'View List' : 'View Map'}
</div>
</>
)}
</div>
<div className="flex flex-row gap-2">
<Suspense><PWAIcon /></Suspense>
Expand Down
69 changes: 69 additions & 0 deletions src/components/CarEventReenactment/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Obstruction from 'obstruction';
import { withStyles } from '@material-ui/core';

import theme from '../../theme';

Check failure on line 6 in src/components/CarEventReenactment/index.jsx

View workflow job for this annotation

GitHub Actions / test

'theme' is defined but never used
import Colors from '../../colors';
import ResizeHandler from '../ResizeHandler';

Check failure on line 8 in src/components/CarEventReenactment/index.jsx

View workflow job for this annotation

GitHub Actions / test

'ResizeHandler' is defined but never used

const styles = () => ({

});

const initialState = {
windowWidth: window.innerWidth,
};


class RouteVisualizer extends Component {
constructor(props) {
super(props);
this.state = {
...initialState,
};

this.onResize = this.onResize.bind(this);
}

componentDidMount() {

}

componentDidUpdate(prevProps) {

}

componentWillUnmount() {
this.setState({ ...initialState });
}


onResize(windowWidth) {
this.setState({ windowWidth });
}


render() {
const { classes } = this.props;
const { } = this.state;

Check failure on line 49 in src/components/CarEventReenactment/index.jsx

View workflow job for this annotation

GitHub Actions / test

Unexpected empty object pattern

Check failure on line 49 in src/components/CarEventReenactment/index.jsx

View workflow job for this annotation

GitHub Actions / test

Multiple spaces found before '}'

return (
<div
ref={this.onContainerRef}
className={classes.carEventReenactmentContainer}
style={{ height: '100%', backgroundColor: Colors.black, display: 'flex', flexDirection: 'column'}}
>

</div>
);
}
}

const stateToProps = Obstruction({
device: 'device',
dongleId: 'dongleId',
routes: 'routes',
});

export default connect(stateToProps)(withStyles(styles)(RouteVisualizer));

0 comments on commit f6ad8a2

Please sign in to comment.