fix: scale dot white+glow, kiosk reconfigure fallback, live weight in settings

style.css:
- Connected dot: white fill + green border/glow (was green-on-green, invisible)

app.js:
- _kioskReconfigureScale(): show #kiosk-needs-update-notice + toast when
  kiosk APK is too old and reconfigureScale() method is missing
- _scaleUpdateStatus(): show/hide #scale-live-diag panel, update device + battery
- _scaleOnMessage weight: update #scale-diag-weight in real time
- _scaleOnMessage status: update #scale-diag-proto with BLE protocol

index.html:
- #kiosk-needs-update-notice: amber warning + download link inside kiosk panel
- #scale-live-diag: device name, battery, live weight readout, reconnect info
- CSS cache bump ?v=20260506d
This commit is contained in:
dadaloop82
2026-05-06 14:07:29 +00:00
parent e002cc4483
commit 891733aa8c
3 changed files with 53 additions and 4 deletions
+2 -2
View File
@@ -308,8 +308,8 @@ body {
transition: background 0.4s, box-shadow 0.4s, border-color 0.4s;
pointer-events: none;
}
/* Connected: bright green fill + white border — visible on both dark and light backgrounds */
.scale-status-connected .scale-status-dot { background: #4ade80; border-color: rgba(255,255,255,0.9); box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 0 6px #4ade80bb; }
/* Connected: white fill + bright-green border ring — clearly visible on any dark/green bg */
.scale-status-connected .scale-status-dot { background: #ffffff; border-color: #4ade80; box-shadow: 0 0 0 1px rgba(0,0,0,0.25), 0 0 8px #4ade80cc, 0 0 2px #fff; }
.scale-status-connected .scale-icon-emoji { filter: none; opacity: 1; }
.scale-status-searching .scale-status-dot { background: #f59e0b; border-color: rgba(0,0,0,0.35); animation: scaleStatusPulse 1.4s infinite; }
.scale-status-searching .scale-icon-emoji { filter: none; opacity: 0.85; }
+28 -1
View File
@@ -290,6 +290,11 @@ function _scaleOnMessage(msg) {
_scaleDevice = msg.device || null;
_scaleBattery = msg.battery ?? null;
_scaleUpdateStatus(_scaleConnected ? 'connected' : 'searching');
// Update protocol info in settings diagnostic
if (msg.protocol) {
const protoEl = document.getElementById('scale-diag-proto');
if (protoEl) protoEl.textContent = `📡 ${msg.protocol}`;
}
// Refresh all scale UI elements immediately so buttons/live-box appear
// without requiring a manual page refresh
updateScaleReadButtons();
@@ -322,6 +327,9 @@ function _scaleOnMessage(msg) {
// Also update edit-form inline scale reading if visible
const editLive = document.getElementById('edit-scale-reading');
if (editLive) editLive.textContent = `${msg.value} ${msg.unit || 'kg'}${liveMsg.stable ? ' ✓' : ' …'}`;
// Update settings diagnostic live weight
const diagW = document.getElementById('scale-diag-weight');
if (diagW) diagW.textContent = `${parseFloat(msg.value).toFixed(1)} ${msg.unit || 'g'}`;
// Always update the persistent live box on the use page (every message, stable or not)
_scaleUpdateLiveBox(liveMsg);
// If weight is NOT stable: stop any running timer/bar but keep the sentinel value.
@@ -803,6 +811,20 @@ function _scaleUpdateStatus(state) {
error: `⚖️ ${t('scale.status_error')}`,
};
el.title = labels[state] || '';
// Update settings live-diagnostic panel
const diag = document.getElementById('scale-live-diag');
if (!diag) return;
diag.style.display = state === 'connected' ? '' : 'none';
if (state === 'connected') {
const devEl = document.getElementById('scale-diag-device');
const batEl = document.getElementById('scale-diag-battery');
if (devEl) devEl.textContent = _scaleDevice || 'Dispositivo sconosciuto';
if (batEl) batEl.textContent = _scaleBattery != null ? `🔋 ${_scaleBattery}%` : '';
const weightEl = document.getElementById('scale-diag-weight');
if (weightEl && _scaleLatestWeight) {
weightEl.textContent = `${parseFloat(_scaleLatestWeight.value).toFixed(1)} ${_scaleLatestWeight.unit || 'g'}`;
}
}
}
/**
@@ -2038,7 +2060,12 @@ async function loadSettingsUI() {
function _kioskReconfigureScale() {
if (typeof _kioskBridge === 'undefined') return;
if (typeof _kioskBridge.reconfigureScale === 'function') {
_kioskBridge.reconfigureScale();
try { _kioskBridge.reconfigureScale(); } catch(e) {}
} else {
// Kiosk APK is outdated — show update notice
const notice = document.getElementById('kiosk-needs-update-notice');
if (notice) notice.style.display = '';
showToast('⚠️ Aggiorna il kiosk per usare questa funzione', 'warning');
}
}