From a032e11a2efb629fde80ae6644ad6719a0c2f735 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:48:21 +0800 Subject: [PATCH] Feat: Create Group in EditMonitor page (#3379) * Feat: Create Group in EditMonitor page * Fix: Start group mon. after child is added * Chore: Swap confirm & cancel for ergonomics * Fix rarely issue that group monitor can throw an error if lastBeat is null * Resume the group monitor in the callback --------- Co-authored-by: Louis Lam --- server/model/monitor.js | 5 +- server/server.js | 5 +- src/components/ActionSelect.vue | 70 +++++++++++ src/components/CreateGroupDialog.vue | 56 +++++++++ src/pages/EditMonitor.vue | 182 +++++++++++++++++++++------ 5 files changed, 277 insertions(+), 41 deletions(-) create mode 100644 src/components/ActionSelect.vue create mode 100644 src/components/CreateGroupDialog.vue diff --git a/server/model/monitor.js b/server/model/monitor.js index 8f32132ba..f33dcbb76 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -351,7 +351,10 @@ class Monitor extends BeanModel { const lastBeat = await Monitor.getPreviousHeartbeat(child.id); // Only change state if the monitor is in worse conditions then the ones before - if (bean.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { + // lastBeat.status could be null + if (!lastBeat) { + bean.status = PENDING; + } else if (bean.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { bean.status = lastBeat.status; } else if (bean.status === PENDING && lastBeat.status === DOWN) { bean.status = lastBeat.status; diff --git a/server/server.js b/server/server.js index 4917402d8..ad01eab2f 100644 --- a/server/server.js +++ b/server/server.js @@ -657,7 +657,10 @@ let needSetup = false; await updateMonitorNotification(bean.id, notificationIDList); await server.sendMonitorList(socket); - await startMonitor(socket.userID, bean.id); + + if (monitor.active !== false) { + await startMonitor(socket.userID, bean.id); + } log.info("monitor", `Added Monitor: ${monitor.id} User ID: ${socket.userID}`); diff --git a/src/components/ActionSelect.vue b/src/components/ActionSelect.vue new file mode 100644 index 000000000..ae09e6566 --- /dev/null +++ b/src/components/ActionSelect.vue @@ -0,0 +1,70 @@ + + + diff --git a/src/components/CreateGroupDialog.vue b/src/components/CreateGroupDialog.vue new file mode 100644 index 000000000..ed20610c7 --- /dev/null +++ b/src/components/CreateGroupDialog.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 333dfaaff..515f84d90 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -102,11 +102,13 @@
- +
@@ -807,6 +809,7 @@ + @@ -814,20 +817,60 @@