diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-24 20:10:53 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-24 20:10:53 +0100 |
| commit | 7dfd7b404cdcf0db8e44a8b357cd108e10a725e1 (patch) | |
| tree | e92fbf31cde6107e818777c8488fa61a67f3e9ff /174bg/database/volumes/pocketbase/pb_hooks/views/stats.html | |
| parent | eb719a5416391521d536980e974f97b7ac8b78e3 (diff) | |
| download | unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.gz unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.bz2 unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.xz unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.zip | |
better arch of stats
Diffstat (limited to '174bg/database/volumes/pocketbase/pb_hooks/views/stats.html')
| -rw-r--r-- | 174bg/database/volumes/pocketbase/pb_hooks/views/stats.html | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html b/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html index b59c1a7..b61a1ba 100644 --- a/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html +++ b/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html @@ -3,8 +3,7 @@ {{end}} {{define "body"}} - <p id="timeDifference">Time Difference: {{.timeDifference}}</p> - <p id="withinThreshold">Within Threshold: {{.withinThreshold}}</p> + <p id="app"></p> <script> window.addEventListener("load", () => { @@ -12,14 +11,22 @@ }); async function fetchStats() { - let heartbeat = await fetch("/api/heartbeat"); - heartbeat = await heartbeat.json(); + let stats = await fetch("/api/stats"); + stats = await stats.json(); + document.getElementById("app").innerHTML = jsonToHtml(stats); + } - const timeDifference = heartbeat.timeDifference; - const withinThreshold = heartbeat.withinThreshold; + function jsonToHtml(json) { + if (json === null || typeof json !== "object") { + return String(json); + } - document.getElementById("timeDifference").textContent = `Time Difference: ${timeDifference}`; - document.getElementById("withinThreshold").textContent = `Within Threshold: ${withinThreshold}`; + let html = "<ul>"; + for (const [key, value] of Object.entries(json)) { + html += `<li>${key}: ${typeof value === "object" && value !== null ? jsonToHtml(value) : String(value)}</li>`; + } + html += "</ul>"; + return html; } </script> {{end}}
\ No newline at end of file |
