Buckets:

download
raw
1.75 kB
"""Dashboard HTML rendering with runtime config injection."""
from __future__ import annotations
import json
from pathlib import Path
_DASHBOARD_HTML = Path(__file__).parent / "dashboard.html"
def render_dashboard_html(
facility_name: str = "",
pv_strip_prefix: str = "",
telemetry_url: str = "",
) -> str:
"""Read dashboard.html and inject runtime config via the OSPREY_CONFIG_PLACEHOLDER sentinel.
The HTML carries a ``/* OSPREY_CONFIG_PLACEHOLDER */`` comment that this replaces
with a ``window.__OSPREY_CONFIG__ = {...};`` literal. If the sentinel is absent,
the HTML is returned unchanged — the replacement is a harmless no-op.
Args:
facility_name: Facility display name injected into the dashboard config.
pv_strip_prefix: PV prefix the dashboard strips when rendering channel names.
telemetry_url: Browser-reachable base URL of the telemetry store (e.g.
``http://localhost:5080``), or ``""`` when the store is not deployed
or agent telemetry is off. Must be the address the OPERATOR's browser
can reach — not the compose DNS name the containers use — because the
dashboard renders it as a link the browser follows. Empty disables the
dashboard's per-run telemetry link entirely.
Returns:
The dashboard HTML with the runtime config injected where the sentinel is present.
"""
html = _DASHBOARD_HTML.read_text()
config = json.dumps(
{
"facility_name": facility_name,
"pv_strip_prefix": pv_strip_prefix,
"telemetry_url": telemetry_url,
}
)
return html.replace("/* OSPREY_CONFIG_PLACEHOLDER */", f"window.__OSPREY_CONFIG__ = {config};")

Xet Storage Details

Size:
1.75 kB
·
Xet hash:
96d734a13ac93fe59bc28e0c1454f33d093bef4f8a8a51a8899de3834d3dadfb

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.