From 573c7faddd40b3af95ab768a5a141af00e0a091e Mon Sep 17 00:00:00 2001 From: LouisLam Date: Thu, 9 Sep 2021 21:24:29 +0800 Subject: [PATCH] switch on the notification, if it is added in EditMonitor.vue --- server/notification.js | 2 ++ server/server.js | 3 ++- src/components/NotificationDialog.vue | 9 ++++++++- src/pages/EditMonitor.vue | 12 +++++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/notification.js b/server/notification.js index b2d9d581..83dabc53 100644 --- a/server/notification.js +++ b/server/notification.js @@ -99,6 +99,8 @@ class Notification { if (notification.applyExisting) { await applyNotificationEveryMonitor(bean.id, userID); } + + return bean; } static async delete(notificationID, userID) { diff --git a/server/server.js b/server/server.js index bfebb89f..2949c4be 100644 --- a/server/server.js +++ b/server/server.js @@ -527,12 +527,13 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString(); try { checkLogin(socket) - await Notification.save(notification, notificationID, socket.userID) + let notificationBean = await Notification.save(notification, notificationID, socket.userID) await sendNotificationList(socket) callback({ ok: true, msg: "Saved", + id: notificationBean.id, }); } catch (e) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 447b1926..6d54d565 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -454,6 +454,7 @@ export default { SMTP, }, props: {}, + emits: ["added"], data() { return { model: null, @@ -532,7 +533,13 @@ export default { this.processing = false; if (res.ok) { - this.modal.hide() + this.modal.hide(); + + // Emit added event, doesn't emit edit. + if (! this.id) { + this.$emit("added", res.id); + } + } }) }, diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index ed09a7ba..420c4900 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -10,7 +10,7 @@
- @@ -190,7 +190,7 @@
- + @@ -283,7 +283,7 @@ export default { methods: { init() { if (this.isAdd) { - console.log("??????") + this.monitor = { type: "http", name: "", @@ -338,6 +338,12 @@ export default { }) } }, + + // Added a Notification Event + // Enable it if the notification is added in EditMonitor.vue + addedNotification(id) { + this.monitor.notificationIDList[id] = true; + }, }, }