@sailingrotevista/rotevista-dash 4.0.15 → 4.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/app.js +28 -37
  2. package/package.json +1 -1
  3. package/style.css +28 -0
package/app.js CHANGED
@@ -18,15 +18,15 @@ let CONFIG = {
18
18
  longWindow: 30000,
19
19
  stabilityTolerance: 2000,
20
20
  stabilityThreshold: 0.85,
21
- minSpeed: 0.5,
21
+ minSpeed: 1,
22
22
  stabilityBreakout: 15
23
23
  },
24
- graphs: { reef1: 15.0, reef2: 20.0, historyMinutes: 5, samples: 60 },
24
+ graphs: { reef1: 20.0, reef2: 25.0, historyMinutes: 10, samples: 60 },
25
25
  scales: {
26
- stw: { stdMax: 12, hercSpan: 4, step: 2 },
27
- sog: { stdMax: 12, hercSpan: 4, step: 2 },
28
- tws: { stdMax: 25, hercSpan: 10, step: 5 },
29
- depth: { stdMax: 20, hercSpan: 10, step: 10 }
26
+ stw: { stdMax: 8, hercSpan: 4, step: 2 },
27
+ sog: { stdMax: 8, hercSpan: 4, step: 2 },
28
+ tws: { stdMax: 15, hercSpan: 10, step: 5 },
29
+ depth: { stdMax: 10, hercSpan: 10, step: 10 }
30
30
  },
31
31
  server: { fallbackIp: "192.168.111.240:3000" }
32
32
  };
@@ -241,9 +241,16 @@ function playGybeAlarm() {
241
241
  }
242
242
 
243
243
  function checkDepthAlarm(m) {
244
- ui.depth.classList.remove('alarm-warning', 'alarm-danger');
245
- if (m < CONFIG.alarms.depthDanger) { ui.depth.classList.add('alarm-danger'); playBingBing(); }
246
- else if (m < CONFIG.alarms.depthWarning) ui.depth.classList.add('alarm-warning');
244
+ // Rimuoviamo sempre le classi prima di riapplicarle
245
+ ui.depth.classList.remove('alarm-warning', 'alarm-danger', 'blink-alarm');
246
+
247
+ // Logica di confronto dinamica
248
+ if (m < CONFIG.alarms.depthDanger) {
249
+ ui.depth.classList.add('alarm-danger', 'blink-alarm');
250
+ playBingBing(); // Il tuo suono di allarme
251
+ } else if (m < CONFIG.alarms.depthWarning) {
252
+ ui.depth.classList.add('alarm-warning');
253
+ }
247
254
  }
248
255
 
249
256
  function updateLeewayDisplay(deg) {
@@ -552,41 +559,25 @@ function startDisplayLoop() {
552
559
  async function fetchServerConfig() {
553
560
  try {
554
561
  const response = await fetch('/rotevista-config');
555
- if (!response.ok) throw new Error(`Server offline o rotta non trovata`);
562
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
556
563
  const data = await response.json();
557
564
 
558
- // 1. Funzione di pulizia: trasforma stringhe in numeri
559
- const parse = (obj) => {
560
- for (let k in obj) {
561
- if (typeof obj[k] === 'object' && obj[k] !== null) parse(obj[k]);
562
- else if (!isNaN(obj[k]) && typeof obj[k] === 'string' && obj[k] !== "")
563
- obj[k] = parseFloat(obj[k]);
564
- }
565
- return obj;
566
- };
567
- const actual = parse(data);
565
+ // Stampa di debug per verificare cosa riceve il client
566
+ console.log("🔍 Configurazione ricevuta dal Server:", data);
568
567
 
569
- // 2. Mappatura Forzata (Deep Merge)
570
- if (actual.alarms) Object.assign(CONFIG.alarms, actual.alarms);
571
-
572
- if (actual.graphs) {
573
- Object.assign(CONFIG.graphs, actual.graphs);
574
- console.log(`📈 GRAFICI: Durata ${CONFIG.graphs.historyMinutes}m | Reef1: ${CONFIG.graphs.reef1}kts | Reef2: ${CONFIG.graphs.reef2}kts`);
575
- }
576
-
577
- if (actual.averaging) {
578
- Object.assign(CONFIG.averaging, actual.averaging);
579
- console.log(`⏱️ STABILITÀ: MinSpeed ${CONFIG.averaging.minSpeed}kts | Breakout: ${CONFIG.averaging.stabilityBreakout}°`);
580
- }
568
+ // Merge intelligente dei dati ricevuti nel CONFIG esistente
569
+ Object.assign(CONFIG.alarms, data.alarms || {});
570
+ Object.assign(CONFIG.graphs, data.graphs || {});
571
+ Object.assign(CONFIG.averaging, data.averaging || {});
581
572
 
582
- if (actual.scales) {
583
- // Per le scale facciamo un merge profondo per ogni box
584
- for (let key in actual.scales) {
585
- if (CONFIG.scales[key]) Object.assign(CONFIG.scales[key], actual.scales[key]);
573
+ // Per le scale, siccome sono nidificate, facciamo un loop
574
+ if (data.scales) {
575
+ for (let key in data.scales) {
576
+ if (CONFIG.scales[key]) Object.assign(CONFIG.scales[key], data.scales[key]);
586
577
  }
587
578
  }
588
579
 
589
- console.log("✅ Configurazione sincronizzata con successo.");
580
+ console.log("✅ Configurazione applicata. Alarmi attivi:", CONFIG.alarms);
590
581
  } catch (err) {
591
582
  console.warn("⚠️ Utilizzo default locali. Motivo:", err.message);
592
583
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "4.0.15",
3
+ "version": "4.0.16",
4
4
  "description": "Public Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
package/style.css CHANGED
@@ -134,6 +134,34 @@ body {
134
134
  .box-tack .value.dual-val { font-size: clamp(0.9rem, 28cqh, 10cqw) !important; }
135
135
  }
136
136
 
137
+ /* ==========================================================================
138
+ AGGIUNTA: Gestione Allarmi Profondità
139
+ ========================================================================== */
140
+
141
+ .alarm-warning {
142
+ color: #e67e22 !important; /* Arancione per Warning */
143
+ }
144
+
145
+ .alarm-danger {
146
+ color: #c0392b !important; /* Rosso per Danger */
147
+ }
148
+
149
+ .blink-alarm {
150
+ animation: blink-depth 0.8s infinite alternate;
151
+ }
152
+
153
+ @keyframes blink-depth {
154
+ from { opacity: 1; }
155
+ to { opacity: 0.3; }
156
+ }
157
+
158
+ /* Override per la Night Mode: se siamo in modalità notte,
159
+ il rosso deve restare ben visibile o diventare più acceso */
160
+ body.night-mode .alarm-danger {
161
+ color: #ff0000 !important;
162
+ text-shadow: 0 0 10px rgba(255, 0, 0, 0.8) !important;
163
+ }
164
+
137
165
  /* ==========================================================================
138
166
  5. TACTICAL FOCUS MODE
139
167
  ========================================================================== */