Add card_presence support: app.py (load/sync/log/RFID+LED gating), config.py GUI dropdown
This commit is contained in:
24
config.py
24
config.py
@@ -47,6 +47,7 @@ def _read_config():
|
||||
"hostname": p.get("device", "hostname", fallback=socket.gethostname()),
|
||||
"device_ip": p.get("device", "ip", fallback=_get_local_ip()),
|
||||
"location": p.get("device", "location", fallback=""),
|
||||
"card_presence": p.get("device", "card_presence", fallback="enable"),
|
||||
"info_reviewed_at":p.get("device", "info_reviewed_at", fallback="1970-01-01T00:00:00"),
|
||||
# preserve other sections verbatim
|
||||
"chrome_url": p.get("chrome", "chrome_url", fallback=""),
|
||||
@@ -84,6 +85,7 @@ def _write_config(cfg):
|
||||
p.set("device", "hostname", cfg["hostname"])
|
||||
p.set("device", "ip", cfg["device_ip"])
|
||||
p.set("device", "location", cfg.get("location", ""))
|
||||
p.set("device", "card_presence", cfg.get("card_presence", "enable"))
|
||||
p.set("device", "info_reviewed_at", cfg.get("info_reviewed_at", "1970-01-01T00:00:00"))
|
||||
|
||||
# Bump last_synced → tells app.py local config is newer → push update request
|
||||
@@ -176,6 +178,12 @@ def main():
|
||||
size=(INPUT_W, 1),
|
||||
tooltip="Physical location, e.g. Floor 2, Line A, Masa-01")],
|
||||
|
||||
[sg.Text("Card Presence", size=(LABEL_W, 1)),
|
||||
sg.Combo(["enable", "disable"],
|
||||
default_value=cfg.get("card_presence", "enable"),
|
||||
key="-CARD_PRESENCE-", size=(INPUT_W - 2, 1), readonly=True,
|
||||
tooltip="enable = card reader active; disable = no card reader")],
|
||||
|
||||
# ── Read-only system info ─────────────────────────────────
|
||||
[sg.HorizontalSeparator()],
|
||||
[sg.Text("── System Info (read-only) ──", font=("Arial Bold", 13),
|
||||
@@ -218,9 +226,10 @@ def main():
|
||||
break
|
||||
|
||||
if event == "-SAVE-":
|
||||
new_hostname = values["-HOSTNAME-"].strip()
|
||||
new_masa = values["-MASA-"].strip()
|
||||
new_location = values["-LOCATION-"].strip()
|
||||
new_hostname = values["-HOSTNAME-"].strip()
|
||||
new_masa = values["-MASA-"].strip()
|
||||
new_location = values["-LOCATION-"].strip()
|
||||
new_card_presence = values["-CARD_PRESENCE-"]
|
||||
|
||||
if not new_hostname or not new_masa:
|
||||
_show_result("Validation Error",
|
||||
@@ -228,10 +237,11 @@ def main():
|
||||
continue
|
||||
|
||||
# Update cfg dict with edited values
|
||||
cfg["hostname"] = new_hostname
|
||||
cfg["device_name"] = new_masa
|
||||
cfg["location"] = new_location
|
||||
cfg["device_ip"] = local_ip
|
||||
cfg["hostname"] = new_hostname
|
||||
cfg["device_name"] = new_masa
|
||||
cfg["location"] = new_location
|
||||
cfg["card_presence"] = new_card_presence
|
||||
cfg["device_ip"] = local_ip
|
||||
|
||||
# 1. Save config.txt (bumps last_synced → triggers server update request)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user