From 6fcbcb7d4f7c782a30ea3ed3f9d2d2d5f8f84047 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Thu, 12 Mar 2026 20:14:25 +0100 Subject: [PATCH] fix(ui): fix [object Object] in device info/stats, soften search button color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stats: battery fallback used ${bat} on an object — now uses battery_mv from core stats when dedicated get_bat returns null - Info: remove old v1 regex JSON parsing, use v2 dict response directly - Search FAB: change from bright orange to muted teal Co-Authored-By: Claude Opus 4.6 --- app/static/css/style.css | 4 ++-- app/static/js/app.js | 23 +++++++---------------- app/static/js/sw.js | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/app/static/css/style.css b/app/static/css/style.css index 999cb5e..52f5d2f 100644 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -1240,9 +1240,9 @@ main { color: white; } -/* Search FAB button (orange gradient) */ +/* Search FAB button (muted teal) */ .fab-search { - background: linear-gradient(135deg, #fd7e14 0%, #e8590c 100%); + background: linear-gradient(135deg, #5fa8a0 0%, #4a8f88 100%); color: white; } diff --git a/app/static/js/app.js b/app/static/js/app.js index 49302cb..42b5c5c 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -1303,19 +1303,10 @@ async function loadDeviceInfo() { return; } - // Parse JSON from the info string - let info; - try { - // Extract JSON part (skip the header lines like "MarWoj|*...") - const jsonMatch = data.info.match(/\{[\s\S]*\}/); - info = jsonMatch ? JSON.parse(jsonMatch[0]) : null; - } catch (e) { - container.innerHTML = `
${escapeHtml(data.info)}
`; - return; - } - - if (!info) { - container.innerHTML = `
${escapeHtml(data.info)}
`; + // API returns info as a dict directly (v2 DeviceManager) + const info = data.info; + if (!info || typeof info !== 'object') { + container.innerHTML = `
No device info available
`; return; } @@ -1401,11 +1392,11 @@ async function loadDeviceStats() { const bat = data.battery || {}; let html = ''; - // Battery + // Battery (from dedicated get_bat or from core stats) if (bat && typeof bat === 'object' && bat.voltage) { html += ``; - } else if (bat) { - html += ``; + } else if (stats.core && stats.core.battery_mv) { + html += ``; } // Core stats diff --git a/app/static/js/sw.js b/app/static/js/sw.js index 0f9c7f6..96d1a0e 100644 --- a/app/static/js/sw.js +++ b/app/static/js/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'mc-webui-v7'; +const CACHE_NAME = 'mc-webui-v8'; const ASSETS_TO_CACHE = [ '/', '/static/css/style.css',
Battery${bat.voltage}V
Battery${bat}
Battery${(stats.core.battery_mv / 1000).toFixed(2)}V