Skip to content

Commit

Permalink
Add notification description
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Sep 18, 2024
1 parent d70becb commit 6f2b4b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/common/util/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ export const getBatteryStatus = (batteryLevel) => {
};

export const formatNotificationTitle = (t, notification, includeId) => {
if (notification.description) {
return notification.description;
}
let title = t(prefixString('event', notification.type));
if (notification.type === 'alarm') {
const alarmString = notification.attributes.alarms;
Expand Down
12 changes: 9 additions & 3 deletions src/settings/NotificationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Checkbox,
FormGroup,
Button,
TextField,
} from '@mui/material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { useTranslation, useTranslationKeys } from '../common/components/LocalizationProvider';
Expand Down Expand Up @@ -93,7 +94,7 @@ const NotificationPage = () => {
{item.notificators?.includes('command') && (
<SelectField
value={item.commandId}
onChange={(event) => setItem({ ...item, commandId: Number(event.target.value) })}
onChange={(e) => setItem({ ...item, commandId: Number(e.target.value) })}
endpoint="/api/commands"
titleGetter={(it) => it.description}
label={t('sharedSavedCommand')}
Expand All @@ -112,7 +113,7 @@ const NotificationPage = () => {
control={(
<Checkbox
checked={item.always}
onChange={(event) => setItem({ ...item, always: event.target.checked })}
onChange={(e) => setItem({ ...item, always: e.target.checked })}
/>
)}
label={t('notificationAlways')}
Expand All @@ -127,9 +128,14 @@ const NotificationPage = () => {
</Typography>
</AccordionSummary>
<AccordionDetails className={classes.details}>
<TextField
value={item.description || ''}
onChange={(e) => setItem({ ...item, description: e.target.value })}
label={t('sharedDescription')}
/>
<SelectField
value={item.calendarId}
onChange={(event) => setItem({ ...item, calendarId: Number(event.target.value) })}
onChange={(e) => setItem({ ...item, calendarId: Number(e.target.value) })}
endpoint="/api/calendars"
label={t('sharedCalendar')}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/settings/NotificationsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const NotificationsPage = () => {
<Table className={classes.table}>
<TableHead>
<TableRow>
<TableCell>{t('sharedDescription')}</TableCell>
<TableCell>{t('notificationType')}</TableCell>
<TableCell>{t('notificationAlways')}</TableCell>
<TableCell>{t('sharedAlarms')}</TableCell>
Expand All @@ -64,6 +65,7 @@ const NotificationsPage = () => {
<TableBody>
{!loading ? items.filter(filterByKeyword(searchKeyword)).map((item) => (
<TableRow key={item.id}>
<TableCell>{item.description}</TableCell>
<TableCell>{t(prefixString('event', item.type))}</TableCell>
<TableCell>{formatBoolean(item.always, t)}</TableCell>
<TableCell>{formatList('alarm', item.attributes.alarms)}</TableCell>
Expand Down

0 comments on commit 6f2b4b4

Please sign in to comment.