2021-09-06 17:46:34 +00:00
|
|
|
{% import "fmt" %}
|
2021-06-29 19:26:36 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
2021-09-06 17:46:34 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
2021-06-29 10:34:36 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
2021-07-02 12:02:42 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
2021-06-29 10:34:36 +00:00
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func AdminPanel(lc *l18n.Localizer) %}
|
2021-06-29 18:43:04 +00:00
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h1>{%s lc.Get("admin.panel_title") %}</h1>
|
2021-06-29 18:43:04 +00:00
|
|
|
<section>
|
2021-09-06 17:46:34 +00:00
|
|
|
<h2>{%s lc.Get("admin.panel_safe") %}</h2>
|
2021-06-29 18:43:04 +00:00
|
|
|
<ul>
|
2021-09-06 17:46:34 +00:00
|
|
|
<li><a href="/about">{%s lc.Get("admin.panel_about") %}</a></li>
|
|
|
|
<li><a href="/user-list">{%s lc.Get("admin.panel_userlist") %}</a></li>
|
|
|
|
<li><a href="/update-header-links">{%s lc.Get("admin.panel_updateheader") %}</a></li>
|
|
|
|
<li><a href="/admin/users/">{%s lc.Get("admin.panel_users") %}</a></li>
|
2021-06-29 18:43:04 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section>
|
2021-09-06 17:46:34 +00:00
|
|
|
<h2>{%s lc.Get("admin.panel_unsafe") %}</h2>
|
2021-06-29 18:43:04 +00:00
|
|
|
<form action="/admin/shutdown" method="POST" style="float:left">
|
|
|
|
<fieldset>
|
2021-09-06 17:46:34 +00:00
|
|
|
<legend>{%s lc.Get("admin.panel_shutdown") %}</legend>
|
2021-06-29 18:43:04 +00:00
|
|
|
<input type="submit" class="btn">
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
<form action="/reindex" method="GET" style="float:left">
|
|
|
|
<fieldset>
|
2021-09-06 17:46:34 +00:00
|
|
|
<legend>{%s lc.Get("admin.panel_reindex") %}</legend>
|
2021-06-29 18:43:04 +00:00
|
|
|
<input type="submit" class="btn">
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func AdminUsersPanel(userList []*user.User, lc *l18n.Localizer) %}
|
2021-06-29 10:34:36 +00:00
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h1>{%s lc.Get("admin.users_title") %}</h1>
|
2021-06-29 10:34:36 +00:00
|
|
|
|
2021-06-29 15:10:48 +00:00
|
|
|
<form action="/admin/reindex-users" method="post">
|
2021-12-30 20:39:31 +00:00
|
|
|
<a class="btn" href="/admin/new-user">{%s lc.Get("admin.users_create") %}</a>
|
2021-09-06 17:46:34 +00:00
|
|
|
<button class="btn" type="submit">{%s lc.Get("admin.users_reindex") %}</button>
|
2021-06-29 10:34:36 +00:00
|
|
|
</form>
|
|
|
|
|
2021-07-02 12:02:42 +00:00
|
|
|
<br>
|
2021-06-29 10:34:36 +00:00
|
|
|
|
2021-06-30 12:56:38 +00:00
|
|
|
<table class="users-table">
|
2021-06-29 10:34:36 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2021-09-06 17:46:34 +00:00
|
|
|
<th>{%s lc.Get("admin.users_name") %}</th>
|
|
|
|
<th>{%s lc.Get("admin.users_group") %}</th>
|
|
|
|
<th>{%s lc.Get("admin.users_registered") %}</th>
|
|
|
|
<th aria-label="{%s lc.Get("admin.users_actions") %}"></th>
|
2021-06-29 10:34:36 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for _, u := range userList %}
|
|
|
|
<tr>
|
2021-06-30 12:56:38 +00:00
|
|
|
<td class="table-cell--fill">
|
|
|
|
<a href="/hypha/{%u cfg.UserHypha %}/{%u u.Name %}">{%s u.Name %}</a>
|
2021-06-29 19:26:36 +00:00
|
|
|
</td>
|
2021-06-29 15:10:48 +00:00
|
|
|
<td>{%s u.Group %}</td>
|
2021-07-01 08:29:19 +00:00
|
|
|
<td>
|
|
|
|
{% if u.RegisteredAt.IsZero() %}
|
2021-09-06 17:46:34 +00:00
|
|
|
{%s lc.Get("admin.users_notime") %}
|
2021-07-01 08:29:19 +00:00
|
|
|
{% else %}
|
|
|
|
{%s u.RegisteredAt.UTC().Format("2006-01-02 15:04") %}
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
2021-06-29 15:10:48 +00:00
|
|
|
<td>
|
2021-09-06 17:46:34 +00:00
|
|
|
<a href="/admin/users/{%u u.Name %}/edit">{%s lc.Get("admin.users_edit") %}</a>
|
2021-06-29 15:10:48 +00:00
|
|
|
</td>
|
2021-06-29 10:34:36 +00:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
2021-06-29 15:10:48 +00:00
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func AdminUserNew(f util.FormData, lc *l18n.Localizer) %}
|
2021-07-02 12:02:42 +00:00
|
|
|
<div class="layout">
|
2021-07-02 14:04:00 +00:00
|
|
|
<main class="main-width form-wrap">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h1>{%s lc.Get("admin.newuser_title") %}</h1>
|
2021-07-02 12:02:42 +00:00
|
|
|
|
2021-07-02 14:04:00 +00:00
|
|
|
{% if f.HasError() %}
|
2021-07-02 12:02:42 +00:00
|
|
|
<div class="notice notice--error">
|
2021-09-06 17:46:34 +00:00
|
|
|
<strong>{%s lc.Get("ui.error") %}:</strong>
|
2021-07-02 14:04:00 +00:00
|
|
|
{%s f.Error() %}
|
2021-07-02 12:02:42 +00:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2021-07-02 14:04:00 +00:00
|
|
|
<form class="form--double" action="" method="post">
|
2021-07-02 12:02:42 +00:00
|
|
|
<div class="form-field">
|
2021-09-06 17:46:34 +00:00
|
|
|
<label for="name">{%s lc.Get("admin.users_name") %}:</label>
|
2021-07-02 14:04:00 +00:00
|
|
|
<input type="text" name="name" id="name" value="{%s f.Get("name") %}" autofocus>
|
2021-07-02 12:02:42 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-field">
|
2021-09-06 17:46:34 +00:00
|
|
|
<label for="password">{%s lc.Get("admin.users_password") %}:</label>
|
2021-07-02 14:04:00 +00:00
|
|
|
<input type="password" name="password" id="password" value="{%s f.Get("password") %}">
|
2021-07-02 12:02:42 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-field">
|
2021-09-06 17:46:34 +00:00
|
|
|
<label for="group">{%s lc.Get("admin.users_group") %}:</label>
|
2021-07-02 12:02:42 +00:00
|
|
|
<select id="group" name="group">
|
2021-07-02 14:04:00 +00:00
|
|
|
<option{% if f.Get("group") == "anon" %} selected{% endif %}>anon</option>
|
|
|
|
<option{% if f.Get("group") == "editor" %} selected{% endif %}>editor</option>
|
|
|
|
<option{% if f.Get("group") == "trusted" %} selected{% endif %}>trusted</option>
|
|
|
|
<option{% if f.Get("group") == "moderator" %} selected{% endif %}>moderator</option>
|
|
|
|
<option{% if f.Get("group") == "admin" %} selected{% endif %}>admin</option>
|
2021-07-02 12:02:42 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-field">
|
|
|
|
<div class="form-field__input">
|
2021-09-06 17:46:34 +00:00
|
|
|
<button class="btn" type="submit">{%s lc.Get("admin.newuser_create") %}</button>
|
|
|
|
<a class="btn btn_weak" href="/admin/users/">{%s lc.Get("ui.cancel") %}</a>
|
2021-07-02 12:02:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func AdminUserEdit(u *user.User, f util.FormData, lc *l18n.Localizer) %}
|
2021-06-29 15:10:48 +00:00
|
|
|
<div class="layout">
|
2021-07-02 14:04:00 +00:00
|
|
|
<main class="main-width form-wrap">
|
|
|
|
<h1>
|
|
|
|
<a href="/admin/users/">←</a>
|
|
|
|
{%s u.Name %}
|
|
|
|
</h1>
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
<h2>{%s lc.Get("admin.user_group_heading") %}</h2>
|
2021-07-02 14:04:00 +00:00
|
|
|
|
|
|
|
{% if f.HasError() %}
|
|
|
|
<div class="notice notice--error">
|
2021-09-06 17:46:34 +00:00
|
|
|
<strong>{%s lc.Get("ui.error") %}:</strong>
|
2021-07-02 14:04:00 +00:00
|
|
|
{%s f.Error() %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-06-29 15:10:48 +00:00
|
|
|
|
|
|
|
<form action="" method="post">
|
2021-06-30 12:56:38 +00:00
|
|
|
<div class="form-field">
|
2021-09-06 17:46:34 +00:00
|
|
|
<select id="group" name="group" aria-label="{%s lc.Get("admin.users_group") %}">
|
2021-07-02 14:04:00 +00:00
|
|
|
<option{% if f.Get("group") == "anon" %} selected{% endif %}>anon</option>
|
|
|
|
<option{% if f.Get("group") == "editor" %} selected{% endif %}>editor</option>
|
|
|
|
<option{% if f.Get("group") == "trusted" %} selected{% endif %}>trusted</option>
|
|
|
|
<option{% if f.Get("group") == "moderator" %} selected{% endif %}>moderator</option>
|
|
|
|
<option{% if f.Get("group") == "admin" %} selected{% endif %}>admin</option>
|
2021-06-30 12:56:38 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
2021-06-29 15:10:48 +00:00
|
|
|
|
2021-07-02 14:04:00 +00:00
|
|
|
<div class="form-field">
|
2021-09-06 17:46:34 +00:00
|
|
|
<button class="btn" type="submit">{%s lc.Get("admin.user_update") %}</button>
|
2021-07-02 14:04:00 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
<h2>{%s lc.Get("admin.user_delete_heading") %}</h2>
|
|
|
|
<p>{%s lc.Get("admin.user_delete_tip") %}</p>
|
|
|
|
<a class="btn btn_destructive" href="/admin/users/{%u u.Name %}/delete">{%s lc.Get("admin.user_delete") %}</a>
|
2021-07-02 14:04:00 +00:00
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func AdminUserDelete(u *user.User, f util.FormData, lc *l18n.Localizer) %}
|
2021-07-02 14:04:00 +00:00
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width form-wrap">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h1>{%s lc.Get("admin.user_delete_heading") %}</h1>
|
2021-07-02 14:04:00 +00:00
|
|
|
|
|
|
|
{% if f.HasError() %}
|
|
|
|
<div class="notice notice--error">
|
2021-09-06 17:46:34 +00:00
|
|
|
<strong>{%s lc.Get("ui.error") %}:</strong>
|
2021-07-02 14:04:00 +00:00
|
|
|
{%s f.Error() %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
<p>{%s= lc.Get("admin.user_delete_warn", &l18n.Replacements{"name": fmt.Sprintf("<strong>%s</strong>", u.Name)}) %}</p>
|
2021-07-02 14:04:00 +00:00
|
|
|
|
|
|
|
<form action="" method="post">
|
2021-09-06 17:46:34 +00:00
|
|
|
<button class="btn btn_destructive" type="submit">{%s lc.Get("admin.user_delete") %}</button>
|
|
|
|
<a class="btn btn_weak" href="/admin/users/{%u u.Name %}/edit">{%s lc.Get("ui.cancel") %}</a>
|
2021-06-29 15:10:48 +00:00
|
|
|
</form>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|