Skip to content

Commit

Permalink
Option to reboot server
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jun 1, 2024
1 parent 92dae40 commit b956608
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/resources/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 18 additions & 1 deletion src/settings/PreferencesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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);
Expand Down Expand Up @@ -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}>
Expand Down Expand Up @@ -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}>
Expand Down

0 comments on commit b956608

Please sign in to comment.