From 06dd04d074a79a082a51d37bb84a19d49b29fc05 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 15 May 2022 14:58:38 -0700 Subject: Add missing user details --- modern/src/common/util/permissions.js | 2 + modern/src/settings/UserPage.js | 218 ++++++++++++++++++++++++- modern/src/settings/components/EditItemView.js | 4 +- 3 files changed, 220 insertions(+), 4 deletions(-) (limited to 'modern/src') diff --git a/modern/src/common/util/permissions.js b/modern/src/common/util/permissions.js index 72ca0b08..27a9ba4f 100644 --- a/modern/src/common/util/permissions.js +++ b/modern/src/common/util/permissions.js @@ -2,6 +2,8 @@ import { useSelector } from 'react-redux'; export const useAdministrator = () => useSelector((state) => state.session.user?.administrator); +export const useManager = () => useSelector((state) => state.session.user?.administrator || (state.session.user?.userLimit || 0) > 0); + export const useReadonly = () => useSelector((state) => state.session.server?.readonly || state.session.user?.readonly); export const useDeviceReadonly = () => useSelector((state) => state.session.server?.readonly || state.session.user?.readonly diff --git a/modern/src/settings/UserPage.js b/modern/src/settings/UserPage.js index 10e49690..a4a5b0fb 100644 --- a/modern/src/settings/UserPage.js +++ b/modern/src/settings/UserPage.js @@ -2,9 +2,10 @@ import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import { - Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControl, InputLabel, Select, MenuItem, + Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControl, InputLabel, Select, MenuItem, FormControlLabel, Checkbox, InputAdornment, IconButton, FilledInput, } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import CachedIcon from '@material-ui/icons/Cached'; import { useDispatch, useSelector } from 'react-redux'; import EditItemView from './components/EditItemView'; import EditAttributesView from './components/EditAttributesView'; @@ -15,6 +16,9 @@ import { sessionActions } from '../store'; import SelectField from '../common/components/SelectField'; import SettingsMenu from './components/SettingsMenu'; import useCommonUserAttributes from '../common/attributes/useCommonUserAttributes'; +import { useAdministrator, useManager } from '../common/util/permissions'; +import { prefixString } from '../common/util/stringUtils'; +import moment from 'moment'; const useStyles = makeStyles(() => ({ details: { @@ -27,6 +31,9 @@ const UserPage = () => { const dispatch = useDispatch(); const t = useTranslation(); + const admin = useAdministrator(); + const manager = useManager(); + const currentUserId = useSelector((state) => state.session.user.id); const commonUserAttributes = useCommonUserAttributes(t); @@ -47,6 +54,7 @@ const UserPage = () => { endpoint="users" item={item} setItem={setItem} + defaultItem={{ deviceLimit: -1 }} validate={validate} onItemSaved={onItemSaved} menu={} @@ -98,6 +106,41 @@ const UserPage = () => { label={t('sharedPhone')} variant="filled" /> + setItem({ ...item, latitude: Number(event.target.value) })} + label={t('positionLatitude')} + variant="filled" + /> + setItem({ ...item, longitude: Number(event.target.value) })} + label={t('positionLongitude')} + variant="filled" + /> + setItem({ ...item, zoom: Number(event.target.value) })} + label={t('serverZoom')} + variant="filled" + /> + + {t('settingsCoordinateFormat')} + + {t('settingsSpeedUnit')}