2022-04-06 16:03:00 +00:00
|
|
|
{% extends "base_settings_page.html" %}
|
|
|
|
{% block content %}
|
|
|
|
|
2022-04-06 16:06:38 +00:00
|
|
|
<a href="/admin/create_user" class="btn btn-primary">Create a new user</a>
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<table class="table table-hover" style="max-width: 1000px;" aria-describedby="Clients list">
|
2022-04-06 16:03:00 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Username</th>
|
|
|
|
<th scope="col">First name</th>
|
|
|
|
<th scope="col">Last name</th>
|
|
|
|
<th scope="col">Email</th>
|
|
|
|
<th scope="col">Account type</th>
|
|
|
|
<th scope="col">Enabled</th>
|
2022-04-06 16:06:38 +00:00
|
|
|
<th scope="col">Actions</th>
|
2022-04-06 16:03:00 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for u in users %}
|
2022-04-19 17:40:36 +00:00
|
|
|
<tr id="row-user-{{ u.uid.0 }}">
|
2022-04-06 16:03:00 +00:00
|
|
|
<td>{{ u.username }}</td>
|
|
|
|
<td>{{ u.first_name }}</td>
|
|
|
|
<td>{{ u.last_name }}</td>
|
|
|
|
<td>{{ u.email }}</td>
|
2022-04-06 16:08:57 +00:00
|
|
|
<td>{% if u.admin %}Admin{% else %}Regular user{% endif %}</td>
|
2022-04-06 16:03:00 +00:00
|
|
|
<td>{% if u.enabled %}Enabled{% else %}Disabled{% endif %}</td>
|
2022-04-08 14:28:19 +00:00
|
|
|
<td>
|
2022-04-19 17:40:36 +00:00
|
|
|
<a href="/admin/edit_user?id={{ u.uid.0 }}">Edit</a>
|
|
|
|
<a href="javascript:delete_user('{{ u.uid.0 }}', '{{ u.username }}')">Delete</a>
|
2022-04-08 14:28:19 +00:00
|
|
|
</td>
|
2022-04-06 16:03:00 +00:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2022-04-08 15:54:51 +00:00
|
|
|
<script>
|
|
|
|
async function delete_user(id, username) {
|
|
|
|
if(!confirm("Do you really want to delete " + username + "'s account?"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
|
|
|
let data = new URLSearchParams();
|
|
|
|
data.append("user_id", id);
|
|
|
|
|
|
|
|
const res = await fetch("/admin/api/delete_user", {
|
|
|
|
body: data,
|
|
|
|
method: "POST",
|
|
|
|
});
|
|
|
|
|
|
|
|
if (res.status != 200)
|
|
|
|
return alert("Failed to delete user account!");
|
|
|
|
|
|
|
|
alert("User account was successfully deleted!");
|
|
|
|
document.getElementById("row-user-" + id).remove()
|
|
|
|
} catch(e) {
|
|
|
|
console.error(e);
|
|
|
|
alert("Failed to delete user account!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2022-04-06 16:03:00 +00:00
|
|
|
{% endblock content %}
|