mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
feat: set childs under maintenance if parent is too
This commit is contained in:
parent
aba515e172
commit
f3ac351d75
3 changed files with 40 additions and 8 deletions
|
@ -1322,7 +1322,17 @@ class Monitor extends BeanModel {
|
||||||
ON maintenance_timeslot.maintenance_id = maintenance.id
|
ON maintenance_timeslot.maintenance_id = maintenance.id
|
||||||
WHERE ${activeCondition}
|
WHERE ${activeCondition}
|
||||||
LIMIT 1`, [ monitorID ]);
|
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 */
|
/** 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}`);
|
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,
|
maintenanceID,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
v-model="affectedMonitors"
|
v-model="affectedMonitors"
|
||||||
:options="affectedMonitorsOptions"
|
:options="affectedMonitorsOptions"
|
||||||
track-by="id"
|
track-by="id"
|
||||||
label="name"
|
label="pathName"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:close-on-select="false"
|
:close-on-select="false"
|
||||||
:clear-on-select="false"
|
:clear-on-select="false"
|
||||||
|
@ -342,17 +342,39 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init();
|
|
||||||
|
|
||||||
this.$root.getMonitorList((res) => {
|
this.$root.getMonitorList((res) => {
|
||||||
if (res.ok) {
|
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({
|
this.affectedMonitorsOptions.push({
|
||||||
id: monitor.id,
|
id: monitor.id,
|
||||||
name: monitor.name,
|
pathName: monitor.pathName,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.init();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -387,7 +409,7 @@ export default {
|
||||||
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
Object.values(res.monitors).map(monitor => {
|
Object.values(res.monitors).map(monitor => {
|
||||||
this.affectedMonitors.push(monitor);
|
this.affectedMonitors.push(this.affectedMonitorsOptions.find(item => item.id === monitor.id));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.msg);
|
toast.error(res.msg);
|
||||||
|
|
Loading…
Reference in a new issue