mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-09-07 09:51:57 +00:00
![Matthew Nickson](/assets/img/avatar_default.png)
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
const { R } = require("redbean-node");
|
|
|
|
class Group extends BeanModel {
|
|
|
|
/**
|
|
* Return an object that ready to parse to JSON for public Only show
|
|
* necessary data to public
|
|
* @param {boolean} showTags Should the JSON include monitor tags
|
|
* @param {boolean} certExpiry Should JSON include info about
|
|
* certificate expiry?
|
|
* @returns {object} Object ready to parse
|
|
*/
|
|
async toPublicJSON(showTags = false, certExpiry = false) {
|
|
let monitorBeanList = await this.getMonitorList();
|
|
let monitorList = [];
|
|
|
|
for (let bean of monitorBeanList) {
|
|
monitorList.push(await bean.toPublicJSON(showTags, certExpiry));
|
|
}
|
|
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
weight: this.weight,
|
|
monitorList,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get all monitors
|
|
* @returns {Bean[]} List of monitors
|
|
*/
|
|
async getMonitorList() {
|
|
return R.convertToBeans("monitor", await R.getAll(`
|
|
SELECT monitor.*, monitor_group.send_url FROM monitor, monitor_group
|
|
WHERE monitor.id = monitor_group.monitor_id
|
|
AND group_id = ?
|
|
ORDER BY monitor_group.weight
|
|
`, [
|
|
this.id,
|
|
]));
|
|
}
|
|
}
|
|
|
|
module.exports = Group;
|