mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-29 18:59:57 +00:00
extra changes frontend
This commit is contained in:
@@ -6,11 +6,12 @@ from io import BytesIO
|
||||
from ultralytics import YOLO
|
||||
import easyocr
|
||||
|
||||
# ANPR shiz
|
||||
car_model = YOLO("yolov8n.pt")
|
||||
plate_model = YOLO("license_plate_detector.pt")
|
||||
ocr_reader = easyocr.Reader(["nl"])
|
||||
|
||||
# ANPR
|
||||
if True:
|
||||
car_model = YOLO("yolov8n.pt")
|
||||
plate_model = YOLO("license_plate_detector.pt")
|
||||
ocr_reader = easyocr.Reader(["nl"])
|
||||
|
||||
# from authlib.integrations.flask_client import OAuth
|
||||
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
<tr>
|
||||
<td><small class="fs-6">{{ plate.id }}</small></td>
|
||||
<td><small class="fs-6">{{ plate.plate }}</small></td>
|
||||
<td>
|
||||
<a href="#" class="btn btn-sm btn-secondary"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#editNumberplateModal"
|
||||
onclick="setEditPlate('{{ plate.id }}', '{{ plate.plate }}')">Edit</a>
|
||||
<form method="POST" action="{{ url_for('dash.delete_plate', plate=plate.plate) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this numberplate?');">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -55,4 +64,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="editNumberplateModal" tabindex="-1" aria-labelledby="editNumberplateModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form id="editNumberplateForm" method="POST">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editNumberplateModalLabel">Edit Numberplate</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="mb-3">
|
||||
{{ form.numberplate.label }} {{ form.numberplate(class="form-control") }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-secondary">Save changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function setEditPlate(id, plate) {
|
||||
// Set the form action to the correct URL for editing
|
||||
document.getElementById('editNumberplateForm').action = '/dash/edit/' + plate;
|
||||
// Set the value of the numberplate input
|
||||
document.querySelector('#editNumberplateForm input[name="numberplate"]').value = plate;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -18,9 +18,10 @@
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="fs-5">Time</th>
|
||||
<th scope="col" class="fs-5">Numberplate</th>
|
||||
<th scope="col" class="fs-5" style="width: 21%">Time</th>
|
||||
<th scope="col" class="fs-5" style="width: 42%">Numberplate</th>
|
||||
<th scope="col" class="fs-5">Gate Status</th>
|
||||
<th scope="col" class="fs-5"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -33,6 +34,10 @@
|
||||
{{ log.allowed }}
|
||||
</span>
|
||||
</td>
|
||||
<td><form method="POST" action="{{ url_for('dash.delete_log', id=log.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this log entry?');">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
{%extends 'base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<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">
|
||||
<h1 class="display-4 fw-bold" style="color: #313A4D;">Numberplate</h1>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fs-4">Edit numberplate</h5>
|
||||
<div class="log-container" style="max-height: 250px; overflow-y: auto;">
|
||||
<form method="POST" class="contact-form">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-field">
|
||||
{{ form.numberplate.label }} {{ form.numberplate(class="form-input") }}
|
||||
</div>
|
||||
<div class="button-container">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fs-4">Change numberplate</h5>
|
||||
<div class="log-container" style="max-height: 250px; overflow-y: auto;">
|
||||
<form method="POST" class="contact-form" id="numberplateForm">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-field">
|
||||
{{ form.numberplate(class="form-input",style="width: 200px; height: 40px;") }}
|
||||
</div>
|
||||
<div class="button-container" style="margin-top: 15px;">
|
||||
{{ form.submit(class="btn btn-sm btn-dark", style="width: 200px;") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fs-4">Numberplates</h5>
|
||||
<div class="log-container" style="max-height: 250px; overflow-y: auto;">
|
||||
<table class="table table-sm table-hover" id="numberplatesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="fs-5">ID</th>
|
||||
<th scope="col" class="fs-5">Numberplate</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="numberplatesBody">
|
||||
{% for plate in plates %}
|
||||
<tr>
|
||||
<td><small class="fs-6">{{ plate.id }}</small></td>
|
||||
<td><small class="fs-6">{{ plate.plate }}</small></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('numberplateForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
const form = e.target;
|
||||
const formData = new FormData(form);
|
||||
|
||||
const response = await fetch(form.action || window.location.pathname, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
// Update the table body
|
||||
const tbody = document.getElementById('numberplatesBody');
|
||||
tbody.innerHTML = '';
|
||||
data.plates.forEach(plate => {
|
||||
tbody.innerHTML += `<tr>
|
||||
<td><small class="fs-6">${plate.id}</small></td>
|
||||
<td><small class="fs-6">${plate.plate}</small></td>
|
||||
</tr>`;
|
||||
});
|
||||
form.reset();
|
||||
} else {
|
||||
alert('Failed to add numberplate.');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
/!-->
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user