diff options
author | Anton Tananaev <anton@traccar.org> | 2024-06-01 07:34:19 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-06-01 07:34:19 -0700 |
commit | b9566085b964583409c8af2d6b0b5ad242b22a2a (patch) | |
tree | 024710db2fafaaaf581bbc9cf57857d8c3bfbe45 /src | |
parent | 92dae4045ccc0f4a01c06670ac21f2c1ea716490 (diff) | |
download | trackermap-web-b9566085b964583409c8af2d6b0b5ad242b22a2a.tar.gz trackermap-web-b9566085b964583409c8af2d6b0b5ad242b22a2a.tar.bz2 trackermap-web-b9566085b964583409c8af2d6b0b5ad242b22a2a.zip |
Option to reboot server
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/l10n/en.json | 1 | ||||
-rw-r--r-- | src/settings/PreferencesPage.jsx | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/resources/l10n/en.json b/src/resources/l10n/en.json index 9bb222f3..608c36d8 100644 --- a/src/resources/l10n/en.json +++ b/src/resources/l10n/en.json @@ -337,6 +337,7 @@ "serverLogoInverted": "Inverted Logo Image", "serverChangeDisable": "Disable Server Change", "serverDisableShare": "Disable Device Sharing", + "serverReboot": "Reboot", "mapTitle": "Map", "mapActive": "Active Maps", "mapOverlay": "Map Overlay", diff --git a/src/settings/PreferencesPage.jsx b/src/settings/PreferencesPage.jsx index f596b478..3b7fcaed 100644 --- a/src/settings/PreferencesPage.jsx +++ b/src/settings/PreferencesPage.jsx @@ -18,7 +18,7 @@ import useMapStyles from '../map/core/useMapStyles'; import useMapOverlays from '../map/overlay/useMapOverlays'; import { useCatch } from '../reactHelper'; import { sessionActions } from '../store'; -import { useRestriction } from '../common/util/permissions'; +import { useAdministrator, useRestriction } from '../common/util/permissions'; import useSettingsStyles from './common/useSettingsStyles'; const deviceFields = [ @@ -35,6 +35,7 @@ const PreferencesPage = () => { const navigate = useNavigate(); const t = useTranslation(); + const admin = useAdministrator(); const readonly = useRestriction('readonly'); const user = useSelector((state) => state.session.user); @@ -86,6 +87,13 @@ const PreferencesPage = () => { } }); + const handleReboot = useCatch(async () => { + const response = await fetch('/api/server/reboot', { method: 'POST' }); + if (!response.ok) { + throw Error(await response.text()); + } + }); + return ( <PageLayout menu={<SettingsMenu />} breadcrumbs={['settingsTitle', 'sharedPreferences']}> <Container maxWidth="xs" className={classes.container}> @@ -352,6 +360,15 @@ const PreferencesPage = () => { > {t('sharedEmulator')} </Button> + {admin && ( + <Button + variant="outlined" + color="error" + onClick={handleReboot} + > + {t('serverReboot')} + </Button> + )} </AccordionDetails> </Accordion> <div className={classes.buttons}> |