source: Klonkt/src/views/pages/admin-users.ejs@ 05a6ca0

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

admin: align users list — fixed position for the delete button

The delete button only appeared on deletable rows, causing the role/view-mode
columns to shift per row. Now an empty placeholder of the same size on
non-deletable rows so everything aligns.

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

  • Property mode set to 100644
File size: 10.2 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 && (u.post_count + u.site_count === 0)) { %>
77 <form method="post" action="/admin/users/<%= u.id %>/delete" class="ax-delete-form"
78 onsubmit="return confirm('Verwijder gebruiker <%= u.username %>?')">
79 <button type="submit" class="ax-icon-btn ax-icon-btn-danger" aria-label="Verwijderen" title="Verwijderen">🗑</button>
80 </form>
81 <% } else { %>
82 <%# Lege plek zodat de kolommen (rol/kijk-modus) op elke rij uitlijnen. %>
83 <span class="ax-icon-btn-spacer" aria-hidden="true"></span>
84 <% } %>
85 </div>
86
87 </li>
88 <% }); %>
89 </ul>
90 <% } %>
91
92</div>
93
94<style>
95.ax-page { max-width: 880px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
96.ax-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
97.ax-header h1 { font-family: var(--font-display, serif); font-size: 1.75rem; margin: 0 0 0.25rem; }
98.ax-tagline { color: var(--ink-muted, var(--ink-soft)); margin: 0; font-size: 0.9rem; }
99.ax-back {
100 display: inline-flex; align-items: center; justify-content: center;
101 width: 40px; height: 40px;
102 border: 1px solid var(--rule); border-radius: 8px;
103 background: var(--paper); color: var(--ink); text-decoration: none;
104 font-size: 1.1rem; flex-shrink: 0; transition: border-color 120ms;
105}
106.ax-back:hover { border-color: var(--accent); }
107
108.ax-flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
109.ax-flash-ok { background: rgba(40,160,90,.15); color: #2a9d5e; border: 1px solid rgba(40,160,90,.3); }
110.ax-flash-err { background: rgba(200,60,60,.15); color: #c33; border: 1px solid rgba(200,60,60,.3); }
111
112.ax-card {
113 background: var(--paper); border: 1px solid var(--rule);
114 border-radius: 12px; padding: 1.25rem;
115}
116.ax-empty { text-align: center; padding: 2rem 1rem; color: var(--ink-muted); }
117.ax-empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.5; }
118.ax-empty p { margin: 0; }
119
120/* ─── User cards ───────────────────────────────────────────────── */
121.ax-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
122.ax-user {
123 display: grid;
124 grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
125 gap: 1rem;
126 align-items: center;
127 padding: 0.85rem 1rem;
128 background: var(--paper);
129 border: 1px solid var(--rule);
130 border-radius: 12px;
131 transition: border-color 120ms;
132}
133.ax-user:hover { border-color: var(--accent); }
134.ax-user.is-self {
135 background: color-mix(in srgb, var(--accent) 7%, var(--paper));
136 border-color: color-mix(in srgb, var(--accent) 25%, var(--rule));
137}
138
139.ax-user-id { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
140.ax-avatar {
141 width: 44px; height: 44px;
142 border-radius: 50%;
143 object-fit: cover;
144 background: var(--paper-2);
145 color: var(--accent);
146 display: inline-flex; align-items: center; justify-content: center;
147 font-family: var(--font-display, serif);
148 font-weight: 700; font-size: 1.1rem;
149 flex-shrink: 0;
150}
151.ax-avatar-empty { /* span variant uses same styling */ }
152.ax-user-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
153.ax-user-name {
154 font-weight: 600; font-size: 0.95rem;
155 display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap;
156}
157.ax-user-name a { color: var(--ink); text-decoration: none; }
158.ax-user-name a:hover { color: var(--accent); }
159.ax-user-email {
160 font-size: 0.82rem;
161 color: var(--ink-muted, var(--ink-soft));
162 overflow: hidden;
163 text-overflow: ellipsis;
164 white-space: nowrap;
165}
166.ax-pill {
167 font-size: 0.7rem; font-weight: 500;
168 color: var(--ink-soft);
169 background: var(--paper-2);
170 padding: 0.15em 0.55em; border-radius: 999px;
171}
172
173/* ─── Stats (3 mini-columns) ──────────────────────────────────── */
174.ax-user-stats {
175 display: flex; gap: 1.25rem;
176 align-items: center;
177}
178.ax-stat {
179 display: flex; flex-direction: column;
180 font-size: 0.8rem;
181 text-align: center;
182 min-width: 0;
183}
184.ax-stat-num {
185 font-family: var(--font-display, serif);
186 font-weight: 600; font-size: 1.05rem;
187 color: var(--ink);
188 font-variant-numeric: tabular-nums;
189}
190.ax-stat-date {
191 font-family: var(--font-ui, system-ui);
192 font-size: 0.75rem;
193 font-weight: 500;
194 white-space: nowrap;
195}
196.ax-stat-label {
197 color: var(--ink-muted, var(--ink-soft));
198 text-transform: uppercase;
199 letter-spacing: 0.04em;
200 font-size: 0.7rem;
201}
202
203/* ─── Role select + delete ────────────────────────────────────── */
204.ax-user-controls {
205 display: flex; gap: 0.5rem; align-items: center;
206 flex-shrink: 0;
207}
208.ax-role-form { margin: 0; }
209.ax-role {
210 display: flex; flex-direction: column; gap: 0.2rem;
211 font-size: 0.7rem;
212}
213.ax-role > span {
214 color: var(--ink-muted);
215 text-transform: uppercase;
216 letter-spacing: 0.04em;
217 font-weight: 600;
218 font-size: 0.7rem;
219}
220.ax-role select {
221 padding: 0.4rem 1.75rem 0.4rem 0.6rem;
222 border: 1px solid var(--rule);
223 border-radius: 6px;
224 background: var(--paper-2);
225 color: var(--ink);
226 font-family: var(--font-ui, system-ui), sans-serif;
227 font-size: 0.85rem;
228 -webkit-appearance: none; appearance: none;
229 cursor: pointer;
230 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>");
231 background-repeat: no-repeat;
232 background-position: right 0.5rem center;
233}
234.ax-role select:disabled { cursor: not-allowed; opacity: 0.5; }
235.ax-ro { align-items: center; }
236.ax-ro input { width: 18px; height: 18px; cursor: pointer; margin-top: 0.15rem; accent-color: var(--accent); }
237.ax-ro input:disabled { cursor: not-allowed; opacity: 0.5; }
238.ax-delete-form { margin: 0; }
239.ax-icon-btn {
240 display: inline-flex; align-items: center; justify-content: center;
241 width: 40px; height: 40px;
242 border: 1px solid var(--rule); border-radius: 8px;
243 background: var(--paper-2); color: var(--ink);
244 cursor: pointer; font-size: 1rem;
245 transition: background 120ms, border-color 120ms, color 120ms;
246}
247.ax-icon-btn:hover { border-color: var(--accent); }
248.ax-icon-btn-danger:hover { color: #dc2626; border-color: #dc2626; }
249.ax-icon-btn-spacer { display: inline-block; width: 40px; height: 40px; flex-shrink: 0; }
250
251/* ─── Mobile: stack everything vertically ─────────────────────── */
252@media (max-width: 720px) {
253 .ax-user {
254 grid-template-columns: 1fr;
255 grid-template-areas: "id" "stats" "controls";
256 gap: 0.75rem;
257 }
258 .ax-user-id { grid-area: id; }
259 .ax-user-stats { grid-area: stats; justify-content: flex-start; gap: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }
260 .ax-user-controls { grid-area: controls; justify-content: space-between; align-items: flex-end; }
261 .ax-role { flex: 1; max-width: 200px; }
262}
263</style>
Note: See TracBrowser for help on using the repository browser.