diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b2cd3..06f3a49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.52 - 2026-11-16 + +- Heat print and PDF: under the lap chart, every lap time in a table – a row per lap, a column per driver in finish order. Each driver's best lap is bold on green and the fastest lap of the heat bold on purple. Only with a single heat, so the full results stay short. + ## 1.89.51 - 2026-11-16 - Run the day automatically no longer starts the preliminary qualifiers once practice is done: it waits, like before the finals, with "Waiting: practice is done – press Generate qualifying from practice". diff --git a/README.md b/README.md index e8e9446..302f927 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ The menu follows how a race day works: **Start** (Dashboard, Race Day), **Create - **▶ 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, 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. - **📈 Lap chart:** every qualifying heat and final has a fold-out lap chart - each driver's place after every lap as a coloured line, place 1 on top, names at their official finish place. Counted from the passings, nothing extra to set up. It is printed and in the PDF of a single heat, and with the finals in the full results. + - **⏱ Lap times:** the print and PDF of a single heat also list every lap, a column per driver in finish order; each driver's best lap is bold on green and the fastest lap of the heat purple. - **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. diff --git a/README.sv.md b/README.sv.md index 016f5a0..61eef49 100644 --- a/README.sv.md +++ b/README.sv.md @@ -129,6 +129,7 @@ Gränssnittet finns på svenska och engelska. - **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, 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. - **📈 Varvdiagram:** varje kvalheat och final har ett utfällbart varvdiagram – varje förares placering efter varje varv som en färgad linje, 1:a överst, namnen vid den officiella placeringen. Räknas från passeringarna, inget att ställa in. Det kommer med i utskrift och PDF av ett enskilt heat, och med finalerna i hela resultatet. + - **⏱ Varvtider:** utskrift och PDF av ett enskilt heat listar också alla varv, en kolumn per förare i placeringsordning; förarens bästa varv är fett på grönt och heatets snabbaste varv lila. - **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. diff --git a/package-lock.json b/package-lock.json index a8f6d61..e2a495c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.51", + "version": "1.89.52", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.51", + "version": "1.89.52", "hasInstallScript": true, "license": "AGPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index ba226eb..48c64ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.51", + "version": "1.89.52", "private": true, "license": "AGPL-3.0-or-later", "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", diff --git a/server.js b/server.js index 3373b2d..83511df 100644 --- a/server.js +++ b/server.js @@ -984,6 +984,21 @@ function normalizePdfLapChart(chart) { return { title: String(chart.title || "").slice(0, 80), lapLabel: String(chart.lapLabel || "").slice(0, 20), laps, series }; } +// A heat's lap times: a row per lap, a column per driver (finish order), best laps marked. +function normalizePdfLapTable(table) { + if (!table || !Array.isArray(table.names) || !Array.isArray(table.rows)) return null; + const names = table.names.slice(0, 24).map((name) => String(name || "-").slice(0, 60)); + if (!names.length) return null; + const rows = table.rows.slice(0, 400).map((row) => names.map((_n, col) => String((Array.isArray(row) ? row[col] : "") ?? "").slice(0, 12))); + if (!rows.length) return null; + const index = (value, max) => { const n = Math.floor(Number(value)); return Number.isInteger(n) && n >= 0 && n < max ? n : -1; }; + const best = names.map((_n, col) => index(Array.isArray(table.best) ? table.best[col] : -1, rows.length)); + const fastest = table.fastest && index(table.fastest.row, rows.length) >= 0 && index(table.fastest.col, names.length) >= 0 + ? { row: index(table.fastest.row, rows.length), col: index(table.fastest.col, names.length) } + : null; + return { title: String(table.title || "").slice(0, 80), lapLabel: String(table.lapLabel || "").slice(0, 20), legend: String(table.legend || "").slice(0, 160), names, rows, best, fastest }; +} + function normalizePdfExportPayload(input = {}) { const title = String(input.title || "RC RaceCore").trim(); const subtitle = String(input.subtitle || "").trim(); @@ -1006,6 +1021,7 @@ function normalizePdfExportPayload(input = {}) { // A country code per row for the flag before the driver's name ("SE", "GB-ENG"); anything else is dropped. flags: Array.isArray(section?.flags) ? section.flags.map((code) => (/^[A-Z]{2}(-[A-Z]{3})?$/.test(String(code || "")) ? String(code) : "")) : [], chart: normalizePdfLapChart(section?.chart), + lapTable: normalizePdfLapTable(section?.lapTable), })) : []; diff --git a/server/pdf_render.js b/server/pdf_render.js index 87025e3..93082c1 100644 --- a/server/pdf_render.js +++ b/server/pdf_render.js @@ -349,6 +349,55 @@ function drawLapChart(writer, chart) { writer.y -= height + 8; } +// The lap times under a heat: a row per lap, a column per driver in finish order. Each driver's +// best lap is bold on green, the fastest lap of the heat bold on purple. +const BEST_LAP_FILL = "#dcf5e3"; +const FASTEST_LAP_FILL = "#eadcfb"; +const FASTEST_LAP_TEXT = "#5b21b6"; +function drawLapTable(writer, table, theme) { + const cols = table.names.length; + const lapW = 24; + const colW = (writer.width - lapW) / cols; + const size = cols > 10 ? 6.5 : 7.5; + const rowH = cols > 10 ? 11 : 12.5; + const headLines = table.names.map((name, index) => wrapText(`${index + 1}. ${name}`, size, true, colW - 4).slice(0, 2)); + const headH = 6 + Math.max(1, ...headLines.map((lines) => lines.length)) * (size + 2.5); + const baseline = (top) => top - rowH + (rowH - size) / 2 + 1.2; + const drawHead = () => { + writer.rect(MARGIN, writer.y - headH, writer.width, headH, theme.headFill); + writer.text(MARGIN + 3, writer.y - 4 - size, fitText(table.lapLabel, size, true, lapW - 4), size, { bold: true, color: theme.headText }); + headLines.forEach((lines, col) => lines.forEach((line, index) => { + writer.text(MARGIN + lapW + col * colW + 2, writer.y - 4 - size - index * (size + 2.5), line, size, { bold: true, color: theme.headText, align: "center", width: colW - 4 }); + })); + writer.y -= headH; + }; + writer.ensure(18 + headH + rowH * 3); + writer.text(MARGIN, writer.y - 10, fitText(table.title, 10, true, writer.width), 10, { bold: true }); + writer.y -= 16; + drawHead(); + table.rows.forEach((row, rowIndex) => { + if (writer.ensure(rowH)) drawHead(); + const top = writer.y; + if (rowIndex % 2 === 1) writer.rect(MARGIN, top - rowH, writer.width, rowH, theme.zebra); + writer.text(MARGIN + 3, baseline(top), String(rowIndex + 1), size, { color: MUTED }); + row.forEach((value, col) => { + const x = MARGIN + lapW + col * colW; + const fastest = Boolean(table.fastest && table.fastest.row === rowIndex && table.fastest.col === col); + const best = table.best[col] === rowIndex; + if (fastest || best) writer.rect(x + 1, top - rowH + 0.6, colW - 2, rowH - 1.2, fastest ? FASTEST_LAP_FILL : BEST_LAP_FILL); + writer.text(x + 2, baseline(top), fitText(value, size, fastest || best, colW - 4), size, { bold: fastest || best, color: fastest ? FASTEST_LAP_TEXT : TEXT, align: "center", width: colW - 4 }); + }); + writer.line(MARGIN, top - rowH, MARGIN + writer.width, top - rowH, RULE, 0.3); + writer.y -= rowH; + }); + if (table.legend) { + writer.ensure(14); + writer.text(MARGIN, writer.y - 9, fitText(table.legend, 7, false, writer.width), 7, { color: MUTED }); + writer.y -= 14; + } + writer.y -= 6; +} + function drawParagraphs(writer, section) { section.rows.forEach((row) => row.forEach((value) => { wrapText(value, 10, false, writer.width).forEach((line) => { @@ -490,6 +539,7 @@ function buildStyledPdf(payload) { if (section.headers.length) drawTable(writer, section, theme); else drawParagraphs(writer, section); if (section.chart) drawLapChart(writer, section.chart); + if (section.lapTable) drawLapTable(writer, section.lapTable, theme); }); drawFooters(writer, pages, payload, theme, pageWidth); diff --git a/src/app.js b/src/app.js index 71a6d07..512f40d 100644 --- a/src/app.js +++ b/src/app.js @@ -204,14 +204,20 @@ const getOverviewHeats = (event, onlySessionId = "") => [...(getRaceOverview(eve }) .filter(({ session }) => !onlySessionId || session.id === onlySessionId); // The lap chart prints with a single heat, and with the finals in the full results. -const renderRaceOverviewHeatsHtml = (event, onlySessionId = "") => getOverviewHeats(event, onlySessionId).map(({ session, rows, phase, lapChart }) => ` +// Lap times under a single heat: a column per driver in finish order, best laps marked. +const renderPrintLapTable = (table) => `
| ${escapeHtml(t("table.lap"))} | ${table.names.map((name, index) => `${index + 1}. ${escapeHtml(name)} | `).join("")}
|---|---|
| ${rowIndex + 1} | ${row.map((ms, col) => { + const cls = table.fastest && table.fastest.row === rowIndex && table.fastest.col === col ? "lap-fastest" : table.best[col] === rowIndex ? "lap-best" : ""; + return `${ms ? escapeHtml(formatLap(ms).replace(/^0:/, "")) : ""} | `; +}).join("")}
${escapeHtml(t("lap_table.legend"))}