This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/resources/views/yuuno/status/index.twig

80 lines
2.8 KiB
Twig
Raw Permalink Normal View History

2017-03-23 15:01:53 +00:00
{% extends '@yuuno/master.twig' %}
{% set title = 'Status' %}
2016-12-10 22:36:24 +00:00
{% block js %}
<script>
var yuunoStatusStates = [
{"text": "Offline", "colour": "#800"},
{"text": "Experiencing Issues", "colour": "#840"},
{"text": "Online", "colour": "#080"}
];
var yuunoStatusEndpoints = {{ endpoints|json_encode|raw }};
function yuunoCheckStatus(endpoint) {
var client = new Sakura.AJAX;
client.SetUrl("{{ route('status.data') }}?history=0&name=" + endpoint);
client.AddCallback(200, function () {
var result = client.JSON(),
field = document.querySelector('[data-status-name="' + endpoint + '"]');
if (result.error) {
if (field) {
field.innerText = 'error';
}
var error = new Sakura.Dialogue;
error.Title = "Status";
error.Text = result.error;
error.Display();
} else {
var state = yuunoStatusStates[result.state];
field.innerText = state.text;
field.style.color = state.colour;
}
});
client.Start(Sakura.HTTPMethod.GET);
}
window.addEventListener("load", function () {
for (var i in yuunoStatusEndpoints) {
var endpoint = yuunoStatusEndpoints[i];
yuunoCheckStatus(endpoint);
}
});
</script>
{% endblock %}
{% block content %}
2016-12-10 22:36:24 +00:00
<div class="content status">
<div class="content__header">Status</div>
2016-08-04 15:34:25 +00:00
<div class="status__services">
2016-12-09 22:28:25 +00:00
{% for name in endpoints %}
2016-12-10 22:36:24 +00:00
<div class="status__service">
<h1>{{ name }}</h1>
<h3 data-status-name="{{ name }}">loading...</h3>
2016-12-09 22:28:25 +00:00
</div>
{% endfor %}
2016-08-04 15:34:25 +00:00
</div>
2016-12-10 22:36:24 +00:00
<div class="content__header">Incidents</div>
2016-12-09 22:28:25 +00:00
{% for date, events in incidents %}
2016-12-10 22:36:24 +00:00
<div class="news__head">{{ date }}</div>
{% if events|length > 0 %}
<table>
{% for event in events %}
{% set state = event.state|lower %}
<tr>
<td><b><span style="font-size: .8em">{{ event.time }} UTC</span></b></td>
<td><b style="font-size: .8em; color: {% if state == 'resolved' %}#080{% elseif state == 'monitoring' %}#800{% else %}#840{% endif %}">{{ event.state }}</b></td>
<td>{{ event.comment }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<i>No incidents occurred.</i>
{% endif %}
2016-12-09 22:28:25 +00:00
{% endfor %}
</div>
{% endblock %}