tfstated/pkg/webui/html/accounts.html
Julien Dessaux d40595cacb
All checks were successful
main / publish (push) Has been skipped
main / main (push) Successful in 4m36s
main / deploy (push) Has been skipped
feat(webui): open a currated version of the user accounts section to non admin users
2025-04-15 00:08:24 +02:00

69 lines
2.1 KiB
HTML

{{ define "main" }}
<h1>User Accounts</h1>
<div class="flex-row" style="justify-content:space-between;">
<div style="min-width:240px;">
<p>
There are <strong>{{ len .Accounts }}</strong> user accounts.
Use this page to inspect user accounts.
</p>
</div>
{{ if .Page.IsAdmin }}
<form action="/accounts" enctype="multipart/form-data" method="post">
<fieldset>
<legend>New User Account</legend>
<div class="grid-2">
<label for="username" style="min-width:92px;">Username</label>
<input {{ if or .UsernameDuplicate .UsernameInvalid }}class="error"{{ end }}
id="username"
name="username"
required
type="text"
value="{{ .Username }}">
<label for="is-admin">Is Admin</label>
<input {{ if .IsAdmin }} checked{{ end }}
id="is-admin"
name="is-admin"
type="checkbox"
value="{{ .IsAdmin }}" />
</div>
{{ if .UsernameDuplicate }}
<span class="error">This username already exist.</span>
{{ else if .UsernameInvalid }}
<span class="error">
<span class="tooltip">
Invalid username.
<span class="tooltip-text">
Username must start with a letter and be composed of only letters, numbers or underscores.
</span>
</span>
</span>
{{ end }}
<div style="align-self:stretch; display:flex; justify-content:flex-end;">
<button class="primary" type="submit" value="submit">Create User Account</button>
</fieldset>
</form>
{{ end }}
</div>
<article>
<table style="width:100%;">
<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>{{ .Created }}</td>
<td>{{ .LastLogin }}</td>
<td>{{ .IsAdmin }}</td>
</tr>
{{ end }}
</tbody>
</table>
</article>
{{ end }}