yoda-sailing 0.1.0 → 0.3.0

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/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "yoda-sailing",
3
- "version": "0.1.0",
4
- "description": "Read-only Signal K webapp for viewing Ruuvi acceleration axes.",
5
- "keywords": ["signalk-webapp", "signalk-category-instruments", "ruuvi"],
6
- "files": ["public"],
7
- "signalk": { "displayName": "YODA Dashboard" },
3
+ "version": "0.3.0",
4
+ "description": "Signal K webapp for vessel navigation, Ruuvi trends and read-only relay status.",
5
+ "keywords": [
6
+ "signalk-webapp",
7
+ "signalk-category-instruments",
8
+ "ruuvi"
9
+ ],
10
+ "files": [
11
+ "public"
12
+ ],
13
+ "signalk": {
14
+ "displayName": "YODA Dashboard"
15
+ },
8
16
  "license": "UNLICENSED"
9
17
  }
@@ -1,76 +1,575 @@
1
- const axes = ['X', 'Y', 'Z'];
2
- const readings = document.querySelector('#sensors');
3
- const status = document.querySelector('#status');
4
- const formatter = new Intl.NumberFormat('fr-FR', { maximumFractionDigits: 3 });
5
-
6
- function findSensors(data) {
7
- const sensors = new Map();
8
-
9
- function walk(value, path) {
10
- if (!value || typeof value !== 'object') return;
11
- const match = /^(.*?)(?:\.)?Acc([XYZ])axis$/i.exec(path);
12
- if (match && /^ruuvi/i.test(match[1]) && Object.hasOwn(value, 'value')) {
13
- const [, sensor, axis] = match;
14
- const samples = sensors.get(sensor) ?? {};
15
- samples[axis.toUpperCase()] = value;
16
- sensors.set(sensor, samples);
17
- return;
1
+
2
+ const sensors = [
3
+ {name:'Cockpit', color:'#62ddd0'},
4
+ {name:'Inside', color:'#ffbd72'},
5
+ {name:'Motor', color:'#bfaaff'}
6
+ ];
7
+ const groups = {
8
+ 'Ambiance': [
9
+ ['temp','Température','°C',null,null],
10
+ ['humidity','Humidité relative','%',null,null],
11
+ ['pressure','Pression','hPa',null,null]
12
+ ],
13
+ 'Accélérations': [
14
+ ['x','Accélération X','mg',null,null],
15
+ ['y','Accélération Y','mg',null,null],
16
+ ['z','Accélération Z','mg',null,null]
17
+ ],
18
+ 'Diagnostic': [
19
+ ['battery','Tension de pile','V',null,null],
20
+ ['rssi','Signal radio','dBm',null,null],
21
+ ['seq','Compteur de mesures','',null,null,'step'],
22
+ ['motion','Compteur de mouvement','',null,null,'step'],
23
+ ['reachable','Disponibilité','',null,null,'step']
24
+ ]
25
+ };
26
+ const sectionIds = ['ambiance', 'accelerations', 'diagnostic'];
27
+ const selected = new Set([0,1,2]);
28
+ const charts = document.querySelector('#charts');
29
+ const toggle = document.querySelector('fieldset');
30
+
31
+ const hour = 3600000;
32
+ const fields = {
33
+ temp: 'Temperature', humidity: 'Humidity', pressure: 'Pressure',
34
+ x: 'AccXaxis', y: 'AccYaxis', z: 'AccZaxis', battery: 'BatteryVoltage',
35
+ rssi: 'SignalStrengthdB', seq: 'SeqCounter', motion: 'MvmCounter'
36
+ };
37
+ const metrics = Object.values(groups).flat();
38
+ const history = sensors.map(() => Object.fromEntries(metrics.map(([key]) => [key, []])));
39
+ const sequences = sensors.map(() => undefined);
40
+ const painters = [];
41
+ const clock = time => new Date(time).toLocaleTimeString('fr-FR', {hour:'2-digit', minute:'2-digit', second:'2-digit'});
42
+
43
+ function at(data, path) {
44
+ return data?.[path] ?? path.split('.').reduce((value, part) => value?.[part], data);
45
+ }
46
+
47
+ function sample(data, key, sensor) {
48
+ const name = 'Ruuvi' + sensor.name;
49
+ if (key === 'reachable') {
50
+ const reachable = at(data,'sensors');
51
+ const id = Object.keys(reachable ?? {}).find(id => id.startsWith(name));
52
+ return id ? reachable[id]?.reachable : undefined;
53
+ }
54
+ return at(data,name + '.' + fields[key])
55
+ ?? (key === 'z' && sensor.name === 'Inside' ? at(data,'RuuviInsideAccZaxis') : undefined);
56
+ }
57
+
58
+ function numeric(key, value) {
59
+ if (key === 'reachable') return typeof value === 'boolean' ? Number(value) : null;
60
+ if (!Number.isFinite(value)) return null;
61
+ if (key === 'temp') return value - 273.15;
62
+ if (key === 'humidity') return value * 100;
63
+ if (key === 'pressure') return value >= 50000 && value <= 115534 ? value / 100 : null;
64
+ if (key === 'seq' && value === 65535 || key === 'motion' && value === 255) return null;
65
+ return value;
66
+ }
67
+
68
+ function record(data, now) {
69
+ sensors.forEach((sensor,i) => {
70
+ const seq = numeric('seq',sample(data,'seq',sensor)?.value);
71
+ const repeated = seq !== null && seq === sequences[i];
72
+ if (seq !== null) sequences[i] = seq;
73
+ for (const [key] of metrics) {
74
+ const points = history[i][key];
75
+ while (points.length && points[0].time < now - hour) points.shift();
76
+ const reading = sample(data,key,sensor);
77
+ const time = Date.parse(reading?.timestamp);
78
+ if (!Number.isFinite(time) || time < now - hour || time > now + 60000) continue;
79
+ if (points.length && time <= points.at(-1).time) continue;
80
+ const value = numeric(key,reading.value);
81
+ // A repeated sensor frame can still carry new receiver-side RSSI or status.
82
+ if (repeated && key !== 'reachable' && key !== 'rssi' && points.at(-1)?.value === value) continue;
83
+ points.push({time,value});
84
+ }
85
+ });
86
+ }
87
+
88
+ function draw(canvas, output, metric, allPoints, cursor) {
89
+ const [key,title,unit,,,mode] = metric;
90
+ const {width,height} = canvas.getBoundingClientRect();
91
+ if (width < 125) return;
92
+ const end = Date.now();
93
+ const start = end - hour;
94
+ const series = allPoints.map(points => points.filter(point => point.time >= start && point.time <= end));
95
+ const scale = window.devicePixelRatio || 1;
96
+ canvas.width = width * scale;
97
+ canvas.height = height * scale;
98
+ const ctx = canvas.getContext('2d');
99
+ ctx.scale(scale,scale);
100
+ const left = key === 'reachable' ? 99 : 55;
101
+ const right = width-19, top = 14, bottom = height-29;
102
+ const visible = series.flatMap((values,i) => selected.has(i) ? values.map(point=>point.value).filter(Number.isFinite) : []);
103
+ const min = visible.length ? Math.min(...visible) : 0;
104
+ const max = visible.length ? Math.max(...visible) : 1;
105
+ const padding = (max-min)*.09 || .5;
106
+ const low = key === 'reachable' ? -.15 : min-padding;
107
+ const high = key === 'reachable' ? 1.15 : max+padding;
108
+ const x = time => left + (time-start) / hour * (right-left);
109
+ const y = value => bottom - (value-low)/(high-low)*(bottom-top);
110
+ const format = new Intl.NumberFormat('fr-FR',{maximumFractionDigits:key==='battery'?2:1});
111
+ ctx.font = '12px system-ui';
112
+ ctx.textAlign = 'right';
113
+ ctx.fillStyle = '#b7cbd6';
114
+ ctx.strokeStyle = '#375163';
115
+ const ticks = key === 'reachable' ? [0,1] : [low,(low+high)/2,high];
116
+ for (const tick of ticks) {
117
+ ctx.beginPath(); ctx.moveTo(left,y(tick)); ctx.lineTo(right,y(tick)); ctx.stroke();
118
+ ctx.fillText(key==='reachable' ? (tick ? 'Joignable' : 'Non joignable') : format.format(tick),left-6,y(tick)+4);
119
+ }
120
+ ctx.textAlign = 'center';
121
+ for (const fraction of [0,.5,1]) {
122
+ const time = start + fraction * hour;
123
+ ctx.fillText(clock(time).slice(0,5),x(time),height-6);
124
+ }
125
+ series.forEach((values,i) => {
126
+ if (!selected.has(i)) return;
127
+ ctx.strokeStyle = sensors[i].color;
128
+ function slope(before, after) {
129
+ return (after.value-before.value)/(after.time-before.time);
18
130
  }
19
- for (const [key, child] of Object.entries(value)) {
20
- if (key !== 'meta' && key !== 'values') walk(child, path ? path + '.' + key : key);
131
+
132
+ function tangent(left, right) {
133
+ return left * right > 0 ? 2 * left * right / (left + right) : 0;
21
134
  }
135
+
136
+ ctx.setLineDash([]);
137
+ ctx.lineWidth = 1.5;
138
+ ctx.beginPath();
139
+ for (let index = 0; index < values.length; index++) {
140
+ const current = values[index];
141
+ const previous = values[index - 1];
142
+ if (current.value === null) continue;
143
+ if (previous?.value == null) {
144
+ ctx.moveTo(x(current.time),y(current.value));
145
+ continue;
146
+ }
147
+ if (mode === 'step') {
148
+ ctx.lineTo(x(current.time),y(previous.value));
149
+ ctx.lineTo(x(current.time),y(current.value));
150
+ continue;
151
+ }
152
+ const before = values[index - 2], after = values[index + 1];
153
+ const interval = current.time - previous.time;
154
+ const secant = slope(previous,current);
155
+ const initial = before?.value != null ? tangent(slope(before,previous),secant) : secant;
156
+ const final = after?.value != null ? tangent(secant,slope(current,after)) : secant;
157
+ // Ordered control values keep each segment inside the range of its endpoints.
158
+ const offset = derivative => Math.sign(secant) * Math.min(Math.abs(derivative),1.5*Math.abs(secant)) * interval/3;
159
+ ctx.bezierCurveTo(
160
+ x(previous.time+interval/3), y(previous.value+offset(initial)),
161
+ x(current.time-interval/3), y(current.value-offset(final)),
162
+ x(current.time),y(current.value)
163
+ );
164
+ }
165
+ ctx.stroke();
166
+
167
+ if (mode !== 'step') {
168
+ const first = values[0], last = values.at(-1);
169
+ ctx.globalAlpha = .4;
170
+ ctx.beginPath();
171
+ if (first?.value != null && first.time > start) {
172
+ ctx.moveTo(x(start),y(first.value));
173
+ ctx.lineTo(x(first.time),y(first.value));
174
+ }
175
+ if (last?.value != null && last.time < end) {
176
+ ctx.moveTo(x(last.time),y(last.value));
177
+ ctx.lineTo(x(end),y(last.value));
178
+ }
179
+ ctx.stroke();
180
+ ctx.globalAlpha = 1;
181
+ }
182
+
183
+ ctx.lineWidth = 1.4;
184
+ ctx.beginPath();
185
+ for (const {time,value} of values) {
186
+ if (value === null) continue;
187
+ const centerX=x(time), centerY=y(value);
188
+ ctx.moveTo(centerX-3,centerY-3);ctx.lineTo(centerX+3,centerY+3);
189
+ ctx.moveTo(centerX-3,centerY+3);ctx.lineTo(centerX+3,centerY-3);
190
+ }
191
+ ctx.stroke();
192
+ });
193
+ const point = cursor === null ? end : start + cursor * hour;
194
+ if (cursor !== null) {
195
+ ctx.setLineDash([3,3]); ctx.strokeStyle='#abc0cc'; ctx.lineWidth=1;
196
+ ctx.beginPath(); ctx.moveTo(x(point),top); ctx.lineTo(x(point),bottom); ctx.stroke();
22
197
  }
198
+ const summaries = sensors.flatMap((sensor,i) => {
199
+ if (!selected.has(i)) return [];
200
+ const reading = series[i].findLast(sample => sample.time <= point);
201
+ const value = reading ? reading.value : null;
202
+ const label = value === null ? 'indisponible'
203
+ : key === 'reachable' ? (value ? 'joignable' : 'non joignable')
204
+ : format.format(value)+(unit?' '+unit:'');
205
+ const count = series[i].filter(sample => sample.value !== null).length;
206
+ return [sensor.name+' '+label+(reading ? ' à '+clock(reading.time) : '')+' ('+count+' pts)'];
207
+ });
208
+ output.textContent = summaries.length ? clock(point)+' · '+summaries.join(' · ') : 'Sélectionne un capteur.';
209
+ }
23
210
 
24
- walk(data, '');
25
- return sensors;
211
+ function render() {
212
+ charts.replaceChildren();
213
+ painters.length = 0;
214
+ Object.entries(groups).forEach(([name, metrics], index) => {
215
+ const section = document.createElement('section');
216
+ section.className = 'chart-group';
217
+ section.id = sectionIds[index];
218
+ const title = document.createElement('h2');
219
+ title.textContent = name;
220
+ const grid = document.createElement('div');
221
+ grid.className = 'grid';
222
+ section.append(title, grid);
223
+ charts.append(section);
224
+ for (const metric of metrics) {
225
+ const card = document.createElement('article');
226
+ const heading = document.createElement('h3');
227
+ heading.textContent = metric[1] + (metric[2] ? ' · '+metric[2] : '');
228
+ const canvas = document.createElement('canvas');
229
+ canvas.setAttribute('role','img');
230
+ canvas.setAttribute('aria-label',metric[1]+' des trois Ruuvi sur une heure');
231
+ const output = document.createElement('output');
232
+ const series = history.map(points=>points[metric[0]]);
233
+ card.append(heading,canvas,output);
234
+ grid.append(card);
235
+ const paint = (cursor = null)=>draw(canvas,output,metric,series,cursor);
236
+ canvas.addEventListener('pointermove',event=>{
237
+ const left = metric[0] === 'reachable' ? 99 : 55;
238
+ const ratio = (event.offsetX-left)/(canvas.clientWidth-left-19);
239
+ paint(Math.max(0,Math.min(1,ratio)));
240
+ });
241
+ canvas.addEventListener('pointerleave',()=>paint());
242
+ painters.push(paint);
243
+ paint();
244
+ }
245
+ });
26
246
  }
247
+ sensors.forEach((sensor,i)=>{
248
+ const label=document.createElement('label');
249
+ label.style.color=sensor.color;
250
+ const input=document.createElement('input');
251
+ input.type='checkbox';input.checked=true;
252
+ input.addEventListener('change',()=>{
253
+ if(input.checked) selected.add(i);
254
+ else selected.delete(i);
255
+ painters.forEach(paint=>paint());
256
+ });
257
+ label.append(input,' '+sensor.name);
258
+ toggle.append(label);
259
+ });
260
+ window.addEventListener('resize',()=>painters.forEach(paint=>paint()));
261
+ render();
262
+
263
+ const ruuvi = document.querySelector('#ruuvi-view');
264
+ const relays = document.querySelector('#relays');
265
+ const relayCards = document.querySelector('#relay-cards');
27
266
 
28
- function render(sensors) {
29
- readings.replaceChildren();
30
- for (const [sensor, samples] of sensors) {
31
- const card = document.createElement('section');
267
+ function updateRelays(data) {
268
+ relayCards.replaceChildren();
269
+ for (let number=1; number<=6; number++) {
270
+ const reading = at(data,'electrical.switches.gx.gxInternalRelay'+number+'.state');
271
+ const card = document.createElement('article');
32
272
  const heading = document.createElement('h2');
33
- heading.textContent = sensor;
34
- const list = document.createElement('dl');
35
- for (const axis of axes) {
36
- const sample = samples[axis];
37
- const label = document.createElement('dt');
38
- label.textContent = axis;
39
- const entry = document.createElement('dd');
40
- const units = sample?.meta?.units;
41
- entry.textContent = Number.isFinite(sample?.value)
42
- ? formatter.format(sample.value) + (units ? ' ' + units : '')
43
- : '—';
44
- list.append(label, entry);
45
- }
46
- const timestamp = Math.max(...Object.values(samples).map(sample => Date.parse(sample.timestamp)).filter(Number.isFinite));
47
- const time = document.createElement('time');
48
- time.textContent = Number.isFinite(timestamp)
49
- ? 'Dernière mesure reçue · ' + new Date(timestamp).toLocaleTimeString('fr-FR')
50
- : 'Horodatage indisponible';
51
- card.append(heading, list, time);
52
- readings.append(card);
273
+ heading.textContent = 'Relais '+number;
274
+ const state = document.createElement('p');
275
+ state.textContent = reading?.value === true ? 'On' : reading?.value === false ? 'Off' : 'Indisponible';
276
+ const time = document.createElement('small');
277
+ const timestamp = Date.parse(reading?.timestamp);
278
+ time.textContent = Number.isFinite(timestamp) ? 'État publié à '+clock(timestamp) : 'Horodatage indisponible';
279
+ card.append(heading,state,time);
280
+ relayCards.append(card);
53
281
  }
54
282
  }
55
283
 
56
- async function refresh() {
284
+
285
+ const pages = {"Vessel": {"Vessel": [["ui_button", "Map YODA"], ["ui_text", "name"], ["ui_text", "mmsi"], ["ui_text", "callsignVHF"]], "Design": [["ui_text", "length"], ["ui_text", "beam"], ["ui_text", "draft"], ["ui_text", "airHeight"], ["ui_text", "aisShipType"], ["ui_text", "aisClass"]], "Sensors": [["ui_text", "gps.fromBow"], ["ui_text", "gps.fromCenter"]]}, "Navigation": {"Global": [["ui_text", "DateTime"], ["ui_text", "LogNM"], ["ui_text", "Engine Rev.YD"], ["ui_text", "WaterTemp"], ["ui_text", "Lat"], ["ui_text", "Lon"]], "Navigation": [["ui_text", "Depth"], ["ui_text", "SOG"], ["ui_text", "STW"], ["ui_text", "HDT"], ["ui_text", "HDM"], ["ui_text", "Autopilot Target HDT"], ["ui_text", "RudderAng"], ["ui_text", "RateOfTurn"], ["ui_gauge", "HDT Compass"], ["ui_gauge", "HDM Compass"]], "Wind": [["ui_text", "SpeedTrue"], ["ui_text", "SpeedApp"], ["ui_text", "SpeedOvG"], ["ui_text", "AngleTrue"], ["ui_text", "AngleApp"], ["ui_gauge", "WDT Compass"], ["ui_gauge", "WDA Compass"]]}, "Propulsion": {"Engine": [["ui_text", "DateTime"], ["ui_text", "Engine runTime"], ["ui_text", "Engine Rev.YD"], ["ui_text", "Engine Rev.56"], ["ui_text", "Engine Rev.86"], ["ui_led", "Engine On/Off"], ["ui_text", "Engine Temperature"], ["ui_text", "Alternator Voltage"], ["ui_text", "Batterie Voltage"]], "Notifications": [["ui_text", "checkEngine"], ["ui_text", "shuttingDown"], ["ui_text", "emergencyStopMode"], ["ui_text", "maintenanceNeeded"], ["ui_text", "revLimitExceeded"], ["ui_text", "highBoostPressure"], ["ui_text", "overTemperature"], ["ui_text", "eGRSystem"], ["ui_text", "powerReduction"], ["ui_text", "preheatIndicator"], ["ui_text", "commError"], ["ui_text", "chargeIndicator"], ["ui_text", "lowCoolantLevel"], ["ui_text", "lowFuelPressure"], ["ui_text", "lowOilLevel"], ["ui_text", "lowOilPressure"], ["ui_text", "lowSystemVoltage"], ["ui_text", "neutralStartProtect"], ["ui_text", "waterFlow"], ["ui_text", "waterInFuel"], ["ui_text", "throttlePositionSensor"], ["ui_text", "subOrSecondaryThrottle"], ["ui_text", "warningLevel1"], ["ui_text", "warningLevel2"]]}, "Ruuvi": {"Cockpit": [["ui_text", "Temp"], ["ui_text", "Humidity"], ["ui_text", "Pressure"], ["ui_chart", "Temp Chart"], ["ui_chart", "Humidity Chart"], ["ui_chart", "Pressure Chart"]], "Inside": [["ui_text", "Temp"], ["ui_text", "Humidity"], ["ui_chart", "Temp Chart"], ["ui_chart", "Humidity Chart"]], "Fridge": [["ui_text", "Temp"], ["ui_text", "Humidity"], ["ui_chart", "Temp Chart"], ["ui_chart", "Humidity Chart"]], "Motor": [["ui_text", "Temp"], ["ui_text", "Humidity"], ["ui_chart", "Temp Chart"], ["ui_chart", "Humidity Chart"]]}, "Batteries": {"Service Battery": [["ui_text", "Voltage"], ["ui_text", "Current"], ["ui_text", "Power"], ["ui_text", "Temperature"], ["ui_chart", "Voltage"], ["ui_chart", "Current"], ["ui_chart", "Power"], ["ui_chart", "Temp"]], "Charges": [["ui_text", "stateOfCharge"], ["ui_text", "lifetimeDischarge"], ["ui_text", "consumedCharge"], ["ui_text", "dischargeSinceFull"], ["ui_text", "dischargedEnergy"], ["ui_text", "timeRemaining"]], "Motor Battery": [["ui_text", "Voltage"], ["ui_chart", "Voltage"]]}, "Switches": {"Switches": [["ui_switch", "Raspi4 IO#11"]], "Audio Alarms": [["ui_led", "sw1"], ["ui_led", "sw0"]]}};
286
+ const nodeRed = document.querySelector('#navigation-view');
287
+ const oldNav = document.querySelector('#old-nav');
288
+ const oldPanels = document.querySelector('#old-panels');
289
+ const mapPanel = document.querySelector('#map-panel');
290
+ const bindings = {"Vessel|Vessel|name": ["name", null], "Vessel|Vessel|mmsi": ["mmsi", null], "Vessel|Vessel|callsignVHF": ["communication", null], "Vessel|Design|length": ["design.length", null], "Vessel|Design|beam": ["design.beam", null], "Vessel|Design|draft": ["design.draft", null], "Vessel|Design|airHeight": ["design.airHeight", null], "Vessel|Design|aisShipType": ["design.aisShipType", null], "Vessel|Sensors|gps.fromBow": ["sensors.gps.fromBow", null], "Vessel|Sensors|gps.fromCenter": ["sensors.gps.fromCenter", null], "Vessel|Design|aisClass": ["sensors.ais.class", null], "Propulsion|Engine|Engine Rev.56": ["propulsion.port.revolutions", "YDNU-02RM.56"], "Propulsion|Engine|Alternator Voltage": ["propulsion.port.alternatorVoltage", null], "Propulsion|Engine|Engine runTime": ["propulsion.port.runTime", null], "Propulsion|Engine|Engine Temperature": ["propulsion.port.temperature", null], "Propulsion|Notifications|chargeIndicator": ["notifications.propulsion.port.chargeIndicator", null], "Propulsion|Notifications|checkEngine": ["notifications.propulsion.port.checkEngine", null], "Propulsion|Notifications|commError": ["notifications.propulsion.port.commError", null], "Propulsion|Notifications|eGRSystem": ["notifications.propulsion.port.eGRSystem", null], "Propulsion|Notifications|emergencyStopMode": ["notifications.propulsion.port.emergencyStopMode", null], "Propulsion|Notifications|highBoostPressure": ["notifications.propulsion.port.highBoostPressure", null], "Propulsion|Notifications|lowCoolantLevel": ["notifications.propulsion.port.lowCoolantLevel", null], "Propulsion|Notifications|lowFuelPressure": ["notifications.propulsion.port.lowFuelPressure", null], "Propulsion|Notifications|lowOilLevel": ["notifications.propulsion.port.lowOilLevel", null], "Propulsion|Notifications|lowOilPressure": ["notifications.propulsion.port.lowOilPressure", null], "Propulsion|Notifications|lowSystemVoltage": ["notifications.propulsion.port.lowSystemVoltage", null], "Propulsion|Notifications|maintenanceNeeded": ["notifications.propulsion.port.maintenanceNeeded", null], "Propulsion|Notifications|neutralStartProtect": ["notifications.propulsion.port.neutralStartProtect", null], "Propulsion|Notifications|overTemperature": ["notifications.propulsion.port.overTemperature", null], "Propulsion|Notifications|powerReduction": ["notifications.propulsion.port.powerReduction", null], "Propulsion|Notifications|preheatIndicator": ["notifications.propulsion.port.preheatIndicator", null], "Propulsion|Notifications|revLimitExceeded": ["notifications.propulsion.port.revLimitExceeded", null], "Propulsion|Notifications|shuttingDown": ["notifications.propulsion.port.shuttingDown", null], "Propulsion|Notifications|subOrSecondaryThrottle": ["notifications.propulsion.port.subOrSecondaryThrottle", null], "Propulsion|Notifications|throttlePositionSensor": ["notifications.propulsion.port.throttlePositionSensor", null], "Propulsion|Notifications|warningLevel1": ["notifications.propulsion.port.warningLevel1", null], "Propulsion|Notifications|warningLevel2": ["notifications.propulsion.port.warningLevel2", null], "Propulsion|Notifications|waterFlow": ["notifications.propulsion.port.waterFlow", null], "Propulsion|Notifications|waterInFuel": ["notifications.propulsion.port.waterInFuel", null], "Propulsion|Engine|Batterie Voltage": ["electrical.batteries.0.voltage", null], "Propulsion|Engine|Engine Rev.YD": ["propulsion.engine_0.revolutions", null], "Propulsion|Engine|DateTime": ["navigation.datetime", null], "Propulsion|Engine|Engine Rev.86": ["propulsion.port.revolutions", "YDNU-02RM.86"], "Propulsion|Engine|Engine On/Off": ["propulsion.engine_0.revolutions", null], "Navigation|Global|Engine Rev.YD": ["propulsion.engine_0.revolutions", null], "Navigation|Global|DateTime": ["navigation.datetime", null], "Navigation|Global|LogNM": ["navigation.log", null], "Navigation|Global|Lat": ["navigation.position", null], "Navigation|Global|Lon": ["navigation.position", null], "Navigation|Navigation|SOG": ["navigation.speedOverGround", null], "Navigation|Navigation|STW": ["navigation.speedThroughWater", null], "Navigation|Navigation|Depth": ["environment.depth.belowSurface", null], "Navigation|Global|WaterTemp": ["environment.water.temperature", null], "Navigation|Wind|SpeedTrue": ["environment.wind.speedTrue", null], "Navigation|Wind|SpeedApp": ["environment.wind.speedApparent", null], "Navigation|Wind|SpeedOvG": ["environment.wind.speedOverGround", null], "Navigation|Wind|AngleTrue": ["environment.wind.directionTrue", null], "Navigation|Wind|AngleApp": ["environment.wind.angleApparent", null], "Navigation|Navigation|HDT": ["navigation.headingTrue", null], "Navigation|Navigation|HDM": ["navigation.headingMagnetic", null], "Navigation|Navigation|RateOfTurn": ["navigation.rateOfTurn", null], "Navigation|Navigation|RudderAng": ["steering.rudderAngle", null], "Navigation|Navigation|HDM Compass": ["navigation.headingMagnetic", null], "Navigation|Navigation|HDT Compass": ["navigation.headingTrue", null], "Navigation|Wind|WDT Compass": ["environment.wind.directionTrue", null], "Navigation|Wind|WDA Compass": ["environment.wind.angleApparent", null], "Navigation|Navigation|Autopilot Target HDT": ["steering.autopilot.target.headingTrue", null], "Ruuvi|Inside|Temp Chart": ["environment.venus.22.temperature", null], "Ruuvi|Inside|Temp": ["environment.venus.22.temperature", null], "Ruuvi|Fridge|Temp Chart": ["environment.inside.refrigerator.temperature", null], "Ruuvi|Fridge|Temp": ["environment.inside.refrigerator.temperature", null], "Ruuvi|Motor|Temp Chart": ["environment.venus.20.temperature", null], "Ruuvi|Motor|Temp": ["environment.venus.20.temperature", null], "Ruuvi|Inside|Humidity Chart": ["environment.venus.22.humidity", null], "Ruuvi|Inside|Humidity": ["environment.venus.22.humidity", null], "Ruuvi|Fridge|Humidity Chart": ["environment.inside.refrigerator.humidity", null], "Ruuvi|Fridge|Humidity": ["environment.inside.refrigerator.humidity", null], "Ruuvi|Motor|Humidity Chart": ["environment.venus.20.humidity", null], "Ruuvi|Motor|Humidity": ["environment.venus.20.humidity", null], "Ruuvi|Cockpit|Temp Chart": ["environment.venus.23.temperature", null], "Ruuvi|Cockpit|Temp": ["environment.venus.23.temperature", null], "Ruuvi|Cockpit|Humidity Chart": ["environment.venus.23.humidity", null], "Ruuvi|Cockpit|Humidity": ["environment.venus.23.humidity", null], "Ruuvi|Cockpit|Pressure Chart": ["environment.venus.23.pressure", null], "Ruuvi|Cockpit|Pressure": ["environment.venus.23.pressure", null], "Batteries|Service Battery|Voltage": ["electrical.batteries.288.voltage", null], "Batteries|Service Battery|Current": ["electrical.batteries.288.current", null], "Batteries|Service Battery|Power": ["electrical.batteries.288.power", null], "Batteries|Service Battery|Temperature": ["electrical.batteries.288.temperature", null], "Batteries|Service Battery|Temp": ["electrical.batteries.288.temperature", null], "Batteries|Motor Battery|Voltage": ["electrical.batteries.288-second.voltage", null], "Batteries|Charges|stateOfCharge": ["electrical.batteries.288.capacity.stateOfCharge", null], "Batteries|Charges|lifetimeDischarge": ["electrical.batteries.288.lifetimeDischarge", null], "Batteries|Charges|consumedCharge": ["electrical.batteries.288.capacity.consumedCharge", null], "Batteries|Charges|dischargeSinceFull": ["electrical.batteries.288.capacity.dischargeSinceFull", null], "Batteries|Charges|dischargedEnergy": ["electrical.batteries.288.capacity.dischargedEnergy", null], "Batteries|Charges|timeRemaining": ["electrical.batteries.288.capacity.timeRemaining", null], "Switches|Switches|Raspi4 IO#11": ["electrical.switches.pin-11.state", null], "Switches|Audio Alarms|sw0": ["electrical.switches.venus-0.state", null], "Switches|Audio Alarms|sw1": ["electrical.switches.venus-1.state", null]};
291
+ function element(tag,text) {
292
+ const item=document.createElement(tag);
293
+ item.textContent=text;
294
+ return item;
295
+ }
296
+ let track = [], map, layer, imported = false;
297
+ const mapStatus=document.querySelector('#map-status');
298
+ function focusTrack() {
299
+ if(map && layer?.getBounds().isValid()) map.fitBounds(layer.getBounds(),{padding:[35,35],maxZoom:17});
300
+ }
301
+ function redrawTrack(recenter = true) {
302
+ if(!map) return;
303
+ if(layer) layer.remove();
304
+ layer=L.featureGroup().addTo(map);
305
+ if (!track.length) {
306
+ mapStatus.textContent = 'En attente d’une position GPS Signal K.';
307
+ map.invalidateSize();
308
+ return;
309
+ }
310
+ if(track.length>1) L.polyline(track.map(p=>[p.lat,p.lon]),{color:'#007f99',weight:4}).addTo(layer);
311
+ track.forEach((point,index)=>{
312
+ const last=index===track.length-1;
313
+ const caption=element('span',
314
+ (last?'Dernier point':'Point '+(index+1))+' · '+point.lat.toFixed(5)+'°, '+point.lon.toFixed(5)+'°'
315
+ +(point.time?' · '+new Date(point.time).toLocaleString('fr-FR'):''));
316
+ L.circleMarker([point.lat,point.lon],{radius:last?8:4,color:last?'#e04829':'#05667c',fillOpacity:.9})
317
+ .bindPopup(caption).addTo(layer);
318
+ });
319
+ const point=track.at(-1);
320
+ document.querySelector('#fix').textContent='Dernier point affiché · '+point.lat.toFixed(5)+'°, '+point.lon.toFixed(5)+'°'
321
+ +(point.time?' · '+new Date(point.time).toLocaleString('fr-FR'):'');
322
+ mapStatus.textContent=track.length+' points · '+(imported?'trace locale':'Signal K');
323
+ map.invalidateSize();
324
+ if (recenter) focusTrack();
325
+ }
326
+ function openMap() {
327
+ mapPanel.hidden=false;
328
+ if(!window.L) {
329
+ mapStatus.textContent='Carte indisponible : vérifie la connexion Internet.';
330
+ return;
331
+ }
332
+ if(!map) {
333
+ map=L.map('gps-map',{scrollWheelZoom:false}).setView([0,0],2);
334
+ L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png',{
335
+ maxZoom:19, attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
336
+ }).addTo(map).on('tileerror',()=>{
337
+ mapStatus.textContent='Fond cartographique indisponible · trace GPS toujours affichée.';
338
+ });
339
+ L.control.scale({imperial:false}).addTo(map);
340
+ }
341
+ redrawTrack();
342
+ mapPanel.scrollIntoView({block:'start'});
343
+ }
344
+ document.querySelector('#fit-map').addEventListener('click',focusTrack);
345
+ document.querySelector('#track-file').addEventListener('change',async event=>{
346
+ const file=event.target.files?.[0];
347
+ if(!file) return;
57
348
  try {
58
- const response = await fetch('/signalk/v1/api/vessels/self', {
59
- cache: 'no-store',
60
- signal: AbortSignal.timeout(10000)
349
+ const data=JSON.parse(await file.text());
350
+ const geometry=data.type==='Feature' ? data.geometry : data;
351
+ if(geometry?.type!=='LineString' || !Array.isArray(geometry.coordinates)
352
+ || geometry.coordinates.length<2 || geometry.coordinates.length>5000)
353
+ throw new Error('Choisis une trace GeoJSON LineString de 2 à 5 000 points.');
354
+ const points=geometry.coordinates.map(item=>{
355
+ if(!Array.isArray(item)) throw new Error('Coordonnées GPS invalides.');
356
+ const [lon,lat]=item;
357
+ if(!Number.isFinite(lat)||!Number.isFinite(lon)||Math.abs(lat)>90||Math.abs(lon)>180)
358
+ throw new Error('Coordonnées GPS invalides.');
359
+ return {lat,lon};
61
360
  });
62
- if (!response.ok) throw new Error('HTTP ' + response.status);
63
- const sensors = findSensors(await response.json());
64
- render(sensors);
65
- status.textContent = sensors.size
66
- ? 'Signal K connecté'
67
- : 'Aucune accélération Ruuvi trouvée dans Signal K.';
68
- } catch (error) {
69
- status.textContent = 'Lecture Signal K indisponible. Nouvelle tentative dans 5 s.';
70
- readings.replaceChildren();
71
- } finally {
72
- setTimeout(refresh, 5000);
361
+ track=points;imported=true;
362
+ document.querySelector('#map-mode').textContent='Trace GeoJSON importée · fond OpenStreetMap';
363
+ openMap();
364
+ } catch(error) {
365
+ mapStatus.textContent=error instanceof SyntaxError?'GeoJSON illisible.':error.message;
366
+ }
367
+ });
368
+ let currentSubpage;
369
+ const liveWidgets = [];
370
+ function showPage(name) {
371
+ currentSubpage = name;
372
+ liveWidgets.length = 0;
373
+ for(const button of oldNav.children) button.setAttribute('aria-pressed',String(button.textContent===name));
374
+ oldPanels.replaceChildren();
375
+ mapPanel.hidden=true;
376
+ for(const [group,widgets] of Object.entries(pages[name])) {
377
+ const card=element('article','');
378
+ card.append(element('h2',group));
379
+ for(const [type,label] of widgets) {
380
+ if(type==='ui_button') continue;
381
+ if(type==='ui_chart'||type==='ui_gauge') {
382
+ card.append(element('h3',label));
383
+ const canvas = document.createElement('canvas');
384
+ const caption = element('small','En attente de données');
385
+ canvas.setAttribute('role','img');
386
+ canvas.setAttribute('aria-label',label);
387
+ card.append(canvas,caption);
388
+ liveWidgets.push({label, binding:bindings[[name,group,label].join('|')],canvas,caption,compass:type==='ui_gauge'});
389
+
390
+ continue;
391
+ }
392
+ const row=element('p','');row.className='reading';
393
+ const value = element('strong','Indisponible');
394
+ row.append(element('span',label),value);
395
+ liveWidgets.push({label,binding:bindings[[name,group,label].join('|')],value});
396
+ card.append(row);
397
+ }
398
+ if(name==='Vessel'&&group==='Vessel'||name==='Navigation'&&group==='Global') {
399
+ const button=element('button','MAP YODA');
400
+ button.type='button';button.addEventListener('click',openMap);card.append(button);
401
+ }
402
+ oldPanels.append(card);
403
+ }
404
+ if(name==='Switches') {
405
+ const p=element('p','GPIO et alarmes affichés en lecture seule.');
406
+ oldPanels.append(p);
407
+ }
408
+ updateWidgets();
409
+ }
410
+ Object.keys(pages).forEach(name=>{
411
+ const button=element('button',name);
412
+ button.type='button';button.addEventListener('click',()=>showPage(name));
413
+ oldNav.append(button);
414
+ });
415
+ const home = document.querySelector('#home');
416
+ const header = document.querySelector('#page-header');
417
+ const pageLinks = header.querySelectorAll('[data-page]');
418
+ const views = { accueil: home, navigation: nodeRed, ruuvi, relais: relays };
419
+ let currentPage;
420
+
421
+ function route() {
422
+ const page = window.location.hash.slice(1) || 'accueil';
423
+ if (!Object.hasOwn(views, page) || page === currentPage) return;
424
+ currentPage = page;
425
+ for (const [name, view] of Object.entries(views)) view.hidden = name !== page;
426
+ header.hidden = page === 'accueil';
427
+ for (const link of pageLinks) {
428
+ if (link.dataset.page === page) link.setAttribute('aria-current', 'page');
429
+ else link.removeAttribute('aria-current');
430
+ }
431
+ if (page === 'navigation' && !oldPanels.hasChildNodes()) showPage('Vessel');
432
+ if (page === 'navigation' && map && !mapPanel.hidden) map.invalidateSize();
433
+ if (page === 'ruuvi') painters.forEach(paint => paint());
434
+ window.scrollTo(0, 0);
435
+ }
436
+ window.addEventListener('hashchange', route);
437
+ let snapshot;
438
+ const trend = new Map();
439
+ const bindingsByPath = [...new Set(Object.values(bindings).filter(([,source])=>!source).map(([path])=>path))];
440
+ const num = new Intl.NumberFormat('fr-FR',{maximumFractionDigits:2});
441
+
442
+ function selectedReading(binding) {
443
+ if (!binding) return undefined;
444
+ const [path,source]=binding;
445
+ const node=at(snapshot,path);
446
+ if (!source) return node;
447
+ return node?.values?.[source] ?? (node?.$source === source ? node : undefined);
448
+ }
449
+
450
+ function display(label, value, path, units) {
451
+ if (value == null) return 'Indisponible';
452
+ if (label === 'callsignVHF') return value.callsignVhf ?? value.callsignVHF ?? 'Indisponible';
453
+ if (label === 'Lat' || label === 'Lon') {
454
+ const coordinate=label==='Lat'?value.latitude:value.longitude;
455
+ return Number.isFinite(coordinate) ? coordinate.toFixed(5)+'°' : 'Indisponible';
456
+ }
457
+ if (label === 'Engine On/Off' && typeof value === 'number') return value > 0 ? 'En marche' : 'Arrêté';
458
+ if (typeof value === 'boolean') return value ? 'On' : 'Off';
459
+ if (typeof value === 'object') {
460
+ const detail=value.overall ?? value.max ?? value.name ?? value.message ?? value.state;
461
+ const dimension=path?.startsWith('design.') && label!=='aisShipType';
462
+ return typeof detail === 'number' && dimension ? num.format(detail)+' m' : String(detail ?? 'Indisponible');
73
463
  }
464
+ if (typeof value !== 'number') return String(value);
465
+ let multiplier=1, offset=0, unit=units ?? '';
466
+ if (path?.endsWith('.temperature')) [offset,unit]=[-273.15,'°C'];
467
+ else if (path?.endsWith('.humidity') || path?.endsWith('.stateOfCharge')) [multiplier,unit]=[100,'%'];
468
+ else if (path?.endsWith('.pressure')) [multiplier,unit]=[.01,'hPa'];
469
+ else if (path?.endsWith('.revolutions')) [multiplier,unit]=[60,'tr/min'];
470
+ else if (label==='LogNM') [multiplier,unit]=[1/1852,'NM'];
471
+ else if (['SOG','STW','SpeedTrue','SpeedApp','SpeedOvG'].includes(label)) [multiplier,unit]=[3600/1852,'nd'];
472
+ else if (['HDT','HDM','Autopilot Target HDT','RudderAng','AngleTrue','AngleApp'].includes(label)) [multiplier,unit]=[180/Math.PI,'°'];
473
+ else if (label==='RateOfTurn') [multiplier,unit]=[180/Math.PI,'°/s'];
474
+ else if (label==='Engine runTime'||label==='timeRemaining') [multiplier,unit]=[1/3600,'h'];
475
+ else if (label==='lifetimeDischarge'||label==='consumedCharge'||label==='dischargeSinceFull') [multiplier,unit]=[1/3600,'Ah'];
476
+ else if (label==='dischargedEnergy' && units==='J') [multiplier,unit]=[1/3600,'Wh'];
477
+ else if (path?.endsWith('.voltage')||path?.endsWith('.alternatorVoltage')) unit='V';
478
+ else if (path?.endsWith('.current')) unit='A';
479
+ else if (path?.endsWith('.power')) unit='W';
480
+ else if (['length','beam','draft','airHeight','gps.fromBow','gps.fromCenter','Depth'].includes(label)) unit='m';
481
+ return num.format(value*multiplier+offset)+(unit?' '+unit:'');
74
482
  }
75
483
 
484
+ function drawWidget(widget, reading, raw) {
485
+ const {canvas,caption,compass,label,binding}=widget;
486
+ canvas.width=300;canvas.height=110;
487
+ const ctx=canvas.getContext('2d');
488
+ ctx.strokeStyle='#62ddd0';ctx.fillStyle='#c3d6df';ctx.font='13px system-ui';
489
+ if (compass) {
490
+ ctx.beginPath();ctx.arc(150,56,36,0,Math.PI*2);ctx.stroke();ctx.fillText('N',145,14);
491
+ if (Number.isFinite(raw)) {
492
+ ctx.beginPath();ctx.moveTo(150,56);ctx.lineTo(150+30*Math.sin(raw),56-30*Math.cos(raw));ctx.stroke();
493
+ }
494
+ caption.textContent=Number.isFinite(raw)?num.format(raw*180/Math.PI)+'°':'Indisponible';
495
+ return;
496
+ }
497
+ const points=trend.get(binding?.[0]) ?? [];
498
+ caption.textContent=points.length ? display(label,points.at(-1).value,binding[0],reading?.meta?.units)+' · '+points.length+' pts':'Indisponible';
499
+ if (!points.length) return;
500
+ const values=points.map(point=>point.value);
501
+ const low=Math.min(...values), high=Math.max(...values);
502
+ const start=Date.now()-hour;
503
+ ctx.beginPath();
504
+ points.forEach(({time,value},i)=>{
505
+ const x=12+276*(time-start)/hour;
506
+ const y=high===low?48:78-(value-low)*58/(high-low);
507
+ if(i===0)ctx.moveTo(x,y);else ctx.lineTo(x,y);
508
+ });
509
+ ctx.stroke();
510
+ }
511
+
512
+ function updateWidgets() {
513
+ for (const widget of liveWidgets) {
514
+ const reading=selectedReading(widget.binding);
515
+ const raw=reading && Object.hasOwn(reading,'value') ? reading.value : reading;
516
+ const label=display(widget.label,raw,widget.binding?.[0],reading?.meta?.units);
517
+ if (widget.canvas) drawWidget(widget,reading,raw);
518
+ else {
519
+ widget.value.textContent=label;
520
+ const timestamp=Date.parse(reading?.timestamp);
521
+ widget.value.title=Number.isFinite(timestamp)?'Reçu à '+clock(timestamp):'';
522
+ }
523
+ }
524
+ }
525
+
526
+ function collectNavigation(now) {
527
+ for (const path of bindingsByPath) {
528
+ const reading=at(snapshot,path);
529
+ const points=trend.get(path) ?? [];
530
+ while(points.length && points[0].time<now-hour)points.shift();
531
+ const time=Date.parse(reading?.timestamp);
532
+ if (Number.isFinite(reading?.value) && Number.isFinite(time) && time>=now-hour && time<=now
533
+ && (!points.length || time>points.at(-1).time)) points.push({time,value:reading.value});
534
+ if (points.length) trend.set(path,points);
535
+ }
536
+ if (imported) return;
537
+ const reading=at(snapshot,'navigation.position');
538
+ const lat=reading?.value?.latitude, lon=reading?.value?.longitude, time=Date.parse(reading?.timestamp);
539
+ if (!Number.isFinite(lat) || Math.abs(lat)>90 || !Number.isFinite(lon) || Math.abs(lon)>180 || !Number.isFinite(time)) return;
540
+ const last=track.at(-1);
541
+ if (last && time<=Date.parse(last.time)) return;
542
+ const first=!track.length;
543
+ track.push({lat,lon,time:new Date(time).toISOString()});
544
+ while(track.length>5000 || (track.length>1 && Date.parse(track[0].time)<now-hour))track.shift();
545
+ if (map && !mapPanel.hidden) redrawTrack(first);
546
+ }
547
+
548
+ const connection = document.createElement('p');
549
+ connection.setAttribute('role','status');
550
+ connection.hidden=true;
551
+ header.after(connection);
552
+
553
+ async function refresh() {
554
+ try {
555
+ const response=await fetch('/signalk/v1/api/vessels/self',{cache:'no-store',signal:AbortSignal.timeout(10000)});
556
+ if (!response.ok) throw new Error('HTTP '+response.status);
557
+ snapshot=await response.json();
558
+ const now=Date.now();
559
+ record(snapshot,now);
560
+ collectNavigation(now);
561
+ updateRelays(snapshot);
562
+ connection.hidden=true;
563
+ } catch {
564
+ snapshot=undefined;
565
+ updateRelays(null);
566
+ connection.textContent='Signal K indisponible · nouvelle tentative dans 5 s';
567
+ connection.hidden=false;
568
+ }
569
+ updateWidgets();
570
+ if (!ruuvi.hidden) painters.forEach(paint=>paint());
571
+ setTimeout(refresh,5000);
572
+ }
573
+ route();
574
+ updateRelays(null);
76
575
  refresh();
package/public/index.html CHANGED
@@ -2,13 +2,65 @@
2
2
  <html lang="fr">
3
3
  <meta charset="utf-8">
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1">
5
- <title>YODA Dashboard</title>
6
- <link rel="stylesheet" href="./style.css">
5
+ <title>YODA · Dufour 390 GL</title>
6
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"><link rel="stylesheet" href="./style.css">
7
+ <header id="page-header" hidden>
8
+ <a class="brand" href="#accueil" aria-label="Retour à l’accueil YODA">YODA</a>
9
+ <nav aria-label="Pages">
10
+ <a href="#navigation" data-page="navigation">Navigation</a>
11
+ <a href="#ruuvi" data-page="ruuvi">Ruuvi</a>
12
+ <a href="#relais" data-page="relais">Relais</a>
13
+ </nav>
14
+ </header>
7
15
  <main>
8
- <h1>YODA Dashboard</h1>
9
- <p>Accélérations Ruuvi · repère propre à chaque capteur</p>
10
- <p id="status" role="status">Connexion à Signal K…</p>
11
- <div id="sensors"></div>
16
+ <section id="home" aria-labelledby="home-title">
17
+ <div class="home-content">
18
+ <h1 id="home-title">YODA</h1>
19
+ <p class="boat-model">Dufour 390 GL</p>
20
+ <nav class="home-menu" aria-label="Accès aux pages">
21
+ <a href="#navigation">Navigation</a>
22
+ <a href="#ruuvi">Ruuvi</a>
23
+ <a href="#relais">Relais</a>
24
+ </nav>
25
+ </div>
26
+ </section>
27
+ <div id="ruuvi-view" hidden>
28
+ <h1>Ruuvi Cookpit-Inside-Motor (last hour)</h1>
29
+
30
+ <div class="controls">
31
+ <fieldset aria-label="Capteurs visibles"></fieldset>
32
+ </div>
33
+ <div class="layout">
34
+ <aside><nav aria-label="Familles de mesures">
35
+ <a href="#ambiance">Ambiance</a>
36
+ <a href="#accelerations">Accélérations</a>
37
+ <a href="#diagnostic">Diagnostic</a>
38
+ </nav></aside>
39
+ <div id="charts"></div>
40
+ </div>
41
+ </div>
42
+ <section id="relays" hidden>
43
+ <h1>Relais</h1>
44
+
45
+ <div class="grid" id="relay-cards"></div>
46
+ </section>
47
+ <section id="navigation-view" hidden>
48
+ <h1>YODA Navigation</h1>
49
+
50
+ <div class="layout"><aside><nav id="old-nav" aria-label="Sous-menus Navigation"></nav></aside>
51
+ <div>
52
+ <div id="old-panels" class="grid"></div>
53
+ <section id="map-panel" hidden>
54
+ <h2>Carte GPS</h2>
55
+ <p id="map-mode">Positions GPS reçues pendant l’ouverture de la page · fond OpenStreetMap</p>
56
+ <button type="button" id="fit-map">Centrer sur la trace</button>
57
+ <label>Ouvrir une trace GeoJSON <input id="track-file" type="file" accept=".json,.geojson"></label>
58
+ <p id="map-status" role="status"></p>
59
+ <div id="gps-map" aria-label="Carte et trace GPS"></div>
60
+ <p id="fix"></p>
61
+ </section>
62
+ </div></div>
63
+ </section>
12
64
  </main>
13
- <script src="./dashboard.js" defer></script>
65
+ <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" defer></script><script src="./dashboard.js" defer></script>
14
66
  </html>
package/public/style.css CHANGED
@@ -1,8 +1,50 @@
1
- :root { color-scheme: dark; font-family: system-ui, sans-serif; background: #101c27; color: #e8f4f6; }
2
- main { margin: 3rem auto; width: min(94%, 56rem); }
3
- #status, time { color: #adc8ce; }
4
- #sensors { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
5
- section { border: 1px solid #38515e; border-radius: 0.75rem; background: #172936; padding: 1rem; }
6
- h2 { margin-top: 0; }
7
- dl { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; font-variant-numeric: tabular-nums; }
8
- dd { margin: 0; text-align: right; }
1
+
2
+ [hidden]{display:none!important}
3
+ :root{color-scheme:dark;font:16px system-ui,sans-serif;background:#0d1923;color:#eaf3f6}
4
+ body{margin:0} header,main{max-width:1680px;margin:auto;padding:1.2rem clamp(.75rem,2vw,2rem)}
5
+ header{border-bottom:1px solid #304554;display:flex;align-items:center;gap:1.1rem}
6
+ header strong{letter-spacing:.15em} header span,small,p{color:#abc0cc}
7
+ h1{font-size:clamp(2rem,5vw,3rem);margin:.5rem 0} p{line-height:1.55}
8
+ .controls{display:flex;flex-wrap:wrap;justify-content:space-between;gap:1rem;margin:1.5rem 0}
9
+ fieldset,nav{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;border:0;padding:0;margin:0}
10
+ button,label{font:inherit;color:inherit;background:#182b39;border:1px solid #405a6b;border-radius:.5rem;padding:.55rem .8rem;cursor:pointer}
11
+ button[aria-pressed=true]{background:#a5e3d6;color:#102631;border-color:#a5e3d6}
12
+ input{accent-color:#91dfce}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem}
13
+ article{min-width:0;background:#142632;border:1px solid #344d5c;border-radius:.8rem;padding:1rem}
14
+ h2{font-size:1.2rem;margin:.1rem 0 .4rem} canvas{display:block;width:100%;height:220px}
15
+ output{display:block;min-height:3rem;color:#c3d6df;font-size:.86rem;line-height:1.45}
16
+ .layout{display:grid;grid-template-columns:clamp(7.5rem,10vw,9rem) minmax(0,1fr);gap:clamp(.65rem,1.4vw,1.25rem)}
17
+ aside nav{position:sticky;top:1rem;display:grid;gap:.45rem;background:#142632;border:1px solid #344d5c;border-radius:.65rem;padding:.4rem}
18
+ aside a{color:#cce3eb;text-decoration:none;padding:.55rem .35rem;border-radius:.35rem;overflow-wrap:anywhere}
19
+ aside a:hover,aside a:focus-visible{background:#a5e3d6;color:#102631}
20
+ .chart-group{scroll-margin-top:1rem;margin-bottom:1.75rem}
21
+ .chart-group:target h2{color:#a5e3d6}
22
+ .chart-group h2{margin-bottom:.65rem;font-size:1.45rem}
23
+ article h3{margin:.1rem 0 .4rem;font-size:1.15rem}
24
+ @media(max-width:1050px){.grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
25
+ @media(max-width:740px){.grid{grid-template-columns:minmax(0,1fr)}}
26
+ @media(max-width:500px){.layout{grid-template-columns:5.7rem minmax(0,1fr)}aside nav{font-size:.77rem}article{padding:.5rem}}
27
+
28
+ #old-nav button{text-align:left;padding:.45rem .35rem;overflow-wrap:anywhere}
29
+ #old-panels article{align-self:start}
30
+ #old-panels .reading{display:flex;justify-content:space-between;align-items:baseline;gap:.55rem;border-bottom:1px solid #304554;padding:.48rem 0;margin:0;font-size:.92rem}
31
+ #old-panels .reading strong{text-align:right;white-space:nowrap;color:#eaf3f6}
32
+ #old-panels canvas{height:110px}
33
+ #old-panels button{margin-top:.8rem}
34
+ #gps-map{height:clamp(290px,55vh,580px);border:1px solid #405a6b;border-radius:.75rem;background:#283b48}
35
+ #map-panel{margin-top:1rem}
36
+ #map-panel label{display:inline-block;margin:.35rem 0}
37
+ #track-file{max-width:100%}
38
+
39
+ #home{min-height:calc(100vh - 2.4rem);display:grid;place-items:center}
40
+ .home-content{width:min(100%,58rem);text-align:center}
41
+ #home-title{font-size:clamp(4.5rem,15vw,9rem);line-height:1;letter-spacing:.07em;margin:0}
42
+ .boat-model{font-size:clamp(1.35rem,4vw,2.4rem);margin:.65rem 0 2.6rem}
43
+ .home-menu{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(.65rem,2vw,1.3rem)}
44
+ .home-menu a,#page-header a{color:inherit;text-decoration:none}
45
+ .home-menu a{min-height:7rem;display:grid;place-items:center;background:#182f3d;border:1px solid #446273;border-radius:.85rem;font-size:clamp(1.2rem,3vw,1.85rem);font-weight:650}
46
+ .home-menu a:hover,.home-menu a:focus-visible{background:#a5e3d6;color:#102631}
47
+ #page-header a{padding:.5rem .65rem;border-radius:.4rem}
48
+ #page-header a[aria-current=page]{background:#a5e3d6;color:#102631}
49
+ .brand{font-weight:750;letter-spacing:.12em}
50
+ @media(max-width:540px){.home-menu{grid-template-columns:1fr}.home-menu a{min-height:4rem}#page-header{gap:.3rem}}