From 73c1e0795ea6b27a89b4c9065717dfd9ca879bab Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 25 May 2022 18:43:59 -0700 Subject: Add notification sound --- modern/src/settings/PreferencesPage.js | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'modern/src/settings') 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 ( } breadcrumbs={['settingsTitle', 'sharedPreferences']}> @@ -105,6 +115,32 @@ const PreferencesPage = () => { + + }> + + {t('sharedSound')} + + + + setSoundEvents(e.target.value)} + endpoint="/api/notifications/types" + keyGetter={(it) => it.type} + titleGetter={(it) => t(prefixString('event', it.type))} + label={t('reportEventTypes')} + /> + setSoundAlarms(e.target.value)} + data={alarms} + keyGetter={(it) => it.key} + label={t('sharedAlarms')} + /> + + ); -- cgit v1.2.3