gatus/static/index.html

66 lines
2.3 KiB
HTML
Raw Normal View History

2019-09-12 22:15:42 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<title>gatus</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container my-3 bg-light rounded p-4 border shadow">
2019-09-17 02:29:06 +02:00
<div class="text-center mb-3">
2019-09-12 22:15:42 +02:00
<div class="display-4">Gatus</div>
</div>
2019-09-17 02:29:06 +02:00
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Status</th>
<th scope="col">Hostname</th>
<th scope="col">Response time</th>
</tr>
</thead>
<tbody id="results">
</tbody>
</table>
</div>
2019-09-12 22:15:42 +02:00
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
2019-09-15 01:25:59 +02:00
2019-09-12 22:15:42 +02:00
<script>
const OK = "<span class=\"badge badge-success\">&#10003;</span>&nbsp;";
const NOK = "<span class=\"badge badge-danger\">X</span>&nbsp;";
function refreshTable() {
$.getJSON("/api/v1/results", function (data) {
let tableBody = "";
for (let serviceName in data) {
let serviceStatus = "";
let hostname =data[serviceName][data[serviceName].length-1].hostname
2019-09-12 22:15:42 +02:00
for (let key in data[serviceName]) {
let entry = data[serviceName][key];
console.log(data[serviceName][key]);
2019-09-16 04:43:28 +02:00
serviceStatus = (entry.success ? OK : NOK) + serviceStatus;
2019-09-12 22:15:42 +02:00
}
tableBody += ""
+ "<tr>"
+ " <td>" + serviceName + "</td>"
+ " <td>" + serviceStatus + "</td>"
+ " <td><a href=\"//" + hostname + "\">" + hostname + "</a></td>"
2019-09-16 04:43:28 +02:00
+ " <td>" + parseInt(data[serviceName][data[serviceName].length-1].duration / 1000000) + "ms </td>"
2019-09-12 22:15:42 +02:00
+ "</tr>";
}
$("#results").html(tableBody);
});
}
refreshTable();
setInterval(function() {
refreshTable();
2019-09-17 02:29:06 +02:00
}, 3000);
2019-09-12 22:15:42 +02:00
</script>
</body>
</html>