From 4dbe654290c3d1f6051ea9650549f7c254d321b4 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Thu, 4 Feb 2021 16:33:02 +0530 Subject: Initial Maintenance Screen --- modern/src/App.js | 6 +- modern/src/MainToolbar.js | 7 +++ modern/src/settings/MaintenancePage.js | 97 +++++++++++++++++++++++++++++++++ modern/src/settings/MaintenancesPage.js | 69 +++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 modern/src/settings/MaintenancePage.js create mode 100644 modern/src/settings/MaintenancesPage.js (limited to 'modern') diff --git a/modern/src/App.js b/modern/src/App.js index f5ebc14..db2f7a9 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -26,6 +26,8 @@ import DriversPage from './settings/DriversPage'; import DriverPage from './settings/DriverPage'; import ComputedAttributesPage from './settings/ComputedAttributesPage'; import ComputedAttributePage from './settings/ComputedAttributePage'; +import MaintenancesPage from './settings/MaintenancesPage'; +import MaintenancePage from './settings/MaintenancePage'; const App = () => { const initialized = useSelector(state => !!state.session.server && !!state.session.user); @@ -51,7 +53,9 @@ const App = () => { - + + + diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index 91b3d69..8f420e1 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -30,6 +30,7 @@ import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; import TrendingUpIcon from '@material-ui/icons/TrendingUp'; import FolderIcon from '@material-ui/icons/Folder'; import ReplayIcon from '@material-ui/icons/Replay'; +import PublishIcon from '@material-ui/icons/Publish'; import t from './common/localization'; const useStyles = makeStyles(theme => ({ @@ -185,6 +186,12 @@ const MainToolbar = () => { + history.push('/settings/maintenances')}> + + + + + {adminEnabled && ( <> diff --git a/modern/src/settings/MaintenancePage.js b/modern/src/settings/MaintenancePage.js new file mode 100644 index 0000000..8c4cdf4 --- /dev/null +++ b/modern/src/settings/MaintenancePage.js @@ -0,0 +1,97 @@ +import React, { useState } from 'react'; + +import t from '../common/localization'; +import EditItemView from '../EditItemView'; +import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, TextField, FormControl, InputLabel, MenuItem, Select, } from '@material-ui/core'; +import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import EditAttributesView from '../attributes/EditAttributesView'; +import positionAttributes from '../attributes/positionAttributes'; + +const useStyles = makeStyles(() => ({ + details: { + flexDirection: 'column', + }, +})); + +const MaintenancePage = () => { + const classes = useStyles(); + + const [item, setItem] = useState(); + + const options = []; + + Object.entries(positionAttributes).map(([key, value]) => { + if (value.type === 'number') { + options.push({ key, name: value.name, type: value.type }) + } + }); + + const handleChange = event => { + const newValue = event.target.value; + setItem({...item, type: newValue}); + } + + return ( + + {item && + <> + + }> + + {t('sharedRequired')} + + + + setItem({...item, name: event.target.value})} + label={t('sharedName')} + variant="filled" /> + + {t('sharedType')} + + + setItem({...item, start: event.target.value})} + label={t('maintenanceStart')} + variant="filled" /> + setItem({...item, period: event.target.value})} + label={t('maintenancePeriod')} + variant="filled" /> + + + + }> + + {t('sharedAttributes')} + + + + setItem({...item, attributes})} + definitions={{}} + /> + + + + } + + ); +} + +export default MaintenancePage; diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js new file mode 100644 index 0000000..9cbf51a --- /dev/null +++ b/modern/src/settings/MaintenancesPage.js @@ -0,0 +1,69 @@ +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 MaintenancesView = ({ updateTimestamp, onMenuClick }) => { + const classes = useStyles(); + + const [items, setItems] = useState([]); + + useEffectAsync(async () => { + const response = await fetch('/api/maintenance'); + if (response.ok) { + setItems(await response.json()); + } + }, [updateTimestamp]); + + return ( + + + + + + {t('sharedName')} + {t('sharedType')} + {t('maintenanceStart')} + {t('maintenancePeriod')} + + + + {items.map(item => ( + + + onMenuClick(event.currentTarget, item.id)}> + + + + {item.name} + {item.type} + {item.start} + {item.period} + + ))} + +
+
+ ); +} + +const MaintenacesPage = () => { + return ( + <> + + + + ); +} + +export default MaintenacesPage; -- cgit v1.2.3