fix: display status with description in weinfo page, add fallbacks for undefined values, handle empty times table

This commit is contained in:
2026-07-11 07:49:27 -04:00
parent ff4e46858b
commit ce66b0de3f

View File

@@ -1,8 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-<begin▁of▁sentence>8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-w, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bal Server List</title> <title>Bal Server List</title>
<link rel="icon" href="Logo_nero.ico" type="image/x-icon"> <link rel="icon" href="Logo_nero.ico" type="image/x-icon">
<script src="/qrcode.min.js"></script> <script src="/qrcode.min.js"></script>
@@ -11,22 +11,22 @@
</head> </head>
<style> <style>
table { table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
margin-top: 20px; margin-top: 20px;
} }
th, td { th, td {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 8px; padding: 8px;
text-align: left; text-align: left;
} }
th { th {
background-color: #f2f2f2; background-color: #f2f2f2;
} }
tr:nth-child(even) { tr:nth-child(even) {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
span{ span {
margin-left:10px; margin-left:10px;
} }
</style> </style>
@@ -91,8 +91,19 @@
document.getElementById('wetld').innerHTML = DOMPurify.sanitize(data.tld||'—'); document.getElementById('wetld').innerHTML = DOMPurify.sanitize(data.tld||'—');
document.getElementById('webalance').innerHTML = data.balance != null ? data.balance : '—'; document.getElementById('webalance').innerHTML = data.balance != null ? data.balance : '—';
document.getElementById('weversion').innerHTML = data.version||'—'; document.getElementById('weversion').innerHTML = data.version||'—';
document.getElementById('westatus').innerHTML = DOMPurify.sanitize(data.status||'—'); const statusMap = {
document.getElementById('weupdate').innerHTML = data.last_update||'—'; 'OK': 'Health check passed',
'TIMEOUT': 'Connection timeout',
'CONNECTION': 'Connection error',
'STATUS': 'HTTP error',
'WRONG REPLY': 'Invalid JSON response',
'REQUEST': 'Request error',
'BODY': 'Body read error',
'DECODE': 'Decode error',
'KO': 'Generic error'
};
const st = (data.status||'').split(':')[0];
document.getElementById('westatus').innerHTML = DOMPurify.sanitize(data.status||'—') + (statusMap[st] ? ' (' + statusMap[st] + ')' : '');
const tableBody = document.querySelector('#wetimes tbody'); const tableBody = document.querySelector('#wetimes tbody');
tableBody.innerHTML =''; tableBody.innerHTML ='';
@@ -130,8 +141,6 @@
} }
getWeInfo(); getWeInfo();
</script> </script>
</body> </body>
</html> </html>