From a3527ffcb8da1507e5908a11eecaf8a8e147e3b8 Mon Sep 17 00:00:00 2001 From: panaaj <38519157+panaaj@users.noreply.github.com> Date: Tue, 28 May 2024 18:07:59 +0930 Subject: [PATCH] Fix alarm not clearing. --- CHANGELOG.md | 4 ++++ helper/alarms/alarms.ts | 2 +- package.json | 2 +- src/app/app.info.ts | 2 +- src/app/modules/alarms/alarms.facade.ts | 2 +- .../modules/alarms/components/alarms-dialog.component.ts | 6 ++++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 922d7377..8de4dbbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG: Freeboard +### v2.8.1 + +- **Fixed**: Unable to clearing alarms on server v2.8 or greater due to 'DELETE' requests not being passed to plugins. + ### v2.8.0 - **Added**: Option to display laylines when destination is active. (#149) diff --git a/helper/alarms/alarms.ts b/helper/alarms/alarms.ts index cd7a09f0..0c60d1d2 100644 --- a/helper/alarms/alarms.ts +++ b/helper/alarms/alarms.ts @@ -25,7 +25,7 @@ const STANDARD_ALARMS = [ let server: FreeboardHelperApp; let pluginId: string; -const ALARM_API_PATH = '/signalk/v1/api/alarms'; +const ALARM_API_PATH = '/signalk/v2/api/alarms'; export const initAlarms = (app: FreeboardHelperApp, id: string) => { server = app; diff --git a/package.json b/package.json index ddbe98b9..2bc9962e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@signalk/freeboard-sk", - "version": "2.8.0", + "version": "2.8.1", "description": "Openlayers chart plotter implementation for Signal K", "keywords": [ "signalk-webapp", diff --git a/src/app/app.info.ts b/src/app/app.info.ts index 40d0beb9..12420d80 100644 --- a/src/app/app.info.ts +++ b/src/app/app.info.ts @@ -274,7 +274,7 @@ export class AppInfo extends Info { this.name = 'Freeboard-SK'; this.shortName = 'Freeboard'; this.description = `Signal K Chart Plotter.`; - this.version = '2.8.0'; + this.version = '2.8.1'; this.url = 'https://github.com/signalk/freeboard-sk'; this.logo = './assets/img/app_logo.png'; diff --git a/src/app/modules/alarms/alarms.facade.ts b/src/app/modules/alarms/alarms.facade.ts index b10c5d71..0d9f864a 100644 --- a/src/app/modules/alarms/alarms.facade.ts +++ b/src/app/modules/alarms/alarms.facade.ts @@ -214,7 +214,7 @@ export class AlarmsFacade { muteAlarm(id: string) { this.alarms.get(id)['muted'] = true; - this.signalk.api.post(`alarms/${id}/silence`, undefined).subscribe( + this.signalk.api.post(this.app.skApiVersion,`alarms/${id}/silence`, undefined).subscribe( () => undefined, (err: HttpErrorResponse) => { console.warn(`Error silencing alarm: ${id}`, err); diff --git a/src/app/modules/alarms/components/alarms-dialog.component.ts b/src/app/modules/alarms/components/alarms-dialog.component.ts index e427e259..ea0ba61f 100644 --- a/src/app/modules/alarms/components/alarms-dialog.component.ts +++ b/src/app/modules/alarms/components/alarms-dialog.component.ts @@ -7,6 +7,7 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Subscription } from 'rxjs'; import { SignalKClient } from 'signalk-client-angular'; import { AlarmsFacade } from '../alarms.facade'; +import { AppInfo } from 'src/app/app.info'; /********* AlarmsDialog ********* data: { @@ -90,6 +91,7 @@ export class AlarmsDialog implements OnInit { private obs: Subscription; constructor( + private app: AppInfo, private signalk: SignalKClient, private facade: AlarmsFacade, public dialogRef: MatDialogRef, @@ -202,7 +204,7 @@ export class AlarmsDialog implements OnInit { } raise(alarmType: string) { - this.signalk.api.post(`alarms/${alarmType}`, undefined).subscribe( + this.signalk.api.post(this.app.skApiVersion,`alarms/${alarmType}`, undefined).subscribe( () => undefined, (err: HttpErrorResponse) => { console.warn(`Error raising alarm: ${alarmType}`, err); @@ -212,7 +214,7 @@ export class AlarmsDialog implements OnInit { } clear(alarmType: string) { - this.signalk.api.delete(`alarms/${alarmType}`).subscribe( + this.signalk.api.delete(this.app.skApiVersion,`alarms/${alarmType}`).subscribe( () => undefined, (err: HttpErrorResponse) => { console.warn(`Error clearing alarm: ${alarmType}`, err);