mirror of
https://github.com/zvx-echo6/central.git
synced 2026-06-10 11:54:37 +02:00
feat(telemetry-separation): dedicated /telemetry tab split from /events by adapter data_class (v0.7.4)
PR #5 of the v0.7.x GUI rework arc. Production code; central-gui restart only (supervisor untouched -- data_class is read only by central-gui per request). - SourceAdapter gains a `data_class` class attr (Literal["event","telemetry"], default "event"). NWIS opts in as "telemetry" (continuous high-volume water gauges); every other adapter stays "event". The /events vs /telemetry split is thus registry-derived from class attrs -- no hardcoded adapter-name lists. - routes.py refactor: `_class_adapter_names(data_class)` and a `data_class` arg on `_adapter_filter_options` scope the flat + domain-grouped chip/legend lists to a class (colors stay keyed to the FULL registry, so an adapter keeps one color across tabs). `_fetch_events` accepts `class_adapters` and adds an `adapter = ANY(...)` condition. Shared `_events_query`, `_events_page(data_class, base_path)` and `_events_rows_fragment(...)` back both tabs; `/events`, `/events/rows`, `/telemetry`, `/telemetry/rows` are thin wrappers. - Templates parameterized with a `base_path` context var (form action, hx-get, hx-push-url header, clear-all redirect, JS BASE_PATH const); the `_events_rows` paginator macro takes `base`. Same templates serve both tabs; nav gains a Telemetry link. - /events.json UNCHANGED -- the cursor path sets no `class_adapters`, so the subject + pagination contract is intact (TestEventsJsonSubject still passes). Adds TestTelemetrySeparation (data_class defaults, registry split 11 event / 1 telemetry, class-scoped filter options, color stability, and the `adapter = ANY(...)` SQL shape incl. the no-class events.json path). Updates the events frontend tests for the base_path-parameterized templates. Full suite: 682 passed, 1 skipped (central and unprivileged zvx, 3x each). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
76d519bcd5
commit
8d193d3266
9 changed files with 247 additions and 92 deletions
|
|
@ -710,6 +710,7 @@ def _events_context(events):
|
|||
return {
|
||||
"events": events,
|
||||
"next_cursor": None,
|
||||
"base_path": "/events",
|
||||
"query_string": "",
|
||||
"pagination": {
|
||||
"total": n, "offset": 0, "limit": 50, "page": 1, "total_pages": 1,
|
||||
|
|
@ -781,13 +782,17 @@ class TestRegistryDrivenAdapterFilter:
|
|||
|
||||
context = mock_templates.TemplateResponse.call_args.kwargs.get("context")
|
||||
|
||||
# The list is exactly the registry, sorted by name (stable), no extras.
|
||||
assert [a["name"] for a in context["adapters"]] == sorted(registry.keys())
|
||||
# v0.7.4: /events shows event-class adapters only (telemetry-class, e.g.
|
||||
# nwis, moved to /telemetry). Registry-derived, sorted, no extras.
|
||||
event_names = sorted(n for n, c in registry.items()
|
||||
if getattr(c, "data_class", "event") == "event")
|
||||
assert [a["name"] for a in context["adapters"]] == event_names
|
||||
# Each entry carries name + display_name (v0.7.1 adds a positional color).
|
||||
by_name = {a["name"]: a for a in context["adapters"]}
|
||||
for cls in registry.values():
|
||||
assert by_name[cls.name]["display_name"] == cls.display_name
|
||||
assert by_name[cls.name]["color"].startswith("#")
|
||||
for name in event_names:
|
||||
cls = registry[name]
|
||||
assert by_name[name]["display_name"] == cls.display_name
|
||||
assert by_name[name]["color"].startswith("#")
|
||||
|
||||
|
||||
class TestPerAdapterRowPartials:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue