mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-24 12:35:57 +00:00
Added incidents to dialogue
This commit is contained in:
parent
edcaf93446
commit
6160fb4fb7
2 changed files with 19 additions and 11 deletions
|
@ -86,27 +86,28 @@ class Notification {
|
|||
}
|
||||
|
||||
static async save(notification, notificationID, userID) {
|
||||
let bean
|
||||
let bean;
|
||||
|
||||
if (notificationID) {
|
||||
bean = await R.findOne("notification", " id = ? AND user_id = ? ", [
|
||||
notificationID,
|
||||
userID,
|
||||
])
|
||||
]);
|
||||
|
||||
if (! bean) {
|
||||
throw new Error("notification not found")
|
||||
throw new Error("notification not found");
|
||||
}
|
||||
|
||||
} else {
|
||||
bean = R.dispense("notification")
|
||||
bean = R.dispense("notification");
|
||||
}
|
||||
|
||||
bean.name = notification.name;
|
||||
bean.user_id = userID;
|
||||
bean.config = JSON.stringify(notification);
|
||||
bean.is_default = notification.isDefault || false;
|
||||
await R.store(bean)
|
||||
bean.incidents = notification.incidents || true;
|
||||
await R.store(bean);
|
||||
|
||||
if (notification.applyExisting) {
|
||||
await applyNotificationEveryMonitor(bean.id, userID);
|
||||
|
@ -119,13 +120,13 @@ class Notification {
|
|||
let bean = await R.findOne("notification", " id = ? AND user_id = ? ", [
|
||||
notificationID,
|
||||
userID,
|
||||
])
|
||||
]);
|
||||
|
||||
if (! bean) {
|
||||
throw new Error("notification not found")
|
||||
throw new Error("notification not found");
|
||||
}
|
||||
|
||||
await R.trash(bean)
|
||||
await R.trash(bean);
|
||||
}
|
||||
|
||||
static checkApprise() {
|
||||
|
@ -145,17 +146,17 @@ async function applyNotificationEveryMonitor(notificationID, userID) {
|
|||
let checkNotification = await R.findOne("monitor_notification", " monitor_id = ? AND notification_id = ? ", [
|
||||
monitors[i].id,
|
||||
notificationID,
|
||||
])
|
||||
]);
|
||||
|
||||
if (! checkNotification) {
|
||||
let relation = R.dispense("monitor_notification");
|
||||
relation.monitor_id = monitors[i].id;
|
||||
relation.notification_id = notificationID;
|
||||
await R.store(relation)
|
||||
await R.store(relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Notification,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,6 +42,12 @@
|
|||
<input v-model="notification.applyExisting" class="form-check-input" type="checkbox">
|
||||
<label class="form-check-label">{{ $t("Apply on all existing monitors") }}</label>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="form-check form-switch">
|
||||
<input v-model="notification.incidents" class="form-check-input" type="checkbox">
|
||||
<label class="form-check-label">{{ $t("Include incidents") }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -145,6 +151,7 @@ export default {
|
|||
name: "",
|
||||
type: null,
|
||||
isDefault: false,
|
||||
incidents: true,
|
||||
};
|
||||
|
||||
// Set Default value here
|
||||
|
|
Loading…
Add table
Reference in a new issue