feat: add per-device custom Chrome production URL override

- Device model: add custom_chrome_url nullable column
- API: GET /api/wmt/config/<mac> 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
This commit is contained in:
ske087
2026-05-25 16:23:29 +03:00
parent e38bf07ef2
commit c1255bdb81
4 changed files with 33 additions and 2 deletions
+2 -2
View File
@@ -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,
+1
View File
@@ -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")
+2
View File
@@ -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')
+28
View File
@@ -72,6 +72,34 @@
</select>
</div>
<hr>
<h6 class="text-muted mb-1">Chrome Launch Production URL Override</h6>
<p class="text-muted small mb-3">
Leave blank to use the global default URL configured in
<a href="{{ url_for('wmt_web.settings') }}" target="_blank">WMT Settings</a>.
Fill in only if this device needs a different production page.
</p>
<div class="mb-3">
<label class="form-label fw-semibold">Custom Production URL
<small class="text-muted fw-normal">(device-specific override)</small>
</label>
<input type="url" name="custom_chrome_url" class="form-control"
value="{{ device.custom_chrome_url or '' if device else '' }}"
placeholder="Leave blank to use global default">
{% if device and device.custom_chrome_url %}
<div class="form-text text-warning">
<i class="fas fa-exclamation-triangle me-1"></i>
This device uses a custom URL instead of the global default.
Clear the field to revert to the global setting.
</div>
{% else %}
<div class="form-text text-success">
<i class="fas fa-check-circle me-1"></i>
Using global default production URL.
</div>
{% endif %}
</div>
{% if device %}
<div class="alert alert-light border small mb-4">
<strong>Last seen:</strong>