web/public/obj/js/services.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-10-16 01:35:06 +02:00
const SERVICE_BLACKLIST = [
'ixvd.net',
'proxy',
'2d.neo.ixvd.net',
'pad.sandbox.neo.ixvd.net',
];
const serviceHolderDiv = document.querySelector('#service-holder');
async function update() {
serviceHolderDiv.innerHTML = 'Loading...';
let fetchResult = await (await fetch('/relay/gatus')).json()
2023-10-16 01:35:06 +02:00
serviceHolderDiv.innerHTML = '';
fetchResult.forEach(s => {
if (!s.results || s.results.length === 0) return;
let service = s.results[0];
if (service.hostname && !SERVICE_BLACKLIST.includes(service.hostname) && service.status === 200) {
let serviceDiv = document.createElement('div');
serviceDiv.classList.add('service');
serviceDiv.innerHTML = `
<span class="service-name"><a href="https://${service.hostname}" target="_blank" style="color: #de4aff">${service.hostname}</a></span>
<span class="service-status"><b style="color: ${service.success ? '#4f4' : 'red'}">${service.success ? 'Online' : 'Offline'}</b></span>
`;
serviceHolderDiv.appendChild(serviceDiv);
}
})
}
update();