From c1255bdb81d09205111be954b0bb52325d42b28d Mon Sep 17 00:00:00 2001 From: ske087 Date: Mon, 25 May 2026 16:23:29 +0300 Subject: [PATCH] feat: add per-device custom Chrome production URL override - Device model: add custom_chrome_url nullable column - API: GET /api/wmt/config/ returns device custom_chrome_url when set, falls back to WMTGlobalConfig.chrome_url for all other devices - Web: device_edit POST saves/clears custom_chrome_url from form - Template: wmt/device_form.html adds Chrome URL override section with clear status indicator (using global vs custom URL) - DB: ALTER TABLE devices ADD COLUMN custom_chrome_url VARCHAR(500) applied --- app/api/wmt.py | 4 ++-- app/models/__init__.py | 1 + app/web/wmt.py | 2 ++ templates/wmt/device_form.html | 28 ++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/api/wmt.py b/app/api/wmt.py index 339c75a..ee60fdb 100644 --- a/app/api/wmt.py +++ b/app/api/wmt.py @@ -98,8 +98,8 @@ def get_device_config(mac_address): _, device_ts, latest_ts = _latest_config_ts(session, mac) payload = { - # Global settings - 'chrome_url': global_cfg.chrome_url, + # Global settings (device custom_chrome_url overrides global chrome_url if set) + 'chrome_url': (device.custom_chrome_url if device and device.custom_chrome_url else global_cfg.chrome_url), 'chrome_local_url': global_cfg.chrome_local_url or '', 'chrome_insecure_origin': global_cfg.chrome_insecure_origin, 'card_api_base_url': global_cfg.card_api_base_url, diff --git a/app/models/__init__.py b/app/models/__init__.py index 47ac946..f46fcd1 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -52,6 +52,7 @@ class Device(Base): config_synced_at = Column(DateTime) # set by server when client confirms in-sync info_reviewed_at = Column(DateTime, default=lambda: datetime(1970, 1, 1)) card_presence = Column(String(10), default='enable') + custom_chrome_url = Column(String(500), nullable=True) # per-device production URL override (overrides WMTGlobalConfig.chrome_url) # Relationships logs = relationship("LogEntry", back_populates="device") diff --git a/app/web/wmt.py b/app/web/wmt.py index 5312f72..08414c8 100644 --- a/app/web/wmt.py +++ b/app/web/wmt.py @@ -299,6 +299,8 @@ def device_edit(device_id): device.location = request.form.get('location', '').strip() or None device.card_presence = request.form.get('card_presence', 'enable') device.description = request.form.get('notes', '').strip() or None + custom_url = request.form.get('custom_chrome_url', '').strip() + device.custom_chrome_url = custom_url if custom_url else None device.config_updated_at = datetime.utcnow() device.info_reviewed_at = datetime.utcnow() flash('Device updated.', 'success') diff --git a/templates/wmt/device_form.html b/templates/wmt/device_form.html index e9514de..de5aa46 100644 --- a/templates/wmt/device_form.html +++ b/templates/wmt/device_form.html @@ -72,6 +72,34 @@ +
+
Chrome Launch – Production URL Override
+

+ Leave blank to use the global default URL configured in + WMT Settings. + Fill in only if this device needs a different production page. +

+
+ + + {% if device and device.custom_chrome_url %} +
+ + This device uses a custom URL instead of the global default. + Clear the field to revert to the global setting. +
+ {% else %} +
+ + Using global default production URL. +
+ {% endif %} +
+ {% if device %}
Last seen: