arche / internal/archesrv/templates/srv_admin_invites.html

commit 154431fd
 1{{ define "title" }}Invites — admin{{ end }} {{ define "navextra" }}<a href="/admin/users">users</a>
 2<a href="/admin/invites">invites</a>{{ end }} {{ define "srv_admin_invites.html" }}{{ template "head" . }}
 3<div class="container">
 4    <h2 style="margin-bottom: 16px">Invite links</h2>
 5    {{ if .Link }}
 6    <div style="background: #e8f5e9;
 7                border: 1px solid #a5d6a7;
 8                border-radius: 3px;
 9                padding: 12px 16px;
10                margin-bottom: 20px">
11        <p style="font-size: 13px; margin-bottom: 6px; color: #2e7d32">
12            <strong>New invite link created:</strong>
13        </p>
14        <code style="font-size: 13px; word-break: break-all">{{.Link}}</code>
15        <p style="font-size: 12px; color: #666; margin-top: 6px">
16            Share this link with the person you want to invite. It can only be used
17            once.
18        </p>
19    </div>
20    {{ end }} {{ if .Invites }}
21    <table style="margin-bottom: 24px">
22        <thead>
23            <tr>
24                <th>Token</th>
25                <th>Created</th>
26                <th>Status</th>
27                <th></th>
28            </tr>
29        </thead>
30        <tbody>
31            {{ range .Invites }}
32            <tr>
33                <td style="font-family: monospace; font-size: 12px">{{.Token}}</td>
34                <td style="font-size: 12px; color: #888">{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
35                <td>
36                    {{ if .UsedBy }}
37                    <span class="badge badge-secret">used</span>
38                {{ else }}
39                    <span class="badge badge-public">unused</span>
40                    {{ end }}
41                </td>
42                <td>
43                    {{ if not .UsedBy }}
44                    <button onclick="deleteInvite({{.ID}})"
45                            style="background: #c0392b;
46                                   font-size: 12px;
47                                   padding: 2px 8px">Revoke</button>
48                    {{ end }}
49                </td>
50            </tr>
51            {{ end }}
52        </tbody>
53    </table>
54{{ else }}
55    <p style="color: #888; margin-bottom: 24px">No invites yet.</p>
56    {{ end }}
57    <form method="post" action="/admin/invites">
58        <button type="submit">Generate invite link</button>
59    </form>
60</div>
61<script>
62  function deleteInvite(id) {
63    if (!confirm("Revoke this invite?")) return;
64    fetch("/admin/invites/" + id, { method: "DELETE" }).then(function (r) {
65      if (r.ok) {
66        location.reload();
67      } else {
68        r.text().then(alert);
69      }
70    });
71  }
72</script>
73{{ template "foot" . }} {{ end }}