Skip to content

Commit

Permalink
Rework lunasea notification to allow for device id and user id
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby Ore committed Feb 28, 2023
1 parent 48b637d commit b21c2ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions server/notification-providers/lunasea.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class LunaSea extends NotificationProvider {
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
let lunaseaurl = "";
if (notification.lunaseaNotificationType === "user") {
lunaseaurl = "https://notify.lunasea.app/v1/custom/user/" + notification.lunaseaDevice;
if (notification.lunaseaTarget === "user") {
lunaseaurl = "https://notify.lunasea.app/v1/custom/user/" + notification.lunaseaUserID;
} else {
lunaseaurl = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice;
}
Expand Down
27 changes: 21 additions & 6 deletions src/components/notifications/LunaSea.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
<template>
<div class="mb-3">
<label for="lunasea-notification-type" class="form-label">{{ $t("Device ID or User ID") }}<span style="color: red;"><sup>*</sup></span></label>
<label for="lunasea-notification-target" class="form-label">{{ $t("Target") }}<span style="color: red;"><sup>*</sup></span></label>
<div class="form-text">
<p>
<select id="lunasea-notification-type" v-model="$parent.notification.lunaseaNotificationType" class="form-select" required>
<select id="lunasea-notification-target" v-model="$parent.notification.lunaseaTarget" class="form-select" required>
<option value="device">Device</option>
<option value="user">User</option>
</select>
</p>
</div>
<label for="lunasea-device" class="form-label">{{ $t("LunaSea ID") }}<span style="color: red;"><sup>*</sup></span></label>
<input id="lunasea-device" v-model="$parent.notification.lunaseaDevice" type="text" class="form-control" required>
<div class="form-text">
<p><span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}</p>
<div v-if="$parent.notification.lunaseaTarget === 'device'">
<label for="lunasea-device" class="form-label">{{ $t("Device ID") }}<span style="color: red;"><sup>*</sup></span></label>
<input id="lunasea-device" v-model="$parent.notification.lunaseaDevice" type="text" class="form-control">
</div>
<div v-if="$parent.notification.lunaseaTarget === 'user'">
<label for="lunasea-device" class="form-label">{{ $t("User ID") }}<span style="color: red;"><sup>*</sup></span></label>
<input id="lunasea-device" v-model="$parent.notification.lunaseaUserID" type="text" class="form-control">
</div>
</div>
</template>

<script lang="ts">
export default {
mounted() {
if (typeof this.$parent.notification.lunaseaTarget === "undefined") {
this.$parent.notification.lunaseaTarget = "device";
}
}
};
</script>

0 comments on commit b21c2ad

Please # to comment.