mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-29 18:59:57 +00:00
Numberplate shows on Dash
Added logs.html for the logs page Changed dashboard.html so the numberplates show on the dashboard Moved models.py to to the dashboard folder
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from application import db, app
|
||||
from application.models import AllowedPlate
|
||||
from application.dashboard.models import AllowedPlate
|
||||
|
||||
with app.app_context():
|
||||
AllowedPlate.query.delete()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from application import db
|
||||
from application.models import AllowedPlate, LoggedItem
|
||||
from application.dashboard.models import AllowedPlate, LoggedItem
|
||||
from application.api.image_processing import process_image
|
||||
from datetime import datetime
|
||||
import asyncio
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<a class="nav-link active text-white" href="/dash/dashboard">
|
||||
Dashboard
|
||||
</a>
|
||||
<a class="nav-link active text-white" href="/dash/logs">
|
||||
Logs
|
||||
</a>
|
||||
<a class="nav-link active text-white" href="/dash/add">
|
||||
Add numberplate
|
||||
</a>
|
||||
|
||||
@@ -4,26 +4,18 @@
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fs-4">Numberplate Logs</h5>
|
||||
<h5 class="card-title fs-4">Registered Numberplates</h5>
|
||||
<div class="log-container" style="max-height: 250px; overflow-y: auto;">
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="fs-5">Time</th>
|
||||
<tr>
|
||||
<th scope="col" class="fs-5">Numberplate</th>
|
||||
<th scope="col" class="fs-5">Gate Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for form in recent_logs %}
|
||||
{% for Plates in AllowedPlates %}
|
||||
<tr>
|
||||
<td><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%S') }}</small></td>
|
||||
<td><small class="fs-6">{{ form.plate }}</small></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">
|
||||
{{ form.allowed }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{Plates.plate}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
36
application/dashboard/templates/logs.html
Normal file
36
application/dashboard/templates/logs.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{%extends 'base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fs-4">Numberplate Logs</h5>
|
||||
<div class="log-container" style="max-height: 250px; overflow-y: auto;">
|
||||
<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">Gate Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for form in recent_logs %}
|
||||
<tr>
|
||||
<td><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%S') }}</small></td>
|
||||
<td><small class="fs-6">{{ form.plate }}</small></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">
|
||||
{{ form.allowed }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,6 +1,6 @@
|
||||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required
|
||||
from application.models import AllowedPlate, LoggedItem
|
||||
from application.dashboard.models import AllowedPlate, LoggedItem
|
||||
from application import db, app
|
||||
from application.dashboard.forms import npForm
|
||||
|
||||
@@ -11,8 +11,11 @@ dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
|
||||
@dash_blueprint.route('/dashboard')
|
||||
#@login_required
|
||||
def dashboard():
|
||||
form = LoggedItem.query.all()
|
||||
return render_template("dashboard.html", form=form)
|
||||
#print("test123")
|
||||
#with app.app_context():
|
||||
Plates = AllowedPlate.query.all()
|
||||
print(Plates)
|
||||
return render_template("dashboard.html", AllowedPlates = Plates)
|
||||
|
||||
@dash_blueprint.route('/add', methods=['GET', 'POST'])
|
||||
#@login_required
|
||||
@@ -30,4 +33,10 @@ def add():
|
||||
|
||||
|
||||
|
||||
return render_template("add.html", form=form)
|
||||
return render_template("add.html", form=form)
|
||||
|
||||
@dash_blueprint.route('/logs', methods=['GET', 'POST'])
|
||||
#@login_required
|
||||
def logs():
|
||||
form = LoggedItem.query.all()
|
||||
return render_template("logs.html", form=form)
|
||||
Reference in New Issue
Block a user