feat(webui): add user accounts list, admin middleware and admin restricted menu entries

This commit is contained in:
Julien Dessaux 2025-02-26 00:07:35 +01:00
parent fb98b4fffe
commit e23a146490
Signed by: adyxax
GPG key ID: F92E51B86E07177E
9 changed files with 143 additions and 2 deletions

View file

@ -0,0 +1,35 @@
{{ define "main" }}
<main class="responsive" id="main">
<div>
<div class="tabs">
<a data-ui="#explorer"{{ if eq .ActiveTab 0 }} class="active"{{ end }}>User Accounts</a>
<a data-ui="#new"{{ if eq .ActiveTab 1 }} class="active"{{ end }}>Create New User Account</a>
</div>
<div id="explorer" class="page padding{{ if eq .ActiveTab 0 }} active{{ end }}">
<table class="clickable-rows no-space">
<thead>
<tr>
<th>Username</th>
<th>Created</th>
<th>Last Login</th>
<th>Is Admin</th>
</tr>
</thead>
<tbody>
{{ range .Accounts }}
<tr>
<td><a href="/accounts/{{ .Id }}">{{ .Username }}</a></td>
<td><a href="/accounts/{{ .Id }}">{{ .Created }}</a></td>
<td><a href="/accounts/{{ .Id }}">{{ .LastLogin }}</a></td>
<td><a href="/accounts/{{ .Id }}">{{ .IsAdmin }}</a></td>
</tr>
{{ end }}
</tbody>
</table>
</div>
<div id="new" class="page padding{{ if eq .ActiveTab 1 }} active{{ end }}">
<p>TODO</p>
</div>
</div>
</main>
{{ end }}

View file

@ -20,6 +20,12 @@
<i>settings</i>
<span>Settings</span>
</a>
{{ if .Page.IsAdmin }}
<a href="/accounts"{{ if eq .Page.Section "accounts" }} class="fill"{{ end}}>
<i>person</i>
<span>User Accounts</span>
</a>
{{ end }}
<a href="/logout">
<i>logout</i>
<span>Logout</span>

View file

@ -2,7 +2,7 @@
<main class="responsive" id="main">
<p>
Created by
<a href="/users/{{ .Account.Id }}">{{ .Account.Username }}</a>
<a href="/accounts/{{ .Account.Id }}" class="link underline">{{ .Account.Username }}</a>
at {{ .Version.Created }}
</p>
<div>