341 lines
12 KiB
HTML
341 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Admin Settings</title>
|
|
<style>
|
|
/*
|
|
Admin settings / maintenance page.
|
|
Two-column layout for settings; table-styled MP3 metadata fields.
|
|
*/
|
|
:root{
|
|
--bg:#0b0f19;
|
|
--panel:#111827;
|
|
--text:#f3f4f6;
|
|
--muted:#9ca3af;
|
|
--accent:#60a5fa;
|
|
--accent-dark:#2563eb;
|
|
--danger:#dc2626;
|
|
--danger-dark:#991b1b;
|
|
--success:#10b981;
|
|
--warning:#f59e0b;
|
|
--border:#374151;
|
|
}
|
|
*{box-sizing:border-box;}
|
|
body{
|
|
margin:0;
|
|
font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
|
|
background:var(--bg);
|
|
color:var(--text);
|
|
line-height:1.5;
|
|
}
|
|
.container{max-width:1200px;margin:0 auto;padding:1.5rem;}
|
|
.topbar{
|
|
display:flex;
|
|
justify-content:space-between;
|
|
align-items:center;
|
|
margin-bottom:1.5rem;
|
|
}
|
|
h1{margin:0;font-size:1.5rem;}
|
|
.nav a{
|
|
color:var(--accent);
|
|
text-decoration:none;
|
|
margin-left:1rem;
|
|
}
|
|
.messages p{
|
|
padding:.75rem 1rem;
|
|
border-radius:.5rem;
|
|
margin:0 0 1rem;
|
|
}
|
|
.messages .success{background:#064e3b;color:#a7f3d0;}
|
|
.messages .error{background:#450a0a;color:#fca5a5;}
|
|
|
|
/* Two-column grid for settings */
|
|
.grid{
|
|
display:grid;
|
|
grid-template-columns:repeat(2, 1fr);
|
|
gap:1.5rem;
|
|
}
|
|
@media (max-width:900px){
|
|
.grid{grid-template-columns:1fr;}
|
|
}
|
|
|
|
.section{
|
|
background:var(--panel);
|
|
border:1px solid var(--border);
|
|
border-radius:.75rem;
|
|
padding:1.25rem;
|
|
}
|
|
.section h2{
|
|
margin-top:0;
|
|
font-size:1.15rem;
|
|
color:var(--accent);
|
|
}
|
|
.section p{
|
|
margin:.5rem 0;
|
|
color:var(--muted);
|
|
font-size:.95rem;
|
|
}
|
|
label{
|
|
display:block;
|
|
margin-top:.75rem;
|
|
font-size:.9rem;
|
|
color:var(--muted);
|
|
}
|
|
input[type="text"],input[type="number"],input[type="password"],textarea,select{
|
|
width:100%;
|
|
padding:.6rem;
|
|
border-radius:.4rem;
|
|
border:1px solid var(--border);
|
|
background:#1f2937;
|
|
color:var(--text);
|
|
font:inherit;
|
|
margin-top:.25rem;
|
|
}
|
|
textarea{resize:vertical;}
|
|
button{
|
|
margin-top:1rem;
|
|
padding:.65rem 1.2rem;
|
|
background:var(--accent-dark);
|
|
color:#fff;
|
|
border:none;
|
|
border-radius:.5rem;
|
|
cursor:pointer;
|
|
font-weight:600;
|
|
}
|
|
button:hover{background:var(--accent);}
|
|
|
|
/* Metadata and email config tables */
|
|
.meta-table{
|
|
width:100%;
|
|
border-collapse:collapse;
|
|
margin-top:.5rem;
|
|
}
|
|
.meta-table td{
|
|
padding:.5rem;
|
|
vertical-align:top;
|
|
border-bottom:1px solid var(--border);
|
|
}
|
|
.meta-table td:first-child{
|
|
width:30%;
|
|
font-size:.9rem;
|
|
color:var(--muted);
|
|
padding-left:0;
|
|
}
|
|
.meta-table td:last-child{padding-right:0;}
|
|
.meta-table tr:last-child td{border-bottom:none;}
|
|
.meta-table input,.meta-table textarea,.meta-table select{
|
|
margin-top:0;
|
|
}
|
|
|
|
.danger-zone{
|
|
grid-column:1 / -1;
|
|
background:#450a0a;
|
|
border:1px solid #7f1d1d;
|
|
border-radius:.75rem;
|
|
padding:1.25rem;
|
|
}
|
|
.danger-zone h2{margin-top:0;color:#fca5a5;}
|
|
.danger-zone button{
|
|
background:var(--danger);
|
|
}
|
|
.danger-zone button:hover{background:var(--danger-dark);}
|
|
|
|
.status-ok{color:var(--success);font-weight:600;}
|
|
.status-bad{color:var(--warning);font-weight:600;}
|
|
.copy-hint{font-size:.85rem;color:var(--muted);margin-top:.25rem;}
|
|
.path{word-break:break-all;font-family:monospace;font-size:.85rem;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="topbar">
|
|
<h1>Admin Settings</h1>
|
|
<div class="nav">
|
|
<a href="{{ url_for('admin_dashboard') }}">← Back to Dashboard</a>
|
|
<a href="{{ url_for('admin_logout') }}">Log out</a>
|
|
</div>
|
|
</div>
|
|
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
<div class="messages">
|
|
{% for category, message in messages %}
|
|
<p class="{{ category }}">{{ message }}</p>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<div class="grid">
|
|
|
|
<!-- Database health check -->
|
|
<div class="section">
|
|
<h2>Database Health</h2>
|
|
{% if health.ok %}
|
|
<p class="status-ok">✅ {{ health.message }}</p>
|
|
{% else %}
|
|
<p class="status-bad">❌ {{ health.message }}</p>
|
|
{% if health.missing_columns %}
|
|
<p>Missing columns: {{ health.missing_columns | join(', ') }}</p>
|
|
<form method="POST" action="{{ url_for('admin_settings') }}">
|
|
<input type="hidden" name="action" value="fix_schema">
|
|
<button type="submit">Fix Missing Columns</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Database statistics -->
|
|
<div class="section">
|
|
<h2>Database Statistics</h2>
|
|
<p><strong>Total requests:</strong> {{ total_records }}</p>
|
|
<p><strong>Database size:</strong> {{ db_size }}</p>
|
|
<p><strong>Uploaded MP3s:</strong> {{ upload_file_count }} files in {{ upload_dir_count }} request folders</p>
|
|
<p><strong>Uploads total size:</strong> {{ upload_size }}</p>
|
|
{% if status_counts %}
|
|
<p><strong>Status breakdown:</strong></p>
|
|
<ul>
|
|
{% for status, count in status_counts.items() %}
|
|
<li>{{ status }}: {{ count }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% endif %}
|
|
<p><strong>Database path:</strong><br><span class="path">{{ db_path }}</span></p>
|
|
<p><strong>Uploads path:</strong><br><span class="path">{{ upload_path }}</span></p>
|
|
</div>
|
|
|
|
<!-- Revision limit -->
|
|
<div class="section">
|
|
<h2>Revision Limit</h2>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="save_max_revisions">
|
|
<label for="max_revisions">Maximum customer revisions allowed</label>
|
|
<input type="number" id="max_revisions" name="max_revisions" min="0" value="{{ current_max_revisions }}">
|
|
<p class="copy-hint">Set to 0 to disable customer-submitted revisions. Operators can still upload new versions manually.</p>
|
|
<button type="submit">Save Revision Limit</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Auto refresh -->
|
|
<div class="section">
|
|
<h2>Dashboard Auto-Refresh</h2>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="save_refresh">
|
|
<label for="refresh_seconds">Refresh interval</label>
|
|
<select id="refresh_seconds" name="refresh_seconds">
|
|
<option value="0" {% if current_refresh_seconds == 0 %}selected{% endif %}>Off</option>
|
|
<option value="10" {% if current_refresh_seconds == 10 %}selected{% endif %}>10 seconds</option>
|
|
<option value="20" {% if current_refresh_seconds == 20 %}selected{% endif %}>20 seconds</option>
|
|
<option value="30" {% if current_refresh_seconds == 30 %}selected{% endif %}>30 seconds</option>
|
|
</select>
|
|
<button type="submit">Save Refresh Interval</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Email / SMTP configuration -->
|
|
<div class="section">
|
|
<h2>Email (SMTP) Settings</h2>
|
|
<p class="copy-hint">These settings are used to send confirmation, preview, and delivery emails to customers. The password is stored encrypted using the Flask secret key.</p>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="save_email_config">
|
|
<table class="meta-table">
|
|
<tr>
|
|
<td>SMTP Host</td>
|
|
<td><input type="text" id="smtp_host" name="smtp_host" value="{{ email_form.smtp_host }}" placeholder="e.g. mailroot8.namespro.ca"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>SMTP Port</td>
|
|
<td><input type="text" id="smtp_port" name="smtp_port" value="{{ email_form.smtp_port }}" placeholder="e.g. 465"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>SMTP Username</td>
|
|
<td><input type="text" id="smtp_user" name="smtp_user" value="{{ email_form.smtp_user }}" placeholder="e.g. ai@hallsworth.ca"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>From Address</td>
|
|
<td><input type="text" id="smtp_from" name="smtp_from" value="{{ email_form.smtp_from }}" placeholder="e.g. ai@hallsworth.ca"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>SMTP Password</td>
|
|
<td>
|
|
<input type="password" id="smtp_pass" name="smtp_pass" placeholder="{% if email_form.smtp_pass_set %}Stored encrypted — type to replace{% else %}Enter password{% endif %}">
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
<button type="submit">Save Email Settings</button>
|
|
</form>
|
|
|
|
<hr style="border:none;border-top:1px solid var(--border);margin:1.5rem 0;">
|
|
|
|
<h3>Send Test Email</h3>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="send_test_email">
|
|
<label for="test_email_address">Test recipient address</label>
|
|
<input type="email" id="test_email_address" name="test_email_address" placeholder="you@example.com" required>
|
|
<button type="submit">Send Test Email</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- MP3 metadata defaults -->
|
|
<div class="section">
|
|
<h2>MP3 Metadata Tags</h2>
|
|
<p class="copy-hint">These values are written into every uploaded MP3 file. The song title from the prompt is written to the Title tag automatically. Blank fields are skipped.</p>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="save_metadata">
|
|
<table class="meta-table">
|
|
<tr>
|
|
<td>Artist</td>
|
|
<td><input type="text" id="artist" name="artist" value="{{ metadata.get('artist', '') }}" placeholder="e.g. Trollgorithm"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Album</td>
|
|
<td><input type="text" id="album" name="album" value="{{ metadata.get('album', '') }}" placeholder="e.g. Theme Song Booth 2026"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Year</td>
|
|
<td><input type="text" id="year" name="year" value="{{ metadata.get('year', '') }}" placeholder="e.g. 2026"></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Comment</td>
|
|
<td><textarea id="comment" name="comment" rows="3" placeholder="e.g. Custom theme song generated at the booth">{{ metadata.get('comment', '') }}</textarea></td>
|
|
</tr>
|
|
</table>
|
|
<button type="submit">Save Metadata Defaults</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Database backup / restore -->
|
|
<div class="section">
|
|
<h2>Database Backup / Restore</h2>
|
|
<p class="copy-hint">Download a copy of the SQLite database before the event. Upload a previous backup to restore it; the current database will be renamed as a timestamped backup.</p>
|
|
|
|
<form method="POST" style="margin-bottom:1rem">
|
|
<input type="hidden" name="action" value="download_db">
|
|
<button type="submit">Download Database Backup</button>
|
|
</form>
|
|
|
|
<form method="POST" enctype="multipart/form-data">
|
|
<input type="hidden" name="action" value="restore_db">
|
|
<label for="db_backup">Restore from backup (.db / .sqlite)</label>
|
|
<input type="file" id="db_backup" name="db_backup" accept=".db,.sqlite,.sqlite3">
|
|
<button type="submit" onclick="return confirm('This will replace the current database. The old one will be kept as a timestamped backup. Continue?')">Restore Database</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- System reset spans both columns -->
|
|
<div class="danger-zone">
|
|
<h2>⚠️ Reset System</h2>
|
|
<p>Use this only at the start of a new event. It will delete every request and every uploaded MP3 file. This cannot be undone.</p>
|
|
<form method="POST" action="{{ url_for('admin_settings') }}" onsubmit="return confirm('ARE YOU SURE? This will delete ALL requests and ALL uploaded files. This cannot be undone.')">
|
|
<input type="hidden" name="action" value="reset_system">
|
|
<button type="submit">Reset System</button>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|