@sailingrotevista/rotevista-dash 4.0.8 → 4.0.10

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 (2) hide show
  1. package/app.js +16 -45
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -566,51 +566,22 @@ function startDisplayLoop() {
566
566
  * Converte i testi in numeri per garantire la precisione dei calcoli.
567
567
  */
568
568
  async function fetchServerConfig() {
569
- if (!window.location.protocol.includes("http")) return;
570
-
571
- const urls = [
572
- '/signalk/v1/api/plugins/rotevista-dash',
573
- '/signalk/v1/api/plugins/@sailingrotevista%2frotevista-dash',
574
- '/plugins/rotevista-dash/settings'
575
- ];
576
-
577
- for (let url of urls) {
578
- try {
579
- const response = await fetch(url);
580
- if (response.ok) {
581
- const data = await response.json();
582
-
583
- // Signal K può incapsulare i dati in settings o configuration
584
- const actual = data.settings || data.configuration || data.options || data;
585
-
586
- if (actual && (actual.alarms || actual.averaging || actual.graphs)) {
587
- // FUNZIONE DI PARSING: Trasforma eventuali testi "12.5" in numeri 12.5 reali
588
- const parseNumbers = (obj) => {
589
- for (let k in obj) {
590
- if (typeof obj[k] === 'object') parseNumbers(obj[k]);
591
- else if (!isNaN(obj[k]) && obj[k] !== "" && typeof obj[k] === 'string') {
592
- obj[k] = parseFloat(obj[k]);
593
- }
594
- }
595
- };
596
- parseNumbers(actual);
597
-
598
- // MAPPATURA INTEGRALE NEL CONFIG LOCALE
599
- if (actual.alarms) CONFIG.alarms = { ...CONFIG.alarms, ...actual.alarms };
600
- if (actual.graphs) CONFIG.graphs = { ...CONFIG.graphs, ...actual.graphs };
601
- if (actual.averaging) CONFIG.averages = { ...CONFIG.averages, ...actual.averaging };
602
- if (actual.scales) {
603
- for (let k in actual.scales) {
604
- CONFIG.scales[k] = { ...CONFIG.scales[k], ...actual.scales[k] };
605
- }
606
- }
607
- console.log("✅ Configurazione caricata correttamente da:", url);
608
- return;
609
- }
610
- }
611
- } catch (e) {
612
- console.warn(`⚠️ Tentativo fallito su ${url}`);
613
- }
569
+ try {
570
+ const response = await fetch(
571
+ '/plugins/rotevista-dash/public-config'
572
+ );
573
+
574
+ if (!response.ok) throw new Error();
575
+
576
+ const actual = await response.json();
577
+
578
+ Object.assign(CONFIG.alarms, actual.alarms || {});
579
+ Object.assign(CONFIG.graphs, actual.graphs || {});
580
+ Object.assign(CONFIG.averages, actual.averaging || {});
581
+
582
+ console.log("✅ Config caricata");
583
+ } catch {
584
+ console.warn("⚠️ Default locali");
614
585
  }
615
586
  }
616
587
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "description": "Public Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {