Panel I/O: PanelDef.io ports, scoped publish and upload, I/O section in the Panels dialog
This commit is contained in:
@@ -112,10 +112,15 @@ def _panel_writable(panel_id: str, request: Request) -> set[str]:
|
||||
panel displays and another controls stays writable, because the unlocked
|
||||
one is what entitles the screen to it. Reads are untouched — read-only is
|
||||
not blind, and a locked dashboard has to keep drawing live data.
|
||||
|
||||
The panel's own ``in`` ports are added outside the lock: it covers the
|
||||
controls on a dashboard, not the sensors on the device. Its ``out`` ports
|
||||
are read, not written, unless a widget targets them too.
|
||||
"""
|
||||
store: DashboardStore | None = getattr(request.app.state, "dashboard_store", None)
|
||||
if store is None:
|
||||
return set()
|
||||
writable = panels.io_in(panel_id)
|
||||
defns = panels.dashboards_for(panel_id, store)
|
||||
bound = sorted(
|
||||
{s.message for d in defns if (s := d.settings.get("locked")) and s.message}
|
||||
@@ -124,7 +129,6 @@ def _panel_writable(panel_id: str, request: Request) -> set[str]:
|
||||
request.app.state, "flow_controller", None
|
||||
)
|
||||
live = controller.state.get_present(bound) if bound and controller else {}
|
||||
writable: set[str] = set()
|
||||
for defn in defns:
|
||||
writable |= (
|
||||
panels.requests_of(defn)
|
||||
@@ -162,8 +166,10 @@ def _panel_may(payload: dict[str, Any], request: Request) -> None:
|
||||
A panel credential names the account that approved the pairing, so without
|
||||
this it would be that person's session hanging on a wall. What a panel
|
||||
genuinely needs is small and worth writing out: the dashboards it was
|
||||
assigned, its own definition, the messages its own widgets bind to, and the
|
||||
bytes those messages currently point at, for a tile drawing a camera frame.
|
||||
assigned, its own definition, the messages its own widgets and ports bind
|
||||
to, and the bytes those messages currently point at, for a tile drawing a
|
||||
camera frame — plus an upload named after one of its ``in`` ports, for a
|
||||
microphone whose recording is the value it publishes.
|
||||
|
||||
Publishing is in the list because a panel cannot be strictly read-only — a
|
||||
control on a panel is the point of putting one there, and a querying chart
|
||||
@@ -223,6 +229,10 @@ def _panel_may(payload: dict[str, Any], request: Request) -> None:
|
||||
# off an old run because it happens to know the digest.
|
||||
digest = unquote(path[len(f"{api}/artifacts/") :])
|
||||
allowed = "/" not in digest and digest in _panel_digests(panel.id, request)
|
||||
elif method == "PUT" and path == f"{api}/artifacts":
|
||||
# What the device's own sensor recorded — a microphone's utterance —
|
||||
# uploaded under the ``in`` message it is about to publish it to.
|
||||
allowed = request.query_params.get("name", "") in panels.io_in(panel.id)
|
||||
|
||||
if not allowed:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user