Merge branch 'master' into 'master'

redo frontend

See merge request elixire/elstat!1
This commit is contained in:
Luna Mendes 2018-06-12 19:45:10 +00:00
commit 16e471d865
1 changed files with 24 additions and 3 deletions

View File

@ -1,9 +1,26 @@
<html> <html>
<head> <head>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<style> <style>
body { background-color: #ddd; }
p { p {
font-size: 15pt; text-align: center;
font-family: sans-serif;
font-size: 13pt;
}
#pretty-box {
padding-left: 5px;
max-width: 500px;
max-height: 250px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
background-color: #eee;
border-radius: 15px;
} }
</style> </style>
<script> <script>
@ -20,7 +37,8 @@
} }
function genText(data) { function genText(data) {
base = `${data.description} - status: ${data.status}`; base = `${data.description}`;
base += ` [${data.status ? "online" : "offline"}]`;
if('latency' in data) { if('latency' in data) {
base += ` - latency: ${data.latency} ms`; base += ` - latency: ${data.latency} ms`;
@ -30,6 +48,7 @@
} }
function curStatHandler(text) { function curStatHandler(text) {
let box = document.getElementById('pretty-box');
let payload = JSON.parse(text); let payload = JSON.parse(text);
for(const service in payload) { for(const service in payload) {
@ -43,7 +62,7 @@
element.id = elementId; element.id = elementId;
element.innerText = genText(data); element.innerText = genText(data);
document.body.appendChild(element); box.appendChild(element);
} else { } else {
existingElement.innerText = genText(data); existingElement.innerText = genText(data);
} }
@ -67,6 +86,8 @@
</head> </head>
<body> <body>
<div id="pretty-box">
</div>
</body> </body>
</html> </html>