This repository has been archived on 2021-05-23. You can view files and clone it, but cannot push or open issues or pull requests.
simpledash/resources/templates/cards/status.html

40 lines
1.4 KiB
HTML
Raw Normal View History

2021-03-26 05:25:10 +00:00
<div class="card-header">
<a class="card-header-title" href="{{.URL}}">
{{if ne .Icon ""}}
{{template "icon" .Icon}}&nbsp;
{{end}}
{{.Title}}
</a>
<div class="card-header-icon">
<div class="tags has-addons">
<p class="tag">Status</p>
<p class="tag is-warning" id="{{.Title}}Status">Loading...</p>
</div>
</div>
</div>
{{if ne .Description ""}}
<div class="card-content">
<p>{{.Description}}</p>
</div>
{{end}}
<div class="card-footer" style="margin-top: auto">
<a class="card-footer-item has-text-info" href="{{.URL}}">{{.URL}}</a>
</div>
<script>
var request = new XMLHttpRequest()
request.open('GET', "/status/{{b64enc .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('{{.Title}}Status').classList.remove("is-warning")
document.getElementById('{{.Title}}Status').classList.add("is-danger")
document.getElementById('{{.Title}}Status').innerHTML = "Offline"
} else {
document.getElementById('{{.Title}}Status').classList.remove("is-warning")
document.getElementById('{{.Title}}Status').classList.add("is-success")
document.getElementById('{{.Title}}Status').innerHTML = "Online"
}
}
request.send()
</script>