File size: 13,794 Bytes
1434f10 8e76f7f 2406314 1434f10 2406314 1434f10 2406314 1434f10 2406314 1434f10 2406314 eab736b 2406314 1434f10 2406314 8e76f7f 2406314 3b5dfb3 2406314 18b702f 1434f10 2406314 18b702f 2406314 1434f10 2406314 1434f10 2406314 3b5dfb3 2406314 53203f7 2406314 53203f7 2406314 1434f10 2406314 8e76f7f 2406314 eab736b 2406314 1434f10 2406314 1434f10 2406314 3b5dfb3 2406314 1434f10 2406314 1434f10 2406314 3b5dfb3 2406314 eab736b 2406314 40f6e09 2406314 40f6e09 2406314 3b5dfb3 2406314 87c8ac5 2406314 1434f10 64c5188 59e06b1 64c5188 59e06b1 64c5188 59e06b1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | {% extends "base.html" %}
{% block title %}Admin - Explorer{% endblock %}
{% block nav_admin %}active{% endblock %}
{% block content %}
<div class="page-header">
<div class="page-header-text">
<div class="page-eyebrow">Admin</div>
<h1 class="page-title">Control the <em>training</em> system.</h1>
<p class="page-subtitle">Manage users, corrections, and the activity log from one place.</p>
</div>
</div>
<!-- Flash messages -->
{% set _tab = request.query_params.get('tab', 'users') %}
{% set _success = request.query_params.get('success', '') %}
{% set _error = request.query_params.get('error', '') %}
{% if _success %}
<div class="alert alert-success">{{ _success }}</div>
{% endif %}
{% if _error %}
<div class="alert alert-error">{{ _error }}</div>
{% endif %}
<!-- ── Tab bar ──────────────────────────────────────────── -->
<div class="tab-bar mb-2">
<button class="tab-btn {% if _tab == 'users' %}active{% endif %}"
onclick="switchTab('users')">USERS</button>
<button class="tab-btn {% if _tab == 'corrections' %}active{% endif %}"
onclick="switchTab('corrections')">CORRECTIONS</button>
<button class="tab-btn {% if _tab == 'activity' %}active{% endif %}"
onclick="switchTab('activity')">ACTIVITY LOG</button>
</div>
<!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
TAB: USERS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
<div id="tab-users" class="tab-panel {% if _tab != 'users' %}hidden{% endif %}">
<!-- Add user form -->
<div class="card mb-2">
<div class="card-label mb-2">ADD NEW USER</div>
<form method="post" action="/admin/users/add">
<div class="grid-3 mb-2">
<div class="field">
<label>Email</label>
<input type="email" name="email" required placeholder="user@example.com" />
</div>
<div class="field">
<label>Full Name</label>
<input type="text" name="name" required placeholder="Jane Smith" />
</div>
<div class="field">
<label>Role</label>
<select name="role" required>
<option value="staff">Staff</option>
<option value="manager">Manager</option>
<option value="admin">Admin</option>
</select>
</div>
</div>
<div class="flex items-center gap-2">
<button type="submit" class="btn btn-primary">+ ADD USER</button>
<span class="text-dim" style="font-size:0.78rem;">
The user sets their own password via the login page, or you can set one via Edit below.
</span>
</div>
</form>
</div>
<!-- Export -->
<div class="flex justify-between items-center mb-2">
<div class="card-label">ALL USERS ({{ users | length }})</div>
<a href="/admin/export/users" class="btn btn-outline" style="font-size:0.72rem;padding:0.35rem 0.9rem;">↓ Export CSV</a>
</div>
<!-- Users table -->
<div class="card">
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Email</th><th>Name</th><th>Role</th><th>Status</th>
<th>Created</th><th>Last Login</th><th></th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.email }}</td>
<td>{{ u.name }}</td>
<td><span class="nav-role role-{{ u.role }}">{{ u.role }}</span></td>
<td>
{% if u.active %}
<span class="text-green" style="font-size:0.8rem;font-weight:700;">Active</span>
{% else %}
<span class="text-red" style="font-size:0.8rem;font-weight:700;">Inactive</span>
{% endif %}
</td>
<td class="text-muted" style="font-size:0.78rem;">{{ (u.created_at or '')[:10] }}</td>
<td class=”text-muted” style=”font-size:0.78rem;”>{{ (u.last_login or '-')[:16] }}</td>
<td>
{% if user.role == 'admin' %}
<button class="btn btn-outline" style="font-size:0.72rem;padding:0.2rem 0.6rem;"
onclick="openEditUser('{{ u.email }}','{{ u.name }}','{{ u.role }}',{{ u.active }})">
Edit
</button>
{% endif %}
</td>
</tr>
{% else %}
<tr><td colspan="7" class="text-center text-muted" style="padding:2rem;">No users found.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div><!-- /tab-users -->
<!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
TAB: CORRECTIONS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
<div id="tab-corrections" class="tab-panel {% if _tab != 'corrections' %}hidden{% endif %}">
<div class="card-label mb-2">STAFF CORRECTIONS ({{ corrections | length }})</div>
<div class="card">
<div class="table-wrap">
<table>
<thead>
<tr>
<th>ID</th><th>Staff</th><th>Quote</th>
<th>Original</th><th>Corrected To</th><th>Date</th><th></th>
</tr>
</thead>
<tbody>
{% for c in corrections %}
<tr>
<td class="text-dim" style="font-size:0.78rem;">{{ c.id }}</td>
<td>{{ c.user_name }}</td>
<td style="max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"
title="{{ c.quote }}">{{ c.quote[:60] }}{% if c.quote|length > 60 %}...{% endif %}</td>
<td class="text-muted" style="font-size:0.78rem;">
{{ c.original_type }}<br>
<span class="text-dim">{{ c.original_cluster }}</span>
</td>
<td style="font-size:0.78rem;">
<strong>{{ c.corrected_type }}</strong><br>
<span class="text-gold">{{ c.corrected_cluster }}</span>
</td>
<td class="text-muted" style="font-size:0.78rem;">{{ (c.created_at or '')[:10] }}</td>
<td>
{% if user.role == 'admin' %}
<form method="post" action="/admin/corrections/delete"
onsubmit="return confirm('Delete correction #{{ c.id }}?')">
<input type="hidden" name="correction_id" value="{{ c.id }}" />
<button type="submit" class="btn btn-outline"
style="font-size:0.72rem;padding:0.2rem 0.6rem;color:var(--red);border-color:rgba(224,82,82,0.35);">
Delete
</button>
</form>
{% endif %}
</td>
</tr>
{% else %}
<tr><td colspan="7" class="text-center text-muted" style="padding:2rem;">No corrections yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div><!-- /tab-corrections -->
<!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
TAB: ACTIVITY LOG
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
<div id="tab-activity" class="tab-panel {% if _tab != 'activity' %}hidden{% endif %}">
<div class="card-label mb-2">ACTIVITY LOG (LAST {{ activity | length }} EVENTS)</div>
<div class="card">
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Time</th><th>User</th><th>Action</th><th>Page</th><th>Details</th>
</tr>
</thead>
<tbody>
{% for a in activity %}
<tr>
<td class="text-muted" style="font-size:0.78rem;">{{ (a.timestamp or '')[:16] }}</td>
<td>{{ a.user_name }}</td>
<td>
<span class="activity-action activity-{{ a.action }}">{{ a.action }}</span>
</td>
<td class="text-dim" style="font-size:0.78rem;">{{ a.page or '-' }}</td>
<td class="text-muted" style="font-size:0.78rem;max-width:260px;overflow:hidden;
text-overflow:ellipsis;white-space:nowrap;" title="{{ a.details }}">
{{ a.details or '' }}
</td>
</tr>
{% else %}
<tr><td colspan="5" class="text-center text-muted" style="padding:2rem;">No activity recorded yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div><!-- /tab-activity -->
<!-- â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
EDIT USER MODAL
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• -->
<div id="edit-user-overlay" class="modal-overlay" hidden onclick="closeEditUser()">
<div class="modal-box" onclick="event.stopPropagation()">
<div class="modal-header">
<span class="card-label">EDIT USER</span>
<button class="modal-close" onclick="closeEditUser()">×</button>
</div>
<div id="edit-user-email-display" class="text-muted mb-2" style="font-size:0.85rem;"></div>
<form method="post" action="/admin/users/update" id="edit-user-form">
<input type="hidden" name="email" id="edit-user-email" />
<div class="grid-2 mb-2">
<div class="field">
<label>Full Name</label>
<input type="text" name="name" id="edit-user-name" />
</div>
<div class="field">
<label>Role</label>
<select name="role" id="edit-user-role">
<option value="staff">Staff</option>
<option value="manager">Manager</option>
<option value="admin">Admin</option>
</select>
</div>
</div>
{% set _is_admin = user.role | lower == 'admin' %}
<div class="{% if _is_admin %}grid-2{% endif %} mb-2">
<div class="field">
<label>Status</label>
<select name="active" id="edit-user-active">
<option value="1">Active</option>
<option value="0">Inactive</option>
</select>
</div>
{% if _is_admin %}
<div class="field">
<label>New Password <span class="text-dim">(leave blank to keep)</span></label>
<input type="password" name="password" id="edit-user-password"
placeholder="New password..." autocomplete="new-password" />
</div>
{% endif %}
</div>
<div class="flex gap-1 mt-2">
<button type="submit" class="btn btn-primary">SAVE CHANGES</button>
<button type="button" class="btn btn-outline" onclick="closeEditUser()">Cancel</button>
<div style="flex:1;"></div>
<button type="button" id="delete-user-btn" class="btn"
style="background:#7f1d1d;color:#fca5a5;border:1px solid #991b1b;"
onclick="deleteUser()">DELETE USER</button>
</div>
</form>
<form method="post" action="/admin/users/delete" id="delete-user-form">
<input type="hidden" name="email" id="delete-user-email" />
</form>
</div>
</div>
<script>
</script>
{% endblock %}
|