From ebdd3d568c4788a1234c7482f4c2397dcc279d6a Mon Sep 17 00:00:00 2001 From: panaaj <38519157+panaaj@users.noreply.github.com> Date: Mon, 20 May 2024 08:49:51 +0930 Subject: [PATCH] chore: docs and formatting --- CHANGELOG.md | 8 + helper/alarms/alarms.ts | 83 +++++-- package.json | 5 +- .../lib/components/build-route.component.ts | 29 ++- src/app/lib/components/dial-text.ts | 5 +- .../dialogs/common/dialogs.component.ts | 72 +++--- .../dialogs/gpx/gpxload/gpxload-dialog.html | 134 ++++++------ .../dialogs/gpx/gpxsave/gpxsave-dialog.html | 130 +++++------ src/app/lib/components/index.ts | 1 + src/app/lib/geoutils.ts | 31 +++ .../components/popover/compass.component.ts | 2 +- src/app/modules/map/mapconfig.ts | 19 ++ src/app/modules/map/ol/index.ts | 3 + .../modules/skresources/lists/chartlist.ts | 38 ++-- .../modules/skresources/resource-dialogs.ts | 206 +++++++++--------- src/assets/help/img/settings_vessels_1.png | Bin 20195 -> 19588 bytes src/assets/help/index.html | 4 + 17 files changed, 440 insertions(+), 330 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b57d7732..bb2793d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # CHANGELOG: Freeboard +### v2.8.0 + +- **Added**: Option to display laylines when destination is active. (#149) +- **Added**: Support for Signal K server "Features" API. +- **Updated**: Measure function to display both segment and total distance. (#153) +- **Updated**: Clearing an alarm no longer sets the value to `null`, sets alarm state to normal instead. + + ### v2.7.1 - **Added**: Set a default waypoint name when adding a waypoint at vessel position. (#146) diff --git a/helper/alarms/alarms.ts b/helper/alarms/alarms.ts index 464ac47b..cd7a09f0 100644 --- a/helper/alarms/alarms.ts +++ b/helper/alarms/alarms.ts @@ -5,7 +5,8 @@ import { ALARM_STATE, Path, PathValue, - Position + Position, + SKVersion } from '@signalk/server-api'; import { FreeboardHelperApp } from '../index'; @@ -24,6 +25,7 @@ const STANDARD_ALARMS = [ let server: FreeboardHelperApp; let pluginId: string; +const ALARM_API_PATH = '/signalk/v1/api/alarms'; export const initAlarms = (app: FreeboardHelperApp, id: string) => { server = app; @@ -48,12 +50,11 @@ export const initAlarms = (app: FreeboardHelperApp, id: string) => { const initAlarmEndpoints = () => { server.debug(`** Registering Alarm Action API endpoint(s) **`); - server.put( - '/signalk/v2/api/notifications/:alarmType', + + server.post( + `${ALARM_API_PATH}/:alarmType`, (req: Request, res: Response, next: NextFunction) => { - server.debug( - `** PUT /signalk/v2/api/notifications/${req.params.alarmType}` - ); + server.debug(`** POST ${ALARM_API_PATH}/${req.params.alarmType}`); if (!STANDARD_ALARMS.includes(req.params.alarmType)) { next(); return; @@ -82,12 +83,57 @@ const initAlarmEndpoints = () => { } } ); + server.post( + `${ALARM_API_PATH}/:alarmType/silence`, + (req: Request, res: Response) => { + server.debug(`** POST ${req.path}`); + if (!STANDARD_ALARMS.includes(req.params.alarmType)) { + res.status(200).json({ + state: 'COMPLETED', + statusCode: 200, + message: `Unsupported Alarm (${req.params.alarmType}).` + }); + return; + } + try { + const al = server.getSelfPath(`notifications.${req.params.alarmType}`); + if (al && al.value) { + server.debug('Alarm value....'); + if (al.value.method && al.value.method.includes('sound')) { + server.debug('Alarm has sound... silence!!!'); + al.value.method = al.value.method.filter((i) => i !== 'sound'); + const r = handlePutAlarmState( + 'vessels.self', + `notifications.${req.params.alarmType}` as Path, + al.value + ); + res.status(200).json(r); + } else { + server.debug('Alarm has no sound... no action required.'); + res.status(200).json({ + state: 'COMPLETED', + statusCode: 200, + message: `Alarm (${req.params.alarmType}) is already silent.` + }); + } + } else { + throw new Error( + `Alarm (${req.params.alarmType}) has no value or was not found!` + ); + } + } catch (e) { + res.status(400).json({ + state: 'FAILED', + statusCode: 400, + message: (e as Error).message + }); + } + } + ); server.delete( - '/signalk/v2/api/notifications/:alarmType', + `${ALARM_API_PATH}/:alarmType`, (req: Request, res: Response, next: NextFunction) => { - server.debug( - `** DELETE /signalk/v2/api/notifications/${req.params.alarmType}` - ); + server.debug(`** DELETE ${ALARM_API_PATH}/${req.params.alarmType}`); if (!STANDARD_ALARMS.includes(req.params.alarmType)) { next(); return; @@ -96,7 +142,11 @@ const initAlarmEndpoints = () => { const r = handlePutAlarmState( 'vessels.self', `notifications.${req.params.alarmType}` as Path, - null + { + message: '', + method: [], + state: ALARM_STATE.normal + } ); res.status(200).json(r); } catch (e) { @@ -137,16 +187,16 @@ const handlePutAlarmState = ( server.debug(JSON.stringify(alarmType)); let noti: PathValue; if (value) { - const alm = buildAlarmMessage(value.message); + const alm = value.state === ALARM_STATE.normal ? null : buildAlarmData(); noti = { path: `notifications.${alarmType}` as Path, value: { state: value.state ?? null, method: value.method ?? null, - message: alm.message + message: value.message } }; - if (alm.data) { + if (alm && alm.data) { // eslint-disable-next-line @typescript-eslint/no-explicit-any (noti.value as any).data = alm.data; } @@ -171,10 +221,9 @@ const handlePutAlarmState = ( } }; -const buildAlarmMessage = (message: string) => { +const buildAlarmData = () => { const pos: { value: Position } = server.getSelfPath('navigation.position'); return { - message: message, data: { position: pos ? pos.value : null } @@ -186,5 +235,5 @@ const emitNotification = (msg: PathValue) => { const delta = { updates: [{ values: [msg] }] }; - server.handleMessage(pluginId, delta); + server.handleMessage(pluginId, delta, SKVersion.v2); }; diff --git a/package.json b/package.json index 645befc5..ddbe98b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@signalk/freeboard-sk", - "version": "2.7.1", + "version": "2.8.0", "description": "Openlayers chart plotter implementation for Signal K", "keywords": [ "signalk-webapp", @@ -87,6 +87,7 @@ "proj4": "2.6.2", "protractor": "~7.0.0", "rxjs": "~6.6.3", + "semver": "^7.6.0", "signalk-client-angular": "^2.0.3", "signalk-worker-angular": "^1.1.4", "simplify-ts": "^1.0.2", @@ -97,4 +98,4 @@ "xml2js": "^0.6.2", "zone.js": "~0.14.4" } -} \ No newline at end of file +} diff --git a/src/app/lib/components/build-route.component.ts b/src/app/lib/components/build-route.component.ts index 23b974d9..8af13195 100644 --- a/src/app/lib/components/build-route.component.ts +++ b/src/app/lib/components/build-route.component.ts @@ -108,23 +108,19 @@ import { (cdkDropListDropped)="dropEventHandler($event)" > @for(item of rtepts; track item; let idx = $index) { -
K}kdSz=IMo*@Wbga!+c`l&!Oh#YMVJp%o#*G@VA5Z)XKgxUePX&= EX)cIGk&rBojSAn=OO+le;D$a?~R@7%dF@of;q4VVD3=)4#IG(QGBm2lt7
zZ3E+IYvu`X4z{N(HFsj z5Dg+*GjXd@DQtXfV%#wu##A@K!@>y
zdGD(^f`Wn#Z*B)-S5xoWrRma`AiWXj1kjPkqU&zSl?E0z@q%zazg-@KyR#R*Z#`bG
ziZXqIho`yQ$8Bw85!-kBUHrrf+Z)}2;jRqRVa2@aWuwtfPk_k!Y)hTB*%Wt6fR&~B
zarg2$Yb&dRKWb3|q@|=Tp?W9C#BE10(C;jCEuHI(8t>}Tq-5k*8k+Cx>$5E>Lm}0R
zua%+1AcS$<+0DtxxiV_*9)nBWh~#hnDQGvML?HOOI0>settings Settings
Display Wind Vectors: Select to display wind vectors for
the vessel on the map.
+