From 5ddf1e04451239ddc64e8a06f36f99a50d64d37b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 21 Sep 2020 22:50:26 -0700 Subject: Add device group selection --- modern/src/DevicePage.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/modern/src/DevicePage.js b/modern/src/DevicePage.js index a4b2e8b0..7d20be39 100644 --- a/modern/src/DevicePage.js +++ b/modern/src/DevicePage.js @@ -5,6 +5,7 @@ import t from './common/localization'; import EditItemView from './EditItemView'; import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControl, InputLabel, Select } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import { useEffectAsync } from './reactHelper'; const useStyles = makeStyles(() => ({ details: { @@ -40,6 +41,14 @@ const DevicePage = () => { const classes = useStyles(); const [item, setItem] = useState(); + const [groups, setGroups] = useState(); + + useEffectAsync(async () => { + const response = await fetch('/api/groups'); + if (response.ok) { + setGroups(await response.json()); + } + }, []); return ( item}> @@ -55,13 +64,13 @@ const DevicePage = () => { setItem({...item, name: event.target.value})} + onChange={event => setItem({...item, name: event.target.value})} label={t('sharedName')} variant="filled" /> setItem({...item, uniqueId: event.target.value})} + onChange={event => setItem({...item, uniqueId: event.target.value})} label={t('deviceIdentifier')} variant="filled" /> @@ -73,22 +82,36 @@ const DevicePage = () => { + {groups && + + {t('groupParent')} + + + } setItem({...item, phone: event.target.value})} + onChange={event => setItem({...item, phone: event.target.value})} label={t('sharedPhone')} variant="filled" /> setItem({...item, model: event.target.value})} + onChange={event => setItem({...item, model: event.target.value})} label={t('deviceModel')} variant="filled" /> setItem({...item, contact: event.target.value})} + onChange={event => setItem({...item, contact: event.target.value})} label={t('deviceContact')} variant="filled" /> @@ -96,8 +119,8 @@ const DevicePage = () => { -- cgit v1.2.3