Add first version of UI
This commit is contained in:
62
static/index.html
Normal file
62
static/index.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!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">
|
||||
<div class="text-center">
|
||||
<div class="display-4">Gatus</div>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
||||
<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>
|
||||
<script>
|
||||
const OK = "<span class=\"badge badge-success\">✓</span> ";
|
||||
const NOK = "<span class=\"badge badge-danger\">X</span> ";
|
||||
|
||||
function refreshTable() {
|
||||
$.getJSON("/api/v1/results", function (data) {
|
||||
let tableBody = "";
|
||||
for (let serviceName in data) {
|
||||
let serviceStatus = "";
|
||||
for (let key in data[serviceName]) {
|
||||
let entry = data[serviceName][key];
|
||||
console.log(data[serviceName][key]);
|
||||
serviceStatus += entry.success ? OK : NOK;
|
||||
}
|
||||
tableBody += ""
|
||||
+ "<tr>"
|
||||
+ " <td>" + serviceName + "</td>"
|
||||
+ " <td>" + serviceStatus + "</td>"
|
||||
+ " <td>" + data[serviceName][0].hostname + "</td>"
|
||||
+ " <td>" + parseInt(data[serviceName][0].duration / 1000000) + "ms </td>"
|
||||
+ "</tr>";
|
||||
}
|
||||
$("#results").html(tableBody);
|
||||
});
|
||||
}
|
||||
|
||||
refreshTable();
|
||||
setInterval(function() {
|
||||
refreshTable();
|
||||
}, 10000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user