[status page]

pull/124/head
LouisLam 3 years ago
parent 34abff4724
commit f9311e4e7f

@ -0,0 +1,50 @@
let express = require("express");
const { allowDevAllOrigin, getSettings } = require("../util-server");
const { R } = require("redbean-node");
let router = express.Router();
// Status Page Config
router.get("/api/status-page/config", async (_request, response) => {
allowDevAllOrigin(response);
let config = getSettings("statusPage");
if (! config.statusPageTheme) {
config.statusPageTheme = "light";
}
response.json(config);
});
// Status Page - Monitor List
router.get("/api/status-page/monitor-list", async (_request, response) => {
allowDevAllOrigin(response);
const monitorList = {};
let list = await R.find("monitor", " public = 1 ORDER BY weight DESC, name ", [
]);
for (let monitor of list) {
monitorList[monitor.id] = await monitor.toJSON();
}
response.json(monitorList);
});
// Status Page Polling Data
router.get("/api/status-page/heartbeat", async (_request, response) => {
allowDevAllOrigin(response);
const monitorList = {};
let list = await R.find("", " ", [
])
for (let monitor of list) {
monitorList[monitor.id] = await monitor.toJSON();
}
response.json({
monitorList: monitorList,
});
});
module.exports = router;

@ -157,53 +157,9 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
response.redirect("https://github.com/louislam/uptime-kuma/wiki/Reset-Password-via-CLI"); response.redirect("https://github.com/louislam/uptime-kuma/wiki/Reset-Password-via-CLI");
}); });
// *************************** // API Router
// Public API const apiRouter = require("./routers/api-router");
// *************************** app.use(apiRouter);
// Status Page Config
app.get("/api/status-page/config", async (_request, response) => {
allowDevAllOrigin(response);
let config = getSettings("statusPage");
if (! config.statusPageTheme) {
config.statusPageTheme = "light";
}
response.json(config);
});
// Status Page - Monitor List
app.get("/api/status-page/monitor-list", async (_request, response) => {
allowDevAllOrigin(response);
const monitorList = {};
let list = await R.find("monitor", " public = 1 ORDER BY weight DESC, name ", [
]);
for (let monitor of list) {
monitorList[monitor.id] = await monitor.toJSON();
}
response.json(monitorList);
});
// Status Page Polling Data
app.get("/api/status-page/heartbeat", async (_request, response) => {
allowDevAllOrigin(response);
const monitorList = {};
let list = await R.find("", " ", [
])
for (let monitor of list) {
monitorList[monitor.id] = await monitor.toJSON();
}
response.json({
monitorList: monitorList,
});
});
// Universal Route Handler, must be at the end of all express route. // Universal Route Handler, must be at the end of all express route.
app.get("*", async (_request, response) => { app.get("*", async (_request, response) => {

@ -368,3 +368,9 @@ h2 {
background-color: #f8d7da; background-color: #f8d7da;
border-color: #f8d7da; border-color: #f8d7da;
} }
.btn-success {
color: #fff;
background-color: #4caf50;
border-color: #4caf50;
}

@ -31,6 +31,10 @@
</div> </div>
</div> </div>
<div class="mt-4">
Free text here.
</div>
<div class="shadow-box list p-4 overall-status mt-4"> <div class="shadow-box list p-4 overall-status mt-4">
<div v-if="false"> <div v-if="false">
<font-awesome-icon icon="check-circle" class="ok" /> <font-awesome-icon icon="check-circle" class="ok" />

Loading…
Cancel
Save