signalk-ais-navionics-converter 1.0.1 → 1.0.2
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/.babelrc +24 -0
- package/README.md +5 -1
- package/package.json +35 -2
- package/public/main.js +310 -0
- package/public/remoteEntry.js +514 -0
- package/public/src_components_PluginConfigurationPanel_jsx.js +22 -0
- package/public/vendors-node_modules_react_index_js.js +76 -0
- package/src/components/PluginConfigurationPanel.jsx +786 -0
- package/src/index.js +0 -0
- package/webpack.config.js +55 -0
- package/.github/workflows/npm-publish.yml +0 -21
- package/img/OpenCpn1.png +0 -0
- package/img/OpenCpn2.png +0 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const PluginConfigurationPanel = ({ configuration, save }) => {
|
|
4
|
+
const [config, setConfig] = useState(configuration || {});
|
|
5
|
+
const [initialConfig, setInitialConfig] = useState(configuration);
|
|
6
|
+
const [loading, setLoading] = useState(false);
|
|
7
|
+
const [status, setStatus] = useState('');
|
|
8
|
+
const [showDialog, setShowDialog] = useState(false);
|
|
9
|
+
const [dialogData, setDialogData] = useState({ title: '', message: '', callback: null });
|
|
10
|
+
const [ownMMSI, setOwnMMSI] = useState(null);
|
|
11
|
+
|
|
12
|
+
const translations = {
|
|
13
|
+
de: {
|
|
14
|
+
general: 'Allgemein',
|
|
15
|
+
tcpServer: 'TCP Server',
|
|
16
|
+
filtering: 'Filterung',
|
|
17
|
+
debugging: 'Debugging',
|
|
18
|
+
vesselFinder: 'VesselFinder',
|
|
19
|
+
cloudVessels: 'Cloud Vessels (AISFleet)',
|
|
20
|
+
|
|
21
|
+
tcpPort: 'TCP Port:',
|
|
22
|
+
updateInterval: 'Update-Intervall für geänderte Schiffe (Sekunden):',
|
|
23
|
+
tcpResendInterval: 'Update-Intervall für unveränderte Schiffe (Sekunden):',
|
|
24
|
+
|
|
25
|
+
skipWithoutCallsign: 'Schiffe ohne Rufzeichen überspringen',
|
|
26
|
+
skipStaleData: 'Schiffe mit alten Daten überspringen',
|
|
27
|
+
staleDataThreshold: 'Schwellenwert für alte Daten (Minuten):',
|
|
28
|
+
staleDataShipname: 'Zeitstempel zum Schiffsnamen hinzufügen ab (Minuten, 0=deaktiviert):',
|
|
29
|
+
|
|
30
|
+
minAlarmSOG: 'Minimale SOG für Alarm (m/s):',
|
|
31
|
+
maxMinutesSOGToZero: 'Maximum Minuten vor SOG auf 0 gesetzt (0=keine Korrektur):',
|
|
32
|
+
|
|
33
|
+
logDebugDetails: 'Debug alle Schiff-Details',
|
|
34
|
+
logMMSI: 'Filter Debug-Ausgabe für MMSI:',
|
|
35
|
+
logDebugStale: 'Debug alte Schiffe',
|
|
36
|
+
logDebugJSON: 'Debug JSON-Daten',
|
|
37
|
+
logDebugAIS: 'Debug AIS-Daten',
|
|
38
|
+
logDebugSOG: 'Debug Schiffe mit korrigierter SOG',
|
|
39
|
+
|
|
40
|
+
vesselFinderEnabled: 'VesselFinder-Weiterleitung aktivieren',
|
|
41
|
+
vesselFinderHost: 'VesselFinder Host:',
|
|
42
|
+
vesselFinderPort: 'VesselFinder UDP Port:',
|
|
43
|
+
vesselFinderUpdateRate: 'VesselFinder Update Rate (Sekunden):',
|
|
44
|
+
|
|
45
|
+
cloudVesselsEnabled: 'Schiffe von AISFleet.com einbeziehen',
|
|
46
|
+
cloudVesselsUpdateInterval: 'Cloud Vessels Update-Intervall (Sekunden):',
|
|
47
|
+
cloudVesselsRadius: 'Radius von eigenem Schiff (Seemeilen):',
|
|
48
|
+
|
|
49
|
+
save: 'Speichern',
|
|
50
|
+
cancel: 'Abbruch',
|
|
51
|
+
unsavedWarning: 'Es gibt ungespeicherte Änderungen. Wirklich abbrechen?',
|
|
52
|
+
unsavedTitle: 'Ungespeicherte Änderungen',
|
|
53
|
+
yes: 'Ja',
|
|
54
|
+
no: 'Nein'
|
|
55
|
+
},
|
|
56
|
+
en: {
|
|
57
|
+
general: 'General',
|
|
58
|
+
tcpServer: 'TCP Server',
|
|
59
|
+
filtering: 'Filtering',
|
|
60
|
+
debugging: 'Debugging',
|
|
61
|
+
vesselFinder: 'VesselFinder',
|
|
62
|
+
cloudVessels: 'Cloud Vessels (AISFleet)',
|
|
63
|
+
|
|
64
|
+
tcpPort: 'TCP Port:',
|
|
65
|
+
updateInterval: 'Update interval for changed vessels (seconds):',
|
|
66
|
+
tcpResendInterval: 'Update interval for unchanged vessels (seconds):',
|
|
67
|
+
|
|
68
|
+
skipWithoutCallsign: 'Skip vessels without callsign',
|
|
69
|
+
skipStaleData: 'Skip vessels with stale data',
|
|
70
|
+
staleDataThreshold: 'Stale data threshold (minutes):',
|
|
71
|
+
staleDataShipname: 'Add timestamp to ship name from (minutes, 0=disabled):',
|
|
72
|
+
|
|
73
|
+
minAlarmSOG: 'Minimum SOG for alarm (m/s):',
|
|
74
|
+
maxMinutesSOGToZero: 'Maximum minutes before SOG set to 0 (0=no correction):',
|
|
75
|
+
|
|
76
|
+
logDebugDetails: 'Debug all vessel details',
|
|
77
|
+
logMMSI: 'Filter Debug MMSI:',
|
|
78
|
+
logDebugStale: 'Debug stale vessels',
|
|
79
|
+
logDebugJSON: 'Debug JSON data',
|
|
80
|
+
logDebugAIS: 'Debug AIS data',
|
|
81
|
+
logDebugSOG: 'Debug vessels with corrected SOG',
|
|
82
|
+
|
|
83
|
+
vesselFinderEnabled: 'Enable VesselFinder forwarding',
|
|
84
|
+
vesselFinderHost: 'VesselFinder Host:',
|
|
85
|
+
vesselFinderPort: 'VesselFinder UDP Port:',
|
|
86
|
+
vesselFinderUpdateRate: 'VesselFinder Update Rate (seconds):',
|
|
87
|
+
|
|
88
|
+
cloudVesselsEnabled: 'Include vessels from AISFleet.com',
|
|
89
|
+
cloudVesselsUpdateInterval: 'Cloud Vessels update interval (seconds):',
|
|
90
|
+
cloudVesselsRadius: 'Radius from own vessel (nautical miles):',
|
|
91
|
+
|
|
92
|
+
save: 'Save',
|
|
93
|
+
cancel: 'Cancel',
|
|
94
|
+
unsavedWarning: 'There are unsaved changes. Really cancel?',
|
|
95
|
+
unsavedTitle: 'Unsaved changes',
|
|
96
|
+
yes: 'Yes',
|
|
97
|
+
no: 'No'
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const [currentLang, setCurrentLang] = useState(config.language === 'de' ? 'de' : 'en');
|
|
102
|
+
const t = translations[currentLang];
|
|
103
|
+
|
|
104
|
+
// Hole eigene MMSI beim Laden
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
const fetchOwnMMSI = async () => {
|
|
107
|
+
try {
|
|
108
|
+
const protocol = window.location.protocol;
|
|
109
|
+
const hostname = window.location.hostname;
|
|
110
|
+
const port = window.location.port;
|
|
111
|
+
const url = `${protocol}//${hostname}${port ? ':' + port : ''}/signalk/v1/api/self`;
|
|
112
|
+
|
|
113
|
+
console.log('Fetching own MMSI from:', url);
|
|
114
|
+
console.log('Protocol:', protocol, 'Hostname:', hostname, 'Port:', port);
|
|
115
|
+
|
|
116
|
+
const response = await fetch(url);
|
|
117
|
+
console.log('Response status:', response.status);
|
|
118
|
+
|
|
119
|
+
if (response.ok) {
|
|
120
|
+
const data = await response.json();
|
|
121
|
+
console.log('Self data received:', JSON.stringify(data, null, 2));
|
|
122
|
+
|
|
123
|
+
// Data könnte String oder Objekt sein
|
|
124
|
+
let vesselKey = null;
|
|
125
|
+
if (typeof data === 'string') {
|
|
126
|
+
// String Format: "vessels.urn:mrn:imo:mmsi:211177520"
|
|
127
|
+
vesselKey = data.replace('vessels.', '');
|
|
128
|
+
console.log('Parsed vessel key from string:', vesselKey);
|
|
129
|
+
} else if (data.vessels && typeof data.vessels === 'object') {
|
|
130
|
+
// Objekt Format
|
|
131
|
+
const mmsiMatch = Object.keys(data.vessels).find(key => key.includes('mmsi:'));
|
|
132
|
+
vesselKey = mmsiMatch;
|
|
133
|
+
console.log('Found vessel key in object:', vesselKey);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (vesselKey) {
|
|
137
|
+
const mmsi = vesselKey.match(/mmsi:(\d+)/)?.[1];
|
|
138
|
+
console.log('Extracted MMSI:', mmsi);
|
|
139
|
+
if (mmsi) {
|
|
140
|
+
setOwnMMSI(mmsi);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
console.error('Failed to fetch self data, status:', response.status);
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
console.error('Failed to fetch own MMSI:', err);
|
|
148
|
+
// Fehler ignorieren - Validierung wird einfach nicht aktiviert
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Verzögert starten um sicherzustellen dass DOM ready ist
|
|
153
|
+
setTimeout(fetchOwnMMSI, 500);
|
|
154
|
+
}, []);
|
|
155
|
+
|
|
156
|
+
const handleConfigChange = (key, value) => {
|
|
157
|
+
setConfig(prev => ({ ...prev, [key]: value }));
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const isMMSIInvalid = () => {
|
|
161
|
+
return ownMMSI && config.logMMSI && config.logMMSI === ownMMSI;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const checkUnsavedChanges = () => {
|
|
165
|
+
return JSON.stringify(config) !== JSON.stringify(initialConfig);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const handleSave = () => {
|
|
169
|
+
// Validiere Debug MMSI
|
|
170
|
+
if (isMMSIInvalid()) {
|
|
171
|
+
setStatus('error');
|
|
172
|
+
const errorMsg = currentLang === 'de'
|
|
173
|
+
? 'Fehler: Sie können nicht die eigene MMSI zum Filtern verwenden!'
|
|
174
|
+
: 'Error: You cannot use your own MMSI for filtering!';
|
|
175
|
+
alert(errorMsg);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
setLoading(true);
|
|
180
|
+
if (save) {
|
|
181
|
+
try {
|
|
182
|
+
const result = save(config);
|
|
183
|
+
|
|
184
|
+
if (result && typeof result.then === 'function') {
|
|
185
|
+
// save() gibt ein Promise zurück
|
|
186
|
+
result
|
|
187
|
+
.then(() => {
|
|
188
|
+
setStatus('success');
|
|
189
|
+
setInitialConfig(config);
|
|
190
|
+
setTimeout(() => setStatus(''), 3000);
|
|
191
|
+
})
|
|
192
|
+
.catch(err => {
|
|
193
|
+
setStatus('error');
|
|
194
|
+
setTimeout(() => setStatus(''), 3000);
|
|
195
|
+
})
|
|
196
|
+
.finally(() => {
|
|
197
|
+
setLoading(false);
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
// save() gibt kein Promise zurück - assume success
|
|
201
|
+
setStatus('success');
|
|
202
|
+
setInitialConfig(config);
|
|
203
|
+
setTimeout(() => setStatus(''), 3000);
|
|
204
|
+
setLoading(false);
|
|
205
|
+
}
|
|
206
|
+
} catch (err) {
|
|
207
|
+
console.error('Error in handleSave:', err);
|
|
208
|
+
setStatus('error');
|
|
209
|
+
setTimeout(() => setStatus(''), 3000);
|
|
210
|
+
setLoading(false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const handleLanguageChange = (lang) => {
|
|
216
|
+
setCurrentLang(lang);
|
|
217
|
+
handleConfigChange('language', lang === 'de');
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div style={styles.container}>
|
|
222
|
+
<div style={styles.header}>
|
|
223
|
+
<h2 style={styles.title}>AIS to NMEA 0183 Converter</h2>
|
|
224
|
+
<button
|
|
225
|
+
onClick={() => window.open('https://github.com/formifan2002/signalk-ais-navionics-converter', '_blank')}
|
|
226
|
+
style={styles.helpButton}
|
|
227
|
+
>
|
|
228
|
+
ℹ️ {currentLang === 'de' ? 'Hilfe' : 'Help'}
|
|
229
|
+
</button>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div style={styles.languageSelector}>
|
|
233
|
+
<button
|
|
234
|
+
onClick={() => handleLanguageChange('de')}
|
|
235
|
+
style={{...styles.langButton, ...(currentLang === 'de' ? styles.langButtonActive : {})}}
|
|
236
|
+
>
|
|
237
|
+
Deutsch
|
|
238
|
+
</button>
|
|
239
|
+
<button
|
|
240
|
+
onClick={() => handleLanguageChange('en')}
|
|
241
|
+
style={{...styles.langButton, ...(currentLang === 'en' ? styles.langButtonActive : {})}}
|
|
242
|
+
>
|
|
243
|
+
English
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
{/* TCP Server */}
|
|
248
|
+
<div style={styles.section}>
|
|
249
|
+
<h3 style={styles.sectionTitle}>{t.tcpServer}</h3>
|
|
250
|
+
|
|
251
|
+
<div style={styles.formGroup}>
|
|
252
|
+
<label style={styles.label}>{t.tcpPort}</label>
|
|
253
|
+
<div style={{
|
|
254
|
+
display: 'block',
|
|
255
|
+
fontSize: '0.85em',
|
|
256
|
+
color: '#666',
|
|
257
|
+
marginTop: '8px',
|
|
258
|
+
marginBottom: '12px',
|
|
259
|
+
fontStyle: 'italic',
|
|
260
|
+
lineHeight: '1.4'
|
|
261
|
+
}}>
|
|
262
|
+
{currentLang === 'de'
|
|
263
|
+
? 'Dieser Port ist später in der Navionics boating app im Menüpunkt \'Gekoppelte Geräte\' als TCP Port anzugeben.'
|
|
264
|
+
: 'This port must be specified later in the Navionics boating app under the menu item \'Paired Devices\' as TCP Port.'}
|
|
265
|
+
</div>
|
|
266
|
+
<input
|
|
267
|
+
type="number"
|
|
268
|
+
min="1"
|
|
269
|
+
max="65535"
|
|
270
|
+
value={config.tcpPort || 10113}
|
|
271
|
+
onChange={(e) => handleConfigChange('tcpPort', Number(e.target.value))}
|
|
272
|
+
style={styles.input}
|
|
273
|
+
/>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<div style={styles.formGroup}>
|
|
277
|
+
<label style={styles.label}>{t.updateInterval}</label>
|
|
278
|
+
<input
|
|
279
|
+
type="number"
|
|
280
|
+
min="1"
|
|
281
|
+
value={config.updateInterval || 15}
|
|
282
|
+
onChange={(e) => handleConfigChange('updateInterval', Number(e.target.value))}
|
|
283
|
+
style={styles.input}
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<div style={styles.formGroup}>
|
|
288
|
+
<label style={styles.label}>{t.tcpResendInterval}</label>
|
|
289
|
+
<input
|
|
290
|
+
type="number"
|
|
291
|
+
min="0"
|
|
292
|
+
value={config.tcpResendInterval || 60}
|
|
293
|
+
onChange={(e) => handleConfigChange('tcpResendInterval', Number(e.target.value))}
|
|
294
|
+
style={styles.input}
|
|
295
|
+
/>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
{/* Filtering */}
|
|
300
|
+
<div style={styles.section}>
|
|
301
|
+
<h3 style={styles.sectionTitle}>{t.filtering}</h3>
|
|
302
|
+
|
|
303
|
+
<div style={styles.formGroup}>
|
|
304
|
+
<label style={styles.checkbox}>
|
|
305
|
+
<input
|
|
306
|
+
type="checkbox"
|
|
307
|
+
checked={config.skipWithoutCallsign || false}
|
|
308
|
+
onChange={(e) => handleConfigChange('skipWithoutCallsign', e.target.checked)}
|
|
309
|
+
/>
|
|
310
|
+
{t.skipWithoutCallsign}
|
|
311
|
+
</label>
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
<div style={styles.formGroup}>
|
|
315
|
+
<label style={styles.checkbox}>
|
|
316
|
+
<input
|
|
317
|
+
type="checkbox"
|
|
318
|
+
checked={config.skipStaleData !== false}
|
|
319
|
+
onChange={(e) => handleConfigChange('skipStaleData', e.target.checked)}
|
|
320
|
+
/>
|
|
321
|
+
{t.skipStaleData}
|
|
322
|
+
</label>
|
|
323
|
+
</div>
|
|
324
|
+
|
|
325
|
+
{config.skipStaleData !== false && (
|
|
326
|
+
<div style={styles.formGroup}>
|
|
327
|
+
<label style={styles.label}>{t.staleDataThreshold}</label>
|
|
328
|
+
<input
|
|
329
|
+
type="number"
|
|
330
|
+
min="1"
|
|
331
|
+
value={config.staleDataThresholdMinutes || 60}
|
|
332
|
+
onChange={(e) => handleConfigChange('staleDataThresholdMinutes', Number(e.target.value))}
|
|
333
|
+
style={styles.input}
|
|
334
|
+
/>
|
|
335
|
+
</div>
|
|
336
|
+
)}
|
|
337
|
+
|
|
338
|
+
<div style={styles.formGroup}>
|
|
339
|
+
<label style={styles.label}>{t.staleDataShipname}</label>
|
|
340
|
+
<input
|
|
341
|
+
type="number"
|
|
342
|
+
min="0"
|
|
343
|
+
value={config.staleDataShipnameAddTime || 5}
|
|
344
|
+
onChange={(e) => handleConfigChange('staleDataShipnameAddTime', Number(e.target.value))}
|
|
345
|
+
style={styles.input}
|
|
346
|
+
/>
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<div style={styles.formGroup}>
|
|
350
|
+
<label style={styles.label}>{t.minAlarmSOG}</label>
|
|
351
|
+
<input
|
|
352
|
+
type="number"
|
|
353
|
+
min="0"
|
|
354
|
+
step="0.1"
|
|
355
|
+
value={config.minAlarmSOG || 0.2}
|
|
356
|
+
onChange={(e) => handleConfigChange('minAlarmSOG', Number(e.target.value))}
|
|
357
|
+
style={styles.input}
|
|
358
|
+
/>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
361
|
+
<div style={styles.formGroup}>
|
|
362
|
+
<label style={styles.label}>{t.maxMinutesSOGToZero}</label>
|
|
363
|
+
<input
|
|
364
|
+
type="number"
|
|
365
|
+
min="0"
|
|
366
|
+
value={config.maxMinutesSOGToZero || 0}
|
|
367
|
+
onChange={(e) => handleConfigChange('maxMinutesSOGToZero', Number(e.target.value))}
|
|
368
|
+
style={styles.input}
|
|
369
|
+
/>
|
|
370
|
+
</div>
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
{/* Debugging */}
|
|
374
|
+
<div style={styles.section}>
|
|
375
|
+
<h3 style={styles.sectionTitle}>{t.debugging}</h3>
|
|
376
|
+
|
|
377
|
+
<div style={styles.formGroup}>
|
|
378
|
+
<label style={styles.checkbox}>
|
|
379
|
+
<input
|
|
380
|
+
type="checkbox"
|
|
381
|
+
checked={config.logDebugDetails || false}
|
|
382
|
+
onChange={(e) => handleConfigChange('logDebugDetails', e.target.checked)}
|
|
383
|
+
/>
|
|
384
|
+
{t.logDebugDetails}
|
|
385
|
+
</label>
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
{config.logDebugDetails && (
|
|
389
|
+
<>
|
|
390
|
+
<div style={styles.formGroup}>
|
|
391
|
+
<label style={styles.label}>{t.logMMSI}</label>
|
|
392
|
+
<div style={{
|
|
393
|
+
display: 'block',
|
|
394
|
+
fontSize: '0.85em',
|
|
395
|
+
color: '#666',
|
|
396
|
+
marginTop: '8px',
|
|
397
|
+
marginBottom: '12px',
|
|
398
|
+
fontStyle: 'italic',
|
|
399
|
+
lineHeight: '1.4'
|
|
400
|
+
}}>
|
|
401
|
+
{currentLang === 'de'
|
|
402
|
+
? 'Debug Ausgaben werden nur für das Schiff mit dieser MMSI erzeugt. Für das eigene Schiff / die eigene MMSI werden keine AIS Daten erzeugt. Wenn das Feld leer bleibt, werden Debug-Ausgaben für alle Schiffe (außer dem eigenen) erzeugt.'
|
|
403
|
+
: 'Debug output is only generated for the vessel with this MMSI. No AIS data is generated for your own vessel / own MMSI. If the field is left empty, debug output is generated for all vessels (except your own).'}
|
|
404
|
+
</div>
|
|
405
|
+
<input
|
|
406
|
+
type="text"
|
|
407
|
+
value={config.logMMSI || ''}
|
|
408
|
+
onChange={(e) => handleConfigChange('logMMSI', e.target.value)}
|
|
409
|
+
placeholder="e.g. 123456789"
|
|
410
|
+
style={{
|
|
411
|
+
...styles.input,
|
|
412
|
+
...(isMMSIInvalid() ? { borderColor: '#dc3545', backgroundColor: '#fff5f5' } : {})
|
|
413
|
+
}}
|
|
414
|
+
/>
|
|
415
|
+
{isMMSIInvalid() && (
|
|
416
|
+
<div style={{
|
|
417
|
+
color: '#dc3545',
|
|
418
|
+
fontSize: '0.85em',
|
|
419
|
+
marginTop: '8px',
|
|
420
|
+
fontWeight: '500'
|
|
421
|
+
}}>
|
|
422
|
+
{currentLang === 'de'
|
|
423
|
+
? '❌ Sie können nicht die eigene MMSI verwenden!'
|
|
424
|
+
: '❌ You cannot use your own MMSI!'}
|
|
425
|
+
</div>
|
|
426
|
+
)}
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div style={styles.formGroup}>
|
|
430
|
+
<label style={styles.checkbox}>
|
|
431
|
+
<input
|
|
432
|
+
type="checkbox"
|
|
433
|
+
checked={config.logDebugStale || false}
|
|
434
|
+
onChange={(e) => handleConfigChange('logDebugStale', e.target.checked)}
|
|
435
|
+
/>
|
|
436
|
+
{t.logDebugStale}
|
|
437
|
+
</label>
|
|
438
|
+
</div>
|
|
439
|
+
|
|
440
|
+
<div style={styles.formGroup}>
|
|
441
|
+
<label style={styles.checkbox}>
|
|
442
|
+
<input
|
|
443
|
+
type="checkbox"
|
|
444
|
+
checked={config.logDebugJSON || false}
|
|
445
|
+
onChange={(e) => handleConfigChange('logDebugJSON', e.target.checked)}
|
|
446
|
+
/>
|
|
447
|
+
{t.logDebugJSON}
|
|
448
|
+
</label>
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
<div style={styles.formGroup}>
|
|
452
|
+
<label style={styles.checkbox}>
|
|
453
|
+
<input
|
|
454
|
+
type="checkbox"
|
|
455
|
+
checked={config.logDebugAIS || false}
|
|
456
|
+
onChange={(e) => handleConfigChange('logDebugAIS', e.target.checked)}
|
|
457
|
+
/>
|
|
458
|
+
{t.logDebugAIS}
|
|
459
|
+
</label>
|
|
460
|
+
</div>
|
|
461
|
+
|
|
462
|
+
<div style={styles.formGroup}>
|
|
463
|
+
<label style={styles.checkbox}>
|
|
464
|
+
<input
|
|
465
|
+
type="checkbox"
|
|
466
|
+
checked={config.logDebugSOG || false}
|
|
467
|
+
onChange={(e) => handleConfigChange('logDebugSOG', e.target.checked)}
|
|
468
|
+
/>
|
|
469
|
+
{t.logDebugSOG}
|
|
470
|
+
</label>
|
|
471
|
+
</div>
|
|
472
|
+
</>
|
|
473
|
+
)}
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
{/* VesselFinder */}
|
|
477
|
+
<div style={styles.section}>
|
|
478
|
+
<h3 style={styles.sectionTitle}>{t.vesselFinder}</h3>
|
|
479
|
+
|
|
480
|
+
<div style={styles.formGroup}>
|
|
481
|
+
<label style={styles.checkbox}>
|
|
482
|
+
<input
|
|
483
|
+
type="checkbox"
|
|
484
|
+
checked={config.vesselFinderEnabled || false}
|
|
485
|
+
onChange={(e) => handleConfigChange('vesselFinderEnabled', e.target.checked)}
|
|
486
|
+
/>
|
|
487
|
+
{t.vesselFinderEnabled}
|
|
488
|
+
</label>
|
|
489
|
+
</div>
|
|
490
|
+
|
|
491
|
+
{config.vesselFinderEnabled && (
|
|
492
|
+
<>
|
|
493
|
+
<div style={styles.formGroup}>
|
|
494
|
+
<label style={styles.label}>{t.vesselFinderHost}</label>
|
|
495
|
+
<input
|
|
496
|
+
type="text"
|
|
497
|
+
value={config.vesselFinderHost || 'ais.vesselfinder.com'}
|
|
498
|
+
onChange={(e) => handleConfigChange('vesselFinderHost', e.target.value)}
|
|
499
|
+
style={styles.input}
|
|
500
|
+
/>
|
|
501
|
+
</div>
|
|
502
|
+
|
|
503
|
+
<div style={styles.formGroup}>
|
|
504
|
+
<label style={styles.label}>{t.vesselFinderPort}</label>
|
|
505
|
+
<input
|
|
506
|
+
type="number"
|
|
507
|
+
min="1"
|
|
508
|
+
max="65535"
|
|
509
|
+
value={config.vesselFinderPort || 5500}
|
|
510
|
+
onChange={(e) => handleConfigChange('vesselFinderPort', Number(e.target.value))}
|
|
511
|
+
style={styles.input}
|
|
512
|
+
/>
|
|
513
|
+
</div>
|
|
514
|
+
|
|
515
|
+
<div style={styles.formGroup}>
|
|
516
|
+
<label style={styles.label}>{t.vesselFinderUpdateRate}</label>
|
|
517
|
+
<input
|
|
518
|
+
type="number"
|
|
519
|
+
min="1"
|
|
520
|
+
value={config.vesselFinderUpdateRate || 60}
|
|
521
|
+
onChange={(e) => handleConfigChange('vesselFinderUpdateRate', Number(e.target.value))}
|
|
522
|
+
style={styles.input}
|
|
523
|
+
/>
|
|
524
|
+
</div>
|
|
525
|
+
</>
|
|
526
|
+
)}
|
|
527
|
+
</div>
|
|
528
|
+
|
|
529
|
+
{/* Cloud Vessels */}
|
|
530
|
+
<div style={styles.section}>
|
|
531
|
+
<h3 style={styles.sectionTitle}>{t.cloudVessels}</h3>
|
|
532
|
+
|
|
533
|
+
<div style={styles.formGroup}>
|
|
534
|
+
<label style={styles.checkbox}>
|
|
535
|
+
<input
|
|
536
|
+
type="checkbox"
|
|
537
|
+
checked={config.cloudVesselsEnabled !== false}
|
|
538
|
+
onChange={(e) => handleConfigChange('cloudVesselsEnabled', e.target.checked)}
|
|
539
|
+
/>
|
|
540
|
+
{t.cloudVesselsEnabled}
|
|
541
|
+
</label>
|
|
542
|
+
</div>
|
|
543
|
+
|
|
544
|
+
{config.cloudVesselsEnabled !== false && (
|
|
545
|
+
<>
|
|
546
|
+
<div style={styles.formGroup}>
|
|
547
|
+
<label style={styles.label}>{t.cloudVesselsUpdateInterval}</label>
|
|
548
|
+
<input
|
|
549
|
+
type="number"
|
|
550
|
+
min="1"
|
|
551
|
+
value={config.cloudVesselsUpdateInterval || 60}
|
|
552
|
+
onChange={(e) => handleConfigChange('cloudVesselsUpdateInterval', Number(e.target.value))}
|
|
553
|
+
style={styles.input}
|
|
554
|
+
/>
|
|
555
|
+
</div>
|
|
556
|
+
|
|
557
|
+
<div style={styles.formGroup}>
|
|
558
|
+
<label style={styles.label}>{t.cloudVesselsRadius}</label>
|
|
559
|
+
<input
|
|
560
|
+
type="number"
|
|
561
|
+
min="1"
|
|
562
|
+
value={config.cloudVesselsRadius || 10}
|
|
563
|
+
onChange={(e) => handleConfigChange('cloudVesselsRadius', Number(e.target.value))}
|
|
564
|
+
style={styles.input}
|
|
565
|
+
/>
|
|
566
|
+
</div>
|
|
567
|
+
</>
|
|
568
|
+
)}
|
|
569
|
+
</div>
|
|
570
|
+
|
|
571
|
+
{status && (
|
|
572
|
+
<div style={{...styles.statusMessage, ...(status === 'error' ? styles.error : styles.success)}}>
|
|
573
|
+
{status === 'success'
|
|
574
|
+
? (currentLang === 'de' ? 'Konfiguration gespeichert' : 'Configuration saved')
|
|
575
|
+
: (currentLang === 'de' ? 'Fehler beim Speichern' : 'Error saving')}
|
|
576
|
+
</div>
|
|
577
|
+
)}
|
|
578
|
+
|
|
579
|
+
<div style={styles.buttonGroup}>
|
|
580
|
+
<button
|
|
581
|
+
onClick={handleSave}
|
|
582
|
+
disabled={loading || isMMSIInvalid()}
|
|
583
|
+
style={{...styles.button, ...styles.primaryButton, ...(isMMSIInvalid() ? { opacity: 0.5, cursor: 'not-allowed' } : {})}}
|
|
584
|
+
>
|
|
585
|
+
{t.save}
|
|
586
|
+
</button>
|
|
587
|
+
<button
|
|
588
|
+
onClick={() => {
|
|
589
|
+
if (checkUnsavedChanges()) {
|
|
590
|
+
setDialogData({
|
|
591
|
+
title: t.unsavedTitle,
|
|
592
|
+
message: t.unsavedWarning,
|
|
593
|
+
callback: () => setConfig(initialConfig)
|
|
594
|
+
});
|
|
595
|
+
setShowDialog(true);
|
|
596
|
+
} else {
|
|
597
|
+
setConfig(initialConfig);
|
|
598
|
+
}
|
|
599
|
+
}}
|
|
600
|
+
style={{...styles.button, ...styles.secondaryButton}}
|
|
601
|
+
>
|
|
602
|
+
{t.cancel}
|
|
603
|
+
</button>
|
|
604
|
+
</div>
|
|
605
|
+
|
|
606
|
+
{showDialog && (
|
|
607
|
+
<div style={styles.dialog}>
|
|
608
|
+
<div style={styles.dialogContent}>
|
|
609
|
+
<h4 style={styles.dialogTitle}>{dialogData.title}</h4>
|
|
610
|
+
<p>{dialogData.message}</p>
|
|
611
|
+
<div style={styles.dialogButtons}>
|
|
612
|
+
<button
|
|
613
|
+
onClick={() => setShowDialog(false)}
|
|
614
|
+
style={{...styles.button, ...styles.secondaryButton}}
|
|
615
|
+
>
|
|
616
|
+
{t.no}
|
|
617
|
+
</button>
|
|
618
|
+
<button
|
|
619
|
+
onClick={() => {
|
|
620
|
+
if (dialogData.callback) dialogData.callback();
|
|
621
|
+
setShowDialog(false);
|
|
622
|
+
}}
|
|
623
|
+
style={{...styles.button, ...styles.primaryButton}}
|
|
624
|
+
>
|
|
625
|
+
{t.yes}
|
|
626
|
+
</button>
|
|
627
|
+
</div>
|
|
628
|
+
</div>
|
|
629
|
+
</div>
|
|
630
|
+
)}
|
|
631
|
+
</div>
|
|
632
|
+
);
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
const styles = {
|
|
636
|
+
container: {
|
|
637
|
+
padding: '20px',
|
|
638
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto',
|
|
639
|
+
},
|
|
640
|
+
header: {
|
|
641
|
+
display: 'flex',
|
|
642
|
+
justifyContent: 'space-between',
|
|
643
|
+
alignItems: 'center',
|
|
644
|
+
marginBottom: '30px',
|
|
645
|
+
paddingBottom: '20px',
|
|
646
|
+
borderBottom: '2px solid #667eea',
|
|
647
|
+
},
|
|
648
|
+
title: {
|
|
649
|
+
margin: 0,
|
|
650
|
+
fontSize: '1.5em',
|
|
651
|
+
fontWeight: '600',
|
|
652
|
+
color: '#333',
|
|
653
|
+
},
|
|
654
|
+
helpButton: {
|
|
655
|
+
padding: '8px 16px',
|
|
656
|
+
backgroundColor: '#667eea',
|
|
657
|
+
color: 'white',
|
|
658
|
+
border: 'none',
|
|
659
|
+
borderRadius: '6px',
|
|
660
|
+
cursor: 'pointer',
|
|
661
|
+
fontWeight: '500',
|
|
662
|
+
fontSize: '0.95em',
|
|
663
|
+
transition: 'background 0.3s',
|
|
664
|
+
},
|
|
665
|
+
languageSelector: {
|
|
666
|
+
display: 'flex',
|
|
667
|
+
gap: '10px',
|
|
668
|
+
marginBottom: '30px',
|
|
669
|
+
},
|
|
670
|
+
langButton: {
|
|
671
|
+
padding: '8px 16px',
|
|
672
|
+
border: '1px solid #ddd',
|
|
673
|
+
borderRadius: '4px',
|
|
674
|
+
cursor: 'pointer',
|
|
675
|
+
fontWeight: '500',
|
|
676
|
+
backgroundColor: '#f5f5f5',
|
|
677
|
+
},
|
|
678
|
+
langButtonActive: {
|
|
679
|
+
backgroundColor: '#667eea',
|
|
680
|
+
color: 'white',
|
|
681
|
+
borderColor: '#667eea',
|
|
682
|
+
},
|
|
683
|
+
section: {
|
|
684
|
+
marginBottom: '30px',
|
|
685
|
+
},
|
|
686
|
+
sectionTitle: {
|
|
687
|
+
fontSize: '1.2em',
|
|
688
|
+
fontWeight: '600',
|
|
689
|
+
marginBottom: '15px',
|
|
690
|
+
color: '#333',
|
|
691
|
+
borderBottom: '2px solid #667eea',
|
|
692
|
+
paddingBottom: '10px',
|
|
693
|
+
},
|
|
694
|
+
formGroup: {
|
|
695
|
+
marginBottom: '15px',
|
|
696
|
+
},
|
|
697
|
+
label: {
|
|
698
|
+
display: 'block',
|
|
699
|
+
fontWeight: '500',
|
|
700
|
+
marginBottom: '5px',
|
|
701
|
+
color: '#333',
|
|
702
|
+
},
|
|
703
|
+
input: {
|
|
704
|
+
padding: '8px',
|
|
705
|
+
border: '1px solid #ddd',
|
|
706
|
+
borderRadius: '4px',
|
|
707
|
+
fontSize: '1em',
|
|
708
|
+
width: '200px',
|
|
709
|
+
},
|
|
710
|
+
checkbox: {
|
|
711
|
+
display: 'flex',
|
|
712
|
+
alignItems: 'center',
|
|
713
|
+
marginBottom: '8px',
|
|
714
|
+
cursor: 'pointer',
|
|
715
|
+
gap: '8px',
|
|
716
|
+
},
|
|
717
|
+
buttonGroup: {
|
|
718
|
+
display: 'flex',
|
|
719
|
+
gap: '10px',
|
|
720
|
+
marginTop: '30px',
|
|
721
|
+
paddingTop: '20px',
|
|
722
|
+
borderTop: '1px solid #ddd',
|
|
723
|
+
},
|
|
724
|
+
button: {
|
|
725
|
+
padding: '10px 20px',
|
|
726
|
+
border: 'none',
|
|
727
|
+
borderRadius: '4px',
|
|
728
|
+
cursor: 'pointer',
|
|
729
|
+
fontWeight: '500',
|
|
730
|
+
fontSize: '1em',
|
|
731
|
+
},
|
|
732
|
+
primaryButton: {
|
|
733
|
+
backgroundColor: '#667eea',
|
|
734
|
+
color: 'white',
|
|
735
|
+
},
|
|
736
|
+
secondaryButton: {
|
|
737
|
+
backgroundColor: '#6c757d',
|
|
738
|
+
color: 'white',
|
|
739
|
+
},
|
|
740
|
+
statusMessage: {
|
|
741
|
+
padding: '12px',
|
|
742
|
+
borderRadius: '4px',
|
|
743
|
+
marginBottom: '15px',
|
|
744
|
+
fontSize: '0.95em',
|
|
745
|
+
},
|
|
746
|
+
success: {
|
|
747
|
+
backgroundColor: '#d4edda',
|
|
748
|
+
color: '#155724',
|
|
749
|
+
},
|
|
750
|
+
error: {
|
|
751
|
+
backgroundColor: '#f8d7da',
|
|
752
|
+
color: '#721c24',
|
|
753
|
+
},
|
|
754
|
+
dialog: {
|
|
755
|
+
position: 'fixed',
|
|
756
|
+
top: 0,
|
|
757
|
+
left: 0,
|
|
758
|
+
right: 0,
|
|
759
|
+
bottom: 0,
|
|
760
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
761
|
+
display: 'flex',
|
|
762
|
+
alignItems: 'center',
|
|
763
|
+
justifyContent: 'center',
|
|
764
|
+
zIndex: 1000,
|
|
765
|
+
},
|
|
766
|
+
dialogContent: {
|
|
767
|
+
backgroundColor: 'white',
|
|
768
|
+
padding: '30px',
|
|
769
|
+
borderRadius: '8px',
|
|
770
|
+
maxWidth: '400px',
|
|
771
|
+
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
|
772
|
+
},
|
|
773
|
+
dialogTitle: {
|
|
774
|
+
marginTop: 0,
|
|
775
|
+
marginBottom: '15px',
|
|
776
|
+
fontSize: '1.1em',
|
|
777
|
+
},
|
|
778
|
+
dialogButtons: {
|
|
779
|
+
display: 'flex',
|
|
780
|
+
gap: '10px',
|
|
781
|
+
justifyContent: 'flex-end',
|
|
782
|
+
marginTop: '20px',
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
export default PluginConfigurationPanel;
|