feat: Overview live-mode-only NRLs + split locations by type
Two Overview improvements for projects that mix vibration + sound: - Live monitoring now includes only live-mode (connected) NRLs. connection_mode lives in the location's metadata JSON (default "connected"); offline/manual NRLs are excluded, and since the section hides when the list is empty, it disappears entirely when no NRL is a live SLM. - The Overview location list is split into separate "Vibration Locations" and "NRLs" sections (driven by enabled modules) instead of one mixed list. Single-module projects still show just their one section. Live-chip repaint listener updated for the per-type list ids. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1135,6 +1135,7 @@ async def get_project_live_stats(project_id: str, db: Session = Depends(get_db))
|
||||
import os
|
||||
import asyncio
|
||||
import httpx
|
||||
import json as _json
|
||||
|
||||
project = db.query(Project).filter_by(id=project_id).first()
|
||||
if not project:
|
||||
@@ -1152,6 +1153,18 @@ async def get_project_live_stats(project_id: str, db: Session = Depends(get_db))
|
||||
.all()
|
||||
)
|
||||
|
||||
# Only connected/live-mode NRLs belong in live monitoring. connection_mode
|
||||
# lives in location_metadata JSON (default "connected"); offline/manual NRLs
|
||||
# are excluded. With none connected, the caller gets [] and hides the section.
|
||||
def _is_connected(loc) -> bool:
|
||||
try:
|
||||
meta = _json.loads(loc.location_metadata or "{}")
|
||||
return meta.get("connection_mode", "connected") != "offline"
|
||||
except Exception:
|
||||
return True
|
||||
|
||||
locations = [loc for loc in locations if _is_connected(loc)]
|
||||
|
||||
# Active SLM unit per location (mirrors portal.active_unit_for_location).
|
||||
def _active_unit(loc_id: str):
|
||||
asg = (
|
||||
|
||||
Reference in New Issue
Block a user