add accordion macro, new user list view

This commit is contained in:
2025-08-04 02:17:27 +03:00
parent abcc10654b
commit c7f29c1cd4
5 changed files with 115 additions and 6 deletions

View File

@ -103,6 +103,7 @@ def create_app():
"InfoboxIcons": InfoboxIcons, "InfoboxIcons": InfoboxIcons,
"InfoboxHTMLClass": InfoboxHTMLClass, "InfoboxHTMLClass": InfoboxHTMLClass,
"InfoboxKind": InfoboxKind, "InfoboxKind": InfoboxKind,
"PermissionLevel": PermissionLevel,
"__commit": commit, "__commit": commit,
"__emoji": EMOJI, "__emoji": EMOJI,
} }

View File

@ -171,3 +171,18 @@
</div> </div>
</div> </div>
{% endmacro %} {% endmacro %}
{% macro accordion(hidden=false, style="", disabled=false) %}
{% if disabled %}
{% set hidden = true %}
{% endif %}
<div class="accordion {{ "hidden" if hidden else ""}}" style="{{style}}">
<div class="accordion-header">
<button type="button" class="accordion-toggle" {{"disabled" if disabled else ""}}>{{ "►" if hidden else "▼" }}</button>
{{ caller('header') }}
</div>
<div class="accordion-content {{ "hidden" if hidden else "" }}">
{{ caller('content') }}
</div>
</div>
{% endmacro %}

View File

@ -1,10 +1,59 @@
{% from "common/macros.html" import timestamp, accordion %}
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<div class="darkbg settings-container"> <div class="darkbg inbox-container">
<ul> {% set guests = (users | selectattr('permission', 'eq', PermissionLevel.GUEST.value) | list) %}
{% for user in users %} {% set not_guests = (users | selectattr('permission', 'gt', PermissionLevel.GUEST.value) | list) %}
<li><a href="{{url_for("users.page", username=user['username'])}}">{{user['username']}}</a> {% call(section) accordion(disabled=(guests | count==0)) %}
{% if section == "header" %}
<span>Unconfirmed guests</span>
{% elif section == "content" %}
<table class="users-table">
<thead>
<th>Username</th>
<th class="small">Signed up on</th>
</thead>
{% for user in guests %}
<tr>
<td>
<a href="{{url_for("users.page", username=user['username'])}}">{{user['username']}}
</a>
</td>
<td>
{{ timestamp(user.created_at) }}
</td>
</tr>
{% endfor %} {% endfor %}
</ul> </table>
{% endif %}
{% endcall %}
{% call(section) accordion() %}
{% if section == "header" %}
<span>Other users</span>
{% elif section == "content" %}
<table class="users-table">
<thead>
<th>Username</th>
<th class="small">Permission</th>
<th class="small">Signed up on</th>
</thead>
{% for user in not_guests %}
<tr>
<td>
<a href="{{url_for("users.page", username=user['username'])}}">{{user['username']}}
</a>
</td>
<td>
{{ user.permission | permission_string }}
</td>
<td>
{{ timestamp(user.created_at) }}
</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endcall %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -570,6 +570,28 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus
border-collapse: collapse; border-collapse: collapse;
} }
.users-table {
border-collapse: collapse;
width: 100%;
margin: 10px 0;
overflow: hidden;
}
.users-table tr th {
background-color: #beb1ce;
padding: 5px 0;
}
.users-table tr td {
background-color: rgb(177, 206, 204.5);
padding: 5px 0;
text-align: center;
}
.users-table .small {
width: 250px;
}
.topic { .topic {
display: grid; display: grid;
grid-template-columns: 1.5fr 96px; grid-template-columns: 1.5fr 96px;

View File

@ -567,6 +567,28 @@ input[type="text"], input[type="password"], textarea, select {
border-collapse: collapse; border-collapse: collapse;
} }
.users-table {
border-collapse: collapse;
width: 100%;
margin: 10px 0;
overflow: hidden;
}
.users-table tr th {
background-color: $button_color2;
padding: 5px 0;
}
.users-table tr td {
background-color: $button_color;
padding: 5px 0;
text-align: center;
}
.users-table .small {
width: 250px;
}
.topic { .topic {
display: grid; display: grid;
grid-template-columns: 1.5fr 96px; grid-template-columns: 1.5fr 96px;