source: Klonkt/src/views/pages/admin.ejs@ edc462d

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

Statistics module (Phase 3): cookie-free tracking + premium stats page

Counters: posts.view_count, audio_tracks.play_count, stat_daily
(pageviews/day) + stat_visitor_day (unique visitors via daily rotating
salted hash of IP+UA, never stored → no cookie, no consent needed).
StatsService records pageview on home + post-view (skips admins), play on
the initial player stream fetch. /admin/stats (god-only +
premiumUnlocked-gated): cards + 14-day cookie-free bar chart
(visitors/views) + top posts/tracks. Dashboard button is premium-gated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

  • Property mode set to 100644
File size: 8.4 KB
Line 
1<div class="container admin-page">
2 <h1>Beheer</h1>
3 <% if (tenancy === 'hub') { %>
4 <p class="admin-tagline">Hub-modus — bedrijfssite met gebruikers, elk hun eigen Klonkt Hub.</p>
5 <% } else { %>
6 <p class="admin-tagline">Solo-modus — jouw site.</p>
7 <% } %>
8
9 <nav class="admin-quick-links" aria-label="Beheer-snelkoppelingen">
10 <% if (tenancy === 'hub') { %>
11 <a href="/admin/sites" class="btn">🌐 Sites</a>
12 <a href="/admin/users" class="btn">👥 Gebruikers</a>
13 <a href="/admin/audio" class="btn">🎵 Audio</a>
14 <a href="/admin/playlists" class="btn">📃 Playlists</a>
15 <a href="/admin/comments" class="btn">💬 Reacties</a>
16 <a href="/admin/settings" class="btn">⚙️ Instellingen</a>
17 <% } else { %>
18 <a href="/posts/new" class="btn">✍️ Nieuwe post</a>
19 <a href="/admin/audio" class="btn">🎵 Audio</a>
20 <a href="/admin/comments" class="btn">💬 Reacties</a>
21 <% if (primarySite) { %>
22 <a href="/admin/sites/<%= primarySite.slug %>/edit" class="btn">🎨 Uiterlijk</a>
23 <% } else { %>
24 <a href="/admin/sites/new" class="btn">🎨 Maak je site aan</a>
25 <% } %>
26 <% if (tenancy === 'circle') { %>
27 <a href="/admin/circle" class="btn">🔗 Cirkel</a>
28 <% } %>
29 <a href="/admin/settings" class="btn">⚙️ Instellingen</a>
30 <% } %>
31 <% if (typeof premiumUnlocked === 'undefined' || premiumUnlocked) { %>
32 <a href="/admin/stats" class="btn">📊 Statistieken</a>
33 <% } %>
34 <a href="/admin/updates" class="btn">🔄 Updates</a>
35 </nav>
36
37 <div class="admin-stats">
38 <% if (tenancy === 'hub') { %>
39 <div class="stat-card"><div class="stat-num"><%= stats.users %></div><div class="stat-label">Gebruikers</div></div>
40 <div class="stat-card"><div class="stat-num"><%= stats.sites %></div><div class="stat-label">Sites</div></div>
41 <% } %>
42 <div class="stat-card"><div class="stat-num"><%= stats.posts %></div><div class="stat-label">Posts</div></div>
43 <div class="stat-card"><div class="stat-num"><%= stats.published %></div><div class="stat-label">Gepubliceerd</div></div>
44 </div>
45
46 <% if (typeof posts !== 'undefined' && posts && posts.length) { %>
47 <% var _drafts = posts.filter(function(p){ return p.isDraft; }).length; %>
48 <h2>Posts<% if (_drafts) { %> <span class="pl-draftcount"><%= _drafts %> concept<%= _drafts === 1 ? '' : 'en' %></span><% } %></h2>
49 <ul class="post-admin-list">
50 <% posts.forEach(function(p) { %>
51 <li class="pal-row<%= p.isDraft ? ' is-draft' : '' %>">
52 <a class="pal-title" href="<%= p.editUrl %>">
53 <% if (p.isDraft) { %><span class="pal-badge">Concept</span><% } %>
54 <span class="pal-name"><%= p.title || '(zonder titel)' %></span>
55 </a>
56 <span class="pal-actions">
57 <a class="pal-link" href="<%= p.editUrl %>">Bewerken</a>
58 <% if (!p.isDraft) { %><a class="pal-link" href="<%= p.viewUrl %>">Bekijk</a><% } %>
59 </span>
60 </li>
61 <% }); %>
62 </ul>
63 <% } %>
64
65 <% if (sites && sites.length) { %>
66 <h2>Sites</h2>
67 <table class="admin-table">
68 <thead>
69 <tr><th>Slug</th><th>Title</th><th>Owner</th><th>Created</th></tr>
70 </thead>
71 <tbody>
72 <% sites.forEach(function(s) { %>
73 <tr>
74 <td><code><%= s.slug %></code></td>
75 <td><%= s.title %></td>
76 <td><%= s.owner_username || '—' %></td>
77 <td><%= formatDate(s.created_at) %></td>
78 </tr>
79 <% }); %>
80 </tbody>
81 </table>
82 <% } %>
83
84 <% if (users && users.length) { %>
85 <h2>Users</h2>
86 <table class="admin-table">
87 <thead>
88 <tr><th>Username</th><th>Email</th><th>Role</th><th>Joined</th></tr>
89 </thead>
90 <tbody>
91 <% users.forEach(function(u) { %>
92 <tr>
93 <td><%= u.username %></td>
94 <td><%= u.email %></td>
95 <td><span class="role-pill role-<%= u.role %>"><%= u.role %></span></td>
96 <td><%= formatDate(u.created_at) %></td>
97 </tr>
98 <% }); %>
99 </tbody>
100 </table>
101 <% } %>
102
103</div>
104
105<style>
106.admin-page { max-width: 1000px; margin: 3rem auto; padding: 0 1rem; }
107.admin-page h1 { font-family: var(--font-display, serif); font-size: 2rem; margin: 0 0 0.25rem; }
108.admin-page h2 { font-family: var(--font-display, serif); font-size: 1.4rem; margin: 2rem 0 0.75rem; }
109.admin-tagline { color: var(--ink-muted); margin: 0 0 2rem; }
110.admin-tagline em { font-style: normal; opacity: 0.7; }
111
112/* Posts/concepten-lijst */
113.pl-draftcount { font-family: var(--font-ui, system-ui); font-size: 0.8rem; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 0.1rem 0.55rem; border-radius: 99px; vertical-align: middle; }
114.post-admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
115.pal-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0.9rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper-2); transition: border-color 120ms; }
116.pal-row:hover { border-color: var(--accent); }
117.pal-row.is-draft { border-left: 3px solid var(--accent); }
118.pal-title { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 600; }
119.pal-title:hover { color: var(--accent); }
120.pal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
121.pal-badge { flex-shrink: 0; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 0.1rem 0.5rem; border-radius: 99px; }
122.pal-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }
123.pal-link { color: var(--ink-muted); font-size: 0.85rem; text-decoration: none; white-space: nowrap; }
124.pal-link:hover { color: var(--accent); text-decoration: underline; }
125
126/* Quick-links grid — mobile-first.
127 auto-fit + minmax means: as many equal columns as fit, each at least 140px.
128 Mobile (~360-440px): 2 per row.
129 Tablet (~480-700px): 3 per row.
130 Desktop (≥ ~720px): all 5 in a single row. */
131.admin-quick-links {
132 display: grid;
133 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
134 gap: 0.5rem;
135 margin: 0 0 1.5rem;
136 padding: 0;
137}
138.admin-quick-links .btn {
139 justify-content: center;
140 padding: 0.7rem 0.9rem;
141 font-weight: 600;
142 text-align: center;
143}
144.admin-quick-links .btn:hover {
145 background: color-mix(in srgb, var(--accent) 8%, var(--paper-2));
146 border-color: var(--accent);
147}
148
149.admin-stats {
150 display: grid;
151 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
152 gap: 0.75rem;
153 margin-bottom: 1rem;
154}
155.stat-card {
156 background: var(--paper-2);
157 border: 1px solid var(--rule);
158 border-radius: 8px;
159 padding: 1rem 1.25rem;
160 text-align: center;
161}
162.stat-num {
163 font-size: 2rem;
164 font-weight: 700;
165 color: var(--accent);
166 line-height: 1;
167 font-family: var(--font-display, serif);
168}
169.stat-label {
170 color: var(--ink-muted);
171 font-size: 0.85rem;
172 text-transform: uppercase;
173 letter-spacing: 0.05em;
174 margin-top: 0.25rem;
175}
176
177.admin-table {
178 width: 100%;
179 border-collapse: collapse;
180 background: var(--paper-2);
181 border: 1px solid var(--rule);
182 border-radius: 8px;
183 overflow: hidden;
184}
185.admin-table th, .admin-table td {
186 padding: 0.6rem 0.9rem;
187 text-align: left;
188 border-bottom: 1px solid var(--rule);
189}
190.admin-table th {
191 background: var(--paper);
192 font-weight: 600;
193 font-size: 0.85rem;
194 text-transform: uppercase;
195 letter-spacing: 0.05em;
196 color: var(--ink-muted);
197}
198.admin-table tr:last-child td { border-bottom: 0; }
199.admin-table code { background: var(--paper); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85rem; }
200
201.role-pill {
202 display: inline-block;
203 padding: 0.1rem 0.5rem;
204 border-radius: 10px;
205 font-size: 0.75rem;
206 text-transform: uppercase;
207 letter-spacing: 0.05em;
208 background: var(--paper);
209 color: var(--ink-muted);
210}
211.role-pill.role-god { background: var(--accent); color: white; }
212.role-pill.role-admin { background: var(--paper); color: var(--accent); border: 1px solid var(--accent); }
213
214.admin-todo {
215 margin: 2rem 0 0;
216 padding: 0.75rem 1rem;
217 background: var(--paper-2);
218 border-left: 3px solid var(--accent);
219 border-radius: 4px;
220 font-size: 0.9rem;
221 color: var(--ink-muted);
222}
223
224@media (max-width: 600px) {
225 .admin-table { font-size: 0.85rem; }
226 .admin-table th, .admin-table td { padding: 0.45rem 0.6rem; }
227}
228</style>
Note: See TracBrowser for help on using the repository browser.