@sailingrotevista/rotevista-dash 4.0.14 → 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 +37 -67
  2. package/package.json +1 -1
  3. package/style.css +28 -0
package/app.js CHANGED
@@ -12,36 +12,23 @@
12
12
  // 1. CONFIGURAZIONE E DEFAULT
13
13
  // ==========================================================================
14
14
  let CONFIG = {
15
- alarms: {
16
- depthDanger: 2.5,
17
- depthWarning: 5.0
18
- },
19
- // Gestione parametri di stabilità e medie
15
+ alarms: { depthDanger: 2.5, depthWarning: 5.0 },
20
16
  averaging: {
21
- smoothWindow: 2000, // Smoothing puntatori (2s)
22
- longWindow: 30000, // Finestra per i valori MEAN (30s)
23
- stabilityTolerance: 2000, // Millisecondi per considerare il buffer "pieno"
24
- stabilityThreshold: 0.85, // Soglia coerenza R per il lampeggio (0.7 - 0.98)
25
- minSpeed: 0, // Nodi minimi per attivare gli allarmi di instabilità
17
+ smoothWindow: 2000,
18
+ longWindow: 30000,
19
+ stabilityTolerance: 2000,
20
+ stabilityThreshold: 0.85,
21
+ minSpeed: 1,
26
22
  stabilityBreakout: 15
27
23
  },
28
- // Parametri per i grafici sparkline
29
- graphs: {
30
- reef1: 15.0, // Soglia primo reef (Orange)
31
- reef2: 20.0, // Soglia secondo reef (Red)
32
- historyMinutes: 5, // Finestra temporale visualizzata
33
- samples: 60 // Numero di punti di campionamento
34
- },
35
- // Configurazioni scale automatiche
24
+ graphs: { reef1: 20.0, reef2: 25.0, historyMinutes: 10, samples: 60 },
36
25
  scales: {
37
- stw: { stdMax: 12, hercSpan: 4, step: 2 },
38
- sog: { stdMax: 12, hercSpan: 4, step: 2 },
39
- tws: { stdMax: 25, hercSpan: 10, step: 5 },
40
- 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 }
41
30
  },
42
- server: {
43
- fallbackIp: "192.168.111.240:3000"
44
- }
31
+ server: { fallbackIp: "192.168.111.240:3000" }
45
32
  };
46
33
 
47
34
  const RENDER_INTERVAL_MS = 1000;
@@ -254,9 +241,16 @@ function playGybeAlarm() {
254
241
  }
255
242
 
256
243
  function checkDepthAlarm(m) {
257
- ui.depth.classList.remove('alarm-warning', 'alarm-danger');
258
- if (m < CONFIG.alarms.depthDanger) { ui.depth.classList.add('alarm-danger'); playBingBing(); }
259
- 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
+ }
260
254
  }
261
255
 
262
256
  function updateLeewayDisplay(deg) {
@@ -560,56 +554,32 @@ function startDisplayLoop() {
560
554
  // 8. CONFIGURAZIONE E GRAFICI UTILS
561
555
  // ==========================================================================
562
556
  /**
563
- * Recupera la configurazione dal server con log di debug estesi.
557
+ * Recupera la configurazione e forza la sovrascrittura di ogni parametro.
564
558
  */
565
559
  async function fetchServerConfig() {
566
560
  try {
567
561
  const response = await fetch('/rotevista-config');
568
- if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
569
-
562
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
570
563
  const data = await response.json();
571
-
572
- // DEBUG 1: Visualizza i dati esattamente come arrivano dal server
573
- console.log("📥 [DEBUG] Dati grezzi ricevuti dal server:", data);
574
-
575
- const parse = (obj) => {
576
- for (let k in obj) {
577
- if (typeof obj[k] === 'object' && obj[k] !== null) parse(obj[k]);
578
- else if (!isNaN(obj[k]) && typeof obj[k] === 'string' && obj[k] !== "")
579
- obj[k] = parseFloat(obj[k]);
580
- }
581
- return obj;
582
- };
583
564
 
584
- const actual = parse(JSON.parse(JSON.stringify(data))); // Cloniamo per sicurezza
565
+ // Stampa di debug per verificare cosa riceve il client
566
+ console.log("🔍 Configurazione ricevuta dal Server:", data);
585
567
 
586
- // DEBUG 2: Visualizza i dati dopo la conversione numerica
587
- console.log("⚙️ [DEBUG] Dati convertiti (numeric):", actual);
588
-
589
- // ASSEGNAZIONE E FUSIONE (Mappatura dei blocchi)
590
- if (actual.alarms) Object.assign(CONFIG.alarms, actual.alarms);
591
- if (actual.graphs) Object.assign(CONFIG.graphs, actual.graphs);
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 || {});
592
572
 
593
- // Gestione specifica per averaging (il blocco più critico)
594
- if (actual.averaging) {
595
- Object.assign(CONFIG.averaging, actual.averaging);
596
- // DEBUG 3: Tabella comparativa per verificare minSpeed e soglie
597
- console.table({
598
- "Parametro": ["longWindow", "minSpeed", "stabilityThreshold", "stabilityBreakout"],
599
- "Valore Attuale": [
600
- CONFIG.averaging.longWindow,
601
- CONFIG.averaging.minSpeed,
602
- CONFIG.averaging.stabilityThreshold,
603
- CONFIG.averaging.stabilityBreakout
604
- ]
605
- });
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]);
577
+ }
606
578
  }
607
-
608
- if (actual.scales) Object.assign(CONFIG.scales, actual.scales);
609
579
 
610
- console.log("✅ [SUCCESS] Configurazione sincronizzata correttamente.");
580
+ console.log("✅ Configurazione applicata. Alarmi attivi:", CONFIG.alarms);
611
581
  } catch (err) {
612
- console.warn("⚠️ [WARNING] Utilizzo default locali. Motivo:", err.message);
582
+ console.warn("⚠️ Utilizzo default locali. Motivo:", err.message);
613
583
  }
614
584
  }
615
585
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "4.0.14",
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
  ========================================================================== */