Automatic spacing by black formatter

This commit is contained in:
2025-05-31 12:23:59 +02:00
parent 33eca57205
commit f37e203678
4 changed files with 130 additions and 125 deletions

View File

@@ -2,86 +2,87 @@
{% block content %} {% block content %}
<div class="col-md-9 ms-sm-auto col-lg-10 px-md-4"> <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> <div
<h1 class="display-4 fw-bold" style="color: #313A4D;">Numberplate</h1> class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
</div> <h1 class="display-4 fw-bold" style="color: #313A4D;">Numberplate</h1>
<div class="col-md-12"> </div>
<div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
</div>
</div> </div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<h5 class="card-title fs-4">Add numberplate</h5> <h5 class="card-title fs-4">Add numberplate</h5>
<div class="log-container" style="max-height: 250px; overflow-y: auto;"> <div class="log-container" style="max-height: 250px; overflow-y: auto;">
<form method="POST" class="contact-form" id="numberplateForm"> <form method="POST" class="contact-form" id="numberplateForm">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<div class="form-field"> <div class="form-field">
{{ form.numberplate(class="form-input",style="width: 200px; height: 40px;") }} {{ form.numberplate(class="form-input",style="width: 200px; height: 40px;") }}
</div> </div>
<div class="button-container" style="margin-top: 15px;"> <div class="button-container" style="margin-top: 15px;">
{{ form.submit(class="btn btn-sm btn-dark", style="width: 200px;") }} {{ form.submit(class="btn btn-sm btn-dark", style="width: 200px;") }}
</div> </div>
</form> </form>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<h5 class="card-title fs-4">Numberplates</h5> <h5 class="card-title fs-4">Numberplates</h5>
<div class="log-container" style="max-height: 250px; overflow-y: auto;"> <div class="log-container" style="max-height: 250px; overflow-y: auto;">
<table class="table table-sm table-hover" id="numberplatesTable"> <table class="table table-sm table-hover" id="numberplatesTable">
<thead> <thead>
<tr> <tr>
<th scope="col" class="fs-5">ID</th> <th scope="col" class="fs-5">ID</th>
<th scope="col" class="fs-5">Numberplate</th> <th scope="col" class="fs-5">Numberplate</th>
</tr> </tr>
</thead> </thead>
<tbody id="numberplatesBody"> <tbody id="numberplatesBody">
{% for plate in plates %} {% for plate in plates %}
<tr> <tr>
<td><small class="fs-6">{{ plate.id }}</small></td> <td><small class="fs-6">{{ plate.id }}</small></td>
<td><small class="fs-6">{{ plate.plate }}</small></td> <td><small class="fs-6">{{ plate.plate }}</small></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<script> <script>
document.getElementById('numberplateForm').addEventListener('submit', async function(e) { document.getElementById('numberplateForm').addEventListener('submit', async function (e) {
e.preventDefault(); e.preventDefault();
const form = e.target; const form = e.target;
const formData = new FormData(form); const formData = new FormData(form);
const response = await fetch(form.action || window.location.pathname, { const response = await fetch(form.action || window.location.pathname, {
method: 'POST', method: 'POST',
body: formData, body: formData,
headers: {'X-Requested-With': 'XMLHttpRequest'} headers: { 'X-Requested-With': 'XMLHttpRequest' }
}); });
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
// Update the table body // Update the table body
const tbody = document.getElementById('numberplatesBody'); const tbody = document.getElementById('numberplatesBody');
tbody.innerHTML = ''; tbody.innerHTML = '';
data.plates.forEach(plate => { data.plates.forEach(plate => {
tbody.innerHTML += `<tr> tbody.innerHTML += `<tr>
<td><small class="fs-6">${plate.id}</small></td> <td><small class="fs-6">${plate.id}</small></td>
<td><small class="fs-6">${plate.plate}</small></td> <td><small class="fs-6">${plate.plate}</small></td>
</tr>`; </tr>`;
});
form.reset();
} else {
alert('Failed to add numberplate.');
}
}); });
form.reset(); </script>
} else { {% endblock %}
alert('Failed to add numberplate.');
}
});
</script>
{% endblock %}

View File

