aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/util
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-21 14:15:55 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-21 18:31:07 -0700
commit7825be90d88e3965c4a41a4e9011ae29b7670be9 (patch)
tree841404affbc6c8e34201f6e06c90bb9d017d580a /modern/src/common/util
parent64f446d6b0aa226eb565709f2513de15f40646aa (diff)
downloadtrackermap-web-7825be90d88e3965c4a41a4e9011ae29b7670be9.tar.gz
trackermap-web-7825be90d88e3965c4a41a4e9011ae29b7670be9.tar.bz2
trackermap-web-7825be90d88e3965c4a41a4e9011ae29b7670be9.zip
Better notification title
Diffstat (limited to 'modern/src/common/util')
-rw-r--r--modern/src/common/util/formatter.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/modern/src/common/util/formatter.js b/modern/src/common/util/formatter.js
index 47bd2cd0..ea18713d 100644
--- a/modern/src/common/util/formatter.js
+++ b/modern/src/common/util/formatter.js
@@ -97,3 +97,22 @@ export const getBatteryStatus = (batteryLevel) => {
}
return 'negative';
};
+
+export const formatNotificationTitle = (t, notification, includeId) => {
+ let title = t(prefixString('event', notification.type));
+ if (notification.type === 'alarm') {
+ const alarmString = notification.attributes.alarms;
+ if (alarmString) {
+ const alarms = alarmString.split(',');
+ if (alarms.length > 1) {
+ title += ` (${alarms.length})`;
+ } else {
+ title += ` ${formatAlarm(alarms[0], t)}`;
+ }
+ }
+ }
+ if (includeId) {
+ title += ` [${notification.id}]`;
+ }
+ return title;
+};