feat(ux): run sessions from Race Day with quick actions

Race Day gets Start practice, New track layout and Create race, a session
picker, only the buttons that apply, and New practice day (replaces Reset
data on Timing; laps stay in the training stats). Timing is for following
and links to Race Day. The Dashboard shows the three common tasks first.
Guide, READMEs, screenshot and the "Run a session" video follow the flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-17 18:32:01 +02:00
1 parent 3a6789f42f
commit c4df90706a
23 files changed
+344 -111

No files matched your search

+106 -11
View File
@@ -346,6 +346,53 @@ function setRacePrologueRemaining(remainingMs) {
setRacePrologue(setPrologueRemaining(racePrologue, remainingMs));
renderView();
}
// --- Race Day as the place where things are run --------------------------------------
// "New practice day": clears the session's laps on Timing for a new day; every lap so far
// is first put in the training stats, where resultsResetAt keeps it (see syncTrainingLedger).
function resetSessionData(session) {
if (!session) return false;
syncTrainingLedger();
session.resultsResetAt = Date.now();
delete state.resultsBySession[session.id];
session.followUpStartedAt = null;
lastFinishAnnouncementSessionId = null;
delete lastOverlayLeaderKeyBySession[session.id];
delete lastOverlayTop3BySession[session.id];
overlayEvents = [];
saveState();
renderView();
return true;
}
// The Open Practice "Start practice" works on: one already running, else a paused one,
// else the latest not-finished one (a club often runs one all season); null = make a new one.
function findOpenPracticeToContinue() {
const practices = state.sessions.filter((session) => session.type === "open_practice");
const latest = (list) => list.sort((a, b) => Number(b.startedAt || 0) - Number(a.startedAt || 0))[0] || null;
return latest(practices.filter((session) => session.status === "running"))
|| latest(practices.filter((session) => session.status === "paused"))
|| practices.filter((session) => session.status === "ready").at(-1)
|| null;
}
// One click from Race Day: continue the Open Practice, or create and start one for today.
async function startPracticeNow() {
let session = findOpenPracticeToContinue();
if (!session) {
const bundle = buildOpenPracticeBundle({ name: t("events.quick_open_practice_default"), date: new Date().toISOString().slice(0, 10) });
state.events.push(bundle.event);
state.sessions.push(bundle.session);
session = bundle.session;
}
selectOperationalSession(session.id, { render: false });
if (session.status === "paused") return resumeOperationalSession(session);
if (session.status === "running") { renderView(); return true; }
const result = await startOperationalSession(session);
if (!result.ok && result.message) alert(result.message);
renderView();
return result.ok;
}
function goRacePrologue() {
const session = getPrologueSession();
setRacePrologue(null);
@@ -405,7 +452,7 @@ const processDecoderMessage = (msg, decoderRole = "main") => processDecoderMessa
getTrackRecordMs,
onTransponderSeen,
}, decoderRole);
const renderDashboard = () => renderDashboardView({ addTrackLayout, state, dom, t, backend, getActiveSession, getStatusLabel, getSessionTypeLabel, getEventName, getModeLabel, getBackendUrl, formatLap, renderSessionsTable, setCurrentView: (view) => { currentView = view; }, updateViewUrl, renderNav, renderView, connectDecoder, disconnectDecoder, openOverlayWindow, ensureAudioContext, playPassingBeep, playFinishSiren, escapeHtml });
const renderDashboard = () => renderDashboardView({ addTrackLayout, startPracticeNow, state, dom, t, backend, getActiveSession, getStatusLabel, getSessionTypeLabel, getEventName, getModeLabel, getBackendUrl, formatLap, renderSessionsTable, setCurrentView: (view) => { currentView = view; }, updateViewUrl, renderNav, renderView, connectDecoder, disconnectDecoder, openOverlayWindow, ensureAudioContext, playPassingBeep, playFinishSiren, escapeHtml });
const renderClasses = () => renderClassesView({ state, dom, t, selectedClassEditId: () => selectedClassEditId, setSelectedClassEditId: (value) => { selectedClassEditId = value; }, uid, saveState, renderView, renderTable, escapeHtml, setFormError, bindModalShell });
// Driver page "Test pronunciation": the passing sound, then two real announcements with the
// spoken name, through race audio (so the chosen voice / Piper is what you hear).
@@ -424,6 +471,7 @@ const renderRaceDay = () => renderRaceDayView({
getRaceDayWarmupCheck, setDriverTransponder, getDefaultPrologueSec,
startRacePrologue, holdRacePrologue, resumeRacePrologue, setRacePrologueRemaining, cancelRacePrologue, goRacePrologue,
isStartPending: (session) => Boolean(session && pendingStartSessionId === session.id),
resetSessionData, startPracticeNow, findOpenPracticeToContinue,
getLiveSession,
renderSuspectLapsPanel: (session) => renderSuspectLapsPanelView(session, { t, escapeHtml, formatLap, ensureSessionResult }),
setCompetitorLapStatus,
@@ -483,7 +531,7 @@ const refreshTimingDynamics = () => {
node.textContent = clock;
});
};
const renderTiming = () => renderTimingView({ state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock, formatRaceClock, renderTable, uid, getActiveSession, ensureSessionResult, buildLeaderboard, getSessionTiming, getVisiblePassings, getEventName, getSessionTypeLabel, getStatusLabel, normalizeStartMode, getStartModeLabel, renderPositionGrid, renderSessionChannelAnalysis, connectDecoder, disconnectDecoder, applyCompetitorCorrection, invalidateCompetitorLastLap, restoreCompetitorLastInvalidLap, startOperationalSession, finishOperationalSession, cancelRaceStart, triggerRaceAudio, getStartLightState: () => raceAudioEngine.getStartLightState(), saveState, updateHeaderState, renderView, normalizeDriver, normalizeCar, processDecoderMessage, getSelectedLeaderboardKey: () => selectedLeaderboardKey, setSelectedLeaderboardKey: (value) => { selectedLeaderboardKey = value; }, getQuickAddDraft: () => quickAddDraft, setQuickAddDraft: (value) => { quickAddDraft = value; }, getPassingValidationLabel, isCountedPassing, getCompetitorPassings, getManualCorrectionSummary, formatTeamActiveMemberLabel, lastFinishAnnouncementSessionId: () => lastFinishAnnouncementSessionId, setLastFinishAnnouncementSessionId: (value) => { lastFinishAnnouncementSessionId = value; }, lastOverlayLeaderKeyBySession, lastOverlayTop3BySession, overlayEvents: () => overlayEvents, setOverlayEvents: (value) => { overlayEvents = value; }, sessionReplay, syncTrainingLedger, setCompetitorLapStatus, getLiveSession, selectLiveSession: (id) => selectOperationalSession(id), openJudging: (rowKey) => { selectedJudgeKey = rowKey; selectedLeaderboardKey = null; navigateToView("judging"); } });
const renderTiming = () => renderTimingView({ state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock, formatRaceClock, renderTable, uid, getActiveSession, ensureSessionResult, buildLeaderboard, getSessionTiming, getVisiblePassings, getEventName, getSessionTypeLabel, getStatusLabel, normalizeStartMode, getStartModeLabel, renderPositionGrid, renderSessionChannelAnalysis, connectDecoder, disconnectDecoder, applyCompetitorCorrection, invalidateCompetitorLastLap, restoreCompetitorLastInvalidLap, startOperationalSession, finishOperationalSession, cancelRaceStart, triggerRaceAudio, getStartLightState: () => raceAudioEngine.getStartLightState(), saveState, updateHeaderState, renderView, normalizeDriver, normalizeCar, processDecoderMessage, getSelectedLeaderboardKey: () => selectedLeaderboardKey, setSelectedLeaderboardKey: (value) => { selectedLeaderboardKey = value; }, getQuickAddDraft: () => quickAddDraft, setQuickAddDraft: (value) => { quickAddDraft = value; }, getPassingValidationLabel, isCountedPassing, getCompetitorPassings, getManualCorrectionSummary, formatTeamActiveMemberLabel, lastFinishAnnouncementSessionId: () => lastFinishAnnouncementSessionId, setLastFinishAnnouncementSessionId: (value) => { lastFinishAnnouncementSessionId = value; }, lastOverlayLeaderKeyBySession, lastOverlayTop3BySession, overlayEvents: () => overlayEvents, setOverlayEvents: (value) => { overlayEvents = value; }, sessionReplay, syncTrainingLedger, setCompetitorLapStatus, getLiveSession, selectLiveSession: (id) => selectOperationalSession(id), openRaceDay: () => navigateToView("race_day"), openJudging: (rowKey) => { selectedJudgeKey = rowKey; selectedLeaderboardKey = null; navigateToView("judging"); } });
const renderJudging = () => renderJudgingView({ state, dom, t, escapeHtml, formatLap, renderTable, getActiveSession, ensureSessionResult, buildLeaderboard, getSessionTypeLabel, getJudgeFilteredRows, getJudgeFilteredLog, getCompetitorPassings, isCountedPassing, getPassingValidationLabel, undoJudgingAdjustment, applyCompetitorCorrection, invalidateCompetitorLastLap, restoreCompetitorLastInvalidLap, renderView, getSelectedJudgeKey: () => selectedJudgeKey, setSelectedJudgeKey: (value) => { selectedJudgeKey = value; }, getJudgingCompetitorFilter: () => judgingCompetitorFilter, setJudgingCompetitorFilter: (value) => { judgingCompetitorFilter = value; }, getJudgingLogFilter: () => judgingLogFilter, setJudgingLogFilter: (value) => { judgingLogFilter = value; } , setCompetitorLapStatus });
const normalizeTrainingState = (training) => normalizeTrainingStateLogic(training, { uid });
const syncTrainingLedger = () => {
@@ -799,6 +847,29 @@ const TRANSLATIONS = {
"series.step3": "3 · Deltävlingar ({count})",
"series.step4": "4 · Ställning",
"series.classes_all": "Alla",
"dashboard.quick_title": "Vanliga uppgifter",
"dashboard.quick_practice": "Starta träning",
"dashboard.quick_practice_hint": "Fortsätter pågående Open Practice eller startar en ny - direkt till Race Day.",
"dashboard.quick_race": "Skapa race",
"dashboard.quick_race_hint": "Kval och finaler för en tävling.",
"dashboard.quick_series": "Skapa serie",
"dashboard.quick_series_hint": "Flera deltävlingar med poäng och ställning.",
"timing.run_on_race_day": "Starta, pausa, avsluta och ny träningsdag görs på Race Day.",
"timing.open_race_day": "Gå till Race Day",
"race_day.quick_title": "Snabbval",
"race_day.start_practice": "Starta träning",
"race_day.pause_practice": "Pausa",
"race_day.resume_practice": "Fortsätt",
"race_day.finish_practice": "Avsluta träning",
"race_day.quick_practice_new": "Starta träning",
"race_day.quick_practice_continue": "Fortsätt träning: {name}",
"race_day.quick_practice_show": "Pågående träning: {name}",
"race_day.quick_layout": "Ny banlayout",
"race_day.quick_race": "Skapa race",
"race_day.pick_session": "Session",
"race_day.new_practice_day": "Ny träningsdag",
"race_day.new_practice_day_hint": "Nollställer dagens varv i tidtagningen. Alla varv finns kvar i träningsstatistiken.",
"race_day.new_practice_day_confirm": "Starta en ny träningsdag i \"{name}\"?\n\nDagens varv nollställs i tidtagningen (topplistan börjar om). Alla varv finns kvar i träningsstatistiken.",
"timing.live_elsewhere": "Varv registreras just nu på \"{name}\", som pågår - inte på den valda sessionen.",
"timing.show_live": "Visa den",
"overlay.obs_show_position_change": "Placering sedan start (▲/▼) i race",
@@ -1287,7 +1358,7 @@ const TRANSLATIONS = {
"dashboard.behind": "Efter schema",
"dashboard.live_note": "Snabb driftpanel för anslutning, overlay och ljud. Djupare konfig ligger kvar under Inställningar.",
"dashboard.get_started": "Kom igång",
"dashboard.get_started_hint": "Följ arbetsordningen första gången. Vid vanlig träning kan du gå direkt till Open Practice.",
"dashboard.get_started_hint": "Följ arbetsordningen första gången. För en vanlig träningskväll räcker knappen Starta träning ovan.",
"dashboard.step_system": "1. Anslut systemet",
"dashboard.step_system_hint": "Konfigurera backend, decoder och AMMC i Inställningar.",
"dashboard.step_register": "2. Lägg in register",
@@ -1295,7 +1366,7 @@ const TRANSLATIONS = {
"dashboard.step_create": "3. Skapa körning",
"dashboard.step_create_hint": "Starta enkel Open Practice eller bygg klubbrace, endurance och sponsor-event.",
"dashboard.step_run": "4. Kör och visa",
"dashboard.step_run_hint": "Starta sessionen i Tidtagning och öppna Overlay på extern skärm.",
"dashboard.step_run_hint": "Starta, pausa och avsluta på Race Day. Följ tiderna i Tidtagning och öppna Overlay på en extern skärm.",
"dashboard.open_settings": "Öppna Inställningar",
"dashboard.open_register": "Öppna Förare",
"dashboard.open_race_setup": "Open Practice / Race Setup",
@@ -2305,7 +2376,7 @@ const TRANSLATIONS = {
"guide.sponsor_3": "3. Skapa event med läge Sponsor Event.",
"guide.sponsor_4": "4. Klicka Hantera på eventet och skapa rundor (kval/heat/final).",
"guide.sponsor_5": "5. Tilldela 4 förare till 4 bilar i Heat 1, byt förare till Heat 2/3 osv.",
"guide.sponsor_6": "6. I Tidtagning: välj session, Sätt aktiv, Starta, Stoppa.",
"guide.sponsor_6": "6. På Race Day: välj session och tryck Start, Pausa och Avsluta. Tidtagning visar tiderna.",
"guide.race_title": "Skapa vanligt race (förare har egna transpondrar)",
"guide.race_1": "1. Lägg in förare med personlig transponder. Brandfältet kan användas för team, sponsor eller bilmärke.",
"guide.race_2": "2. Skapa event med läge Race.",
@@ -2344,7 +2415,7 @@ const TRANSLATIONS = {
"guide.open_practice_2": "Om transpondern inte matchar en registrerad förare visas transpondernumret som namn.",
"guide.open_practice_3": "Open Practice påverkar inte seedning, kval eller finaler.",
"guide.open_practice_4": "Gå till Race Setup och använd Snabbstart Open Practice. Du behöver bara ange ett namn; klass, deltagare, preset och racetid behövs inte.",
"guide.open_practice_5": "Efter skapandet öppnas Tidtagning direkt. Klicka Starta och låt sessionen gå tills du själv stoppar den.",
"guide.open_practice_5": "Enklast: tryck Starta träning på Översikten eller Race Day - då fortsätter en pågående Open Practice eller så skapas och startas en ny. Ny träningsdag på Race Day nollställer dagens varv utan att statistiken försvinner, och Ny banlayout finns bland snabbvalen.",
"guide.team_title": "Lagrace / Endurance",
"guide.team_1": "Gå till Race Setup och skapa ett race i rätt klass.",
"guide.team_2": "Öppna Hantera och gå till sektionen Lag.",
@@ -2607,6 +2678,29 @@ const TRANSLATIONS = {
"series.step3": "3 · Rounds ({count})",
"series.step4": "4 · Standings",
"series.classes_all": "All",
"dashboard.quick_title": "Common tasks",
"dashboard.quick_practice": "Start practice",
"dashboard.quick_practice_hint": "Continues the running Open Practice or starts a new one - straight to Race Day.",
"dashboard.quick_race": "Create race",
"dashboard.quick_race_hint": "Qualifying and finals for one event.",
"dashboard.quick_series": "Create series",
"dashboard.quick_series_hint": "Several rounds with points and standings.",
"timing.run_on_race_day": "Start, pause, finish and new practice day are done on Race Day.",
"timing.open_race_day": "Go to Race Day",
"race_day.quick_title": "Quick actions",
"race_day.start_practice": "Start practice",
"race_day.pause_practice": "Pause",
"race_day.resume_practice": "Resume",
"race_day.finish_practice": "Finish practice",
"race_day.quick_practice_new": "Start practice",
"race_day.quick_practice_continue": "Continue practice: {name}",
"race_day.quick_practice_show": "Practice running: {name}",
"race_day.quick_layout": "New track layout",
"race_day.quick_race": "Create race",
"race_day.pick_session": "Session",
"race_day.new_practice_day": "New practice day",
"race_day.new_practice_day_hint": "Clears today's laps in timing. Every lap stays in the training statistics.",
"race_day.new_practice_day_confirm": "Start a new practice day in \"{name}\"?\n\nToday's laps are cleared in timing (the leaderboard starts over). Every lap stays in the training statistics.",
"timing.live_elsewhere": "Laps are being recorded on \"{name}\", which is running - not on the selected session.",
"timing.show_live": "Show it",
"overlay.obs_show_position_change": "Places since the start (▲/▼) in races",
@@ -3095,7 +3189,7 @@ const TRANSLATIONS = {
"dashboard.behind": "Behind schedule",
"dashboard.live_note": "Quick operations panel for connection, overlay and audio. Deeper configuration remains under Settings.",
"dashboard.get_started": "Getting started",
"dashboard.get_started_hint": "Follow this order for initial setup. For normal practice, go directly to Open Practice.",
"dashboard.get_started_hint": "Follow this order for initial setup. For a normal practice evening, the Start practice button above is all you need.",
"dashboard.step_system": "1. Connect the system",
"dashboard.step_system_hint": "Configure backend, decoder and AMMC in Settings.",
"dashboard.step_register": "2. Build the directory",
@@ -3103,7 +3197,7 @@ const TRANSLATIONS = {
"dashboard.step_create": "3. Create a run",
"dashboard.step_create_hint": "Start a simple Open Practice or build club races, endurance and sponsor events.",
"dashboard.step_run": "4. Run and display",
"dashboard.step_run_hint": "Start the session in Timing and open Overlay on an external display.",
"dashboard.step_run_hint": "Start, pause and finish on Race Day. Follow the times in Timing and open Overlay on an external display.",
"dashboard.open_settings": "Open Settings",
"dashboard.open_register": "Open Drivers",
"dashboard.open_race_setup": "Open Practice / Race Setup",
@@ -4113,7 +4207,7 @@ const TRANSLATIONS = {
"guide.sponsor_3": "3. Create event in Track Event mode.",
"guide.sponsor_4": "4. Click Manage and create rounds (qualification/heat/final).",
"guide.sponsor_5": "5. Assign 4 drivers to 4 cars in Heat 1, rotate drivers for Heat 2/3, then finals.",
"guide.sponsor_6": "6. In Timing: select session, Set Active, Start, Stop.",
"guide.sponsor_6": "6. On Race Day: pick the session and press Start, Pause and Finish. Timing shows the times.",
"guide.race_title": "Create regular race (driver transponders)",
"guide.race_1": "1. Add drivers with personal transponder IDs. The brand field can be used for team, sponsor or car brand.",
"guide.race_2": "2. Create event in Race mode.",
@@ -4152,7 +4246,7 @@ const TRANSLATIONS = {
"guide.open_practice_2": "If the transponder does not match a registered driver, the transponder number is shown as the name.",
"guide.open_practice_3": "Open Practice does not affect seeding, qualifying or finals.",
"guide.open_practice_4": "Go to Race Setup and use Quick Open Practice. Only a name is required; class, participants, preset and race duration are not needed.",
"guide.open_practice_5": "Timing opens directly after creation. Click Start and let the session run until you stop it yourself.",
"guide.open_practice_5": "Easiest: press Start practice on the Dashboard or Race Day - it continues a running Open Practice or creates and starts a new one. New practice day on Race Day clears the day's laps without losing statistics, and New track layout is among the quick actions.",
"guide.team_title": "Team Race / Endurance",
"guide.team_1": "Go to Race Setup and create a race in the correct class.",
"guide.team_2": "Open Manage and go to the Teams section.",
@@ -6013,10 +6107,11 @@ function renderEventWorkspace(mode) {
isValidIsoDate,
saveState,
purgeSessionPassings,
// Opens the session where it is run: Race Day (start/pause/finish moved there from Timing).
openTimingSession: (sessionId) => {
state.activeSessionId = sessionId;
saveState();
currentView = "timing";
currentView = "race_day";
updateViewUrl(currentView);
renderNav();
updateHeaderState();
+13
View File
@@ -66,6 +66,7 @@ export function renderDashboardView(deps) {
playFinishSiren,
escapeHtml,
addTrackLayout,
startPracticeNow = async () => false,
} = deps;
const active = getActiveSession();
@@ -78,6 +79,11 @@ export function renderDashboardView(deps) {
dom.view.innerHTML = `
${renderTrackLayoutBar({ state, t, escapeHtml, showNewButton: !active || isPracticeSessionType(active.type) })}
<section class="dashboard-quick mt-16" aria-label="${escapeHtml(t("dashboard.quick_title"))}">
<button class="btn btn-primary dashboard-quick-btn" type="button" id="dashboardQuickPractice"><strong>▶ ${t("dashboard.quick_practice")}</strong><small>${t("dashboard.quick_practice_hint")}</small></button>
<button class="btn dashboard-quick-btn" type="button" id="dashboardQuickRace"><strong>🏁 ${t("dashboard.quick_race")}</strong><small>${t("dashboard.quick_race_hint")}</small></button>
<button class="btn dashboard-quick-btn" type="button" id="dashboardQuickSeries"><strong>🏆 ${t("dashboard.quick_series")}</strong><small>${t("dashboard.quick_series_hint")}</small></button>
</section>
<section class="panel dashboard-workflow mt-16">
<div class="panel-header">
<div>
@@ -210,6 +216,13 @@ export function renderDashboardView(deps) {
document.getElementById("workflowDrivers")?.addEventListener("click", () => navigateTo("drivers"));
document.getElementById("workflowRaceSetup")?.addEventListener("click", () => navigateTo("race_setup"));
document.getElementById("workflowRaceDay")?.addEventListener("click", () => navigateTo("race_day"));
// The three things a club evening usually starts with.
document.getElementById("dashboardQuickPractice")?.addEventListener("click", async () => {
navigateTo("race_day");
await startPracticeNow();
});
document.getElementById("dashboardQuickRace")?.addEventListener("click", () => navigateTo("race_setup"));
document.getElementById("dashboardQuickSeries")?.addEventListener("click", () => navigateTo("series"));
document.getElementById("workflowTiming")?.addEventListener("click", () => navigateTo("timing"));
document.getElementById("workflowOverlay")?.addEventListener("click", () => navigateTo("overlay"));
+43 -7
View File
@@ -175,6 +175,7 @@ export function renderRaceDayView(deps) {
getRaceDayWarmupCheck, setDriverTransponder, getDefaultPrologueSec,
startRacePrologue, holdRacePrologue, resumeRacePrologue, setRacePrologueRemaining, cancelRacePrologue, goRacePrologue,
isStartPending, renderSuspectLapsPanel = () => "", setCompetitorLapStatus = () => false, getLiveSession = () => null,
resetSessionData = () => false, startPracticeNow = async () => false, findOpenPracticeToContinue = () => null,
} = deps;
const queue = buildRaceDayQueue(state);
const session = queue.current;
@@ -200,14 +201,32 @@ export function renderRaceDayView(deps) {
// Another session is running while a different one is selected: say where laps go.
const liveSession = getLiveSession();
const liveElsewhere = liveSession && session && liveSession.id !== session.id && ["running", "paused"].includes(liveSession.status) ? liveSession : null;
// Quick actions for the common club evening, so nobody has to know where things live.
const practice = findOpenPracticeToContinue();
const practiceLabel = !practice ? t("race_day.quick_practice_new")
: practice.status === "running" ? t("race_day.quick_practice_show", { name: practice.name })
: t("race_day.quick_practice_continue", { name: practice.name });
const sessionChoices = state.sessions.slice().sort((a, b) => {
const rank = (item) => (["running", "paused"].includes(item.status) ? 0 : item.status === "ready" ? 1 : 2);
return rank(a) - rank(b) || Number(b.startedAt || 0) - Number(a.startedAt || 0);
});
const isPracticeSession = Boolean(session && (isPracticeSessionType(session.type) || session.type === "practice"));
const isLiveSession = ["running", "paused"].includes(session?.status);
// Layouts are a practice thing: never offered while a race session is in focus.
const layoutAllowed = !session || isPracticeSessionType(session.type);
dom.view.innerHTML = `
<section class="race-day-quick" aria-label="${escapeHtml(t("race_day.quick_title"))}">
<button class="btn btn-primary race-day-quick-btn" type="button" id="raceDayQuickPractice">▶ ${escapeHtml(practiceLabel)}</button>
${layoutAllowed ? `<button class="btn race-day-quick-btn" type="button" data-track-layout-new>🧱 ${escapeHtml(t("race_day.quick_layout"))}</button>` : ""}
<button class="btn race-day-quick-btn" type="button" id="raceDayQuickRace">🏁 ${escapeHtml(t("race_day.quick_race"))}</button>
</section>
${liveElsewhere ? `<div class="live-elsewhere-banner" id="liveElsewhereBanner"><span>⏱ ${escapeHtml(t("timing.live_elsewhere", { name: liveElsewhere.name }))}</span><button class="btn btn-mini" type="button" data-show-live="${escapeHtml(liveElsewhere.id)}">${escapeHtml(t("timing.show_live"))}</button></div>` : ""}
<section class="race-day-hero ${preflight.ready ? "is-ready" : "has-blockers"}">
<div>
<span class="race-day-kicker">${t("race_day.current")}</span>
<h2>${session ? escapeHtml(session.name) : t("race_day.no_session")}</h2>
<p>${session ? `${escapeHtml(getEventName(session.eventId))} · ${escapeHtml(getSessionTypeLabel(session.type))} · ${escapeHtml(getStartModeLabel(session.startMode))}` : t("race_day.no_session_hint")}</p>
${renderTrackLayoutBar({ state, t, escapeHtml, showNewButton: !session || isPracticeSessionType(session.type) })}
${renderTrackLayoutBar({ state, t, escapeHtml, showNewButton: false })}
</div>
${prologue
? `<div class="race-day-clock is-prologue"><strong data-prologue-clock>${formatMmSs(warmupForChecks.remainingMs)}</strong><span>${t("prologue.to_start")}</span></div>`
@@ -222,20 +241,28 @@ export function renderRaceDayView(deps) {
<span class="pill ${preflight.ready ? "pill-green" : "pill-red"}">${t(preflight.ready ? "race_day.ready" : "race_day.not_ready")}</span>
</div>
<div class="panel-body">
<label class="race-day-session-picker"><span>${t("race_day.pick_session")}</span>
<select id="raceDaySessionSelect">
${session ? "" : `<option value="">${t("race_day.none")}</option>`}
${sessionChoices.map((item) => `<option value="${escapeHtml(item.id)}" ${session?.id === item.id ? "selected" : ""}>${escapeHtml(`${item.name} · ${getEventName(item.eventId)} · ${getStatusLabel(item.status)}`)}</option>`).join("")}
</select>
</label>
${session && !isSelected ? `<button id="raceDayActivate" class="btn" type="button">${t("race_day.activate")}</button>` : ""}
<div class="race-day-actions">
${usesPrologue
? renderPrologueControls({ t, escapeHtml, getDefaultPrologueSec }, session, warmupForChecks, canStart)
: `<button id="raceDayStart" class="btn btn-primary" type="button" ${canStart ? "" : "disabled"}>${t("timing.start")}</button>`}
: isLiveSession ? "" : `<button id="raceDayStart" class="btn btn-primary" type="button" ${canStart ? "" : "disabled"}>${t(isPracticeSession ? "race_day.start_practice" : "timing.start")}</button>`}
${prologue ? "" : `
<button id="raceDayPause" class="btn" type="button" ${session?.status === "running" ? "" : "disabled"}>${t("audio.race_pause")}</button>
<button id="raceDayResume" class="btn" type="button" ${session?.status === "paused" ? "" : "disabled"}>${t("audio.race_resume")}</button>
<button id="raceDayFinish" class="btn btn-danger" type="button" ${["running", "paused"].includes(session?.status) ? "" : "disabled"}>${t("race_day.finish")}</button>`}
<!-- Practice gets plain words; a race keeps race wording. Only the buttons that apply are shown. -->
${session?.status === "running" ? `<button id="raceDayPause" class="btn" type="button">${t(isPracticeSession ? "race_day.pause_practice" : "audio.race_pause")}</button>` : ""}
${session?.status === "paused" ? `<button id="raceDayResume" class="btn btn-primary" type="button">${t(isPracticeSession ? "race_day.resume_practice" : "audio.race_resume")}</button>` : ""}
${isLiveSession ? `<button id="raceDayFinish" class="btn btn-danger" type="button">${t(isPracticeSession ? "race_day.finish_practice" : "race_day.finish")}</button>` : ""}
${isPracticeSession ? `<button id="raceDayNewPracticeDay" class="btn" type="button" title="${escapeHtml(t("race_day.new_practice_day_hint"))}">${t("race_day.new_practice_day")}</button>` : ""}`}
</div>
<div id="raceDayStartLights" class="race-start-lights" data-state="${escapeHtml(getStartLightState())}">
${isPracticeSession ? "" : `<div id="raceDayStartLights" class="race-start-lights" data-state="${escapeHtml(getStartLightState())}">
${[1, 2, 3, 4, 5].map((light) => `<span data-start-light="${light}"></span>`).join("")}
<strong>${escapeHtml(getStartLightState())}</strong>
</div>
</div>`}
<div class="race-day-shortcuts">
<button id="raceDayTiming" class="btn btn-mini" type="button">${t("nav.timing")}</button>
<button id="raceDayOverlay" class="btn btn-mini" type="button">${t("nav.overlay")}</button>
@@ -339,6 +366,15 @@ export function renderRaceDayView(deps) {
if (!result.ok && button) button.disabled = false;
});
dom.view.querySelector("[data-show-live]")?.addEventListener("click", (event) => selectSession(event.currentTarget.dataset.showLive));
document.getElementById("raceDayQuickPractice")?.addEventListener("click", (event) => {
event.currentTarget.disabled = true;
startPracticeNow();
});
document.getElementById("raceDayQuickRace")?.addEventListener("click", () => navigateTo("race_setup"));
document.getElementById("raceDaySessionSelect")?.addEventListener("change", (event) => { if (event.target.value) selectSession(event.target.value); });
document.getElementById("raceDayNewPracticeDay")?.addEventListener("click", () => {
if (session && window.confirm(t("race_day.new_practice_day_confirm", { name: session.name }))) resetSessionData(session);
});
dom.view.querySelectorAll("[data-lap-action]").forEach((button) => button.addEventListener("click", () => {
if (session && setCompetitorLapStatus(session, button.dataset.lapRow, Number(button.dataset.lapTs), button.dataset.lapAction)) renderView();
}));
+12
View File
@@ -4634,3 +4634,15 @@ tr.is-removed td.lap-actions {
/* Laps are going to a running session other than the selected one */
.live-elsewhere-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 14px; border: 1px solid #f5a623; border-radius: 10px; background: color-mix(in srgb, #f5a623 14%, transparent); font-weight: 600; }
/* Race Day quick actions and session picker */
.race-day-quick { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.race-day-quick-btn { font-size: 1rem; padding: 12px 18px; min-height: 48px; }
.race-day-session-picker { display: grid; gap: 4px; margin-bottom: 12px; max-width: 520px; }
.timing-run-on-race-day { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
/* Dashboard: the three common tasks */
.dashboard-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.dashboard-quick-btn { display: grid; gap: 4px; text-align: left; padding: 16px 18px; min-height: 76px; }
.dashboard-quick-btn strong { font-size: 1.05rem; }
.dashboard-quick-btn small { font-weight: 400; opacity: 0.85; white-space: normal; }
+4 -61
View File
@@ -411,7 +411,7 @@ export function renderTimingView(deps) {
getManualCorrectionSummary, formatTeamActiveMemberLabel, formatRaceClock, renderSessionChannelAnalysis,
setLastFinishAnnouncementSessionId, lastOverlayLeaderKeyBySession, lastOverlayTop3BySession, overlayEvents, setOverlayEvents, sessionReplay,
syncTrainingLedger = () => {}, setCompetitorLapStatus = () => false, openJudging = () => {},
getLiveSession = () => null, selectLiveSession = () => {},
getLiveSession = () => null, selectLiveSession = () => {}, openRaceDay = () => {},
} = deps;
const helperDeps = {
@@ -502,14 +502,9 @@ export function renderTimingView(deps) {
</select>
<div class="actions">
<button id="setActiveSession" class="btn">${t("timing.set_active")}</button>
<button id="startSession" class="btn btn-primary">${t("timing.start")}</button>
<button id="stopSession" class="btn">${t("timing.stop")}</button>
<button id="resetSession" class="btn btn-danger">${t("timing.reset")}</button>
</div>
<div id="raceStartLights" class="race-start-lights" data-state="${escapeHtml(getStartLightState())}">
${[1, 2, 3, 4, 5].map((light) => `<span data-start-light="${light}"></span>`).join("")}
<strong>${escapeHtml(getStartLightState())}</strong>
</div>
<!-- Start, pause, finish and "new practice day" live on Race Day; Timing is for following. -->
<p class="hint timing-run-on-race-day">${t("timing.run_on_race_day")} <button id="timingOpenRaceDay" class="btn btn-mini" type="button">${t("timing.open_race_day")}</button></p>
</div>
</div>
<div class="panel-body timing-session-summary">
@@ -755,35 +750,7 @@ export function renderTimingView(deps) {
renderView();
});
document.getElementById("startSession")?.addEventListener("click", async () => {
const session = getActiveSession();
const startButton = document.getElementById("startSession");
if (!session || startButton?.disabled) return;
if (startButton) startButton.disabled = true;
const updateStartDisplay = (label, lights = 0) => {
if (startButton && label) startButton.textContent = label;
const panel = document.getElementById("raceStartLights");
if (!panel) return;
panel.dataset.state = label;
panel.querySelector("strong")?.replaceChildren(document.createTextNode(label));
panel.querySelectorAll("[data-start-light]").forEach((node) => node.classList.toggle("is-on", Number(node.dataset.startLight) <= lights));
};
const result = await startOperationalSession(session, {
onCountdown: (seconds) => updateStartDisplay(String(seconds), 0),
onLight: (light) => updateStartDisplay("LIGHT_" + light, light),
onArmed: () => updateStartDisplay("WAIT_RANDOM", 5),
});
if (!result.ok) {
if (result.message) alert(result.message);
if (startButton) startButton.disabled = false;
updateStartDisplay(t("timing.start"), 0);
}
});
document.getElementById("stopSession")?.addEventListener("click", () => {
const session = getActiveSession();
if (session) finishOperationalSession(session);
});
document.getElementById("timingOpenRaceDay")?.addEventListener("click", () => openRaceDay());
dom.view.querySelector("[data-show-live]")?.addEventListener("click", (event) => selectLiveSession(event.currentTarget.dataset.showLive));
// Remove / restore / approve one lap - from the suspect panel or a driver's lap list.
@@ -792,36 +759,12 @@ export function renderTimingView(deps) {
if (session && setCompetitorLapStatus(session, button.dataset.lapRow, Number(button.dataset.lapTs), button.dataset.lapAction)) renderView();
}));
document.getElementById("resetSession")?.addEventListener("click", () => {
const session = getActiveSession();
if (!session) {
return;
}
if (!confirm(t("timing.clear_confirm"))) {
return;
}
// Every lap so far goes into the training stats first; resultsResetAt then keeps them
// there although they leave this session's results (see syncTrainingLedger).
syncTrainingLedger();
session.resultsResetAt = Date.now();
delete state.resultsBySession[session.id];
session.followUpStartedAt = null;
setLastFinishAnnouncementSessionId(null);
delete lastOverlayLeaderKeyBySession[session.id];
delete lastOverlayTop3BySession[session.id];
setOverlayEvents([]);
saveState();
renderView();
});
document.querySelectorAll("[data-race-audio-cue]").forEach((node) => {
node.addEventListener("click", () => {
const cue = node.dataset.raceAudioCue;
const session = getActiveSession();
if (cue === "false_start") {
cancelRaceStart();
const startButton = document.getElementById("startSession");
if (startButton) { startButton.disabled = false; startButton.textContent = t("timing.start"); }
} else if (cue === "race_paused" && session?.status === "running") {
session.status = "paused";
session.pausedAt = Date.now();