Group GUI controls by camera

This commit is contained in:
2026-08-03 01:05:11 +02:00
parent f4ab49e0c8
commit 10d9936d22
7 changed files with 321 additions and 70 deletions
+38 -9
View File
@@ -4,21 +4,25 @@ from frigate_camera_control_bridge.ui import render_page
class DummyAction:
def __init__(self):
self.id = "example_camera_siren"
def __init__(self, suffix="siren", name_key="action.siren", state="ON", kind="dahua_coaxial_io"):
self.id = f"example_camera_{suffix}"
self.platform = "switch"
self.kind = "dahua_coaxial_io"
self.state = "ON"
self.kind = kind
self.state = state
self.auto_off_seconds = 180
self.auto_off_at = 1234567890
self.cfg = {
"name_key": "action.siren",
"requires_ack": True,
"snapshot": {"camera": "example", "frigate_url": "http://frigate.example.test:5000"},
"name_key": name_key,
"camera_name": "Example camera",
"requires_ack": name_key == "action.siren",
"snapshot": {
"camera": "example",
"frigate_url": "http://frigate.example.test:5000",
},
}
def display_name(self, lang):
return "Example siren"
return f"Example {self.id}"
def command_list(self):
return ["on", "off"]
@@ -30,7 +34,32 @@ class UiRenderTest(unittest.TestCase):
self.assertIn('data-auto-off-at="1234567890"', html)
self.assertIn('data-requires-ack="true"', html)
self.assertIn("Example siren", html)
self.assertIn("Example camera", html)
def test_controls_from_same_camera_share_one_card(self):
actions = [
DummyAction("siren", "action.siren"),
DummyAction("white", "action.manual_white", state="OFF"),
DummyAction("red_blue", "action.red_blue", state="OFF"),
]
html = render_page(actions, "en")
self.assertEqual(html.count('class="camera-card"'), 1)
self.assertEqual(html.count('class="action-control"'), 3)
self.assertIn("3 controls", html)
self.assertIn("White light", html)
self.assertIn("Red-blue light", html)
self.assertIn("Siren", html)
def test_all_off_renders_in_topbar_not_camera_grid(self):
action = DummyAction("all_off", "action.all_off", state=None, kind="all_off")
html = render_page([action], "en")
self.assertIn('class="global-strip"', html)
self.assertIn('class="global-action"', html)
self.assertNotIn('class="camera-card"', html)
if __name__ == "__main__":