Round dashboards: one face at a time, a face per widget type, paged by swipe, dots and keys; slider reading; face row in the editor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8b8cb5cda9
commit
84071ee106
@@ -252,7 +252,11 @@ PANEL_WIDGETS = [
|
||||
{
|
||||
"id": "w_slider",
|
||||
"type": "slider",
|
||||
"config": {"target": "demo.slider", "dtype": "float"},
|
||||
"config": {
|
||||
"target": "demo.slider",
|
||||
"dtype": "float",
|
||||
"reading": {"message": "demo.slider_reading", "dtype": "float"},
|
||||
},
|
||||
},
|
||||
{"id": "w_input", "type": "input", "config": {"target": "demo.input"}},
|
||||
{"id": "w_dropdown", "type": "dropdown", "config": {"target": "demo.dropdown"}},
|
||||
@@ -333,7 +337,12 @@ def test_a_panel_speaks_only_its_own_widgets_messages(
|
||||
), target
|
||||
|
||||
# And reads the history of everything its widgets bind to.
|
||||
for name in ("demo.temperature", "demo.switch_state", "demo.query_series"):
|
||||
for name in (
|
||||
"demo.temperature",
|
||||
"demo.switch_state",
|
||||
"demo.slider_reading",
|
||||
"demo.query_series",
|
||||
):
|
||||
assert (
|
||||
client.get(f"{messages}/{name}/history", headers=panel_headers).status_code
|
||||
== 200
|
||||
|
||||
@@ -445,25 +445,28 @@ def test_a_dashboard_is_cut_into_a_sane_number_of_columns():
|
||||
DashboardDef(name="house", columns=columns)
|
||||
|
||||
|
||||
def test_a_round_dashboard_is_square_and_rings_one_of_its_own_widgets():
|
||||
dial = WidgetDef(id="dial", type="slider", layout={"lg": Placement(x=1)})
|
||||
stat = WidgetDef(id="stat", type="stat")
|
||||
|
||||
knob = DashboardDef(
|
||||
name="knob",
|
||||
shape="round",
|
||||
canvas_width=360,
|
||||
canvas_height=200,
|
||||
ring="dial",
|
||||
widgets=[dial, stat],
|
||||
)
|
||||
def test_a_round_dashboard_is_square():
|
||||
knob = DashboardDef(name="knob", shape="round", canvas_width=360, canvas_height=200)
|
||||
|
||||
assert knob.canvas_height == 360
|
||||
# Drawn along the edge, so the outline of the grid leaves it out.
|
||||
assert [shape.type for shape in knob.footprint] == ["stat"]
|
||||
for shape, ring in (("rect", "dial"), ("round", "gone"), ("round", "stat")):
|
||||
with pytest.raises(ValueError):
|
||||
DashboardDef(name="knob", shape=shape, ring=ring, widgets=[dial, stat])
|
||||
|
||||
|
||||
def test_a_slider_reads_what_it_shows_beside_its_value():
|
||||
"""The room's temperature beside its setpoint: read, and held to numbers."""
|
||||
setpoint = {"target": "house.setpoint", "dtype": "float"}
|
||||
slider = WidgetDef(
|
||||
id="target",
|
||||
type="slider",
|
||||
config={**setpoint, "reading": {"message": "house.indoor", "dtype": "float"}},
|
||||
)
|
||||
|
||||
assert slider.messages == ["house.indoor"]
|
||||
with pytest.raises(ValueError):
|
||||
WidgetDef(
|
||||
id="target",
|
||||
type="slider",
|
||||
config={**setpoint, "reading": {"message": "house.mode", "dtype": "str"}},
|
||||
)
|
||||
|
||||
|
||||
def test_a_setting_refuses_a_message_it_cannot_carry():
|
||||
|
||||
Reference in New Issue
Block a user