@sailingrotevista/rotevista-dash 4.0.6 → 4.0.7
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 +18 -23
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -560,36 +560,33 @@ function startDisplayLoop() {
|
|
|
560
560
|
// 8. CONFIGURAZIONE E GRAFICI UTILS
|
|
561
561
|
// ==========================================================================
|
|
562
562
|
/**
|
|
563
|
-
* Recupera la configurazione
|
|
564
|
-
*
|
|
565
|
-
*/
|
|
566
|
-
/**
|
|
567
|
-
* Recupera la configurazione dal server Signal K provando diversi percorsi.
|
|
568
|
-
* Gestisce i permessi e converte i dati in formato numerico.
|
|
563
|
+
* Recupera la configurazione provando i percorsi standard e quelli "scoped".
|
|
564
|
+
* Gestisce il parsing dei numeri e la mappatura dei grafici.
|
|
569
565
|
*/
|
|
570
566
|
async function fetchServerConfig() {
|
|
571
567
|
if (!window.location.protocol.includes("http")) return;
|
|
572
|
-
|
|
573
|
-
// Elenco
|
|
568
|
+
|
|
569
|
+
// Elenco di tutti i percorsi dove Signal K potrebbe aver salvato i settings
|
|
574
570
|
const urls = [
|
|
575
|
-
'/
|
|
576
|
-
'/
|
|
577
|
-
'/plugins/rotevista-dash/
|
|
571
|
+
'/plugins/rotevista-dash/settings',
|
|
572
|
+
'/plugins/@sailingrotevista%2frotevista-dash/settings',
|
|
573
|
+
'/signalk/v1/api/plugins/rotevista-dash/settings',
|
|
574
|
+
'/signalk/v1/api/plugins/@sailingrotevista%2frotevista-dash/settings',
|
|
575
|
+
'/plugins/rotevista-dash/config' // Quello che ti ha dato 401
|
|
578
576
|
];
|
|
579
577
|
|
|
580
578
|
for (let url of urls) {
|
|
581
579
|
try {
|
|
582
|
-
console.log(`Tentativo di caricamento configurazione da: ${url}`);
|
|
583
580
|
const response = await fetch(url);
|
|
584
581
|
|
|
585
582
|
if (response.ok) {
|
|
586
583
|
const data = await response.json();
|
|
587
584
|
|
|
588
|
-
// Signal K può
|
|
589
|
-
const actual = data.settings || data.configuration || data.
|
|
590
|
-
|
|
585
|
+
// Signal K può restituire i dati direttamente, in 'configuration' o in 'settings'
|
|
586
|
+
const actual = data.settings || data.configuration || data.options || data;
|
|
587
|
+
|
|
591
588
|
if (actual && (actual.alarms || actual.averaging || actual.graphs)) {
|
|
592
|
-
// FUNZIONE DI PARSING:
|
|
589
|
+
// FUNZIONE DI PARSING: Trasforma i testi in numeri per i calcoli
|
|
593
590
|
const parseNumbers = (obj) => {
|
|
594
591
|
for (let k in obj) {
|
|
595
592
|
if (typeof obj[k] === 'object') parseNumbers(obj[k]);
|
|
@@ -600,7 +597,7 @@ async function fetchServerConfig() {
|
|
|
600
597
|
};
|
|
601
598
|
parseNumbers(actual);
|
|
602
599
|
|
|
603
|
-
// APPLICAZIONE
|
|
600
|
+
// APPLICAZIONE CONFIGURAZIONE (Ora include anche i grafici!)
|
|
604
601
|
if (actual.alarms) CONFIG.alarms = { ...CONFIG.alarms, ...actual.alarms };
|
|
605
602
|
if (actual.graphs) CONFIG.graphs = { ...CONFIG.graphs, ...actual.graphs };
|
|
606
603
|
if (actual.averaging) CONFIG.averages = { ...CONFIG.averages, ...actual.averaging };
|
|
@@ -609,15 +606,13 @@ async function fetchServerConfig() {
|
|
|
609
606
|
CONFIG.scales[k] = { ...CONFIG.scales[k], ...actual.scales[k] };
|
|
610
607
|
}
|
|
611
608
|
}
|
|
612
|
-
console.log("✅
|
|
613
|
-
return; //
|
|
609
|
+
console.log("✅ CONFIGURAZIONE CARICATA DA:", url);
|
|
610
|
+
return; // Abbiamo trovato i dati, usciamo dal loop
|
|
614
611
|
}
|
|
615
612
|
}
|
|
616
|
-
} catch (e) {
|
|
617
|
-
console.warn(`⚠️ Errore durante il fetch su ${url}:`, e.message);
|
|
618
|
-
}
|
|
613
|
+
} catch (e) { }
|
|
619
614
|
}
|
|
620
|
-
console.warn("⚠️ Nessun
|
|
615
|
+
console.warn("⚠️ Nessun dato di configurazione trovato nei percorsi standard. Uso i default.");
|
|
621
616
|
}
|
|
622
617
|
|
|
623
618
|
function manageHistory(t, v) {
|