mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 19:39:40 +08:00
[status page] many update and save group list
This commit is contained in:
33
server/model/group.js
Normal file
33
server/model/group.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const { BeanModel } = require("redbean-node/dist/bean-model");
|
||||
const { R } = require("redbean-node");
|
||||
|
||||
class Group extends BeanModel {
|
||||
|
||||
async toPublicJSON() {
|
||||
|
||||
let monitorBeanList = R.convertToBeans("monitor", await R.getAll(`
|
||||
SELECT * FROM monitor, monitor_group
|
||||
WHERE monitor.id = monitor_group.monitor_id
|
||||
AND group_id = ?
|
||||
`, [
|
||||
this.id,
|
||||
]));
|
||||
|
||||
console.log(monitorBeanList);
|
||||
|
||||
let monitorList = [];
|
||||
|
||||
for (let bean of monitorBeanList) {
|
||||
monitorList.push(await bean.toPublicJSON());
|
||||
}
|
||||
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
weight: this.weight,
|
||||
monitorList,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Group;
|
@@ -10,6 +10,7 @@ class Incident extends BeanModel {
|
||||
content: this.content,
|
||||
pin: this.pin,
|
||||
createdDate: this.createdDate,
|
||||
lastUpdatedDate: this.lastUpdatedDate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,10 @@ class Monitor extends BeanModel {
|
||||
* Only show necessary data to public
|
||||
*/
|
||||
async toPublicJSON() {
|
||||
// TODO Only show necessary
|
||||
return this.toJSON();
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user