Files
icinga-webhook-gateway/templates/service_info.html
2024-01-01 20:41:29 +01:00

126 lines
5.2 KiB
HTML

{% include "head.html" %}
<html>
<body>
{% include "navbar.html" %}
<div class="container">
<script>
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function submit_manual(){
fetch("/report", {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify({
"service" : "{{ service.service }}",
"token" : "{{ service.token }}",
"status" : "OK",
"info" : "Submitted from Web-Interface" })
}).then( () => {
sleep(1000).then( () => {
window.location.reload()
})
}).catch( () => {
alert("Submission failed, see console for details.")
})
}
</script>
<h2 class="service-name">Service: {{ service.service }}</h2>
{% if service.staticly_configured %}
{% endif %}
{% if service.special_type == "SMART" %}
<div class="service-info-button mt-3" style="background-color: orange;">
Smart Monitor {% if smart_entry %} for: {{ smart.model_number }} {% endif %}
</div>
{% endif %}
{% if not service.staticly_configured %}
<a class="service-info-button mt-3" style="background-color: orange;"
href="/entry-form?service={{ service.service }}">Modify</a>
<a class="service-info-button mt-3" style="background-color: red;"
href="/entry-form?service={{ service.service }}&operation=delete">Delete</a>
{% else %}
<div class="static-configured-info">
This service is staticly configured, to edit or delete it, you have to modify the
configuration file on the server.
</div>
{% endif %}
<a href="{{ icinga_link }}" style="clear: both;" class="last-status hover mr-3">
<p style="color: darkred;">Show in Icinga</p>
</a>
<button style="clear: both;" class="last-status hover mr-3" onclick="submit_manual()">
<p style="color: darkred;">Submit manual OK</p>
</button>
<div class="last-status">
{% if status_list | length > 0 %}
<p class="{{ status_list[0].status }}">
{{ status_list[0].status }} submitted on {{ status_list[0].human_date() }}
</p>
{% else %}
<p style="color: darkred;">No status for this service submitted</p>
{% endif %}
</div>
<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">Owner: {{ service.owner }}</div>
<div style="display: none;"
class="service-token">Secret Token: {{ service.token }}</div>
</div>
<h5 class="clear my-4">Curl</h5>
<div class="ml-3 example">
curl -X POST \ <br>
<div class="example-indent">
-H "Content-Type: application/json" \ <br>
-d '{ "service" : "{{ service.service }}",
"token" : "{{ service.token }}", <br>
"status" : "OK", "info" : "Free Text Information here" }' \<br>
{{ flask.request.url_root.replace("http://", "https://" )}}report
</div>
</div>
<h5 class="my-4">Python</h5>
<div class="ml-3 example">
import requests<br>
requests.post("{{ flask.request.url_root.replace("http://", "https://")}}report",
<br>
<div class="example-indent-double">
json= { "service" : "{{ service.service }}", <br>
<div class="example-indent-double">
"token" : "{{ service.token }}", <br>
"status" : "OK", </br>
"info" : "additional information" })
</div>
</div>
</div>
<table class="mb-4 mt-5 status-table">
<thead>
<th>Date</th>
<th>Status</th>
<th>Info</th>
</thead>
<tbody class="mt-2">
{% for status in status_list %}
<tr>
<td>{{ status.human_date() }}</td>
<td class="{{ status.status }}">{{ status.status }}</td>
<td>{{ status.info_text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>