feat: set childs under maintenance if parent is too
This commit is contained in:
parent
aba515e172
commit
f3ac351d75
|
@ -1322,7 +1322,17 @@ class Monitor extends BeanModel {
|
|||
ON maintenance_timeslot.maintenance_id = maintenance.id
|
||||
WHERE ${activeCondition}
|
||||
LIMIT 1`, [ monitorID ]);
|
||||
return maintenance.count !== 0;
|
||||
|
||||
if (maintenance.count !== 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if parent is under maintenance
|
||||
const parent = await Monitor.getParent(monitorID);
|
||||
if (parent === null) {
|
||||
return false;
|
||||
}
|
||||
return await Monitor.isUnderMaintenance(parent.id);
|
||||
}
|
||||
|
||||
/** Make sure monitor interval is between bounds */
|
||||
|
|
|
@ -187,7 +187,7 @@ module.exports.maintenanceSocketHandler = (socket) => {
|
|||
|
||||
log.debug("maintenance", `Get Monitors for Maintenance: ${maintenanceID} User ID: ${socket.userID}`);
|
||||
|
||||
let monitors = await R.getAll("SELECT monitor.id, monitor.name FROM monitor_maintenance mm JOIN monitor ON mm.monitor_id = monitor.id WHERE mm.maintenance_id = ? ", [
|
||||
let monitors = await R.getAll("SELECT monitor.id FROM monitor_maintenance mm JOIN monitor ON mm.monitor_id = monitor.id WHERE mm.maintenance_id = ? ", [
|
||||
maintenanceID,
|
||||
]);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
v-model="affectedMonitors"
|
||||
:options="affectedMonitorsOptions"
|
||||
track-by="id"
|
||||
label="name"
|
||||
label="pathName"
|
||||
:multiple="true"
|
||||
:close-on-select="false"
|
||||
:clear-on-select="false"
|
||||
|
@ -342,17 +342,39 @@ export default {
|
|||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
|
||||
this.$root.getMonitorList((res) => {
|
||||
if (res.ok) {
|
||||
Object.values(this.$root.monitorList).map(monitor => {
|
||||
Object.values(this.$root.monitorList).sort((m1, m2) => {
|
||||
|
||||
if (m1.active !== m2.active) {
|
||||
if (m1.active === 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m2.active === 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (m1.weight !== m2.weight) {
|
||||
if (m1.weight > m2.weight) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (m1.weight < m2.weight) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return m1.pathName.localeCompare(m2.pathName);
|
||||
}).map(monitor => {
|
||||
this.affectedMonitorsOptions.push({
|
||||
id: monitor.id,
|
||||
name: monitor.name,
|
||||
pathName: monitor.pathName,
|
||||
});
|
||||
});
|
||||
}
|
||||
this.init();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
@ -387,7 +409,7 @@ export default {
|
|||
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
||||
if (res.ok) {
|
||||
Object.values(res.monitors).map(monitor => {
|
||||
this.affectedMonitors.push(monitor);
|
||||
this.affectedMonitors.push(this.affectedMonitorsOptions.find(item => item.id === monitor.id));
|
||||
});
|
||||
} else {
|
||||
toast.error(res.msg);
|
||||
|
|
Loading…
Reference in New Issue