OXYGENHUB
◆ job-waits oxygenhub / templates / admin.html
8.1 KiB · HTML · last changed Administration is a sectioned page with a left-hand menu 1 month ago source blame history raw
19bb31ff Andy McCall ↶ 1
{% extends "base.html" %}
e71846aa Andy McCall ↶ 2
{% import "assistants_panel.html" as ai %}
2a83f530 Andy McCall ↶ 3
{% import "variables_panel.html" as va %}
4ac01a73 Andy McCall ↶ 4
{% import "secrets_panel.html" as se %}
19bb31ff Andy McCall ↶ 5
{% block title %}Administration{% endblock %}
6
{% block content %}
7
<div class="head"><h1>Administration <small>{{ accounts.len() }} accounts · {{ orgs.len() }} organisations · {{ repos }} repositories</small></h1></div>
e8e7158b Andy McCall ↶ 8
<div class="sectioned">
9
<nav class="section-nav" aria-label="Sections">
10
  <a href="#accounts">Accounts</a>
11
  <a href="#registration">Registration</a>
12
  <a href="#organisations">Organisations</a>
13
  <a href="#signin">Sign in with</a>
14
  <a href="#mail">Mail</a>
15
  <a href="#variables">Variables</a>
16
  <a href="#secrets">Secrets</a>
17
  <a href="#assistants">AI assistants</a>
18
  <a href="#audit">Audit log</a>
19
  <a href="/admin/runners">Runners ↗</a>
20
  <a href="/admin/storage">Storage and maintenance ↗</a>
21
</nav>
22
<div class="sections">
19bb31ff Andy McCall ↶ 23
{% if let Some(n) = notice %}<p class="note">{{ n }}</p>{% endif %}
e8e7158b Andy McCall ↶ 24
<section class="panel" id="accounts">
19bb31ff Andy McCall ↶ 25
  <h2>Accounts</h2>
e8e7158b Andy McCall ↶ 26
  <div class="table"><table class="small"><tr><th>Username</th><th>Email</th><th>Flags</th><th>Last seen</th><th></th></tr>
19bb31ff Andy McCall ↶ 27
  {% for a in accounts %}
6a178055 Andy McCall ↶ 28
  <tr><td><a href="/{{ a.username }}">{{ a.username }}</a></td><td>{{ a.email }}{% if !a.email.is_empty() %} <span class="small mute" title="{% if a.email_verified %}verified{% else %}not verified{% endif %}">{% if a.email_verified %}✔{% else %}○{% endif %}</span>{% endif %}</td><td>{% if a.is_admin %}<span class="tag">admin</span>{% endif %}{% if a.banned %} <span class="tag bad">banned</span>{% endif %}{% if a.disabled %} <span class="tag warn">disabled</span>{% endif %}{% if a.totp_enabled() %} <span class="tag">2fa</span>{% endif %}</td>
19bb31ff Andy McCall ↶ 29
  <td>{% if a.last_seen_ms > 0 %}<time title="{{ a.last_seen_ms|when_i }}">{{ a.last_seen_ms|ago_i }}</time>{% else %}<span class="mute">never</span>{% endif %}</td>
30
  <td><form class="tiny" method="post" action="/admin/account"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><input type="hidden" name="username" value="{{ a.username }}">
31
    {% if a.banned %}<button name="action" value="unban">unban</button>{% else %}<button name="action" value="ban">ban</button>{% endif %}
34beb1a7 Andy McCall ↶ 32
    {% if a.is_admin %}<button name="action" value="demote">demote</button>{% else %}<button name="action" value="promote">make admin</button>{% endif %}
6a178055 Andy McCall ↶ 33
    {% if a.disabled %}<button name="action" value="enable">enable</button>{% else %}<button name="action" value="disable" title="Refuse sign-in, sessions, tokens and pushes until enabled again">disable</button>{% endif %}
34
    {% if !a.blocked() %}<button name="action" value="reset_link" title="A one-time password reset link to hand over">reset link</button>{% endif %}</form>
35
    <details class="tiny delete-account"><summary>delete</summary><form class="tiny" method="post" action="/admin/account"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><input type="hidden" name="username" value="{{ a.username }}">
36
    <label class="small">Deleting removes the account, its tokens, keys and memberships for good; what it wrote stays under its name, which stays retired. Type <strong>{{ a.username }}</strong> to confirm:
37
    <input name="confirm" autocomplete="off" required></label> <button class="danger" name="action" value="delete">delete {{ a.username }}</button></form></details></td></tr>
19bb31ff Andy McCall ↶ 38
  {% endfor %}
e8e7158b Andy McCall ↶ 39
  </table></div>
19bb31ff Andy McCall ↶ 40
</section>
e8e7158b Andy McCall ↶ 41
<section class="panel" id="registration">
42
  <h2>Registration and invitations</h2>
19bb31ff Andy McCall ↶ 43
  <form class="card" method="post" action="/admin/registration">
44
    <input type="hidden" name="_csrf" value="{{ shell.csrf }}">
e8e7158b Andy McCall ↶ 45
    <label for="regmode">Who may register</label>
46
    <select id="regmode" name="mode">{% for m in ["open", "invite", "closed"] %}<option value="{{ m }}"{% if mode.as_str() == *m %} selected{% endif %}>{{ m }}</option>{% endfor %}</select>
19bb31ff Andy McCall ↶ 47
    <button type="submit">SET</button>
48
  </form>
49
  <form class="card" method="post" action="/admin/invite"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><button type="submit">NEW INVITATION</button></form>
e8e7158b Andy McCall ↶ 50
  {% if !invitations.is_empty() %}<ul class="plain small">{% for (code, used, at) in invitations %}<li><code>{{ code }}</code> {% if used.is_some() %}<span class="mute">used</span>{% else %}<a href="/register?invite={{ code }}">link</a>{% endif %} · {{ at|ago_i }}</li>{% endfor %}</ul>{% endif %}
51
</section>
52
<section class="panel" id="organisations">
53
  <h2>Organisations</h2>
54
  {% if orgs.is_empty() %}<p class="mute small">None yet.</p>{% else %}<ul class="plain">{% for o in orgs %}<li><img class="avatar xs" src="/avatar/{{ o.name }}" alt=""> <a href="/{{ o.name }}">{{ o.name }}</a> · <a class="small" href="/orgs/{{ o.name }}/settings">settings</a></li>{% endfor %}</ul>{% endif %}
55
</section>
56
<section class="panel" id="signin">
57
  <h2>Sign in with</h2>
58
  <p class="small mute">A first sign-in links the account with the same verified email, or makes an account when registration is open. Secrets are kept sealed.</p>
83940d53 Andy McCall ↶ 59
  {% for p in providers %}
60
  <form class="card" method="post" action="/admin/signin">
61
    <input type="hidden" name="_csrf" value="{{ shell.csrf }}"><input type="hidden" name="provider" value="{{ p.id }}">
e8e7158b Andy McCall ↶ 62
    <h3>{{ p.name }} {% if p.enabled && p.has_secret && !p.client_id.is_empty() %}<span class="tag head">on</span>{% else %}<span class="tag dim">off</span>{% endif %}</h3>
83940d53 Andy McCall ↶ 63
    <label for="cid-{{ p.id }}">Client id</label><input type="text" id="cid-{{ p.id }}" name="client_id" value="{{ p.client_id }}" autocomplete="off">
64
    <label for="sec-{{ p.id }}">Client secret</label><input type="password" id="sec-{{ p.id }}" name="secret" placeholder="{% if p.has_secret %}unchanged{% else %}none{% endif %}" autocomplete="new-password">
65
    <div class="choice"><label><input type="checkbox" name="enabled" value="1"{% if p.enabled %} checked{% endif %}> on</label></div>
66
    <p class="small mute">Callback URL to register with {{ p.name }}: <code>{{ p.callback }}</code></p>
67
    <button type="submit">SAVE</button>
68
  </form>
69
  {% endfor %}
e8e7158b Andy McCall ↶ 70
</section>
71
<section class="panel" id="mail">
72
  <h2>Mail</h2>
3556d08e Andy McCall ↶ 73
  <form class="card" method="post" action="/admin/mail">
74
    <input type="hidden" name="_csrf" value="{{ shell.csrf }}">
e8e7158b Andy McCall ↶ 75
    <label for="smtp">SMTP URL</label>
76
    <input type="text" id="smtp" name="smtp" value="{{ mail_smtp }}" placeholder="smtps://user:[email protected]:465">
77
    <label for="mailfrom">From</label>
78
    <input type="text" id="mailfrom" name="from" value="{{ mail_from }}" placeholder="OxygenHub &lt;[email protected]&gt;">
3556d08e Andy McCall ↶ 79
    <button type="submit">SAVE</button>
80
  </form>
81
  <form class="card" method="post" action="/admin/mail/test"><input type="hidden" name="_csrf" value="{{ shell.csrf }}"><button type="submit"{% if !mail_enabled || my_email.is_empty() %} disabled{% endif %}>SEND A TEST{% if !my_email.is_empty() %} TO {{ my_email }}{% endif %}</button></form>
82
  <p class="small mute">{% if mail_enabled %}Mail is on: verification and reset links go by email.{% else %}Mail is off: verification and reset links are issued by hand.{% endif %} An empty URL turns it off. The password stays on the server and is shown masked.</p>
e8e7158b Andy McCall ↶ 83
</section>
2a83f530 Andy McCall ↶ 84
{% call va::panel("/admin", variables, shell.csrf, "Every repository's jobs get these, unless an organisation or repository sets the same name.") %}
4ac01a73 Andy McCall ↶ 85
{% call se::panel("/admin", secrets, shell.csrf, "Every repository's jobs may use these, unless an organisation or repository sets the same name.") %}
e71846aa Andy McCall ↶ 86
{% call ai::panel("/admin", assistants, shell.csrf, "Every repository on the site may ask these, unless an organisation or repository turns one off.") %}
e8e7158b Andy McCall ↶ 87
<section class="panel" id="audit">
88
  <h2>Audit log</h2>
89
  <div class="table"><table class="small"><tr><th>When</th><th>Who</th><th>Action</th><th>Target</th><th>Detail</th></tr>
90
  {% for r in audit %}<tr><td><time title="{{ r.at_ms|when_i }}">{{ r.at_ms|ago_i }}</time></td><td>{{ r.actor }}</td><td><code>{{ r.action }}</code></td><td>{{ r.target }}</td><td class="mute">{{ r.detail }}</td></tr>{% endfor %}
91
  </table></div>
92
  <p class="pager small"><a href="/admin#audit">newest</a>{% if let Some(o) = audit_older %} <a class="go small" href="/admin?audit_before={{ o }}#audit">older</a>{% endif %}</p>
93
</section>
94
</div>
95
</div>
19bb31ff Andy McCall ↶ 96
{% endblock %}