@sailingrotevista/rotevista-dash 4.0.11 → 4.0.13
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.
- package/app.js +24 -15
- package/index.js +21 -6
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -559,29 +559,38 @@ function startDisplayLoop() {
|
|
|
559
559
|
// ==========================================================================
|
|
560
560
|
// 8. CONFIGURAZIONE E GRAFICI UTILS
|
|
561
561
|
// ==========================================================================
|
|
562
|
-
|
|
563
562
|
/**
|
|
564
|
-
* Recupera la configurazione
|
|
565
|
-
*
|
|
566
|
-
* Converte i testi in numeri per garantire la precisione dei calcoli.
|
|
563
|
+
* Recupera la configurazione tramite l'endpoint dedicato /rotevista-config.
|
|
564
|
+
* Questo bypassa i blocchi di sicurezza standard di Signal K.
|
|
567
565
|
*/
|
|
568
566
|
async function fetchServerConfig() {
|
|
569
567
|
try {
|
|
570
|
-
const response = await fetch(
|
|
571
|
-
|
|
572
|
-
|
|
568
|
+
const response = await fetch('/rotevista-config');
|
|
569
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
570
|
+
|
|
571
|
+
const data = await response.json();
|
|
573
572
|
|
|
574
|
-
|
|
573
|
+
// Funzione di utilità per garantire che i valori siano numeri (evita bug nei grafici)
|
|
574
|
+
const parse = (obj) => {
|
|
575
|
+
for (let k in obj) {
|
|
576
|
+
if (typeof obj[k] === 'object') parse(obj[k]);
|
|
577
|
+
else if (!isNaN(obj[k]) && typeof obj[k] === 'string' && obj[k] !== "")
|
|
578
|
+
obj[k] = parseFloat(obj[k]);
|
|
579
|
+
}
|
|
580
|
+
return obj;
|
|
581
|
+
};
|
|
575
582
|
|
|
576
|
-
const actual =
|
|
583
|
+
const actual = parse(data);
|
|
577
584
|
|
|
578
|
-
|
|
579
|
-
Object.assign(CONFIG.
|
|
580
|
-
Object.assign(CONFIG.
|
|
585
|
+
// Fondiamo i dati del server con il CONFIG locale
|
|
586
|
+
if (actual.alarms) Object.assign(CONFIG.alarms, actual.alarms);
|
|
587
|
+
if (actual.graphs) Object.assign(CONFIG.graphs, actual.graphs);
|
|
588
|
+
if (actual.averaging) Object.assign(CONFIG.averages, actual.averaging);
|
|
589
|
+
if (actual.scales) Object.assign(CONFIG.scales, actual.scales);
|
|
581
590
|
|
|
582
|
-
console.log("✅
|
|
583
|
-
} catch {
|
|
584
|
-
console.warn("⚠️
|
|
591
|
+
console.log("✅ Configurazione sincronizzata via /rotevista-config");
|
|
592
|
+
} catch (err) {
|
|
593
|
+
console.warn("⚠️ Utilizzo default locali (Endpoint non ancora attivo o server offline).");
|
|
585
594
|
}
|
|
586
595
|
}
|
|
587
596
|
|
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* ==========================================================================
|
|
3
3
|
* Rotevista Dash Configuration Plugin
|
|
4
4
|
* ==========================================================================
|
|
5
|
-
* Definisce l'interfaccia di configurazione in Signal K Admin
|
|
6
|
-
*
|
|
5
|
+
* Definisce l'interfaccia di configurazione in Signal K Admin e crea
|
|
6
|
+
* l'endpoint pubblico per la comunicazione con la Dashboard.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
module.exports = function (app) {
|
|
@@ -12,9 +12,25 @@ module.exports = function (app) {
|
|
|
12
12
|
plugin.name = 'Rotevista Dash Configuration';
|
|
13
13
|
plugin.description = 'Configure boat-specific tactical and safety parameters for the Dashboard';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* plugin.start: Inizializza il plugin e crea la rotta API per la Dashboard.
|
|
17
|
+
*/
|
|
18
|
+
plugin.start = function (options) {
|
|
19
|
+
// Esponiamo i settings su un endpoint dedicato per bypassare i blocchi 401.
|
|
20
|
+
app.get('/rotevista-config', (req, res) => {
|
|
21
|
+
res.json(options);
|
|
22
|
+
});
|
|
17
23
|
|
|
24
|
+
app.debug('Rotevista Dashboard Config Endpoint active at /rotevista-config');
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
plugin.stop = function () {
|
|
28
|
+
// Pulizia risorse allo spegnimento del plugin.
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* plugin.schema: Definisce l'interfaccia grafica in Signal K Admin.
|
|
33
|
+
*/
|
|
18
34
|
plugin.schema = {
|
|
19
35
|
type: 'object',
|
|
20
36
|
title: 'Rotevista Dashboard Settings',
|
|
@@ -62,7 +78,6 @@ module.exports = function (app) {
|
|
|
62
78
|
title: 'Strategic Timeline (Minutes)',
|
|
63
79
|
description: "Total duration shown in the charts. Vertical grid lines mark 1-minute intervals for short durations and 5-minute intervals for long ones.",
|
|
64
80
|
default: 5,
|
|
65
|
-
// Menu a tendina per evitare inserimenti errati
|
|
66
81
|
enum: [5, 10, 15, 30, 60]
|
|
67
82
|
}
|
|
68
83
|
}
|
|
@@ -76,7 +91,7 @@ module.exports = function (app) {
|
|
|
76
91
|
longWindow: {
|
|
77
92
|
type: 'number',
|
|
78
93
|
title: 'Decision Stability Window (ms)',
|
|
79
|
-
description: "The time range used to calculate MEAN values. A longer window (e.g. 30s) provides a solid base for strategy, while a shorter one reacts faster to
|
|
94
|
+
description: "The time range used to calculate MEAN values. A longer window (e.g. 30s) provides a solid base for strategy, while a shorter one reacts faster to every oscillation.",
|
|
80
95
|
default: 30000
|
|
81
96
|
},
|
|
82
97
|
smoothWindow: {
|