@@ -1,72 +1,74 @@
{%extends 'base.html' %} {%extends 'base.html' %}
{% block content %} {% block content %}
<div class="col-md-9 ms-sm-auto col-lg-10 px-md-4"> <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> <div
<h1 class="display-4 fw-bold" style="color: #313A4D;">Dashboard</h1> class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
</div> <h1 class="display-4 fw-bold" style="color: #313A4D;">Dashboard</h1>
<div class="col-md-12"> </div>
<div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
</div>
</div> </div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<h5 class="card-title fs-4">Logs</h5> <h5 class="card-title fs-4">Logs</h5>
<div class="log-container" style="max-height: 250px; overflow-y: auto;"> <div class="log-container" style="max-height: 250px; overflow-y: auto;">
<table class="table table-sm table-hover"> <table class="table table-sm table-hover">
<thead> <thead>
<tr> <tr>
<th scope="col" class="fs-5">Time</th> <th scope="col" class="fs-5">Time</th>
<th scope="col" class="fs-5">Numberplate</th> <th scope="col" class="fs-5">Numberplate</th>
<th scope="col" class="fs-5">Gate Status</th> <th scope="col" class="fs-5">Gate Status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for log in logs %} {% for log in logs %}
<tr> <tr>
<td><small class="fs-6">{{ log.dateLogged.strftime('%H:%M:%S') }}</small></td> <td><small class="fs-6">{{ log.dateLogged.strftime('%H:%M:%S') }}</small></td>
<td><small class="fs-6">{{ log.plate }}</small></td> <td><small class="fs-6">{{ log.plate }}</small></td>
<td> <td>
<span class="badge {% if log.status == 'success' %}bg-success{% elif log.status == 'warning' %}bg-warning{% elif log.status == 'error' %}bg-danger{% else %}bg-secondary{% endif %} fs-6"> <span
{{ log.allowed }} class="badge {% if log.status == 'success' %}bg-success{% elif log.status == 'warning' %}bg-warning{% elif log.status == 'error' %}bg-danger{% else %}bg-secondary{% endif %} fs-6">
</span> {{ log.allowed }}
</td> </span>
</tr> </td>
{% endfor %} </tr>
</tbody> {% endfor %}
</table> </tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<h5 class="card-title fs-4">Numberplates</h5> <h5 class="card-title fs-4">Numberplates</h5>
<div class="log-container" style="max-height: 250px; overflow-y: auto;"> <div class="log-container" style="max-height: 250px; overflow-y: auto;">
<table class="table table-sm table-hover"> <table class="table table-sm table-hover">
<thead> <thead>
<tr> <tr>
<th scope="col" class="fs-5">ID</th> <th scope="col" class="fs-5">ID</th>
<th scope="col" class="fs-5">Numberplate</th> <th scope="col" class="fs-5">Numberplate</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for plate in plates %} {% for plate in plates %}
<tr> <tr>
<td><small class="fs-6">{{ plate.id }}</small></td> <td><small class="fs-6">{{ plate.id }}</small></td>
<td><small class="fs-6">{{ plate.plate }}</small></td> <td><small class="fs-6">{{ plate.plate }}</small></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}

View File

@@ -20,7 +20,8 @@
<td><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%S') }}</small></td> <td><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%S') }}</small></td>
<td><small class="fs-6">{{ form.plate }}</small></td> <td><small class="fs-6">{{ form.plate }}</small></td>
<td> <td>
<span class="badge {% if log.status == 'success' %}bg-success{% elif log.status == 'warning' %}bg-warning{% elif log.status == 'error' %}bg-danger{% else %}bg-secondary{% endif %} fs-6"> <span
class="badge {% if log.status == 'success' %}bg-success{% elif log.status == 'warning' %}bg-warning{% elif log.status == 'error' %}bg-danger{% else %}bg-secondary{% endif %} fs-6">
{{ form.allowed }} {{ form.allowed }}
</span> </span>
</td> </td>

View File

@@ -29,6 +29,7 @@ def add():
db.session.add(ap) db.session.add(ap)
db.session.commit() db.session.commit()
# Update the list on the page with JavaScript
if request.headers.get("X-Requested-With") == "XMLHttpRequest": if request.headers.get("X-Requested-With") == "XMLHttpRequest":
plates = AllowedPlate.query.order_by(AllowedPlate.id).all() plates = AllowedPlate.query.order_by(AllowedPlate.id).all()
return jsonify( return jsonify(