CodingNic

Watch Regions & History

Module Overview

Watch Regions & History 5 min read

Module Overview

Watch Regions & History

Module 2 already built the full watch-regions backend: the schema’s partial unique index, the repo functions that keep “at most one default” honest under concurrent writes, and every route, including the dedicated POST /:id/default endpoint. Module 3 built a screen that shows one region’s live traffic. This module closes the gap between those two things: a real control panel for adding, enabling, and defaulting regions, a map that actually opens on the operator’s chosen default, “look anywhere” panning that falls back to on-demand lookups the moment you drag off the watched area, a fading trail of where the selected aircraft has actually been, and a scrubber that reconstructs any recent moment from the database.

Why This Matters

Nothing here is a bolt-on. The default-region UX, free-pan fallback, trails, and history playback all read from the same position_snapshots and watch_regions tables the first two modules built, and they all extend the same store and the same MapPanel you already have running. By the end of this module the map behaves like the real, finished app: it opens where the operator told it to, it never goes dead just because you panned somewhere the poller isn’t watching, and it can answer “what was happening here ten minutes ago” without a single new table.

What You’ll Learn

  • Growing the store from a single flat aircraft list into per-region positions with an operator-configurable default, and building the watch-regions control panel on top of the repo and routes Module 2 already shipped
  • “Look anywhere” free-pan: a stateless /api/live/:lat/:lon/:radius endpoint, a store slice that tracks when the map has wandered off the watched region, and a one-click way back
  • Fading aircraft trails, reconstructed from position_snapshots for whichever aircraft is currently selected
  • Historical playback: a bounded time-range query over the same table, and a scrubber UI that replays it

Outcome

By the end of this module, the map is the real SKYWATCH map: default-region-aware on load, free to pan anywhere without losing live data, trailing the selected aircraft’s recent track, and able to step back through the last twenty minutes on demand.

Let’s get started.