user handling
This commit is contained in:
@@ -13,12 +13,12 @@
|
||||
<div class="navbar">
|
||||
<div class="topbranding">{{ top_branding }}</div>
|
||||
<div class="navbar-inner">
|
||||
<b><a href="/">Home</a></b><br>
|
||||
<div><b><a href="/">Home</a></b></div>
|
||||
<div id="rooms-rolled" onclick="toggleRoomDropdown()">
|
||||
<i class="bi bi-arrow-right-square-fill"> </i>Rooms<br>
|
||||
<i class="bi bi-arrow-right-square-fill"> </i>Rooms
|
||||
</div>
|
||||
<div id="rooms-unrolled" style="display: none;" onclick="untoggleRoomDropdown()">
|
||||
<i class="bi bi-arrow-down-square-fill"> </i>Rooms<br>
|
||||
<i class="bi bi-arrow-down-square-fill"> </i>Rooms
|
||||
<ul>
|
||||
{% for room in roominfo %}
|
||||
<li><a href="/room/{{ room.shortcode }}">{{ room.name }}</a></li>
|
||||
@@ -26,8 +26,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="device.html">Device Management</a><br>
|
||||
<a href="users.html">User Management</a>
|
||||
<div><a href="/devices">Device Management</a></div>
|
||||
<div><a href="/users">User Management</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-flex">
|
||||
|
||||
8
web/empty_room.html.jinja
Normal file
8
web/empty_room.html.jinja
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "base.html.jinja" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="content">
|
||||
<h2>Room: {{ current_room.name }}</h2>
|
||||
<p>This room has no sensors assigned to it.</p>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -33,15 +33,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"> </i>Rooms<br>
|
||||
<div><b><a href="index.html">Home</a></b></div>
|
||||
<div><i class="bi bi-arrow-down-square-fill"> </i>Rooms</div>
|
||||
<!--{%- for item in rooms %}
|
||||
 <a href="{{ item[0] }}">{{ item[1] }}</a>{% if not loop.last %},{% endif %}
|
||||
{%- endfor %}-->
|
||||
<hr>
|
||||
<!--{%- if user.device_privileges % and so on}-->
|
||||
<a href="device.html">Device Management</a><br>
|
||||
<a href="users.html">User Management</a>
|
||||
<div><a href="/devices.html">Device Management</a></div>
|
||||
{% if user.id != 1%}
|
||||
<div><a href="/users.html">User Management</a></div>
|
||||
{% else %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-flex">
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<p> {{ user_greeting_before }}{{userinfo.username}}{{user_greeting_after}}</p>
|
||||
<p> {{ landing_information }} </p>
|
||||
<div class="intro-text">
|
||||
<p> {{ user_greeting_before }}{{userinfo.username}}{{user_greeting_after}}</p>
|
||||
<p> {{ landing_information }} </p>
|
||||
</div>
|
||||
<div class="rooms-table">
|
||||
<table>
|
||||
<thead>
|
||||
@@ -14,8 +16,7 @@
|
||||
</tr>
|
||||
<tr class="searchbar">
|
||||
<td colspan="255">
|
||||
<i class="bi bi-search"></i>
|
||||
<input type="text" id="tableRoomSearch" placeholder="Search by room name..." onkeyup="tableSearch()">
|
||||
<input type="text" id="tableRoomSearch" placeholder="Search by room name..." onkeyup="tableSearch('tableRooms', 'tableRoomSearch')">
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ fig }}
|
||||
</div>
|
||||
{{ fig }}
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
81
web/users.html.jinja
Normal file
81
web/users.html.jinja
Normal file
@@ -0,0 +1,81 @@
|
||||
{% extends "base.html.jinja" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="content">
|
||||
<h2>User Management</h2>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul class="flashes">
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<form method="POST" action="/users">
|
||||
<label for="username">Old password:</label>
|
||||
<input type="text" id="old_password" name="old_password" required>
|
||||
<br>
|
||||
<label for="password">New Password:</label>
|
||||
<input type="password" id="new_password" name="new_password" required>
|
||||
<br>
|
||||
<button type="submit">Change Password</button>
|
||||
</form>
|
||||
{% if admin %}
|
||||
<div class="add-user">
|
||||
<h3>Add New User:</h3>
|
||||
<form method="POST" action="/users">
|
||||
<label for="new_username">Username:</label>
|
||||
<input type="text" id="new_username" name="new_username" required>
|
||||
<br>
|
||||
<label for="new_password">Password:</label>
|
||||
<input type="password" id="new_password" name="new_password" required>
|
||||
<br>
|
||||
<label for="is_admin">Admin Privileges:</label>
|
||||
<input type="checkbox" id="is_admin" name="is_admin">
|
||||
<br>
|
||||
<button type="submit">Add User</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="users-list">
|
||||
<h3>Existing Users:</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="table-header">
|
||||
<th>User ID</th>
|
||||
<th>Username</th>
|
||||
<th>Admin status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr class="searchbar">
|
||||
<td colspan="255">
|
||||
<input type="text" id="userSearch" placeholder="Search by user name..." onkeyup="tableSearch('userSearch', 'userlist',1)">
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="userlist">
|
||||
{% for tableuser in userlist %}
|
||||
<tr>
|
||||
<td> {{ tableuser[0] }} </td>
|
||||
<td> {{ tableuser[1] }} </td>
|
||||
<td> {{ tableuser[2] }} </td>
|
||||
{% if (tableuser[0] == 1) or (tableuser[0] == userinfo.id) %}
|
||||
<!-- TODO: delete self prevention still does not work -->
|
||||
<td><div class="fake-button">Cannot Delete</div></td>
|
||||
{% else %}
|
||||
<td>
|
||||
<form method="POST" action="/users">
|
||||
<button name="delete" value="{{ tableuser[0] }}", type="submit">Delete User</button>
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user