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:
1 parent
3a6789f42f
commit
c4df90706a
23 files changed
+344
-111
No files matched your search
+4
-61
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user