fix: improve layout & manual callback

This commit is contained in:
2023-11-12 08:38:43 +01:00
parent c1addbf9fb
commit 163854d7bd

View File

@@ -5,21 +5,29 @@
<div class="container"> <div class="container">
<script> <script>
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function submit_manual(){ function submit_manual(){
await fetch("/report", { fetch("/report", {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
"service" : "{{ service.service }}",
"token" : "{{ service.token }}", "token" : "{{ service.token }}",
"status" : "OK", "status" : "OK",
"info" : "Submitted from Web-Interface" }) "info" : "Submitted from Web-Interface" })
} }).then( () => {
) sleep(1000).then( () => {
window.location.reload() window.location.reload()
} })
}).catch( () => {
alert("Submission failed, see console for details.")
})
}
</script> </script>
<h2 class="service-name">Service: {{ service.service }}</h2> <h2 class="service-name">Service: {{ service.service }}</h2>
@@ -38,23 +46,23 @@
</div> </div>
{% endif %} {% endif %}
<a href="{{ icinga_link }}" style="clear: both;" class="last-status hover mr-3"> <a href="{{ icinga_link }}" style="clear: both;" class="last-status hover mr-3">
<p style="color: darkred;">Show in Icinga</p> <p style="color: darkred;">Show in Icinga</p>
</a> </a>
<button style="clear: both;" class="hover mr-3" onclick="submit_manual()"> <button style="clear: both;" class="last-status hover mr-3" onclick="submit_manual()">
<p style="color: darkred;">Submit manual OK</p> <p style="color: darkred;">Submit manual OK</p>
</button> </button>
<div class="last-status"> <div class="last-status">
{% if status_list | length > 0 %} {% if status_list | length > 0 %}
<p class="{{ status_list[0].status }}"> <p class="{{ status_list[0].status }}">
{{ status_list[0].status }} submitted on {{ status_list[0].human_date() }} {{ status_list[0].status }} submitted on {{ status_list[0].human_date() }}
</p> </p>
{% else %} {% else %}
<p style="color: darkred;">No status for this service submitted</p> <p style="color: darkred;">No status for this service submitted</p>
{% endif %} {% endif %}
</div> </div>
<div class="clear p-4 box mt-4 mb-3" style="display: none;"> <div class="clear p-4 box mt-4 mb-3" style="display: none;">
<div class="service-timeout">Timeout: {{ service.timeout }} days</div> <div class="service-timeout">Timeout: {{ service.timeout }} days</div>
@@ -90,23 +98,23 @@
</div> </div>
</div> </div>
<table class="mb-4 mt-5 status-table"> <table class="mb-4 mt-5 status-table">
<thead> <thead>
<th>Date</th> <th>Date</th>
<th>Status</th> <th>Status</th>
<th>Info</th> <th>Info</th>
</thead> </thead>
<tbody class="mt-2"> <tbody class="mt-2">
{% for status in status_list %} {% for status in status_list %}
<tr> <tr>
<td>{{ status.human_date() }}</td> <td>{{ status.human_date() }}</td>
<td class="{{ status.status }}">{{ status.status }}</td> <td class="{{ status.status }}">{{ status.status }}</td>
<td>{{ status.info_text }}</td> <td>{{ status.info_text }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</body> </body>
</html> </html>