feat: upload progress bar — fieldset layout, accent colors, file name display, completion animation, 800ms redirect delay; decorelate formats from fichiers; server-side poll via token; bump PeerTube embed audio player

This commit is contained in:
Pontoporeia
2026-05-11 13:12:36 +02:00
parent cdec3e96a6
commit 927ee2fe2a
12 changed files with 420 additions and 212 deletions

View File

@@ -0,0 +1,43 @@
<?php
/**
* upload-progress.php
*
* Returns the current upload/processing progress for a given token.
* Called by the client-side upload-progress.js while the form XHR is in flight.
*
* GET /admin/actions/upload-progress.php?token=<token>
*
* Response: JSON
* { "stage": "upload"|"processing"|"done", "pct": 45, "file": "video.mp4" }
*
* Progress data is written by ThesisEditController / ThesisCreateController
* to a temp file during processing.
*/
require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../src/AdminAuth.php';
AdminAuth::requireLogin();
header('Content-Type: application/json');
$token = $_GET['token'] ?? '';
if (!preg_match('/^[a-f0-9]{16}$/', $token)) {
echo json_encode(['stage' => 'error', 'error' => 'Invalid token']);
exit;
}
$progressFile = sys_get_temp_dir() . '/xamxam_upload_' . $token . '.json';
if (!file_exists($progressFile)) {
// No progress file yet — still in upload phase (or token invalid)
echo json_encode(['stage' => 'upload', 'pct' => 0, 'file' => '']);
exit;
}
$data = json_decode(file_get_contents($progressFile), true);
if (!$data) {
echo json_encode(['stage' => 'upload', 'pct' => 0, 'file' => '']);
exit;
}
echo json_encode($data);