blob: ef428a5e2ce52e7281daba26614ac1c99392d132 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
(function () {
const table = document.querySelector('#monitorcito');
function loadData () {
fetch('/api')
.then((response) => response.json())
.then((serviceStatus) => {
while (table.firstChild) {
table.removeChild(table.firstChild)
}
for (const [service, isActive] of Object.entries(serviceStatus)) {
const row = document.createElement('tr');
const serviceCell = document.createElement('td');
serviceCell.appendChild(document.createTextNode(service));
const isActiveCell = document.createElement('td');
isActiveCell.appendChild(document.createTextNode(isActive ? 'OK' : 'FAIL'));
isActiveCell.classList.add(isActive);
row.appendChild(serviceCell);
row.appendChild(isActiveCell);
table.appendChild(row);
}
setTimeout(loadData, 5000);
})
.catch(() => {
const container = document.querySelector('main');
container.removeChild(table);
const paragraph = document.createElement('p');
paragraph.appendChild(document.createTextNode('Everything is broken. If your internet works, please check the server\'s not on fire. When in doubt, just refresh.'));
paragraph.classList.add('critical');
container.appendChild(paragraph);
})
}
loadData();
}
)();
|