feat(overlay): click a driver to open their training stats
In RaceCore's own overlay a driver row opens Training stats for that driver and class; the stand-alone overlay window opens them in a new tab. The public overlay gets no links: the mobile profile link is personal and can write.
This commit is contained in:
1 parent
cade201d5a
commit
4def444202
8 files changed
+105
-3
No files matched your search
@@ -6,6 +6,10 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- **Overlay → a driver's training stats in one click.** In RaceCore's own Overlay a click on a driver opens Training stats for that driver and class; the stand-alone overlay window stays up and opens them in a new tab. The public overlay has no links, since the driver's mobile profile link is personal and can also write.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Fewer personal best calls in Open Practice.** On fresh packs everyone beats their own best almost every lap early in the day, so the speaker never stopped. Now: no personal best call for a driver's first 10 laps of the day (since the practice started or was reset), at most one call per driver per minute, and the next call needs a best at least 0.1 s better than the last one called. The best lap is still shown on screen and in the overlay. The three values are under Settings → Audio (0 turns a rule off). Races are unaffected, and fastest lap of the session and track record calls stay as before.
|
||||
|
||||
@@ -238,6 +238,7 @@ Settings → Audio:
|
||||
|
||||
The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus an OBS mode with layout (leaderboard, grid, lower third), theme (panel, transparent, chroma), rows and columns:
|
||||
- Columns: laps, result, best, gap, and **places since the start** (▲/▼ in heats and finals).
|
||||
- **Click a driver** in RaceCore's own overlay to open that driver's training stats (the stand-alone overlay window opens them in a new tab). The public overlay has no such links.
|
||||
- **Copy OBS URL** gives a browser-source link; the chosen columns are part of the link.
|
||||
- Public overlays live at `/public-overlay/<mode>` and can require a token: set `PUBLIC_OVERLAY_TOKEN` and add `?token=...`. Publish only `/public-overlay/*` through your reverse proxy.
|
||||
- Club branding (name, logo, PDF theme) is applied to the sidebar, overlays, mobile profiles and PDFs; branding can also be set per event.
|
||||
|
||||
@@ -251,6 +251,7 @@ Inställningar → Ljud:
|
||||
|
||||
Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus ett OBS-läge med layout (leaderboard, grid, lower third), tema (panel, transparent, chroma), rader och kolumner:
|
||||
- Kolumner: varv, resultat, bästa, gap och **placering sedan start** (▲/▼ i heat och finaler).
|
||||
- **Klicka på en förare** i RaceCores egen overlay för att öppna förarens träningsstatistik (det fristående overlay-fönstret öppnar den i en ny flik). Den publika overlayn har inga sådana länkar.
|
||||
- **Kopiera OBS-URL** ger en länk för browser source; valda kolumner ingår i länken.
|
||||
- Publika overlays finns på `/public-overlay/<läge>` och kan kräva en nyckel: sätt `PUBLIC_OVERLAY_TOKEN` och lägg till `?token=...`. Publicera bara `/public-overlay/*` via din reverse proxy.
|
||||
- Klubbprofilen (namn, logga, PDF-tema) används i menyn, overlays, mobilprofiler och PDF; den kan även sättas per tävling.
|
||||
|
||||
+30
-1
@@ -489,7 +489,7 @@ const renderRaceDay = () => renderRaceDayView({
|
||||
navigateTo: navigateToView,
|
||||
getStartLightState: () => raceAudioEngine.getStartLightState(),
|
||||
});
|
||||
const renderOverlay = () => renderOverlayPageView({ state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock, formatPredictedLapDelta, getActiveSession, buildLeaderboard, ensureSessionResult, getSessionTiming, getVisiblePassings, resolveEventBranding, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings, getOverlayModeLabel, getStatusLabel, getObsOverlayConfig, buildOverlayPanels, normalizeStartMode, renderPositionGrid, getEventName, getSessionTypeLabel, getStartModeLabel, renderRaceStandingsTableView, renderTeamOverlay, renderObsOverlay, renderOverlayLeaderboard, renderOverlaySidePanel, formatTeamActiveMemberLabel, getSessionGridEntries, getSessionGridOrder, overlayViewMode, overlayMode, publicOverlayMode, overlayEvents, overlayRotationIndex, openOverlayWindow, buildOverlayUrl });
|
||||
const renderOverlay = () => renderOverlayPageView({ state, dom, t, escapeHtml, formatLap, formatCountdown, formatElapsedClock, formatPredictedLapDelta, getActiveSession, buildLeaderboard, ensureSessionResult, getSessionTiming, getVisiblePassings, resolveEventBranding, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings, getOverlayModeLabel, getStatusLabel, getObsOverlayConfig, buildOverlayPanels, normalizeStartMode, renderPositionGrid, getEventName, getSessionTypeLabel, getStartModeLabel, renderRaceStandingsTableView, renderTeamOverlay, renderObsOverlay, renderOverlayLeaderboard: (rows, deps, options = {}) => renderOverlayLeaderboard(rows, deps, { ...options, driverLinks: !publicOverlayMode }), renderOverlaySidePanel, formatTeamActiveMemberLabel, getSessionGridEntries, getSessionGridOrder, overlayViewMode, overlayMode, publicOverlayMode, overlayEvents, overlayRotationIndex, openOverlayWindow, buildOverlayUrl });
|
||||
const refreshOverlayDynamics = () => {
|
||||
const active = getActiveSession();
|
||||
if (!active) return;
|
||||
@@ -2545,6 +2545,7 @@ const TRANSLATIONS = {
|
||||
"overlay.obs_theme_chroma": "Chroma",
|
||||
"overlay.team_battle": "Lagkamp",
|
||||
"overlay.active_member": "Aktiv förare/bil",
|
||||
"overlay.open_training_stats": "Klicka för att se förarens träningsstatistik",
|
||||
"overlay.top_three": "Topp 3",
|
||||
"guide.host_title": "Hur Managed AMMC körs",
|
||||
"guide.decoder_roles_title": "Decoderroller, IP och portar",
|
||||
@@ -4382,6 +4383,7 @@ const TRANSLATIONS = {
|
||||
"overlay.obs_theme_chroma": "Chroma",
|
||||
"overlay.team_battle": "Team battle",
|
||||
"overlay.active_member": "Active driver/car",
|
||||
"overlay.open_training_stats": "Click to see this driver's training stats",
|
||||
"overlay.top_three": "Top 3",
|
||||
"guide.host_title": "How Managed AMMC Runs",
|
||||
"guide.decoder_roles_title": "Decoder roles, IP addresses, and ports",
|
||||
@@ -4785,6 +4787,11 @@ async function init() {
|
||||
}
|
||||
});
|
||||
|
||||
// One listener for the overlay's driver links: the overlay re-renders every tick.
|
||||
document.addEventListener("click", (event) => {
|
||||
const link = event.target instanceof Element ? event.target.closest("[data-training-driver]") : null;
|
||||
if (link) openDriverTrainingStats(String(link.dataset.trainingDriver || ""));
|
||||
});
|
||||
startOverlaySync();
|
||||
startBackgroundHydration();
|
||||
startOverlayRotation();
|
||||
@@ -5810,6 +5817,28 @@ function navigateToView(view, { settingsTab = "" } = {}) {
|
||||
renderView();
|
||||
}
|
||||
|
||||
// Overlay: a click on a driver opens their own training stats. In the menu's Overlay it switches
|
||||
// view; the stand-alone overlay window stays up and opens the stats in a new tab. The public
|
||||
// overlay has no links: the driver's mobile profile link is personal and can also write.
|
||||
function openDriverTrainingStats(driverId) {
|
||||
if (publicOverlayMode || !driverId) return;
|
||||
const classId = String(state.drivers.find((driver) => driver.id === driverId)?.classId || "");
|
||||
if (overlayMode) {
|
||||
const url = new URL("/", window.location.origin);
|
||||
url.searchParams.set("view", "training");
|
||||
url.searchParams.set("driver", driverId);
|
||||
if (classId) url.searchParams.set("class", classId);
|
||||
window.open(url.toString(), "_blank");
|
||||
return;
|
||||
}
|
||||
selectedTrainingDriverId = driverId;
|
||||
selectedTrainingClassId = classId;
|
||||
currentView = "training";
|
||||
updateViewUrl("training", driverId, classId);
|
||||
renderNav();
|
||||
renderView();
|
||||
}
|
||||
|
||||
function selectOperationalSession(sessionId, options = {}) {
|
||||
const session = state.sessions.find((item) => item.id === sessionId);
|
||||
if (!session) return false;
|
||||
|
||||
+5
-2
@@ -56,7 +56,9 @@ export function renderOverlaySidePanel(panel, { t, escapeHtml }) {
|
||||
`;
|
||||
}
|
||||
|
||||
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true } = {}) {
|
||||
// driverLinks: a click on a driver opens their training stats (RaceCore's own overlay only - never
|
||||
// the public overlay, see openDriverTrainingStats in app.js).
|
||||
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false } = {}) {
|
||||
if (!rows.length) {
|
||||
return `<p>${t("timing.no_laps")}</p>`;
|
||||
}
|
||||
@@ -70,8 +72,9 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
|
||||
.map((row, idx) => {
|
||||
const posClass = idx === 0 ? "pos-1" : idx === 1 ? "pos-2" : idx === 2 ? "pos-3" : "";
|
||||
const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute([idx + 1, row.displayName || row.driverName, row.laps ?? 0, row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : "";
|
||||
const linkAttrs = driverLinks && row.driverId && !row.teamId ? ` data-training-driver="${escapeHtml(row.driverId)}" title="${escapeHtml(t("overlay.open_training_stats"))}"` : "";
|
||||
return `
|
||||
<article class="overlay-race-row ${idx === 0 ? "overlay-race-row-leader" : ""} ${row.invalidPending ? "overlay-race-row-invalid" : ""}"${rowSortAttr} data-overlay-competitor="${escapeHtml(row.key)}">
|
||||
<article class="overlay-race-row ${idx === 0 ? "overlay-race-row-leader" : ""} ${row.invalidPending ? "overlay-race-row-invalid" : ""} ${linkAttrs ? "is-linked" : ""}"${rowSortAttr}${linkAttrs} data-overlay-competitor="${escapeHtml(row.key)}">
|
||||
<div class="overlay-race-pos">
|
||||
<span class="pos-pill ${posClass}">${idx + 1}</span>
|
||||
</div>
|
||||
|
||||
@@ -4693,3 +4693,7 @@ tr.is-removed td.lap-actions {
|
||||
.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; }
|
||||
|
||||
/* RaceCore's own overlay: a driver row opens their training stats. */
|
||||
.overlay-race-row.is-linked { cursor: pointer; }
|
||||
.overlay-race-row.is-linked:hover .overlay-race-driver strong { text-decoration: underline; text-underline-offset: 3px; }
|
||||
@@ -0,0 +1,58 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
// Overlay -> a driver's own training stats in one click. In the menu's Overlay it switches to
|
||||
// Training stats with that driver; the stand-alone overlay window opens them in a new tab; the
|
||||
// public overlay has no links (the mobile profile link is personal and can write).
|
||||
export async function runOverlayDriverLinkSmoke({ evaluate, navigate, savedState, waitFor, base, send }) {
|
||||
const patchState = async (patch) => {
|
||||
const current = await savedState();
|
||||
Object.assign(current, patch);
|
||||
const response = await fetch(base + "/api/state", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(current) });
|
||||
assert.equal(response.ok, true);
|
||||
};
|
||||
const seeded = await savedState();
|
||||
const startedAt = Date.now() - 120000;
|
||||
const passings = [21000, 20500].map((lapMs, index) => ({ driverId: "ol_driver", driverName: "OL Driver", competitorKey: "driver_ol_driver", transponder: "8550001", lapMs, timestamp: startedAt + (index + 1) * 21000, validLap: true }));
|
||||
await patchState({
|
||||
classes: [...seeded.classes, { id: "ol_class", name: "OL Class" }],
|
||||
drivers: [...seeded.drivers, { id: "ol_driver", name: "OL Driver", classId: "ol_class", transponder: "8550001" }],
|
||||
events: [...seeded.events, { id: "ol_event", name: "OL Practice", classId: "ol_class", mode: "race", raceConfig: { practiceOnly: true } }],
|
||||
sessions: [...seeded.sessions.map((session) => (["running", "paused"].includes(session.status) ? { ...session, status: "finished", endedAt: Date.now() } : session)), { id: "ol_practice", eventId: "ol_event", name: "OL Open Practice", type: "open_practice", durationMin: 600, status: "running", startedAt }],
|
||||
resultsBySession: { ...seeded.resultsBySession, ol_practice: { passings, competitors: { driver_ol_driver: { key: "driver_ol_driver", driverId: "ol_driver", driverName: "OL Driver", displayName: "OL Driver", transponder: "8550001", laps: 2, lastLapMs: 20500, bestLapMs: 20500, startTimestamp: startedAt, lastTimestamp: startedAt + 42000 } } } },
|
||||
activeSessionId: "ol_practice",
|
||||
});
|
||||
const row = `document.querySelector('[data-training-driver="ol_driver"]')`;
|
||||
try {
|
||||
// The menu's Overlay: switches view in place.
|
||||
await navigate("dashboard", "view");
|
||||
await evaluate(`[...document.querySelectorAll(".nav-item")].find((button) => /^Overlay$/.test(button.textContent.trim())).click()`);
|
||||
await waitFor(async () => evaluate(`Boolean(${row})`), "the driver row is a link in the menu's Overlay");
|
||||
await evaluate(`${row}.querySelector("strong").click()`);
|
||||
await waitFor(async () => (await evaluate(`location.search`)).includes("view=training"), "Training stats opened");
|
||||
const search = await evaluate(`location.search`);
|
||||
// Training stats group a person's driver records (one per class) into one profile.
|
||||
assert.equal(new URLSearchParams(search).get("driver"), "legacy:ol driver", "OL Driver's profile is selected");
|
||||
assert.match(search, /class=ol_class/);
|
||||
assert.match(await evaluate(`document.getElementById("view").innerText`), /OL Driver/, "the driver's own stats are shown");
|
||||
console.log("PASS a click on a driver in the Overlay opens that driver's training stats");
|
||||
|
||||
// The stand-alone overlay window stays up and opens a new tab.
|
||||
await navigate("overlay", "view");
|
||||
await waitFor(async () => evaluate(`Boolean(${row})`), "the driver row is a link in the overlay window");
|
||||
await evaluate(`window.__opened = []; window.open = (url, target) => { window.__opened.push([url, target]); return null; }; ${row}.click()`);
|
||||
const [openedUrl, target] = (await evaluate(`window.__opened`))[0];
|
||||
assert.equal(target, "_blank");
|
||||
assert.match(openedUrl, /view=training&driver=ol_driver&class=ol_class/);
|
||||
assert.equal(await evaluate(`new URLSearchParams(location.search).get("view")`), "overlay", "the overlay window stays on the overlay");
|
||||
console.log("PASS the stand-alone overlay window opens the driver's stats in a new tab");
|
||||
|
||||
// The public overlay: no links.
|
||||
await send("Page.navigate", { url: base + "/public-overlay/leaderboard" });
|
||||
await waitFor(async () => evaluate(`Boolean(document.querySelector('[data-overlay-competitor="driver_ol_driver"]'))`), "public overlay shows the driver");
|
||||
assert.equal(await evaluate(`Boolean(document.querySelector("[data-training-driver]"))`), false, "no training links on the public overlay");
|
||||
console.log("PASS the public overlay has no links to drivers' stats");
|
||||
} finally {
|
||||
const current = await savedState();
|
||||
await patchState({ sessions: current.sessions.map((session) => (session.id === "ol_practice" ? { ...session, status: "finished", endedAt: Date.now() } : session)), activeSessionId: "" });
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { runTrackLayoutsSmoke } from "./browser_track_layouts.js";
|
||||
import { runPrologueSmoke } from "./browser_prologue.js";
|
||||
import { runPracticeResetSmoke } from "./browser_practice_reset.js";
|
||||
import { runSuspectLapsSmoke } from "./browser_suspect_laps.js";
|
||||
import { runOverlayDriverLinkSmoke } from "./browser_overlay_driver_link.js";
|
||||
import { runCorrectionsScopeSmoke } from "./browser_corrections_scope.js";
|
||||
import { runDriversPageSmoke } from "./browser_drivers_page.js";
|
||||
import { runSeriesSmoke } from "./browser_series.js";
|
||||
@@ -163,6 +164,7 @@ try {
|
||||
await runPrologueSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs });
|
||||
await runPracticeResetSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs });
|
||||
await runSuspectLapsSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs });
|
||||
await runOverlayDriverLinkSmoke({ evaluate, navigate, savedState, waitFor, base, send });
|
||||
await runCorrectionsScopeSmoke({ evaluate, navigate, savedState, waitFor, base });
|
||||
await runDriversPageSmoke({ evaluate, navigate, savedState, waitFor, base });
|
||||
await runSeriesSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs });
|
||||
|
||||
Reference in new issue
Block a user