aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modern/src/settings/NotificationPage.js41
-rw-r--r--web/l10n/en.json2
2 files changed, 33 insertions, 10 deletions
diff --git a/modern/src/settings/NotificationPage.js b/modern/src/settings/NotificationPage.js
index 4aa318ae..a5a9d8d2 100644
--- a/modern/src/settings/NotificationPage.js
+++ b/modern/src/settings/NotificationPage.js
@@ -8,6 +8,7 @@ import {
FormControlLabel,
Checkbox,
FormGroup,
+ Button,
} from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
@@ -16,6 +17,7 @@ import EditItemView from './components/EditItemView';
import { prefixString, unprefixString } from '../common/util/stringUtils';
import SelectField from '../common/components/SelectField';
import SettingsMenu from './components/SettingsMenu';
+import { useCatch } from '../reactHelper';
const useStyles = makeStyles((theme) => ({
details: {
@@ -37,6 +39,19 @@ const NotificationPage = () => {
name: t(it),
}));
+ const testNotificators = useCatch(async () => {
+ await Promise.all(item.notificators.split(/[, ]+/).map(async (notificator) => {
+ const response = await fetch(`/api/notifications/test/${notificator}`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(item),
+ });
+ if (!response.ok) {
+ throw Error(await response.text());
+ }
+ }));
+ });
+
const validate = () => item && item.type && item.notificators;
return (
@@ -66,15 +81,6 @@ const NotificationPage = () => {
titleGetter={(it) => t(prefixString('event', it.type))}
label={t('sharedType')}
/>
- <SelectField
- multiple
- value={item.notificators ? item.notificators.split(/[, ]+/) : []}
- onChange={(e) => setItem({ ...item, notificators: e.target.value.join() })}
- endpoint="/api/notifications/notificators"
- keyGetter={(it) => it.type}
- titleGetter={(it) => t(prefixString('notificator', it.type))}
- label={t('notificationNotificators')}
- />
{item.type === 'alarm' && (
<SelectField
multiple
@@ -85,6 +91,23 @@ const NotificationPage = () => {
label={t('sharedAlarms')}
/>
)}
+ <SelectField
+ multiple
+ value={item.notificators ? item.notificators.split(/[, ]+/) : []}
+ onChange={(e) => setItem({ ...item, notificators: e.target.value.join() })}
+ endpoint="/api/notifications/notificators"
+ keyGetter={(it) => it.type}
+ titleGetter={(it) => t(prefixString('notificator', it.type))}
+ label={t('notificationNotificators')}
+ />
+ <Button
+ variant="outlined"
+ color="primary"
+ onClick={testNotificators}
+ disabled={!item.notificators}
+ >
+ {t('sharedTestNotificators')}
+ </Button>
<FormGroup>
<FormControlLabel
control={(
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 4db574e2..fc5a13a1 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -59,7 +59,7 @@
"sharedDevice": "Device",
"sharedTest": "Test",
"sharedTestNotification": "Send Test Notification",
- "sharedTestChannels": "Test Channels",
+ "sharedTestNotificators": "Test Channels",
"sharedTestExpression": "Test Expression",
"sharedCalendar": "Calendar",
"sharedCalendars": "Calendars",