merge develop into main

This commit is contained in:
dadaloop82
2026-05-06 13:44:54 +00:00
4 changed files with 56 additions and 7 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: white dot with green glow — always visible regardless of header color */
.scale-status-connected .scale-status-dot { background: #ffffff; border-color: #22c55e; box-shadow: 0 0 6px #22c55e; }
/* 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; }
.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; }
+22
View File
@@ -2018,6 +2018,28 @@ async function loadSettingsUI() {
if (kioskBanner && /; wv\)/.test(navigator.userAgent)) {
kioskBanner.style.display = 'none';
}
// In kiosk mode: replace WebSocket scale config with native BLE reconfigure panel
const isKiosk = typeof _kioskBridge !== 'undefined';
const scaleGwDl = document.getElementById('scale-gateway-download-section');
const scaleWsEl = document.getElementById('scale-websocket-section');
const scaleTestEl = document.getElementById('scale-test-section');
const scaleKiosk = document.getElementById('scale-kiosk-panel');
if (isKiosk) {
if (scaleGwDl) scaleGwDl.style.display = 'none';
if (scaleWsEl) scaleWsEl.style.display = 'none';
if (scaleTestEl) scaleTestEl.style.display = 'none';
if (scaleKiosk) scaleKiosk.style.display = '';
// Auto-set URL to localhost gateway (always port 8765 in kiosk)
if (scaleUrlUiEl && !scaleUrlUiEl.value) scaleUrlUiEl.value = 'ws://localhost:8765';
}
}
// ── Kiosk: trigger native BLE scale reconfiguration wizard ────────────
function _kioskReconfigureScale() {
if (typeof _kioskBridge === 'undefined') return;
if (typeof _kioskBridge.reconfigureScale === 'function') {
_kioskBridge.reconfigureScale();
}
}
// ── Kiosk overlay: X (close) + ↻ (refresh) buttons ───────────────────
@@ -42,6 +42,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.android.material.button.MaterialButton
import it.dadaloop.evershelf.kiosk.scale.GatewayService
import org.json.JSONObject
import java.net.URL
import java.util.Locale
@@ -418,6 +419,23 @@ class KioskActivity : AppCompatActivity() {
fun stopSpeech() { tts?.stop() }
@JavascriptInterface
fun isTtsReady(): String = if (ttsReady) "true" else "false"
@JavascriptInterface
fun reconfigureScale() {
// Stop the BLE gateway service, clear saved scale device,
// and launch SetupActivity directly at step 4 (BLE scan)
runOnUiThread {
GatewayService.stop(this@KioskActivity)
prefs.edit()
.remove("scale_device_address")
.remove("scale_device_name")
.putBoolean("has_scale", false)
.putBoolean("setup_complete", false)
.apply()
val intent = Intent(this@KioskActivity, SetupActivity::class.java)
intent.putExtra("start_step", 4)
startActivity(intent)
}
}
}, "_kioskBridge")
val url = prefs.getString(KEY_URL, "http://evershelf.local") ?: "http://evershelf.local"
+14 -5
View File
@@ -11,7 +11,7 @@
<title>EverShelf</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" href="assets/img/logo/logo_icon.png">
<link rel="stylesheet" href="assets/css/style.css?v=20260506a">
<link rel="stylesheet" href="assets/css/style.css?v=20260506b">
<!-- QuaggaJS for barcode scanning -->
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.8.4/dist/quagga.min.js"></script>
<!-- @xenova/transformers: ES-module bootstrap that exposes a lazy category-classifier as window._categoryPipelinePromise -->
@@ -1034,8 +1034,15 @@
<h4 data-i18n="settings.scale.title">⚖️ Bilancia Smart</h4>
<p class="settings-hint" data-i18n="settings.scale.hint">Collega una bilancia Bluetooth tramite il gateway Android per leggere il peso automaticamente.</p>
<!-- Kiosk-mode panel: replace WebSocket config with native reconfigure button -->
<div id="scale-kiosk-panel" style="display:none;background:rgba(16,185,129,0.07);border:1px solid rgba(16,185,129,0.25);border-radius:10px;padding:14px;margin-bottom:16px">
<p style="margin:0 0 6px;font-weight:600">📡 Bilancia BLE integrata nel Kiosk</p>
<p class="settings-hint" style="margin-bottom:12px">La bilancia è gestita direttamente dal Gateway BLE interno al kiosk. Per abbinare un nuovo dispositivo usa il wizard di configurazione.</p>
<button class="btn btn-secondary full-width" onclick="_kioskReconfigureScale()">🔄 Riconfigura bilancia BLE</button>
</div>
<!-- Download gateway app -->
<div style="background:rgba(124,58,237,0.07);border:1px solid rgba(124,58,237,0.2);border-radius:10px;padding:14px;margin-bottom:16px">
<div id="scale-gateway-download-section" style="background:rgba(124,58,237,0.07);border:1px solid rgba(124,58,237,0.2);border-radius:10px;padding:14px;margin-bottom:16px">
<p style="margin:0 0 4px;font-weight:600">📱 EverShelf Scale Gateway</p>
<p class="settings-hint" style="margin-bottom:10px" data-i18n="settings.scale.download_hint">App Android che fa da ponte tra la bilancia BLE e questo sito.</p>
<a href="https://github.com/dadaloop82/EverShelf/releases/latest/download/evershelf-scale-gateway.apk" target="_blank" rel="noopener noreferrer" class="btn btn-large btn-accent full-width" style="text-decoration:none;display:block;text-align:center" data-i18n="settings.scale.download_btn">📥 Scarica Gateway Android (APK)</a>
@@ -1054,7 +1061,7 @@
</div>
<!-- Gateway URL -->
<div class="form-group">
<div id="scale-websocket-section" class="form-group">
<label data-i18n="settings.scale.url_label">🌐 URL Gateway WebSocket</label>
<div style="display:flex;gap:8px;align-items:center">
<input type="url" id="setting-scale-url" class="form-input" style="flex:1" placeholder="ws://192.168.1.x:8765" data-i18n-placeholder="settings.scale.url_placeholder">
@@ -1065,8 +1072,10 @@
</div>
<!-- Test button -->
<button class="btn btn-secondary full-width mt-2" onclick="testScaleConnection()" data-i18n="settings.scale.test_btn">🔗 Testa connessione</button>
<div id="scale-test-status" style="display:none;margin-top:8px" class="settings-status"></div>
<div id="scale-test-section">
<button class="btn btn-secondary full-width mt-2" onclick="testScaleConnection()" data-i18n="settings.scale.test_btn">🔗 Testa connessione</button>
<div id="scale-test-status" style="display:none;margin-top:8px" class="settings-status"></div>
</div>
<!-- Protocol info -->
<div class="settings-hint" style="margin-top:16px;padding:10px;background:var(--bg-secondary,#f8fafc);border-radius:8px">