diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-27 19:59:00 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-27 19:59:00 -0700 |
commit | 96af05dbf2171c4e194cf67c3c93d134ef467e50 (patch) | |
tree | 4d8ae6dc11c76268de16c7a89d51ca236fefa44c /modern | |
parent | 3fdfe78d0f3568072f838a0721e9521258d95c1e (diff) | |
download | trackermap-web-96af05dbf2171c4e194cf67c3c93d134ef467e50.tar.gz trackermap-web-96af05dbf2171c4e194cf67c3c93d134ef467e50.tar.bz2 trackermap-web-96af05dbf2171c4e194cf67c3c93d134ef467e50.zip |
Add server attributes
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/admin/ServerPage.js | 119 |
1 files changed, 67 insertions, 52 deletions
diff --git a/modern/src/admin/ServerPage.js b/modern/src/admin/ServerPage.js index 01b8db14..d8961040 100644 --- a/modern/src/admin/ServerPage.js +++ b/modern/src/admin/ServerPage.js @@ -8,6 +8,9 @@ import { useHistory } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; import MainToolbar from '../MainToolbar'; import { sessionActions } from '../store'; +import EditAttributesView from '../attributes/EditAttributesView'; +import deviceAttributes from '../attributes/deviceAttributes'; +import userAttributes from '../attributes/userAttributes'; const useStyles = makeStyles(theme => ({ container: { @@ -49,58 +52,70 @@ const ServerPage = () => { <> <MainToolbar /> <Container maxWidth='xs' className={classes.container}> - <form> - {item && - <> - <Accordion defaultExpanded> - <AccordionSummary expandIcon={<ExpandMoreIcon />}> - <Typography variant="subtitle1"> - {t('sharedPreferences')} - </Typography> - </AccordionSummary> - <AccordionDetails className={classes.details}> - <TextField - margin="normal" - defaultValue={item.announcement} - onChange={event => setItem({...item, announcement: event.target.value})} - label={t('serverAnnouncement')} - variant="filled" /> - </AccordionDetails> - </Accordion> - <Accordion> - <AccordionSummary expandIcon={<ExpandMoreIcon />}> - <Typography variant="subtitle1"> - {t('sharedPermissions')} - </Typography> - </AccordionSummary> - <AccordionDetails className={classes.details}> - <FormControlLabel - control={<Checkbox checked={item.registration} onChange={event => setItem({...item, registration: event.target.checked})} />} - label={t('serverRegistration')} /> - <FormControlLabel - control={<Checkbox checked={item.readonly} onChange={event => setItem({...item, readonly: event.target.checked})} />} - label={t('serverReadonly')} /> - <FormControlLabel - control={<Checkbox checked={item.deviceReadonly} onChange={event => setItem({...item, deviceReadonly: event.target.checked})} />} - label={t('userDeviceReadonly')} /> - <FormControlLabel - control={<Checkbox checked={item.limitCommands} onChange={event => setItem({...item, limitCommands: event.target.checked})} />} - label={t('userLimitCommands')} /> - </AccordionDetails> - </Accordion> - </> - } - <FormControl fullWidth margin='normal'> - <div className={classes.buttons}> - <Button type='button' color='primary' variant='outlined' onClick={() => history.goBack()}> - {t('sharedCancel')} - </Button> - <Button type='button' color='primary' variant='contained' onClick={handleSave}> - {t('sharedSave')} - </Button> - </div> - </FormControl> - </form> + {item && + <> + <Accordion defaultExpanded> + <AccordionSummary expandIcon={<ExpandMoreIcon />}> + <Typography variant="subtitle1"> + {t('sharedPreferences')} + </Typography> + </AccordionSummary> + <AccordionDetails className={classes.details}> + <TextField + margin="normal" + defaultValue={item.announcement} + onChange={event => setItem({...item, announcement: event.target.value})} + label={t('serverAnnouncement')} + variant="filled" /> + </AccordionDetails> + </Accordion> + <Accordion> + <AccordionSummary expandIcon={<ExpandMoreIcon />}> + <Typography variant="subtitle1"> + {t('sharedPermissions')} + </Typography> + </AccordionSummary> + <AccordionDetails className={classes.details}> + <FormControlLabel + control={<Checkbox checked={item.registration} onChange={event => setItem({...item, registration: event.target.checked})} />} + label={t('serverRegistration')} /> + <FormControlLabel + control={<Checkbox checked={item.readonly} onChange={event => setItem({...item, readonly: event.target.checked})} />} + label={t('serverReadonly')} /> + <FormControlLabel + control={<Checkbox checked={item.deviceReadonly} onChange={event => setItem({...item, deviceReadonly: event.target.checked})} />} + label={t('userDeviceReadonly')} /> + <FormControlLabel + control={<Checkbox checked={item.limitCommands} onChange={event => setItem({...item, limitCommands: event.target.checked})} />} + label={t('userLimitCommands')} /> + </AccordionDetails> + </Accordion> + <Accordion> + <AccordionSummary expandIcon={<ExpandMoreIcon />}> + <Typography variant="subtitle1"> + {t('sharedAttributes')} + </Typography> + </AccordionSummary> + <AccordionDetails className={classes.details}> + <EditAttributesView + attributes={item.attributes} + setAttributes={attributes => setItem({...item, attributes})} + definitions={{...userAttributes, ...deviceAttributes}} + /> + </AccordionDetails> + </Accordion> + </> + } + <FormControl fullWidth margin='normal'> + <div className={classes.buttons}> + <Button type='button' color='primary' variant='outlined' onClick={() => history.goBack()}> + {t('sharedCancel')} + </Button> + <Button type='button' color='primary' variant='contained' onClick={handleSave}> + {t('sharedSave')} + </Button> + </div> + </FormControl> </Container> </> ); |