aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-25 18:43:59 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-25 18:43:59 -0700
commit73c1e0795ea6b27a89b4c9065717dfd9ca879bab (patch)
treefc36ea2ee2408aa084573a5702e7330100a3cddb /modern/src/settings
parent13d0373b91687da59af67df582ed385f86437298 (diff)
downloadtrackermap-web-73c1e0795ea6b27a89b4c9065717dfd9ca879bab.tar.gz
trackermap-web-73c1e0795ea6b27a89b4c9065717dfd9ca879bab.tar.bz2
trackermap-web-73c1e0795ea6b27a89b4c9065717dfd9ca879bab.zip
Add notification sound
Diffstat (limited to 'modern/src/settings')
-rw-r--r--modern/src/settings/PreferencesPage.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/modern/src/settings/PreferencesPage.js b/modern/src/settings/PreferencesPage.js
index 344beed8..64268e63 100644
--- a/modern/src/settings/PreferencesPage.js
+++ b/modern/src/settings/PreferencesPage.js
@@ -15,11 +15,13 @@ import {
} from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
-import { useLocalization, useTranslation } from '../common/components/LocalizationProvider';
+import { useLocalization, useTranslation, useTranslationKeys } from '../common/components/LocalizationProvider';
import usePersistedState from '../common/util/usePersistedState';
import PageLayout from '../common/components/PageLayout';
import SettingsMenu from './components/SettingsMenu';
import usePositionAttributes from '../common/attributes/usePositionAttributes';
+import { prefixString, unprefixString } from '../common/util/stringUtils';
+import SelectField from '../common/components/SelectField';
const useStyles = makeStyles((theme) => ({
container: {
@@ -47,6 +49,14 @@ const PreferencesPage = () => {
const [mapFollow, setMapFollow] = usePersistedState('mapFollow', false);
const [mapCluster, setMapCluster] = usePersistedState('mapCluster', true);
+ const alarms = useTranslationKeys((it) => it.startsWith('alarm')).map((it) => ({
+ key: unprefixString('alarm', it),
+ name: t(it),
+ }));
+
+ const [soundEvents, setSoundEvents] = usePersistedState('soundEvents', []);
+ const [soundAlarms, setSoundAlarms] = usePersistedState('soundAlarms', ['sos']);
+
return (
<PageLayout menu={<SettingsMenu />} breadcrumbs={['settingsTitle', 'sharedPreferences']}>
<Container maxWidth="xs" className={classes.container}>
@@ -105,6 +115,32 @@ const PreferencesPage = () => {
</FormGroup>
</AccordionDetails>
</Accordion>
+ <Accordion>
+ <AccordionSummary expandIcon={<ExpandMoreIcon />}>
+ <Typography variant="subtitle1">
+ {t('sharedSound')}
+ </Typography>
+ </AccordionSummary>
+ <AccordionDetails className={classes.details}>
+ <SelectField
+ multiple
+ value={soundEvents}
+ onChange={(e) => setSoundEvents(e.target.value)}
+ endpoint="/api/notifications/types"
+ keyGetter={(it) => it.type}
+ titleGetter={(it) => t(prefixString('event', it.type))}
+ label={t('reportEventTypes')}
+ />
+ <SelectField
+ multiple
+ value={soundAlarms}
+ onChange={(e) => setSoundAlarms(e.target.value)}
+ data={alarms}
+ keyGetter={(it) => it.key}
+ label={t('sharedAlarms')}
+ />
+ </AccordionDetails>
+ </Accordion>
</Container>
</PageLayout>
);