From 2ea3cf62d8649588094b820652de017d5baae888 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Wed, 16 Dec 2020 15:13:08 +0530 Subject: Driver Implementations --- modern/src/App.js | 4 +++ modern/src/MainToolbar.js | 6 ++++ modern/src/settings/DriverPage.js | 65 ++++++++++++++++++++++++++++++++++++++ modern/src/settings/DriversPage.js | 65 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 modern/src/settings/DriverPage.js create mode 100644 modern/src/settings/DriversPage.js diff --git a/modern/src/App.js b/modern/src/App.js index 83fd931..94f1ed7 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -22,6 +22,8 @@ import TripReportPage from './reports/TripReportPage'; import StopReportPage from './reports/StopReportPage'; import SummaryReportPage from './reports/SummaryReportPage'; import ChartReportPage from './reports/ChartReportPage'; +import DriversPage from './settings/DriversPage'; +import DriverPage from './settings/DriverPage'; const App = () => { const initialized = useSelector(state => !!state.session.server && !!state.session.user); @@ -52,6 +54,8 @@ const App = () => { + + )} diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index 930e66a..6e2981f 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -173,6 +173,12 @@ const MainToolbar = () => { + history.push('/settings/drivers')}> + + + + + {adminEnabled && ( <> diff --git a/modern/src/settings/DriverPage.js b/modern/src/settings/DriverPage.js new file mode 100644 index 0000000..86feab8 --- /dev/null +++ b/modern/src/settings/DriverPage.js @@ -0,0 +1,65 @@ +import React, { useState } from 'react'; +import TextField from '@material-ui/core/TextField'; +import t from '../common/localization'; +import EditItemView from '../EditItemView'; +import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography } from '@material-ui/core'; +import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import EditAttributesView from '../attributes/EditAttributesView'; + +const useStyles = makeStyles(() => ({ + details: { + flexDirection: 'column', + }, +})); + +const DriverPage = () => { + const classes = useStyles(); + + const [item, setItem] = useState(); + + return ( + + {item && + <> + + }> + + {t('sharedRequired')} + + + + setItem({...item, name: event.target.value})} + label={t('sharedName')} + variant="filled" /> + setItem({...item, uniqueId: event.target.value})} + label={t('deviceIdentifier')} + variant="filled" /> + + + + }> + + {t('sharedAttributes')} + + + + setItem({...item, attributes})} + definitions={{}} + /> + + + + } + + ); +} + +export default DriverPage; diff --git a/modern/src/settings/DriversPage.js b/modern/src/settings/DriversPage.js new file mode 100644 index 0000000..957e225 --- /dev/null +++ b/modern/src/settings/DriversPage.js @@ -0,0 +1,65 @@ +import React, { useState } from 'react'; +import MainToolbar from '../MainToolbar'; +import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, makeStyles, IconButton } from '@material-ui/core'; +import MoreVertIcon from '@material-ui/icons/MoreVert'; +import t from '../common/localization'; +import { useEffectAsync } from '../reactHelper'; +import EditCollectionView from '../EditCollectionView'; + +const useStyles = makeStyles(theme => ({ + columnAction: { + width: theme.spacing(1), + padding: theme.spacing(0, 1), + }, +})); + +const DriversView = ({ updateTimestamp, onMenuClick }) => { + const classes = useStyles(); + + const [items, setItems] = useState([]); + + useEffectAsync(async () => { + const response = await fetch('/api/drivers'); + if (response.ok) { + setItems(await response.json()); + } + }, [updateTimestamp]); + + return ( + + + + + + {t('sharedName')} + {t('deviceIdentifier')} + + + + {items.map((item) => ( + + + onMenuClick(event.currentTarget, item.id)}> + + + + {item.name} + {item.uniqueId} + + ))} + +
+
+ ); +} + +const DriversPage = () => { + return ( + <> + + + + ); +} + +export default DriversPage; -- cgit v1.2.3