From eb8f6668231cc9e3d8cc52b0807720215259b633 Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Sat, 22 Feb 2025 09:58:16 +0100 Subject: [PATCH] ui: Parameterize the ui refresh interval and the interval for updating system states --- dashboard/ui.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dashboard/ui.py b/dashboard/ui.py index 1473368..6313b3a 100644 --- a/dashboard/ui.py +++ b/dashboard/ui.py @@ -7,7 +7,11 @@ from .thing import System, SystemState from nicegui import ui -def init_ui(systems: List[System]): +def init_ui( + systems: List[System], + ui_refresh_interval: float = 2, # in seconds + system_state_update_interval: float = 15 # in seconds +): @ui.refreshable def systems_list(): @@ -42,7 +46,7 @@ def init_ui(systems: List[System]): for t in systems: t.update_state() - ui.timer(15, callback=update_states) - ui.timer(2, systems_list.refresh) + ui.timer(system_state_update_interval, callback=update_states) + ui.timer(ui_refresh_interval, systems_list.refresh) dark = ui.dark_mode(None) # auto