Add run percent and approved-runs modal

Introduce a percent field for runs and surface approved runs in the video modal. UI: add a numeric Percent input to the run submission form and show percent in submission lists and admin detail view (default 100%). Video modal: refactor openVideo to accept an item, add renderApprovedRunsForLevel to load and display approved runs for the same level with player, percent and video link, plus related modal HTML. Server: normalize and validate percent on run create/update (required), returning 400 when missing. Styles: add CSS for modal runs layout and responsive tweaks.
This commit is contained in:
miles committed 2026-04-01 00:11:13 -05:00
1 parent cdc65ec881
commit 52531abcc7
4 files changed
+59 -7

No files matched your search

+3 -2
View File
@@ -113,6 +113,7 @@ function normalizeRun(payload, existingRun) {
playerName: String(payload.playerName || existingRun?.playerName || '').trim(),
levelTitle: String(payload.levelTitle || existingRun?.levelTitle || '').trim(),
videoUrl: String(payload.videoUrl || existingRun?.videoUrl || '').trim(),
percent: String(payload.percent || existingRun?.percent || '100').trim(),
rawFootageUrl: String(payload.rawFootageUrl || existingRun?.rawFootageUrl || '').trim(),
notes: String(payload.notes || existingRun?.notes || '').trim(),
status: String(payload.status || existingRun?.status || 'pending').trim().toLowerCase(),
@@ -232,8 +233,8 @@ const server = http.createServer((req, res) => {
try {
const payload = JSON.parse(body || '{}');
const nextRun = normalizeRun(payload);
if (!nextRun.playerName || !nextRun.levelTitle || !nextRun.videoUrl) {
sendJson(res, 400, { error: 'playerName, levelTitle, and videoUrl are required' });
if (!nextRun.playerName || !nextRun.levelTitle || !nextRun.videoUrl || !nextRun.percent) {
sendJson(res, 400, { error: 'playerName, levelTitle, videoUrl, and percent are required' });
return;
}
const runs = readRuns();