This repository has been archived on 2021-03-29. You can view files and clone it, but cannot push or open issues or pull requests.
statusboard/Resources/Views/home.leaf

58 lines
3.1 KiB
Plaintext
Raw Normal View History

2020-11-11 22:49:55 +00:00
#let(homeStatus = "active")
#let(pageTitle = "Home")
#define(body):
<div class="container">
<div class="page-header"><h1 class="page-title">Status</h1></div>
#for((node,services) in config.services):
<h6>#(node)</h6>
<div class="row row-cards row-deck">
#for(service in services):
<div class="col">
<div class="card">
<div class="card-header">
<h3 class="card-title">#(service["name"])</h3>
<div class="card-options">
2020-11-12 01:02:50 +00:00
<span class="tag #if(service["url"]): btn-loading #endif">
2020-11-11 22:49:55 +00:00
Status
<span id="#(service["name"])Status" class="tag-addon">Unavailable</span>
</span>
</div>
</div>
<div class="card-body">
#(service["description"])
</div>
#if(service["url"]):
<div class="card-footer">
URL: <a href="#(service["url"])">#(service["url"])</a>
</div>
#endif
</div>
#if(service["url"]):
<script>
fullURL = '#(service["url"])'
var url = fullURL.replace("https://", "")
url = url.replace("http://", "")
var request = new XMLHttpRequest()
request.open('GET', "/status/" + url, true)
request.onload = function () {
var data = JSON.parse(this.response)
if (data.down === "true" || parseInt(data.code) > 500 && parseInt(data.code) < 600 ) {
document.getElementById('#(service["name"])Status').classList.add("tag-danger")
2020-11-12 01:02:50 +00:00
document.getElementById('#(service["name"])Status').parentElement.classList.remove("btn-loading")
2020-11-11 22:49:55 +00:00
document.getElementById('#(service["name"])Status').innerHTML = "Offline"
} else {
document.getElementById('#(service["name"])Status').classList.add("tag-success")
2020-11-12 01:02:50 +00:00
document.getElementById('#(service["name"])Status').parentElement.classList.remove("btn-loading")
2020-11-11 22:49:55 +00:00
document.getElementById('#(service["name"])Status').innerHTML = "Online"
}
}
request.send()
</script>
#endif
</div>
#endfor
</div>
#endfor
</div>
#enddefine
#inline("base")