Add admin maintenance console

Admin-only page reachable from a new card on the admin panel (replacing the
Quick Actions card) that centralises housekeeping operations:

* Database integrity: PRAGMA integrity_check / quick_check / foreign_key_check,
  plus VACUUM + ANALYZE to reclaim free space.
* Leftover records: detects and removes orphaned rows left behind by deleted
  players/content (player_feedback, player_edit, playlist_content, dangling
  player.playlist_id) and orphaned edited-media folders on disk.
* Player authentication tokens: manual reset (single or all), a configurable
  automatic reset interval, and cancellation of a pending reset.

Resetting a token rotates player.auth_code and sets auth_reset_required, so the
next heartbeat (POST /api/player-feedback) answers 401 + auth_required and the
client restarts its authentication flow. A successful authentication clears the
flag and stamps auth_token_issued_at, from which the interval is measured.

New: PlayerAuthConfig model, add_player_auth_reset migration (registered in
docker-entrypoint.sh), admin/maintenance.html.
This commit is contained in:
2026-10-14 22:13:18 +03:00
parent 2539f82868
commit 88827be7be
10 changed files with 1124 additions and 19 deletions
+10 -14
View File
@@ -129,15 +129,18 @@
</div>
{% endif %}
<!-- Quick Actions Card -->
<div class="card">
<h2>⚡ Quick Actions</h2>
<div class="quick-actions">
<a href="{{ url_for('players.list') }}" class="btn btn-secondary">🖥️ View Players</a>
<a href="{{ url_for('content.content_list') }}" class="btn btn-secondary">📋 View Playlists</a>
<a href="{{ url_for('content.content_list') }}" class="btn btn-secondary">📁 View Media Library</a>
<!-- Maintenance Card (Admin Only) -->
{% if current_user.is_admin %}
<div class="card management-card" style="background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);">
<h2>🛠️ Maintenance</h2>
<p>Database integrity, leftover records and player authentication tokens</p>
<div class="card-actions">
<a href="{{ url_for('admin.maintenance') }}" class="btn btn-primary">
Open Maintenance
</a>
</div>
</div>
{% endif %}
</div>
<style>
@@ -228,13 +231,6 @@ body.dark-mode .stat-value {
margin-top: 20px;
}
.quick-actions {
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 15px;
}
.btn {
padding: 10px 20px;
text-decoration: none;