database access for rooms and mqtt client + generator

This commit is contained in:
2025-12-09 09:07:07 +01:00
parent 75f4b7e1eb
commit 0a7b029141
16 changed files with 486 additions and 96 deletions

View File

@@ -13,8 +13,18 @@
<div class="navbar">
<div class="topbranding">{{ top_branding }}</div>
<div class="navbar-inner">
<b><a href="index.html">Home</a></b><br>
<i class="bi bi-arrow-down-square-fill">&nbsp;</i>Rooms<br>
<b><a href="/">Home</a></b><br>
<div id="rooms-rolled" onclick="toggleRoomDropdown()">
<i class="bi bi-arrow-right-square-fill">&nbsp;</i>Rooms<br>
</div>
<div id="rooms-unrolled" style="display: none;" onclick="untoggleRoomDropdown()">
<i class="bi bi-arrow-down-square-fill">&nbsp;</i>Rooms<br>
<ul>
{% for room in roominfo %}
<li><a href="/room/{{ room.shortcode }}">{{ room.name }}</a></li>
{% endfor %}
</ul>
</div>
<hr>
<a href="device.html">Device Management</a><br>
<a href="users.html">User Management</a>
@@ -22,10 +32,14 @@
</div>
<div class="right-flex">
<div class="topline">
<div class="user section"> {{ userinfo.name }}</div>
<div class="logout section"> <a href="logout">
Logout <i class="bi bi-power"></i>
</a></div>
<div class="user section"> {{ userinfo.username }}</div>
<div class="logout section">
{% if userinfo.username != "nouser" %}
<a href="/logout">Logout<i class="bi bi-power"></i></a>
{% else %}
<a href="/login">Login<i class="bi bi-box-arrow-in-right"></i></a>
{% endif %}
</div>
</div>
{% block content %}

View File

@@ -2,7 +2,7 @@
{% block content %}
<div class="content">
<p> {{ user_greeting_before }}{{userinfo.name}}{{user_greeting_after}}</p>
<p> {{ user_greeting_before }}{{userinfo.username}}{{user_greeting_after}}</p>
<p> {{ landing_information }} </p>
<div class="rooms-table">
<table>
@@ -22,7 +22,7 @@
<tbody id="tableRooms">
{% for room in roominfo %}
<tr>
<td><a href="./room/{{ room.shortcode }}">{{ room.name }}</a>
<td><a href="/room/{{ room.shortcode }}">{{ room.name }}</a>
{%- for sensorinfo in room.roomdata %}
{% if sensorinfo.state == 0 %}
<td class="data-valid">

25
web/login.html.jinja Normal file
View File

@@ -0,0 +1,25 @@
{% extends "base.html.jinja" %}
{% block content %}
<div class="content">
<h2>Login</h2>
<form method="POST" action="/login">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<button type="submit">Login</button>
</form>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class="flashes">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
{% endblock content %}

33
web/room.html.jinja Normal file
View File

@@ -0,0 +1,33 @@
{% extends "base.html.jinja" %}
{% block content %}
<div class="content">
<h2>Room: {{ current_room.name }}</h2>
<div class="current-readings">
<h3>Current readings:</h3>
<div style="display: flex;">
{% for sensorinfo in sensorinfolist %}
<div style="border: 2px black solid; width: fit-content; text-align: center;">
<div style="border-bottom: 2px gray solid; font-weight: bold;">
{{ sensorinfo.type }}
</div>
<div style="font-weight: bolder; font-size: xxx-large; border-bottom: 2px gray solid;">
{{ sensorinfo.reading }}
</div>
{% if sensorinfo.state == 0 %}
<div class="data-valid">
{% elif sensorinfo.state == 1 %}
<div class="data-late">
{% else %}
<div class="data-missing">
{% endif %}
Last updated: {{ sensorinfo.timestamp }}
</div>
</div>
{% endfor %}
</div>
{{ fig }}
</div>
</div>
{% endblock content %}

View File

@@ -0,0 +1,17 @@
<div style="border: 2px black solid; width: fit-content; text-align: center;">
<div style="border-bottom: 2px gray solid; font-weight: bold;">
Temperature
</div>
<div style="font-weight: bolder; font-size: xxx-large; border-bottom: 2px gray solid;">
22 °C
</div>
<div style="padding: 1ex 2ex; background-color:
;">
{% if sensor.delayed %}
style
{% else %}
{% endif %}
Last updated: 2024-06-01 12:00
</div>
</div>