aboutsummaryrefslogtreecommitdiff
path: root/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html
blob: b59c1a750d7ec08cec74c67e645924463ebdf6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{{define "title"}}
    stats
{{end}}

{{define "body"}}
    <p id="timeDifference">Time Difference: {{.timeDifference}}</p>
    <p id="withinThreshold">Within Threshold: {{.withinThreshold}}</p>

    <script>
        window.addEventListener("load", () => {
            setInterval(fetchStats, 100);
        });

        async function fetchStats() {
            let heartbeat = await fetch("/api/heartbeat");
            heartbeat = await heartbeat.json();

            const timeDifference = heartbeat.timeDifference;
            const withinThreshold = heartbeat.withinThreshold;

            document.getElementById("timeDifference").textContent = `Time Difference: ${timeDifference}`;
            document.getElementById("withinThreshold").textContent = `Within Threshold: ${withinThreshold}`;
        }
    </script>
{{end}}