From a7ac003479e6b046ad3aa003aaffaed439104524 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:32:04 +0800 Subject: [PATCH] Fix: [ALAS] Checkbox cannot be dynamically updated --- module/webui/app.py | 4 ++-- module/webui/utils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/module/webui/app.py b/module/webui/app.py index 594f6c29a..14cac03fb 100644 --- a/module/webui/app.py +++ b/module/webui/app.py @@ -71,6 +71,7 @@ from module.webui.utils import ( parse_pin_value, raise_exception, re_fullmatch, + to_pin_value, ) from module.webui.widgets import ( BinarySwitchButton, @@ -496,11 +497,10 @@ class AlasGUI(Frame): valid.append(k) for set_key, set_value in config_updater.save_callback(k, v): - logger.info([set_key, set_value, pin["_".join(set_key.split("."))]]) modified[set_key] = set_value deep_set(config, set_key, set_value) valid.append(set_key) - pin["_".join(set_key.split("."))] = set_value + pin["_".join(set_key.split("."))] = to_pin_value(set_value) else: modified.pop(k) invalid.append(k) diff --git a/module/webui/utils.py b/module/webui/utils.py index e69907e54..e813c99ac 100644 --- a/module/webui/utils.py +++ b/module/webui/utils.py @@ -427,6 +427,18 @@ def parse_pin_value(val, valuetype: str = None): return v +def to_pin_value(val): + """ + Convert bool to checkbox + """ + if val is True: + return [True] + elif val is False: + return [] + else: + return val + + def login(password): if get_localstorage("password") == str(password): return True