feat(results): print or PDF one finished heat; results list finals first (1.89.12)
This commit is contained in:
1 parent
3a0e871ebc
commit
4a1460b480
10 files changed
+111
-35
No files matched your search
@@ -8,6 +8,16 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.12
|
||||
|
||||
### Added
|
||||
|
||||
- Race overview: a finished heat or final has its own 🖨 and PDF buttons that print just that heat.
|
||||
|
||||
### Changed
|
||||
|
||||
- Printed and PDF results start with the finals (A final first), then qualifying, then practice.
|
||||
|
||||
## 1.89.11
|
||||
|
||||
### Added
|
||||
|
||||
@@ -112,7 +112,7 @@ The menu follows how a race day works: **Start** (Dashboard, Race Day), **Create
|
||||
- **📺 Drivers' board** (`/public-overlay/schedule`, also under Overlay) shows what is on track, the next three heats with their drivers, then the rest of the day. A heat that has been called is highlighted "Called – get ready". It works on a phone or a TV in the pits.
|
||||
- **Calling a heat:** when a heat is 10 minutes away (set under **Call**), Race Day asks the race controller: **📢 Call now** reads the heat and its drivers over the speakers and highlights it on the drivers' board; **Later** asks again in 2 minutes. With the autopilot on, heats are called on their own.
|
||||
- **▶ Run the day automatically** starts each heat's count-down on its own when the schedule says so, and waits (saying why) while a heat runs, the decoder is offline or a heat is not ready. With several classes on one day, every class's heats run in the same order. Finals are never created automatically: when a class's qualifying is done it says "Waiting: check qualifying and press 🏁 Create finals for …" with the class names, so qualifying can be corrected first. Then the autopilot runs the finals. It runs only in the browser where it was turned on. **■ Stop autopilot** to run heats by hand; turning it on again carries on with the next heat not yet run. **⏸ Pause the day** pauses the heat on track (or holds the count-down) and the autopilot until **Resume the day**.
|
||||
- **Race overview** (under the heat queue): the whole race of the current event in one place - the podium from the A final, then practice, qualifying and finals that open and close, each with the standings and every heat's result (laps, result, best lap, and the car in sponsor heats). **Print**, **PDF** and **CSV** export the whole race with every heat.
|
||||
- **Race overview** (under the heat queue): the whole race of the current event in one place - the podium from the A final, then practice, qualifying and finals that open and close, each with the standings and every heat's result (laps, result, best lap, and the car in sponsor heats). **Print**, **PDF** and **CSV** export the whole race with every heat, finals on top (A final first), then qualifying, then practice. A finished heat or final has its own **🖨** and **PDF** buttons for just that heat, e.g. for the board in the pits.
|
||||
- **Speaker panel** (under the start buttons): track call, track clear, red flag, pause, resume, false start and marshal warning. Under **Sound and calls** are quick switches that save at once: mute all, lap time calls, race leader calls, practice hype and the speaker cues.
|
||||
- **Preflight** checks the decoder, participants, transponders (missing or duplicated), the lap window, the grid and audio. Blockers come first, each with a shortcut to the right setting. The min/max lap time can be edited right there.
|
||||
- **An automatic SQLite backup** is taken before every start.
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ Gränssnittet finns på svenska och engelska.
|
||||
- **Upprop:** när ett heat har 10 minuter kvar (ändras under **Upprop**) frågar Race Day race controllern: **📢 Ropa ut** läser upp heatet och förarna i högtalarna och markerar det i förarvyn; **Senare** frågar igen om 2 minuter. När automatiken är på ropas heaten upp av sig själva.
|
||||
- **▶ Kör dagen automatiskt** startar varje heats nedräkning själv när schemat säger det, och väntar (och säger varför) medan ett heat körs, decodern är frånkopplad eller ett heat inte är redo. Med flera klasser samma dag körs alla klassernas heat i samma ordning. Finaler skapas aldrig automatiskt: när kvalet är klart i en klass står det "Väntar: kontrollera kvalet och tryck 🏁 Skapa finaler för …" med klassernas namn, så att kvalet kan korrigeras först. Sedan kör automatiken finalerna. Den körs bara i webbläsaren där den slogs på. **■ Stoppa automatiken** för att köra för hand; slår du på den igen fortsätter den med nästa heat som inte är kört. **⏸ Pausa dagen** pausar heatet på banan (eller håller nedräkningen) och automatiken tills **Fortsätt dagen**.
|
||||
- **Heat-kön** visar aktuellt, nästa och därpå följande heat i körordning: träning, kval omgång för omgång (Q1 H1, Q1 H2, Q2 H1 …), sedan finaler från lägsta (C, B, A). När ett heat är klart väljer **▶ Nästa** nästa heat med ett klick. Sessionslistorna i Race Setup och på Race Day följer samma ordning, så ett heat som tagits bort och skapats om hamnar på rätt plats; **▲▼** på en session i Race Setup flyttar den tidigare eller senare.
|
||||
- **Race-översikt** (under heatkön): hela racet för det aktuella eventet på ett ställe – pallen från A-finalen, sedan träning, kval och finaler som kan fällas ut, var och en med ställning och varje heats resultat (varv, resultat, bästa varv, och bilen i sponsorheat). **Skriv ut**, **PDF** och **CSV** exporterar hela racet med alla heat.
|
||||
- **Race-översikt** (under heatkön): hela racet för det aktuella eventet på ett ställe – pallen från A-finalen, sedan träning, kval och finaler som kan fällas ut, var och en med ställning och varje heats resultat (varv, resultat, bästa varv, och bilen i sponsorheat). **Skriv ut**, **PDF** och **CSV** exporterar hela racet med alla heat, finalerna överst (A-finalen först), sedan kval och sist träning. Ett avslutat heat eller en final har egna knappar **🖨** och **PDF** för bara det heatet, t.ex. till tavlan i depån.
|
||||
- **Speakerpanel** (under startknapparna): stopp på banan, banan fri, röd flagg, paus, fortsätt, tjuvstart och banvaktsvarning. Under **Ljud och utrop** finns snabbval som sparas direkt: tysta allt, varvtidsutrop, ledarutrop, pepp under träning och speaker-utropen.
|
||||
- **Förkontrollen** kontrollerar decoder, deltagare, transpondrar (saknade eller dubbletter), varvtidsgränser, grid och ljud. Blockerare visas först, var och en med en genväg till rätt inställning. Min/max-varvtid kan ändras direkt där.
|
||||
- **En automatisk SQLite-backup** tas före varje start.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.11",
|
||||
"version": "1.89.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.11",
|
||||
"version": "1.89.12",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.11",
|
||||
"version": "1.89.12",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
+74
-24
@@ -162,15 +162,69 @@ const renderRaceOverviewFor = (event) => (event ? renderRaceOverviewPanel(getRac
|
||||
const bindRaceOverviewFor = (root, event) => event && bindRaceOverviewPanel(root, getRaceOverview(event), {
|
||||
print: () => openPrintWindow(`${event.name} - ${t("events.results_overview")}`, buildRaceResultsHtml(event)),
|
||||
pdf: () => exportRaceResultsPdf(event),
|
||||
printHeat: (sessionId) => printHeatResult(event, sessionId),
|
||||
pdfHeat: (sessionId) => exportHeatResultPdf(event, sessionId),
|
||||
csv: (overview) => downloadCsvFile(`${sanitizeFilenameSegment(event.name)}_race_overview.csv`, buildRaceOverviewCsvRows(overview, { t, formatLap, phaseLabel: raceOverviewPhaseLabel })),
|
||||
});
|
||||
// Every heat's result, for the printed results overview.
|
||||
const renderRaceOverviewHeatsHtml = (event) => (getRaceOverview(event)?.phases || []).flatMap((phase) => phase.heats.map(({ session, rows }) => `
|
||||
// Every heat's result, for the printed results overview (or just one heat: onlySessionId).
|
||||
// Results read from the top: finals (A final first), then qualifying, then practice.
|
||||
const PHASE_PRINT_ORDER = { final: 0, qualification: 1, practice: 2 };
|
||||
const finalLetterLeg = (name) => { const match = String(name || "").match(/^([A-Z])\b.*?(\d+)\s*$/); return match ? [match[1].charCodeAt(0), Number(match[2])] : [0, 0]; };
|
||||
const getOverviewHeats = (event, onlySessionId = "") => [...(getRaceOverview(event)?.phases || [])]
|
||||
.sort((a, b) => (PHASE_PRINT_ORDER[a.type] ?? 3) - (PHASE_PRINT_ORDER[b.type] ?? 3))
|
||||
.flatMap((phase) => {
|
||||
const heats = phase.type === "final"
|
||||
? [...phase.heats].sort((a, b) => { const [la, ga] = finalLetterLeg(a.session.name); const [lb, gb] = finalLetterLeg(b.session.name); return la - lb || ga - gb; })
|
||||
: phase.heats;
|
||||
return heats.map((heat) => ({ ...heat, phase }));
|
||||
})
|
||||
.filter(({ session }) => !onlySessionId || session.id === onlySessionId);
|
||||
const renderRaceOverviewHeatsHtml = (event, onlySessionId = "") => getOverviewHeats(event, onlySessionId).map(({ session, rows, phase }) => `
|
||||
<section class="print-block">
|
||||
<h2>${escapeHtml(raceOverviewPhaseLabel(phase.type))} • ${escapeHtml(session.name)}</h2>
|
||||
${renderTable([t("table.pos"), ...(rows.some((row) => row.qual) ? [t("table.qual")] : []), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td>${rows.some((item) => item.qual) ? qualCell(row.qual, escapeHtml) : ""}<td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
</section>`)).join("");
|
||||
</section>`).join("");
|
||||
const buildHeatPdfSection = ({ session, rows, phase }) => {
|
||||
const withCar = rows.some((row) => row.car);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return buildPdfSection(
|
||||
`${raceOverviewPhaseLabel(phase.type)} • ${session.name}`,
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), ...(withCar ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => [String(row.pos), ...(withQual ? [row.qual || "-"] : []), row.name, ...(withCar ? [row.car || "-"] : []), String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "-"])
|
||||
);
|
||||
};
|
||||
// One finished heat or final on its own page: for the board in the pits right after it.
|
||||
const printHeatResult = (event, sessionId) => {
|
||||
const heat = getOverviewHeats(event, sessionId)[0];
|
||||
if (!heat) return;
|
||||
openPrintWindow(`${event.name} - ${heat.session.name}`, `
|
||||
<header class="print-header">
|
||||
<div>
|
||||
<p class="print-kicker">${escapeHtml(getClassName(event.classId))}</p>
|
||||
<h1>${escapeHtml(event.name)}</h1>
|
||||
<p>${escapeHtml(event.date || "-")}</p>
|
||||
</div>
|
||||
<div class="print-meta">${buildPrintBrandBlock(resolveEventBranding(event))}</div>
|
||||
</header>
|
||||
${renderRaceOverviewHeatsHtml(event, sessionId)}`);
|
||||
};
|
||||
async function exportHeatResultPdf(event, sessionId) {
|
||||
const heat = getOverviewHeats(event, sessionId)[0];
|
||||
if (!heat) return;
|
||||
const branding = resolveEventBranding(event);
|
||||
await requestPdfExport({
|
||||
filename: `${event.name.replaceAll(/\s+/g, "_")}_${heat.session.name.replaceAll(/\s+/g, "_")}.pdf`,
|
||||
title: event.name,
|
||||
subtitle: `${getClassName(event.classId)} • ${event.date || "-"}`,
|
||||
brandName: branding.brandName,
|
||||
brandTagline: branding.brandTagline,
|
||||
footer: branding.pdfFooter,
|
||||
theme: branding.pdfTheme,
|
||||
logoDataUrl: await ensurePdfLogoDataUrl(branding.logoDataUrl),
|
||||
sections: [buildHeatPdfSection(heat)],
|
||||
});
|
||||
}
|
||||
const getSessionsForEvent = (eventId) => getSessionsForEventHelper(state, eventId);
|
||||
const getModeLabel = (mode) => getModeLabelHelper(mode, { t });
|
||||
const normalizeStartMode = (mode) => normalizeStartModeHelper(mode);
|
||||
@@ -3121,6 +3175,8 @@ const TRANSLATIONS = {
|
||||
"race_overview.title": "Race-översikt – {name}",
|
||||
"race_overview.hint": "Hela racet på ett ställe: ställning och varje heat för träning, kval och finaler.",
|
||||
"race_overview.print": "Skriv ut",
|
||||
"race_overview.print_heat": "Skriv ut bara detta heat",
|
||||
"race_overview.pdf_heat": "PDF för bara detta heat",
|
||||
"race_overview.car": "Bil",
|
||||
"race_overview.total": "Total",
|
||||
"race_overview.standings": "Ställning",
|
||||
@@ -5396,6 +5452,8 @@ const TRANSLATIONS = {
|
||||
"race_overview.title": "Race overview – {name}",
|
||||
"race_overview.hint": "The whole race in one place: standings and every heat for practice, qualifying and finals.",
|
||||
"race_overview.print": "Print",
|
||||
"race_overview.print_heat": "Print just this heat",
|
||||
"race_overview.pdf_heat": "PDF of just this heat",
|
||||
"race_overview.car": "Car",
|
||||
"race_overview.total": "Total",
|
||||
"race_overview.standings": "Standings",
|
||||
@@ -8116,9 +8174,15 @@ async function exportRaceResultsPdf(event) {
|
||||
logoDataUrl: await ensurePdfLogoDataUrl(branding.logoDataUrl),
|
||||
sections: [
|
||||
buildPdfSection(
|
||||
t("events.practice_standings"),
|
||||
[t("table.pos"), t("table.driver"), t("table.score")],
|
||||
buildPracticeStandings(event).map((row) => [String(row.rank), row.driverName || "-", row.score || "-"])
|
||||
t("events.final_standings"),
|
||||
...(() => {
|
||||
const rows = buildFinalStandings(event);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return [
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), t("table.score")],
|
||||
rows.map((row) => [String(row.rank), ...(withQual ? [row.qual || "-"] : []), row.driverName || "-", row.score || "-"]),
|
||||
];
|
||||
})()
|
||||
),
|
||||
buildPdfSection(
|
||||
t("events.qualifying_standings"),
|
||||
@@ -8130,25 +8194,11 @@ async function exportRaceResultsPdf(event) {
|
||||
])
|
||||
),
|
||||
buildPdfSection(
|
||||
t("events.final_standings"),
|
||||
...(() => {
|
||||
const rows = buildFinalStandings(event);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return [
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), t("table.score")],
|
||||
rows.map((row) => [String(row.rank), ...(withQual ? [row.qual || "-"] : []), row.driverName || "-", row.score || "-"]),
|
||||
];
|
||||
})()
|
||||
t("events.practice_standings"),
|
||||
[t("table.pos"), t("table.driver"), t("table.score")],
|
||||
buildPracticeStandings(event).map((row) => [String(row.rank), row.driverName || "-", row.score || "-"])
|
||||
),
|
||||
...(getRaceOverview(event)?.phases || []).flatMap((phase) => phase.heats.map(({ session, rows }) => {
|
||||
const withCar = rows.some((row) => row.car);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return buildPdfSection(
|
||||
`${raceOverviewPhaseLabel(phase.type)} • ${session.name}`,
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), ...(withCar ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => [String(row.pos), ...(withQual ? [row.qual || "-"] : []), row.name, ...(withCar ? [row.car || "-"] : []), String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "-"])
|
||||
);
|
||||
})),
|
||||
...getOverviewHeats(event).map(buildHeatPdfSection),
|
||||
...buildTeamRaceStandings(event).map(({ session, rows }) =>
|
||||
buildPdfSection(
|
||||
`${t("events.team_standings")} • ${session.name}`,
|
||||
|
||||
@@ -29,7 +29,7 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
|
||||
<h4>${t("race_overview.standings")}</h4>
|
||||
${renderRaceStandingsTableView(phase.standings, t("race_overview.no_results"))}
|
||||
${phase.heats.map(({ session, rows }) => `
|
||||
<h4>${escapeHtml(session.name)} <small>${escapeHtml(getStatusLabel(session.status))}</small></h4>
|
||||
<h4>${escapeHtml(session.name)} <small>${escapeHtml(getStatusLabel(session.status))}</small>${session.status === "finished" && rows.length ? ` <span class="race-overview-heat-actions"><button class="btn btn-mini" type="button" data-heat-print="${escapeHtml(session.id)}" title="${escapeHtml(t("race_overview.print_heat"))}">🖨</button><button class="btn btn-mini" type="button" data-heat-pdf="${escapeHtml(session.id)}" title="${escapeHtml(t("race_overview.pdf_heat"))}">PDF</button></span>` : ""}</h4>
|
||||
${rows.length ? heatTable(rows) : `<p class="hint">${t("race_overview.no_results")}</p>`}`).join("")}`
|
||||
: `<p class="hint">${t("race_overview.not_run")}</p>`}
|
||||
</details>`).join("")}
|
||||
@@ -37,11 +37,13 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
|
||||
</section>`;
|
||||
}
|
||||
|
||||
export function bindRaceOverviewPanel(root, overview, { print, pdf, csv }) {
|
||||
export function bindRaceOverviewPanel(root, overview, { print, pdf, csv, printHeat = () => {}, pdfHeat = () => {} }) {
|
||||
if (!root || !overview) return;
|
||||
root.querySelectorAll(".race-overview-phase").forEach((node) => node.addEventListener("toggle", () => {
|
||||
if (node.open) openPhases.add(node.dataset.phase); else openPhases.delete(node.dataset.phase);
|
||||
}));
|
||||
root.querySelectorAll("[data-heat-print]").forEach((button) => button.addEventListener("click", () => printHeat(button.dataset.heatPrint)));
|
||||
root.querySelectorAll("[data-heat-pdf]").forEach((button) => button.addEventListener("click", () => pdfHeat(button.dataset.heatPdf)));
|
||||
const actions = { print, pdf, csv };
|
||||
root.querySelectorAll("[data-race-overview]").forEach((button) => button.addEventListener("click", () => actions[button.dataset.raceOverview]?.(overview)));
|
||||
}
|
||||
@@ -441,16 +441,16 @@ export function buildRaceResultsHtml(event, { t, escapeHtml, resolveEventBrandin
|
||||
</div>
|
||||
</header>
|
||||
<section class="print-block">
|
||||
<h2>${t("events.practice_standings")}</h2>
|
||||
${renderRaceStandingsTableView(buildPracticeStandings(event), t("events.no_practice_results"))}
|
||||
<h2>${t("events.final_standings")}</h2>
|
||||
${renderRaceStandingsTableView(buildFinalStandings(event), t("events.no_final_results"))}
|
||||
</section>
|
||||
<section class="print-block">
|
||||
<h2>${t("events.qualifying_standings")}</h2>
|
||||
${renderRaceStandingsTableView(buildQualifyingStandings(event), t("events.no_qualifying_results"))}
|
||||
</section>
|
||||
<section class="print-block">
|
||||
<h2>${t("events.final_standings")}</h2>
|
||||
${renderRaceStandingsTableView(buildFinalStandings(event), t("events.no_final_results"))}
|
||||
<h2>${t("events.practice_standings")}</h2>
|
||||
${renderRaceStandingsTableView(buildPracticeStandings(event), t("events.no_practice_results"))}
|
||||
</section>
|
||||
<section class="print-block">
|
||||
<h2>${t("events.team_standings")}</h2>
|
||||
|
||||
@@ -5040,3 +5040,4 @@ body[data-theme="light"] .overlay-race-driver .overlay-pit-badge.is-done { color
|
||||
.obs-tv-cell .overlay-split-chip { background: #0b4a6b; }
|
||||
body[data-theme="light"] .overlay-split-chip { color: #075985; }
|
||||
body[data-theme="light"] .overlay-pit-badge.is-done { color: #7a4a00; }
|
||||
.race-overview-heat-actions { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
|
||||
@@ -71,3 +71,16 @@ test("finals show each driver's qualifying place, with TQ for the top qualifier"
|
||||
assert.deepEqual(finals.standings.map((row) => [row.rank, row.qual]), [["A1", "2"], ["A2", "TQ"]]);
|
||||
assert.equal(overview.phases.find((phase) => phase.type === "practice").heats[0].rows[0].qual, "", "only finals get the column");
|
||||
});
|
||||
|
||||
test("a finished heat in the overview has its own print and PDF buttons; a heat not run has none", async () => {
|
||||
const { renderRaceOverviewPanel } = await import("../src/race_overview_view.js");
|
||||
const row = { pos: 1, name: "Roy", laps: 12, result: "12/5:01.2", bestLapMs: 18000 };
|
||||
const overview = { event: { name: "Cup" }, podium: [], phases: [{ type: "final", planned: 2, standings: [], heats: [
|
||||
{ session: { id: "fA", name: "A Final 1", status: "finished" }, rows: [row] },
|
||||
{ session: { id: "fB", name: "A Final 2", status: "ready" }, rows: [] },
|
||||
] }] };
|
||||
const html = renderRaceOverviewPanel(overview, { t: (k) => k, escapeHtml: String, formatLap: String, renderTable: () => "<table></table>", renderRaceStandingsTableView: () => "", phaseLabel: (x) => x, getStatusLabel: (x) => x });
|
||||
assert.match(html, /data-heat-print="fA"/);
|
||||
assert.match(html, /data-heat-pdf="fA"/);
|
||||
assert.doesNotMatch(html, /data-heat-print="fB"/);
|
||||
});
|
||||
Reference in new issue
Block a user