fix: restart periodic keys on device page switch, render display output in UI grid

- daemon.go: call stopPeriodicKeys/startPeriodicKeys after page switch
  from device gesture and auto-switch (was missing, causing goroutines
  to never restart for the correct page)
- app.js: forward display output background to /api/render preview URL
- index.html: show preview image and text from display output when key
  has no configured background/icon/label
This commit is contained in:
totmin
2026-06-17 11:12:00 +07:00
parent 5bf8f5d3b0
commit 9b55c6618c
3 changed files with 22 additions and 12 deletions
+13 -5
View File
@@ -116,7 +116,7 @@ document.addEventListener('alpine:init', () => {
syncSettings() {
this.settingsForm = {
brightness: this.config.devices?.[0]?.brightness || 75,
brightness: this.getDeviceConfig(this.activeDeckSerial)?.brightness ?? 75,
font: this.config.font || 'medium',
screensaver_enabled: this.config.screensaver?.enabled || false,
screensaver_idle: this.config.screensaver?.idle_seconds || 30,
@@ -141,6 +141,10 @@ document.addEventListener('alpine:init', () => {
|| { keys_x: 5, keys_y: 3, num_keys: 15 }
},
getDeviceConfig(serial) {
return this.config.devices?.find(d => d.serial === serial)
},
// ── Grid ──
get gridKeys() {
const page = this.currentPage
@@ -183,7 +187,8 @@ document.addEventListener('alpine:init', () => {
if (label) url += `&label=${encodeURIComponent(label)}`
if (k.icon_scale != null) url += `&icon_scale=${k.icon_scale}`
if (k.font_size != null) url += `&font_size=${k.font_size}`
if (k.background) url += `&background=${encodeURIComponent(k.background)}`
const bg = dout?.background || k.background
if (bg) url += `&background=${encodeURIComponent(bg)}`
return url
},
@@ -584,10 +589,13 @@ document.addEventListener('alpine:init', () => {
// ── Settings ──
async saveSettings() {
if (!this.config.devices || this.config.devices.length === 0) {
this.config.devices = [{ serial: '', brightness: 75 }]
if (!this.config.devices) this.config.devices = []
let dev = this.config.devices.find(d => d.serial === this.activeDeckSerial)
if (!dev) {
dev = { serial: this.activeDeckSerial, brightness: 75 }
this.config.devices.push(dev)
}
this.config.devices[0].brightness = parseInt(this.settingsForm.brightness)
dev.brightness = parseInt(this.settingsForm.brightness)
this.config.font = this.settingsForm.font || 'medium'
this.config.screensaver = {
enabled: this.settingsForm.screensaver_enabled,