feat: show last rtt in web page

This commit is contained in:
əlemi 2024-12-02 23:44:27 +01:00
parent bd771fd4a6
commit 728f1a46ae
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -72,13 +72,13 @@ function cell(timestamp, rtt) {
} }
} }
function card(key, history) { function card(key, history, last_rtt) {
let bar = ""; let bar = "";
for (let el of history) { for (let el of history) {
bar += cell(el[0], el[1]); bar += cell(el[0], el[1]);
} }
return `<div class="card"> return `<div class="card">
<h3>${key}</h3> <h3>${key} (${last_rtt}ms)</h3>
<div class="box"> <div class="box">
<span class="nobr">${bar}</span> <span class="nobr">${bar}</span>
</div> </div>
@ -99,7 +99,7 @@ async function updateStatus() {
for (let key of keys) { for (let key of keys) {
let res = await fetch(`/api/status/${key}`); let res = await fetch(`/api/status/${key}`);
let history = await res.json(); let history = await res.json();
out += card(key, history); out += card(key, history, status[key]);
} }
main.innerHTML = out; main.innerHTML = out;