aboutsummaryrefslogtreecommitdiff
path: root/modern/src/admin
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/admin')
-rw-r--r--modern/src/admin/ServerPage.js77
-rw-r--r--modern/src/admin/StatisticsPage.js27
-rw-r--r--modern/src/admin/UsersPage.js82
3 files changed, 87 insertions, 99 deletions
diff --git a/modern/src/admin/ServerPage.js b/modern/src/admin/ServerPage.js
index c33a6316..6d5b575a 100644
--- a/modern/src/admin/ServerPage.js
+++ b/modern/src/admin/ServerPage.js
@@ -1,31 +1,33 @@
import React from 'react';
import TextField from '@material-ui/core/TextField';
-import t from '../common/localization';
-import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, Button, FormControl, Container, Checkbox, FormControlLabel } from '@material-ui/core';
+import {
+ Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, Button, FormControl, Container, Checkbox, FormControlLabel,
+} from '@material-ui/core';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import { useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
+import t from '../common/localization';
import { sessionActions } from '../store';
import EditAttributesView from '../attributes/EditAttributesView';
import deviceAttributes from '../attributes/deviceAttributes';
import userAttributes from '../attributes/userAttributes';
import OptionsLayout from '../settings/OptionsLayout';
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
container: {
- marginTop: theme.spacing(2)
+ marginTop: theme.spacing(2),
},
buttons: {
display: 'flex',
justifyContent: 'space-evenly',
'& > *': {
- flexBasis: '33%'
- }
+ flexBasis: '33%',
+ },
},
details: {
- flexDirection: 'column'
- }
+ flexDirection: 'column',
+ },
}));
const ServerPage = () => {
@@ -33,15 +35,14 @@ const ServerPage = () => {
const dispatch = useDispatch();
const classes = useStyles();
- const item = useSelector(state => state.session.server);
- const setItem = updatedItem =>
- dispatch(sessionActions.updateServer(updatedItem));
+ const item = useSelector((state) => state.session.server);
+ const setItem = (updatedItem) => dispatch(sessionActions.updateServer(updatedItem));
const handleSave = async () => {
const response = await fetch('/api/server', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(item)
+ body: JSON.stringify(item),
});
if (response.ok) {
@@ -64,9 +65,7 @@ const ServerPage = () => {
<TextField
margin="normal"
value={item.announcement || ''}
- onChange={event =>
- setItem({ ...item, announcement: event.target.value })
- }
+ onChange={(event) => setItem({ ...item, announcement: event.target.value })}
label={t('serverAnnouncement')}
variant="filled"
/>
@@ -80,53 +79,45 @@ const ServerPage = () => {
</AccordionSummary>
<AccordionDetails className={classes.details}>
<FormControlLabel
- control={
+ control={(
<Checkbox
checked={item.registration}
- onChange={event =>
- setItem({ ...item, registration: event.target.checked })
- }
+ onChange={(event) => setItem({ ...item, registration: event.target.checked })}
/>
- }
+ )}
label={t('serverRegistration')}
/>
<FormControlLabel
- control={
+ control={(
<Checkbox
checked={item.readonly}
- onChange={event =>
- setItem({ ...item, readonly: event.target.checked })
- }
+ onChange={(event) => setItem({ ...item, readonly: event.target.checked })}
/>
- }
+ )}
label={t('serverReadonly')}
/>
<FormControlLabel
- control={
+ control={(
<Checkbox
checked={item.deviceReadonly}
- onChange={event =>
- setItem({
- ...item,
- deviceReadonly: event.target.checked
- })
- }
+ onChange={(event) => setItem({
+ ...item,
+ deviceReadonly: event.target.checked,
+ })}
/>
- }
+ )}
label={t('userDeviceReadonly')}
/>
<FormControlLabel
- control={
+ control={(
<Checkbox
checked={item.limitCommands}
- onChange={event =>
- setItem({
- ...item,
- limitCommands: event.target.checked
- })
- }
+ onChange={(event) => setItem({
+ ...item,
+ limitCommands: event.target.checked,
+ })}
/>
- }
+ )}
label={t('userLimitCommands')}
/>
</AccordionDetails>
@@ -140,9 +131,9 @@ const ServerPage = () => {
<AccordionDetails className={classes.details}>
<EditAttributesView
attributes={item.attributes}
- setAttributes={attributes => setItem({ ...item, attributes })}
+ setAttributes={(attributes) => setItem({ ...item, attributes })}
definitions={{ ...userAttributes, ...deviceAttributes }}
- />
+ />
</AccordionDetails>
</Accordion>
</>
diff --git a/modern/src/admin/StatisticsPage.js b/modern/src/admin/StatisticsPage.js
index b1504c87..8a6e6013 100644
--- a/modern/src/admin/StatisticsPage.js
+++ b/modern/src/admin/StatisticsPage.js
@@ -1,9 +1,10 @@
-
import React, { useState } from 'react';
-import { FormControl, InputLabel,Select, MenuItem, TextField, Button, TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper } from '@material-ui/core';
+import {
+ FormControl, InputLabel, Select, MenuItem, TextField, Button, TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper,
+} from '@material-ui/core';
+import moment from 'moment';
import t from '../common/localization';
import { formatDate } from '../common/formatter';
-import moment from 'moment';
import OptionsLayout from '../settings/OptionsLayout';
const Filter = ({ setItems }) => {
@@ -59,10 +60,10 @@ const Filter = ({ setItems }) => {
const query = new URLSearchParams({
from: selectedFrom.toISOString(),
- to: selectedTo.toISOString()
+ to: selectedTo.toISOString(),
});
const response = await fetch(`/api/statistics?${query.toString()}`, {
- Accept: 'application/json'
+ Accept: 'application/json',
});
if (response.ok) {
setItems(await response.json());
@@ -73,7 +74,7 @@ const Filter = ({ setItems }) => {
<>
<FormControl variant="filled" margin="normal" fullWidth>
<InputLabel>{t('reportPeriod')}</InputLabel>
- <Select value={period} onChange={e => setPeriod(e.target.value)}>
+ <Select value={period} onChange={(e) => setPeriod(e.target.value)}>
<MenuItem value="today">{t('reportToday')}</MenuItem>
<MenuItem value="yesterday">{t('reportYesterday')}</MenuItem>
<MenuItem value="thisWeek">{t('reportThisWeek')}</MenuItem>
@@ -90,9 +91,7 @@ const Filter = ({ setItems }) => {
label={t('reportFrom')}
type="datetime-local"
value={from.format(moment.HTML5_FMT.DATETIME_LOCAL)}
- onChange={e =>
- setFrom(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))
- }
+ onChange={(e) => setFrom(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))}
fullWidth
/>
)}
@@ -103,9 +102,7 @@ const Filter = ({ setItems }) => {
label={t('reportTo')}
type="datetime-local"
value={to.format(moment.HTML5_FMT.DATETIME_LOCAL)}
- onChange={e =>
- setTo(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))
- }
+ onChange={(e) => setTo(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))}
fullWidth
/>
)}
@@ -117,7 +114,7 @@ const Filter = ({ setItems }) => {
>
{t('reportShow')}
</Button>
- </>
+ </>
);
};
@@ -144,7 +141,7 @@ const StatisticsPage = () => {
</TableRow>
</TableHead>
<TableBody>
- {items.map(item => (
+ {items.map((item) => (
<TableRow key={item.id}>
<TableCell>{formatDate(item.captureTime)}</TableCell>
<TableCell>{item.activeUsers}</TableCell>
@@ -155,7 +152,7 @@ const StatisticsPage = () => {
<TableCell>{item.mailSent}</TableCell>
<TableCell>{item.smsSent}</TableCell>
<TableCell>{item.geocoderRequests}</TableCell>
- <TableCell>{item.geolocationRequests}</TableCell>
+ <TableCell>{item.geolocationRequests}</TableCell>
</TableRow>
))}
</TableBody>
diff --git a/modern/src/admin/UsersPage.js b/modern/src/admin/UsersPage.js
index ceaab6ab..6afe099e 100644
--- a/modern/src/admin/UsersPage.js
+++ b/modern/src/admin/UsersPage.js
@@ -1,5 +1,7 @@
import React, { useState } from 'react';
-import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, makeStyles, IconButton } from '@material-ui/core';
+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';
@@ -7,11 +9,11 @@ import EditCollectionView from '../EditCollectionView';
import { formatBoolean } from '../common/formatter';
import OptionsLayout from '../settings/OptionsLayout';
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
columnAction: {
width: theme.spacing(1),
- padding: theme.spacing(0, 1)
- }
+ padding: theme.spacing(0, 1),
+ },
}));
const UsersView = ({ updateTimestamp, onMenuClick }) => {
@@ -28,48 +30,46 @@ const UsersView = ({ updateTimestamp, onMenuClick }) => {
return (
<TableContainer>
- <Table>
- <TableHead>
- <TableRow>
- <TableCell className={classes.columnAction} />
- <TableCell>{t('sharedName')}</TableCell>
- <TableCell>{t('userEmail')}</TableCell>
- <TableCell>{t('userAdmin')}</TableCell>
- <TableCell>{t('sharedDisabled')}</TableCell>
- </TableRow>
- </TableHead>
- <TableBody>
- {items.map(item => (
- <TableRow key={item.id}>
- <TableCell className={classes.columnAction} padding="none">
+ <Table>
+ <TableHead>
+ <TableRow>
+ <TableCell className={classes.columnAction} />
+ <TableCell>{t('sharedName')}</TableCell>
+ <TableCell>{t('userEmail')}</TableCell>
+ <TableCell>{t('userAdmin')}</TableCell>
+ <TableCell>{t('sharedDisabled')}</TableCell>
+ </TableRow>
+ </TableHead>
+ <TableBody>
+ {items.map((item) => (
+ <TableRow key={item.id}>
+ <TableCell className={classes.columnAction} padding="none">
<IconButton
- onClick={event => onMenuClick(event.currentTarget, item.id)}
+ onClick={(event) => onMenuClick(event.currentTarget, item.id)}
>
- <MoreVertIcon />
- </IconButton>
- </TableCell>
- <TableCell>{item.name}</TableCell>
- <TableCell>{item.email}</TableCell>
- <TableCell>{formatBoolean(item, 'administrator')}</TableCell>
- <TableCell>{formatBoolean(item, 'disabled')}</TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
+ <MoreVertIcon />
+ </IconButton>
+ </TableCell>
+ <TableCell>{item.name}</TableCell>
+ <TableCell>{item.email}</TableCell>
+ <TableCell>{formatBoolean(item, 'administrator')}</TableCell>
+ <TableCell>{formatBoolean(item, 'disabled')}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</TableContainer>
);
};
-const UsersPage = () => {
- return (
- <OptionsLayout>
- <EditCollectionView
- content={UsersView}
- editPath="/user"
- endpoint="users"
- />
- </OptionsLayout>
- );
-};
+const UsersPage = () => (
+ <OptionsLayout>
+ <EditCollectionView
+ content={UsersView}
+ editPath="/user"
+ endpoint="users"
+ />
+ </OptionsLayout>
+);
export default UsersPage;