feat: entry creation % details

This commit is contained in:
2023-07-02 16:20:38 +02:00
parent 8fc4fca2a1
commit af6c3ff0eb
7 changed files with 271 additions and 27 deletions

View File

@@ -0,0 +1,24 @@
{% include "head.html" %}
<body>
<div class="container mt-5">
<button class="mt-4 mb-4 btn btn-secondary" onclick="window.location.href='/'">
Back
</button>
{% if form.service.errors %}
<ul class="errors">
{% for error in form.service.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
<form method="POST" action="/entry-form">
{{ form.csrf_token }}
{{ form.service.label }} {{ form.service(size=20) }} </br>
{{ form.timeout.label }} {{ form.timeout() }} </br>
<input type="submit" value="Go">
</form>
</div>
</body>
</html>

24
templates/head.html Normal file
View File

@@ -0,0 +1,24 @@
<head>
<link rel="stylesheet" type="text/css" href="/static/site.css">
<link rel="shortcut icon" href="/static/defaultFavicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- needed for @media-css mofiers -->
<meta content="width=device-width, initial-scale=1" name="viewport" />
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<!-- Bootstrap core CSS -->
<link href="https://cdn.atlantishq.de/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdn.atlantishq.de/css/mdb.min.css" rel="stylesheet">
<script src="https://cdn.atlantishq.de/js/jquery.js"></script>
<script src="https://cdn.atlantishq.de/js/popper.js"></script>
<script src="https://cdn.atlantishq.de/js/bootstrap.js"></script>
<script src="https://cdn.atlantishq.de/js/mdb.min.js"></script>
<script src="https://cdn.atlantishq.de/js/addons/datatables.min.js" type="text/javascript">
</script>
</head>

12
templates/navbar.html Normal file
View File

@@ -0,0 +1,12 @@
<div class="navbar">
{% if user %}
<div style="float: left;" class="navbar-el">{{ user }}</div>
{% endif %}
<a href="/overview" style="float: left;" class="navbar-el">Overview</a>
<a href="/entry-form" style="float: left;" class="navbar-el">Create Service</a>
{% if user %}
<a href="/oauth2/sign_out" class="navbar-el">Logout</a>
{% else %}
<div class="navbar-el placeholder"></div>
{% endif %}
</div>

View File

@@ -1,33 +1,12 @@
<head>
<link rel="stylesheet" type="text/css" href="/static/site.css">
<link rel="shortcut icon" href="/static/defaultFavicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- needed for @media-css mofiers -->
<meta content="width=device-width, initial-scale=1" name="viewport" />
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<!-- Bootstrap core CSS -->
<link href="https://cdn.atlantishq.de/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdn.atlantishq.de/css/mdb.min.css" rel="stylesheet">
<script src="https://cdn.atlantishq.de/js/jquery.js"></script>
<script src="https://cdn.atlantishq.de/js/popper.js"></script>
<script src="https://cdn.atlantishq.de/js/bootstrap.js"></script>
<script src="https://cdn.atlantishq.de/js/mdb.min.js"></script>
<script src="https://cdn.atlantishq.de/js/addons/datatables.min.js" type="text/javascript">
</script>
</head>
{% include "head.html" %}
<html>
<body>
{% include "navbar.html" %}
<div class="container">
<div class="row">
{% for status in status_list %}
<div class="col-md-5 m-3 p-2 border rounded"
<a href="/service-details?service={{ status.service}}"
class="col-md-5 m-3 p-2 border rounded overview-tile"
{% if status.status == "OK" %}
style="background-color: lightgreen;"
{% elif status.status == "WARNING" %}
@@ -44,7 +23,7 @@
{% else %}
{{ datetime.fromtimestamp(status.timestamp).strftime("%H:%M %d.%m.%y") }}
{% endif %}
</div>
</a>
{% endfor %}
</div>
</div>

View File

@@ -0,0 +1,61 @@
{% include "head.html" %}
<html>
<body>
{% include "navbar.html" %}
<div class="container">
<h2 class="service-name">Service: {{ service.service }}</h2>
<div class="service-timeout">Timeout: {{ service.timeout }}d</div>
<div class="service-token">Secret Token: {{ service.token }}</div>
<div class="last-status">
{% if status_list | length > 0 %}
<p>{{ status_list[0].status }} submitted on {{ status_list[0].timestamp }}</i>
{% else %}
<p style="color: darkred;">No status for this service submitted</i>
{% endif %}
</div>
<h5 class="my-4">Curl</h5>
<div class="ml-3 example">
curl -X POST \ <br>
<div class="example-indent">
-H "application/json" \ <br>
-d '{ "service_name" : "{{ service.service }}",
"token" : "{{ service.token }}", \<br>
"status" : "OK", "info" : "Free Text Information here" }' \<br>
{{ flask.request.url_root }}
</div>
</div>
<h5 class="my-4">Python</h5>
<div class="ml-3 example">
import requests
requests.post("{{ flask.request.url_root }}",<br>
<div class="example-indent-double">
json= { "service_name" : "{{ 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>
{% for status in status_list %}
<td>status.human_date()<td>
<td>status.status</td>
<td>status.info</td>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>