add video backend server, fix styling and more #54

Merged
quoije merged 131 commits from 2026-video.backend into prod 2025-12-22 05:42:04 -05:00
2 changed files with 48 additions and 7 deletions
Showing only changes of commit 762f75ad62 - Show all commits
+28 -3
View File
@@ -3,6 +3,24 @@ window.onload = async function () {
let winnersCache = null; let winnersCache = null;
let completionsCache = null; let completionsCache = null;
function setTableBodyLoading(tbodyId, colspan) {
const tbody = document.getElementById(tbodyId);
if (!tbody) return;
const span = Number.isFinite(Number(colspan)) ? Number(colspan) : 1;
tbody.innerHTML = `
<tr>
<td colspan="${span}" class="text-center py-4" aria-live="polite" aria-busy="true">
<div class="d-inline-flex align-items-center gap-2">
<div class="spinner-border text-secondary" role="status" aria-label="Chargement">
<span class="visually-hidden">Chargement...</span>
</div>
<span class="text-muted">Chargement…</span>
</div>
</td>
</tr>
`;
}
async function fetchActiveYear() { async function fetchActiveYear() {
try { try {
const res = await fetch('/api/settings/year', { method: 'GET' }); const res = await fetch('/api/settings/year', { method: 'GET' });
@@ -229,6 +247,16 @@ window.onload = async function () {
} }
try { try {
// Show loading states immediately (avoid "blank" panels)
const table = document.querySelector('.user-table');
const spinner = document.getElementById('loading-spinner');
const statsError = document.getElementById('stats-error');
if (spinner) spinner.classList.remove('d-none');
if (table) table.classList.add('d-none');
if (statsError) statsError.classList.add('d-none');
setTableBodyLoading('winners-table-body', 2);
setTableBodyLoading('completers-table-body', 4);
const activeYear = await fetchActiveYear(); const activeYear = await fetchActiveYear();
if (activeYear) { if (activeYear) {
document.title = `Pool Oscars ${activeYear} - Statistiques des utilisateurs`; document.title = `Pool Oscars ${activeYear} - Statistiques des utilisateurs`;
@@ -257,9 +285,6 @@ window.onload = async function () {
const stats = await statsRes.json(); const stats = await statsRes.json();
const userTableBody = document.getElementById('user-table-body'); const userTableBody = document.getElementById('user-table-body');
const table = document.querySelector('.user-table');
const spinner = document.getElementById('loading-spinner');
const statsError = document.getElementById('stats-error');
// Ensure watchedRatio is treated as a number and sort in descending order // Ensure watchedRatio is treated as a number and sort in descending order
stats.sort((a, b) => parseFloat(b.watchedRatio) - parseFloat(a.watchedRatio)); stats.sort((a, b) => parseFloat(b.watchedRatio) - parseFloat(a.watchedRatio));
+20 -4
View File
@@ -91,8 +91,10 @@
<div id="stats-error" class="alert alert-danger d-none" role="alert"></div> <div id="stats-error" class="alert alert-danger d-none" role="alert"></div>
<!-- Spinner shown while loading --> <!-- Spinner shown while loading -->
<div id="loading-spinner" class="spinner-border text-primary" role="status"> <div id="loading-spinner" class="d-flex justify-content-center align-items-center my-5" aria-live="polite" aria-busy="true">
<span class="visually-hidden">Loading...</span> <div class="spinner-border text-secondary" role="status" aria-label="Chargement">
<span class="visually-hidden">Chargement...</span>
</div>
</div> </div>
<!-- Table for users and movies watched --> <!-- Table for users and movies watched -->
@@ -123,7 +125,14 @@
</thead> </thead>
<tbody id="winners-table-body"> <tbody id="winners-table-body">
<tr> <tr>
<td colspan="2" class="text-muted">Chargement…</td> <td colspan="2" class="text-center py-4" aria-live="polite" aria-busy="true">
<div class="d-inline-flex align-items-center gap-2">
<div class="spinner-border text-secondary" role="status" aria-label="Chargement">
<span class="visually-hidden">Chargement...</span>
</div>
<span class="text-muted">Chargement…</span>
</div>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -146,7 +155,14 @@
</thead> </thead>
<tbody id="completers-table-body"> <tbody id="completers-table-body">
<tr> <tr>
<td colspan="4" class="text-muted">Chargement…</td> <td colspan="4" class="text-center py-4" aria-live="polite" aria-busy="true">
<div class="d-inline-flex align-items-center gap-2">
<div class="spinner-border text-secondary" role="status" aria-label="Chargement">
<span class="visually-hidden">Chargement...</span>
</div>
<span class="text-muted">Chargement…</span>
</div>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>