@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.
- package/app.js +16 -45
- 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
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
|