source: Klonkt/src/views/pages/admin.ejs@ 07775b7

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

tenancy: runtime Solo/Hub mode + mode-aware /admin (Phase 1)

Admin can switch live between modes in Admin -> Settings:

  • solo: exactly one site (the primary/owner site), no /sites routing, leaner /admin.
  • hub: main site + /sites/:slug routing (company; /gebruikers + assignment flow = Phase 2).

Switching is non-destructive (hides only, deletes nothing).

  • app_settings (key/value singleton) + SettingsService (cached getTenancy/setTenancy).
  • resolveSite: solo pins to the primary site + disables /sites/:slug + host mapping.
  • /admin/settings (god-only) toggle; /admin dashboard rewritten, mode-aware.

Tested on the demo: solo/hub dashboard tiles, /sites routing per mode, toggle back/forth.

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

  • Property mode set to 100644
File size: 5.7 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 PrutFolio.</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 <% } %>
24 <a href="/account" class="btn">👤 Account</a>
25 <a href="/admin/settings" class="btn">⚙️ Instellingen</a>
26 <% } %>
27 </nav>
28
29 <div class="admin-stats">
30 <% if (tenancy === 'hub') { %>
31 <div class="stat-card"><div class="stat-num"><%= stats.users %></div><div class="stat-label">Gebruikers</div></div>
32 <div class="stat-card"><div class="stat-num"><%= stats.sites %></div><div class="stat-label">Sites</div></div>
33 <% } %>
34 <div class="stat-card"><div class="stat-num"><%= stats.posts %></div><div class="stat-label">Posts</div></div>
35 <div class="stat-card"><div class="stat-num"><%= stats.published %></div><div class="stat-label">Gepubliceerd</div></div>
36 </div>
37
38 <% if (sites && sites.length) { %>
39 <h2>Sites</h2>
40 <table class="admin-table">
41 <thead>
42 <tr><th>Slug</th><th>Title</th><th>Owner</th><th>Created</th></tr>
43 </thead>
44 <tbody>
45 <% sites.forEach(function(s) { %>
46 <tr>
47 <td><code><%= s.slug %></code></td>
48 <td><%= s.title %></td>
49 <td><%= s.owner_username || '—' %></td>
50 <td><%= formatDate(s.created_at) %></td>
51 </tr>
52 <% }); %>
53 </tbody>
54 </table>
55 <% } %>
56
57 <% if (users && users.length) { %>
58 <h2>Users</h2>
59 <table class="admin-table">
60 <thead>
61 <tr><th>Username</th><th>Email</th><th>Role</th><th>Joined</th></tr>
62 </thead>
63 <tbody>
64 <% users.forEach(function(u) { %>
65 <tr>
66 <td><%= u.username %></td>
67 <td><%= u.email %></td>
68 <td><span class="role-pill role-<%= u.role %>"><%= u.role %></span></td>
69 <td><%= formatDate(u.created_at) %></td>
70 </tr>
71 <% }); %>
72 </tbody>
73 </table>
74 <% } %>
75
76</div>
77
78<style>
79.admin-page { max-width: 1000px; margin: 3rem auto; padding: 0 1rem; }
80.admin-page h1 { font-family: var(--font-display, serif); font-size: 2rem; margin: 0 0 0.25rem; }
81.admin-page h2 { font-family: var(--font-display, serif); font-size: 1.4rem; margin: 2rem 0 0.75rem; }
82.admin-tagline { color: var(--ink-muted); margin: 0 0 2rem; }
83.admin-tagline em { font-style: normal; opacity: 0.7; }
84
85/* Quick-links grid — mobile-first.
86 auto-fit + minmax means: as many equal columns as fit, each at least 140px.
87 Mobile (~360-440px): 2 per row.
88 Tablet (~480-700px): 3 per row.
89 Desktop (≥ ~720px): all 5 in a single row. */
90.admin-quick-links {
91 display: grid;
92 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
93 gap: 0.5rem;
94 margin: 0 0 1.5rem;
95 padding: 0;
96}
97.admin-quick-links .btn {
98 justify-content: center;
99 padding: 0.7rem 0.9rem;
100 font-weight: 600;
101 text-align: center;
102}
103.admin-quick-links .btn:hover {
104 background: color-mix(in srgb, var(--accent) 8%, var(--paper-2));
105 border-color: var(--accent);
106}
107
108.admin-stats {
109 display: grid;
110 grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
111 gap: 0.75rem;
112 margin-bottom: 1rem;
113}
114.stat-card {
115 background: var(--paper-2);
116 border: 1px solid var(--rule);
117 border-radius: 8px;
118 padding: 1rem 1.25rem;
119 text-align: center;
120}
121.stat-num {
122 font-size: 2rem;
123 font-weight: 700;
124 color: var(--accent);
125 line-height: 1;
126 font-family: var(--font-display, serif);
127}
128.stat-label {
129 color: var(--ink-muted);
130 font-size: 0.85rem;
131 text-transform: uppercase;
132 letter-spacing: 0.05em;
133 margin-top: 0.25rem;
134}
135
136.admin-table {
137 width: 100%;
138 border-collapse: collapse;
139 background: var(--paper-2);
140 border: 1px solid var(--rule);
141 border-radius: 8px;
142 overflow: hidden;
143}
144.admin-table th, .admin-table td {
145 padding: 0.6rem 0.9rem;
146 text-align: left;
147 border-bottom: 1px solid var(--rule);
148}
149.admin-table th {
150 background: var(--paper);
151 font-weight: 600;
152 font-size: 0.85rem;
153 text-transform: uppercase;
154 letter-spacing: 0.05em;
155 color: var(--ink-muted);
156}
157.admin-table tr:last-child td { border-bottom: 0; }
158.admin-table code { background: var(--paper); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85rem; }
159
160.role-pill {
161 display: inline-block;
162 padding: 0.1rem 0.5rem;
163 border-radius: 10px;
164 font-size: 0.75rem;
165 text-transform: uppercase;
166 letter-spacing: 0.05em;
167 background: var(--paper);
168 color: var(--ink-muted);
169}
170.role-pill.role-god { background: var(--accent); color: white; }
171.role-pill.role-admin { background: var(--paper); color: var(--accent); border: 1px solid var(--accent); }
172
173.admin-todo {
174 margin: 2rem 0 0;
175 padding: 0.75rem 1rem;
176 background: var(--paper-2);
177 border-left: 3px solid var(--accent);
178 border-radius: 4px;
179 font-size: 0.9rem;
180 color: var(--ink-muted);
181}
182
183@media (max-width: 600px) {
184 .admin-table { font-size: 0.85rem; }
185 .admin-table th, .admin-table td { padding: 0.45rem 0.6rem; }
186}
187</style>
Note: See TracBrowser for help on using the repository browser.