Page redesign with global time range and Midnight Train branding - #2
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR redesigns the dashboard UI around a single global time-range selector and updates the app’s “Midnight Train” branding, ensuring stats, charts, and event listings all query consistently within the selected range.
Changes:
- Added a global time range selector (presets + custom) and wired it into stats, chart, and event query panels.
- Updated API calls to support time-range filtering for stats and to fetch the latest confirmed train by default.
- Refreshed branding (header icon/title/tagline, footer links/credits) and updated favicon usage.
Reviewed changes
Copilot reviewed 10 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Removes obsolete rolling-window stats fields from the Stats type. |
| src/components/TimeRangeQuery.tsx | Refactors to be driven by global start/end props and auto-fetch on change. |
| src/components/StatsPanel.tsx | Adds start/end props and fetches time-scoped stats; hardens dB parsing. |
| src/components/LatestTrain.tsx | Switches to “latest confirmed” behavior and updates panel title. |
| src/components/GlobalTimeRange.tsx | New global time-range selector component (presets + custom apply). |
| src/components/DetectionChart.tsx | Makes chart time-range-driven and improves tick generation/formatting. |
| src/App.tsx | Integrates global time range, updates header branding, adds footer. |
| src/App.css | Adds styles for new branding/footer/global range UI and adjusts layout. |
| src/api.ts | Extends stats query params and changes latest endpoint behavior. |
| public/icons.svg | Removes unused icon sprite asset. |
| public/favicon.svg | Removes old SVG favicon asset. |
| index.html | Switches favicon link to train-icon.png. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+61
| function handlePreset(preset: Preset) { | ||
| if (preset === 'custom') { | ||
| onChange({ preset: 'custom', start: undefined, end: undefined }); | ||
| } else { | ||
| onChange(makePresetRange(preset)); | ||
| } | ||
| } |
Owner
Author
There was a problem hiding this comment.
made a change to delay setting values for "Custom" until "Apply" is clicked
Comment on lines
+412
to
+416
| .preset-btn.active { | ||
| background: var(--accent); | ||
| border-color: var(--accent); | ||
| color: #fff; | ||
| } |
Comment on lines
16
to
20
| export async function fetchLatest(): Promise<Detection> { | ||
| const res = await fetch(`${BASE_URL}/api/detections/latest?confirmed_only=true`); | ||
| if (res.status === 404) throw new Error('No detections found'); | ||
| if (!res.ok) throw new Error('Failed to fetch latest detection'); | ||
| return res.json() as Promise<Detection>; |
Comment on lines
5
to
7
| <link rel="icon" type="image/png" href="/train-icon.png" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>train-detection-app</title> |
Comment on lines
+55
to
+62
| function handlePreset(preset: Preset) { | ||
| setCustomError(null); | ||
| if (preset === 'custom') { | ||
| onChange({ ...value, preset: 'custom' }); | ||
| } else { | ||
| onChange(makePresetRange(preset)); | ||
| } | ||
| } |
Comment on lines
+178
to
+186
| const endMs = end ? new Date(end).getTime() : Date.now(); | ||
| const startMs = start ? new Date(start).getTime() : undefined; | ||
| const dataMinMs = detections.length > 0 | ||
| ? detections.reduce((min, d) => Math.min(min, new Date(d.timestamp).getTime()), Infinity) | ||
| : undefined; | ||
| const effectiveStartMs = startMs ?? dataMinMs; | ||
| const rangeDays = effectiveStartMs !== undefined ? (endMs - effectiveStartMs) / (24 * 60 * 60 * 1000) : 365; | ||
| const ticks = effectiveStartMs !== undefined ? generateTicks(effectiveStartMs, endMs, rangeDays) : undefined; | ||
| const tickFormatter = (ms: number) => formatXTick(ms, rangeDays); |
Comment on lines
+98
to
+104
| <button | ||
| key={p.preset} | ||
| className={`range-btn${activePreset === p.preset ? ' active' : ''}`} | ||
| onClick={() => handlePreset(p.preset)} | ||
| > | ||
| {p.label} | ||
| </button> |
Comment on lines
+51
to
+52
| <StatCard label="Avg dB" value={isNaN(parseFloat(stats.avg_decibels)) ? '0.0 dB' : `${parseFloat(stats.avg_decibels).toFixed(1)} dB`} /> | ||
| <StatCard label="Max dB" value={isNaN(parseFloat(stats.max_decibels)) ? '0.0 dB' : `${parseFloat(stats.max_decibels).toFixed(1)} dB`} /> |
Comment on lines
+65
to
+69
| const interval = 48 * 60 * 60 * 1000; | ||
| while (t <= endMs) { if (t >= startMs) ticks.push(t); t += interval; } | ||
| } | ||
|
|
||
| return ticks; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesigns the dashboard UI around a single global time-range selector and updates the app’s “Midnight Train” branding, ensuring stats, charts, and event listings all query consistently within the selected range.
Changes: