[Perl] DAQ system for the FAPG.
1
import{initialiseGraphControls}from"./dashboard/graph-controls.js";
2
import{createProbeCharts}from"./dashboard/charts.js";
3
import{createInsightsCharts}from"./dashboard/insights.js";
4
import{createWeatherCharts}from"./dashboard/weather-page.js";
5
import{loadWeatherForecast}from"./dashboard/weather-forecast.js";
6
import{DASHBOARD_REFRESH_MS}from"./dashboard/constants.js";
7
import{loadQuickReadings}from"./dashboard/quick-readings.js";
8
import{createStatusLoader}from"./dashboard/status.js";
9
import{createTimeframeState}from"./dashboard/timeframe.js";
10
11
// Global chart defaults: incline x-axis labels for better mobile readability
12
Chart.defaults.scales.category.ticks.maxRotation = 45;
13
Chart.defaults.scales.category.ticks.minRotation = 45;
14
15
const=createTimeframeState;
16
const=createProbeChartstimeframe;
17
const=createInsightsCharts;
18
const=createWeatherCharts;
19
const=createStatusLoader;
20
21
document.querySelectorAll".tab-button".forEachbutton=>{
22
button.addEventListener"click",()=>probes.activateTabbutton.dataset.probe;
23
};
24
25
initialiseGraphControlstimeframe,()=>{
26
probes.reloadDisplayed;
27
};
28
29
window.addEventListener"hashchange",()=>{
30
const=probes.probeFromLocation;
31
ifprobeprobes.activateTabprobe;
32
};
33
34
const=probes.probeFromHash;
35
const=probes.probeFromLocation;
36
37
if initialProbe {
38
probes.activateTabinitialProbe;
39
40
ifinitialHashProbe{
41
document.getElementById`probe-${initialHashProbe}`?.scrollIntoView;
42
}
43
} else if probes.activeProbe {
44
probes.loadDisplayed;
45
}
46
47
let=null;
48
49
function(){
50
ifrefreshInFlightreturnrefreshInFlight;
51
52
refreshInFlight=Promise.allSettled
53
probes.loadDisplayed,
54
insights.reload,
55
weatherPage.reload,
56
loadWeatherForecast,
57
loadQuickReadings,
58
loadStatuses
59
.finally()=>{
60
refreshInFlight=null;
61
};
62
returnrefreshInFlight;
63
}
64
65
function(){
66
returndocument.hidden?null:refreshDashboard;
67
}
68
69
document.addEventListener"visibilitychange",()=>{
70
if!document.hiddenrefreshDashboard;
71
};
72
73
refreshVisibleDashboard;
74
setIntervalrefreshVisibleDashboard, DASHBOARD_REFRESH_MS;
75