|
|
|
|
@ -1060,6 +1060,27 @@ let needSetup = false;
|
|
|
|
|
|
|
|
|
|
const startTime = Date.now();
|
|
|
|
|
|
|
|
|
|
// Check if this is a group monitor and unlink children before deletion
|
|
|
|
|
const monitor = await R.findOne("monitor", " id = ? AND user_id = ? ", [
|
|
|
|
|
monitorID,
|
|
|
|
|
socket.userID,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (monitor && monitor.type === "group") {
|
|
|
|
|
// Get all children before unlinking them
|
|
|
|
|
const children = await Monitor.getChildren(monitorID);
|
|
|
|
|
|
|
|
|
|
// Unlink all children from the group
|
|
|
|
|
await Monitor.unlinkAllChildren(monitorID);
|
|
|
|
|
|
|
|
|
|
// Notify frontend to update each child monitor's parent to null
|
|
|
|
|
if (children && children.length > 0) {
|
|
|
|
|
for (const child of children) {
|
|
|
|
|
await server.sendUpdateMonitorIntoList(socket, child.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
|
|
|
|
|
monitorID,
|
|
|
|
|
socket.userID,
|
|
|
|
|
|