source: Klonkt/src/views/pages/admin-users.ejs@ 0c2228a

main
Last change on this file since 0c2228a was 0c2228a, checked in by roboburr <roboburr@…>, 3 months ago

hub: home button actually visible + delete for every user (cascade)

  • topnav: the hub-home brand used .site-title, which is display:none everywhere (the profile header carries the name). Now its own visible class .nav-hub-home -> the hub name is truly shown top-left on /user/ pages, linking to the hub home.
  • admin/users: delete button for EVERY user (except yourself), not only empty accounts. Deletion cascades (sites + posts + playlists + audio + members + comments) atomically in a transaction; god-only, not the last god, not yourself. Confirmation warns when content will be removed.

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 10.4 KB
Line 
1<div class="container ax-page">
2
3 <p><a href="/admin" class="btn">&larr; Beheer</a></p>
4 <header class="ax-header">
5 <div>
6 <h1>Users</h1>
7 <p class="ax-tagline">Beheer gebruikers, rollen, en verwijderingen.</p>
8 </div>
9 </header>
10
11 <% if (success) { %><div class="ax-flash ax-flash-ok"><%= success %></div><% } %>
12 <% if (error) { %><div class="ax-flash ax-flash-err"><%= error %></div><% } %>
13
14 <% if (!users.length) { %>
15 <div class="ax-card">
16 <div class="ax-empty">
17 <div class="ax-empty-icon">👤</div>
18 <p>Geen gebruikers.</p>
19 </div>
20 </div>
21 <% } else { %>
22 <ul class="ax-list">
23 <% users.forEach(function(u) { %>
24 <li class="ax-user<%= u.id === user.id ? ' is-self' : '' %>">
25
26 <div class="ax-user-id">
27 <% if (u.avatar_url) { %>
28 <img class="ax-avatar" src="<%= u.avatar_url %>" alt="">
29 <% } else { %>
30 <span class="ax-avatar ax-avatar-empty"><%= u.username.charAt(0).toUpperCase() %></span>
31 <% } %>
32 <div class="ax-user-meta">
33 <div class="ax-user-name">
34 <a href="/users/<%= encodeURIComponent(u.username) %>"><%= u.username %></a>
35 <% if (u.id === user.id) { %><span class="ax-pill">jij</span><% } %>
36 </div>
37 <div class="ax-user-email"><%= u.email %></div>
38 </div>
39 </div>
40
41 <div class="ax-user-stats">
42 <span class="ax-stat" title="Sites">
43 <span class="ax-stat-num"><%= u.site_count %></span>
44 <span class="ax-stat-label">sites</span>
45 </span>
46 <span class="ax-stat" title="Posts">
47 <span class="ax-stat-num"><%= u.post_count %></span>
48 <span class="ax-stat-label">posts</span>
49 </span>
50 <span class="ax-stat" title="Geregistreerd op">
51 <span class="ax-stat-num ax-stat-date"><%= formatDate(u.created_at) %></span>
52 <span class="ax-stat-label">joined</span>
53 </span>
54 </div>
55
56 <div class="ax-user-controls">
57 <form method="post" action="/admin/users/<%= u.id %>/role" class="ax-role-form">
58 <label class="ax-role">
59 <span>Rol</span>
60 <select name="role" onchange="this.form.submit()" <% if (u.id === user.id) { %>disabled<% } %>>
61 <option value="member" <%= u.role === 'member' ? 'selected' : '' %>>member</option>
62 <option value="admin" <%= u.role === 'admin' ? 'selected' : '' %>>admin</option>
63 <option value="god" <%= u.role === 'god' ? 'selected' : '' %>>god</option>
64 </select>
65 </label>
66 </form>
67
68 <form method="post" action="/admin/users/<%= u.id %>/readonly" class="ax-role-form">
69 <label class="ax-role ax-ro" title="Alleen-lezen: kan alles bekijken, niets wijzigen">
70 <span>Kijk-modus</span>
71 <input type="checkbox" name="readonly" value="1" <%= u.readonly ? 'checked' : '' %>
72 onchange="this.form.submit()" <% if (u.id === user.id) { %>disabled<% } %>>
73 </label>
74 </form>
75
76 <% if (u.id !== user.id) { %>
77 <% var _warn = (u.post_count + u.site_count > 0)
78 ? ('Dit verwijdert ook hun site + ' + u.post_count + ' post(s). ')
79 : ''; %>
80 <form method="post" action="/admin/users/<%= u.id %>/delete" class="ax-delete-form"
81 onsubmit="return confirm('Gebruiker <%= u.username %> verwijderen? <%= _warn %>Dit kan niet ongedaan worden.')">
82 <button type="submit" class="ax-icon-btn ax-icon-btn-danger" aria-label="Verwijderen" title="Verwijderen">🗑</button>
83 </form>
84 <% } else { %>
85 <%# Lege plek zodat de kolommen (rol/kijk-modus) op elke rij uitlijnen. %>
86 <span class="ax-icon-btn-spacer" aria-hidden="true"></span>
87 <% } %>
88 </div>
89
90 </li>
91 <% }); %>
92 </ul>
93 <% } %>
94
95</div>
96
97<style>
98.ax-page { max-width: 880px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
99.ax-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
100.ax-header h1 { font-family: var(--font-display, serif); font-size: 1.75rem; margin: 0 0 0.25rem; }
101.ax-tagline { color: var(--ink-muted, var(--ink-soft)); margin: 0; font-size: 0.9rem; }
102.ax-back {
103 display: inline-flex; align-items: center; justify-content: center;
104 width: 40px; height: 40px;
105 border: 1px solid var(--rule); border-radius: 8px;
106 background: var(--paper); color: var(--ink); text-decoration: none;
107 font-size: 1.1rem; flex-shrink: 0; transition: border-color 120ms;
108}
109.ax-back:hover { border-color: var(--accent); }
110
111.ax-flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
112.ax-flash-ok { background: rgba(40,160,90,.15); color: #2a9d5e; border: 1px solid rgba(40,160,90,.3); }
113.ax-flash-err { background: rgba(200,60,60,.15); color: #c33; border: 1px solid rgba(200,60,60,.3); }
114
115.ax-card {
116 background: var(--paper); border: 1px solid var(--rule);
117 border-radius: 12px; padding: 1.25rem;
118}
119.ax-empty { text-align: center; padding: 2rem 1rem; color: var(--ink-muted); }
120.ax-empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.5; }
121.ax-empty p { margin: 0; }
122
123/* ─── User cards ───────────────────────────────────────────────── */
124.ax-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
125.ax-user {
126 display: grid;
127 grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
128 gap: 1rem;
129 align-items: center;
130 padding: 0.85rem 1rem;
131 background: var(--paper);
132 border: 1px solid var(--rule);
133 border-radius: 12px;
134 transition: border-color 120ms;
135}
136.ax-user:hover { border-color: var(--accent); }
137.ax-user.is-self {
138 background: color-mix(in srgb, var(--accent) 7%, var(--paper));
139 border-color: color-mix(in srgb, var(--accent) 25%, var(--rule));
140}
141
142.ax-user-id { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
143.ax-avatar {
144 width: 44px; height: 44px;
145 border-radius: 50%;
146 object-fit: cover;
147 background: var(--paper-2);
148 color: var(--accent);
149 display: inline-flex; align-items: center; justify-content: center;
150 font-family: var(--font-display, serif);
151 font-weight: 700; font-size: 1.1rem;
152 flex-shrink: 0;
153}
154.ax-avatar-empty { /* span variant uses same styling */ }
155.ax-user-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
156.ax-user-name {
157 font-weight: 600; font-size: 0.95rem;
158 display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap;
159}
160.ax-user-name a { color: var(--ink); text-decoration: none; }
161.ax-user-name a:hover { color: var(--accent); }
162.ax-user-email {
163 font-size: 0.82rem;
164 color: var(--ink-muted, var(--ink-soft));
165 overflow: hidden;
166 text-overflow: ellipsis;
167 white-space: nowrap;
168}
169.ax-pill {
170 font-size: 0.7rem; font-weight: 500;
171 color: var(--ink-soft);
172 background: var(--paper-2);
173 padding: 0.15em 0.55em; border-radius: 999px;
174}
175
176/* ─── Stats (3 mini-columns) ──────────────────────────────────── */
177.ax-user-stats {
178 display: flex; gap: 1.25rem;
179 align-items: center;
180}
181.ax-stat {
182 display: flex; flex-direction: column;
183 font-size: 0.8rem;
184 text-align: center;
185 min-width: 0;
186}
187.ax-stat-num {
188 font-family: var(--font-display, serif);
189 font-weight: 600; font-size: 1.05rem;
190 color: var(--ink);
191 font-variant-numeric: tabular-nums;
192}
193.ax-stat-date {
194 font-family: var(--font-ui, system-ui);
195 font-size: 0.75rem;
196 font-weight: 500;
197 white-space: nowrap;
198}
199.ax-stat-label {
200 color: var(--ink-muted, var(--ink-soft));
201 text-transform: uppercase;
202 letter-spacing: 0.04em;
203 font-size: 0.7rem;
204}
205
206/* ─── Role select + delete ────────────────────────────────────── */
207.ax-user-controls {
208 display: flex; gap: 0.5rem; align-items: center;
209 flex-shrink: 0;
210}
211.ax-role-form { margin: 0; }
212.ax-role {
213 display: flex; flex-direction: column; gap: 0.2rem;
214 font-size: 0.7rem;
215}
216.ax-role > span {
217 color: var(--ink-muted);
218 text-transform: uppercase;
219 letter-spacing: 0.04em;
220 font-weight: 600;
221 font-size: 0.7rem;
222}
223.ax-role select {
224 padding: 0.4rem 1.75rem 0.4rem 0.6rem;
225 border: 1px solid var(--rule);
226 border-radius: 6px;
227 background: var(--paper-2);
228 color: var(--ink);
229 font-family: var(--font-ui, system-ui), sans-serif;
230 font-size: 0.85rem;
231 -webkit-appearance: none; appearance: none;
232 cursor: pointer;
233 background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
234 background-repeat: no-repeat;
235 background-position: right 0.5rem center;
236}
237.ax-role select:disabled { cursor: not-allowed; opacity: 0.5; }
238.ax-ro { align-items: center; }
239.ax-ro input { width: 18px; height: 18px; cursor: pointer; margin-top: 0.15rem; accent-color: var(--accent); }
240.ax-ro input:disabled { cursor: not-allowed; opacity: 0.5; }
241.ax-delete-form { margin: 0; }
242.ax-icon-btn {
243 display: inline-flex; align-items: center; justify-content: center;
244 width: 40px; height: 40px;
245 border: 1px solid var(--rule); border-radius: 8px;
246 background: var(--paper-2); color: var(--ink);
247 cursor: pointer; font-size: 1rem;
248 transition: background 120ms, border-color 120ms, color 120ms;
249}
250.ax-icon-btn:hover { border-color: var(--accent); }
251.ax-icon-btn-danger:hover { color: #dc2626; border-color: #dc2626; }
252.ax-icon-btn-spacer { display: inline-block; width: 40px; height: 40px; flex-shrink: 0; }
253
254/* ─── Mobile: stack everything vertically ─────────────────────── */
255@media (max-width: 720px) {
256 .ax-user {
257 grid-template-columns: 1fr;
258 grid-template-areas: "id" "stats" "controls";
259 gap: 0.75rem;
260 }
261 .ax-user-id { grid-area: id; }
262 .ax-user-stats { grid-area: stats; justify-content: flex-start; gap: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }
263 .ax-user-controls { grid-area: controls; justify-content: space-between; align-items: flex-end; }
264 .ax-role { flex: 1; max-width: 200px; }
265}
266</style>
Note: See TracBrowser for help on using the repository browser.