From 89751b5f3345ee23938b879acb3bcfaee4a0023a Mon Sep 17 00:00:00 2001 From: seb <seb@ruse.tech> Date: Mon, 9 Dec 2024 17:36:49 -0500 Subject: [PATCH 1/6] refactor options and add pushover-sound-up field --- src/components/notifications/Pushover.vue | 69 +++++++++++++++-------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/src/components/notifications/Pushover.vue b/src/components/notifications/Pushover.vue index 7ee0eafb6..869fba1ed 100644 --- a/src/components/notifications/Pushover.vue +++ b/src/components/notifications/Pushover.vue @@ -16,34 +16,24 @@ <option>1</option> <option>2</option> </select> - <label for="pushover-sound" class="form-label">{{ $t("Notification Sound") }}</label> - <select id="pushover-sound" v-model="$parent.notification.pushoversounds" class="form-select"> - <option value="pushover">{{ $t("pushoversounds pushover") }}</option> - <option value="bike">{{ $t("pushoversounds bike") }}</option> - <option value="bugle">{{ $t("pushoversounds bugle") }}</option> - <option value="cashregister">{{ $t("pushoversounds cashregister") }}</option> - <option value="classical">{{ $t("pushoversounds classical") }}</option> - <option value="cosmic">{{ $t("pushoversounds cosmic") }}</option> - <option value="falling">{{ $t("pushoversounds falling") }}</option> - <option value="gamelan">{{ $t("pushoversounds gamelan") }}</option> - <option value="incoming">{{ $t("pushoversounds incoming") }}</option> - <option value="intermission">{{ $t("pushoversounds intermission") }}</option> - <option value="magic">{{ $t("pushoversounds magic") }}</option> - <option value="mechanical">{{ $t("pushoversounds mechanical") }}</option> - <option value="pianobar">{{ $t("pushoversounds pianobar") }}</option> - <option value="siren">{{ $t("pushoversounds siren") }}</option> - <option value="spacealarm">{{ $t("pushoversounds spacealarm") }}</option> - <option value="tugboat">{{ $t("pushoversounds tugboat") }}</option> - <option value="alien">{{ $t("pushoversounds alien") }}</option> - <option value="climb">{{ $t("pushoversounds climb") }}</option> - <option value="persistent">{{ $t("pushoversounds persistent") }}</option> - <option value="echo">{{ $t("pushoversounds echo") }}</option> - <option value="updown">{{ $t("pushoversounds updown") }}</option> - <option value="vibrate">{{ $t("pushoversounds vibrate") }}</option> - <option value="none">{{ $t("pushoversounds none") }}</option> + + <label for="pushover-sound-down" class="form-label">{{ $t("Notification Sound - Down") }}</label> + <select id="pushover-sound-down" v-model="$parent.notification.pushoversounds" class="form-select"> + <option v-for="sound in soundOptions" :key="sound" :value="sound"> + {{ $t(`pushoversounds ${sound}`) }} + </option> </select> + + <label for="pushover-sound-up" class="form-label">{{ $t("Notification Sound - Up") }}</label> + <select id="pushover-sound-up" v-model="$parent.notification.pushoversounds_up" class="form-select"> + <option v-for="sound in soundOptions" :key="sound" :value="sound"> + {{ $t(`pushoversounds ${sound}`) }} + </option> + </select> + <label for="pushover-ttl" class="form-label">{{ $t("pushoverMessageTtl") }}</label> <input id="pushover-ttl" v-model="$parent.notification.pushoverttl" type="number" min="0" step="1" class="form-control"> + <div class="form-text"> <span style="color: red;"><sup>*</sup></span>{{ $t("Required") }} <i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;"> @@ -66,5 +56,34 @@ export default { components: { HiddenInput, }, + data() { + return { + soundOptions: [ + "pushover", + "bike", + "bugle", + "cashregister", + "classical", + "cosmic", + "falling", + "gamelan", + "incoming", + "intermission", + "magic", + "mechanical", + "pianobar", + "siren", + "spacealarm", + "tugboat", + "alien", + "climb", + "persistent", + "echo", + "updown", + "vibrate", + "none", + ], + }; + }, }; </script> From 6c8b159174363b9d173cd2033f0bd1f9cf33dc46 Mon Sep 17 00:00:00 2001 From: seb <seb@ruse.tech> Date: Mon, 9 Dec 2024 17:37:29 -0500 Subject: [PATCH 2/6] add logic to select sound for UP vs DOWN events --- server/notification-providers/pushover.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 8422b64c2..260b7e3b3 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -1,5 +1,6 @@ const { getMonitorRelativeURL } = require("../../src/util"); const { setting } = require("../util-server"); +const { UP, DOWN } = require("../../src/util"); const NotificationProvider = require("./notification-provider"); const axios = require("axios"); @@ -43,15 +44,19 @@ class Pushover extends NotificationProvider { if (heartbeatJSON == null) { await axios.post(url, data); return okMsg; - } else { - data.message += `\n<b>Time (${heartbeatJSON["timezone"]})</b>:${heartbeatJSON["localDateTime"]}`; - await axios.post(url, data); - return okMsg; } + + if (heartbeatJSON.status === UP) { + data.sound = notification.pushoversounds_up; + } + + data.message += `\n<b>Time (${heartbeatJSON["timezone"]})</b>: ${heartbeatJSON["localDateTime"]}`; + await axios.post(url, data); + return okMsg; + } catch (error) { this.throwGeneralAxiosError(error); } - } } From 12b9d55ef590715e306ec68310fa6f4472611774 Mon Sep 17 00:00:00 2001 From: seb <seb@ruse.tech> Date: Mon, 9 Dec 2024 17:47:31 -0500 Subject: [PATCH 3/6] remove unused import --- server/notification-providers/pushover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 260b7e3b3..ae43ff4db 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -1,6 +1,6 @@ const { getMonitorRelativeURL } = require("../../src/util"); const { setting } = require("../util-server"); -const { UP, DOWN } = require("../../src/util"); +const { UP } = require("../../src/util"); const NotificationProvider = require("./notification-provider"); const axios = require("axios"); From ddb98ac1d425f079b1f24af8d4a01a486ea9debd Mon Sep 17 00:00:00 2001 From: seb <seb@ruse.tech> Date: Mon, 9 Dec 2024 18:01:41 -0500 Subject: [PATCH 4/6] update to keep translations --- src/components/notifications/Pushover.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/notifications/Pushover.vue b/src/components/notifications/Pushover.vue index 869fba1ed..e2fecd29f 100644 --- a/src/components/notifications/Pushover.vue +++ b/src/components/notifications/Pushover.vue @@ -17,14 +17,14 @@ <option>2</option> </select> - <label for="pushover-sound-down" class="form-label">{{ $t("Notification Sound - Down") }}</label> + <label for="pushover-sound-down" class="form-label">{{ $t("Notification Sound") }} - Up</label> <select id="pushover-sound-down" v-model="$parent.notification.pushoversounds" class="form-select"> <option v-for="sound in soundOptions" :key="sound" :value="sound"> {{ $t(`pushoversounds ${sound}`) }} </option> </select> - <label for="pushover-sound-up" class="form-label">{{ $t("Notification Sound - Up") }}</label> + <label for="pushover-sound-up" class="form-label">{{ $t("Notification Sound") }} - Down</label> <select id="pushover-sound-up" v-model="$parent.notification.pushoversounds_up" class="form-select"> <option v-for="sound in soundOptions" :key="sound" :value="sound"> {{ $t(`pushoversounds ${sound}`) }} From 8c3589d40c352ee0a30ad440896c5c4989018d70 Mon Sep 17 00:00:00 2001 From: Ruse <seb@ruse.tech> Date: Wed, 11 Dec 2024 21:11:42 -0500 Subject: [PATCH 5/6] Update server/notification-providers/pushover.js Co-authored-by: Frank Elsinga <frank@elsinga.de> --- server/notification-providers/pushover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index ae43ff4db..3799d0858 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -46,7 +46,7 @@ class Pushover extends NotificationProvider { return okMsg; } - if (heartbeatJSON.status === UP) { + if (heartbeatJSON.status === UP && notification.pushoversounds_up) { data.sound = notification.pushoversounds_up; } From 7a8ab0271e657d4d98870b8de10d87c60b6b453d Mon Sep 17 00:00:00 2001 From: Ruse <seb@ruse.tech> Date: Wed, 11 Dec 2024 21:11:52 -0500 Subject: [PATCH 6/6] Update server/notification-providers/pushover.js Co-authored-by: Frank Elsinga <frank@elsinga.de> --- server/notification-providers/pushover.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 3799d0858..fdceeaa44 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -47,6 +47,7 @@ class Pushover extends NotificationProvider { } if (heartbeatJSON.status === UP && notification.pushoversounds_up) { + // default = DOWN => DOWN-sound is also played for non-UP/DOWN notiifcations data.sound = notification.pushoversounds_up; }