@sailingrotevista/rotevista-dash 4.0.12 → 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 +14 -21
- package/index.js +21 -6
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -559,25 +559,18 @@ function startDisplayLoop() {
|
|
|
559
559
|
// ==========================================================================
|
|
560
560
|
// 8. CONFIGURAZIONE E GRAFICI UTILS
|
|
561
561
|
// ==========================================================================
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* Recupera la configurazione dal server Signal K.
|
|
565
|
-
* Prova i percorsi API ufficiali e quelli scoped (@sailingrotevista).
|
|
566
|
-
* Converte i testi in numeri per garantire la precisione dei calcoli.
|
|
567
|
-
*/
|
|
568
562
|
/**
|
|
569
|
-
* Recupera la configurazione
|
|
570
|
-
*
|
|
563
|
+
* Recupera la configurazione tramite l'endpoint dedicato /rotevista-config.
|
|
564
|
+
* Questo bypassa i blocchi di sicurezza standard di Signal K.
|
|
571
565
|
*/
|
|
572
566
|
async function fetchServerConfig() {
|
|
573
567
|
try {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (!response.ok) throw new Error(`Status: ${response.status}`);
|
|
568
|
+
const response = await fetch('/rotevista-config');
|
|
569
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
577
570
|
|
|
578
|
-
const
|
|
571
|
+
const data = await response.json();
|
|
579
572
|
|
|
580
|
-
//
|
|
573
|
+
// Funzione di utilità per garantire che i valori siano numeri (evita bug nei grafici)
|
|
581
574
|
const parse = (obj) => {
|
|
582
575
|
for (let k in obj) {
|
|
583
576
|
if (typeof obj[k] === 'object') parse(obj[k]);
|
|
@@ -587,17 +580,17 @@ async function fetchServerConfig() {
|
|
|
587
580
|
return obj;
|
|
588
581
|
};
|
|
589
582
|
|
|
590
|
-
const
|
|
583
|
+
const actual = parse(data);
|
|
591
584
|
|
|
592
|
-
//
|
|
593
|
-
if (
|
|
594
|
-
if (
|
|
595
|
-
if (
|
|
596
|
-
if (
|
|
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);
|
|
597
590
|
|
|
598
|
-
console.log("✅ Configurazione
|
|
591
|
+
console.log("✅ Configurazione sincronizzata via /rotevista-config");
|
|
599
592
|
} catch (err) {
|
|
600
|
-
console.warn("⚠️
|
|
593
|
+
console.warn("⚠️ Utilizzo default locali (Endpoint non ancora attivo o server offline).");
|
|
601
594
|
}
|
|
602
595
|
}
|
|
603
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: {
|