mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-03-28 17:42:45 +01:00
fix(ui): fix [object Object] in device info/stats, soften search button color
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = `<pre class="mb-0 small">${escapeHtml(data.info)}</pre>`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
container.innerHTML = `<pre class="mb-0 small">${escapeHtml(data.info)}</pre>`;
|
||||
// API returns info as a dict directly (v2 DeviceManager)
|
||||
const info = data.info;
|
||||
if (!info || typeof info !== 'object') {
|
||||
container.innerHTML = `<div class="alert alert-warning mb-0">No device info available</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1401,11 +1392,11 @@ async function loadDeviceStats() {
|
||||
const bat = data.battery || {};
|
||||
let html = '<table class="table table-sm mb-0"><tbody>';
|
||||
|
||||
// Battery
|
||||
// Battery (from dedicated get_bat or from core stats)
|
||||
if (bat && typeof bat === 'object' && bat.voltage) {
|
||||
html += `<tr><td class="text-muted">Battery</td><td>${bat.voltage}V</td></tr>`;
|
||||
} else if (bat) {
|
||||
html += `<tr><td class="text-muted">Battery</td><td>${bat}</td></tr>`;
|
||||
} else if (stats.core && stats.core.battery_mv) {
|
||||
html += `<tr><td class="text-muted">Battery</td><td>${(stats.core.battery_mv / 1000).toFixed(2)}V</td></tr>`;
|
||||
}
|
||||
|
||||
// Core stats
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const CACHE_NAME = 'mc-webui-v7';
|
||||
const CACHE_NAME = 'mc-webui-v8';
|
||||
const ASSETS_TO_CACHE = [
|
||||
'/',
|
||||
'/static/css/style.css',
|
||||
|
||||
Reference in New Issue
Block a user