diff --git a/src/app/app.component.html b/src/app/app.component.html index 0a660ee9..07c5296d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -734,7 +734,8 @@ - @if(app.data.autopilot.hasApi) { + @if(app.data.autopilot.hasApi && + app.data.vessels.self.autopilot.default) {
< @@ -113,6 +142,10 @@ import { SKStreamFacade } from 'src/app/modules'; >> @@ -132,6 +169,10 @@ import { SKStreamFacade } from 'src/app/modules'; -1 @@ -149,6 +194,10 @@ import { SKStreamFacade } from 'src/app/modules'; +10 @@ -172,7 +225,8 @@ import { SKStreamFacade } from 'src/app/modules'; (click)="toggleEngaged()" [disabled]=" !app.data.autopilot.hasApi || - app.data.vessels.self.autopilot.state === 'offline' || + !app.data.vessels.self.autopilot.default || + app.data.vessels.self.autopilot.state === 'off-line' || !app.data.vessels.self.autopilot.state " [ngClass]="{ @@ -191,7 +245,8 @@ import { SKStreamFacade } from 'src/app/modules'; [matMenuTriggerFor]="modemenu" [disabled]=" !app.data.autopilot.hasApi || - app.data.vessels.self.autopilot.state === 'offline' || + !app.data.vessels.self.autopilot.default || + app.data.vessels.self.autopilot.state === 'off-line' || !app.data.vessels.self.autopilot.state " > @@ -210,7 +265,8 @@ import { SKStreamFacade } from 'src/app/modules'; }" [disabled]=" !app.data.autopilot.hasApi || - app.data.vessels.self.autopilot.state === 'offline' || + !app.data.vessels.self.autopilot.default || + app.data.vessels.self.autopilot.state === 'off-line' || !app.data.vessels.self.autopilot.state " mat-raised-button @@ -271,6 +327,7 @@ export class AutopilotComponent { () => { this.autopilotOptions = { modes: [], states: [] }; this.app.data.autopilot.hasApi = false; + this.app.showMessage('No autopilot providers found!'); } ); } @@ -289,8 +346,12 @@ export class AutopilotComponent { let msg = `Error setting Autopilot state!\n`; if (error.status === 403) { msg += 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); } - this.app.showAlert(`Error (${error.status}):`, msg); } ); } @@ -308,8 +369,15 @@ export class AutopilotComponent { () => { this.app.debug(`Target adjusted: ${value} deg.`); }, - (err: HttpErrorResponse) => { - this.app.debug(err); + (error: HttpErrorResponse) => { + if (error.status === 403) { + const msg = 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); + } } ); } @@ -322,8 +390,15 @@ export class AutopilotComponent { () => { this.app.debug(`Set dodge mode.`); }, - (err: HttpErrorResponse) => { - this.app.debug(err); + (error: HttpErrorResponse) => { + if (error.status === 403) { + const msg = 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); + } } ); } else { @@ -333,8 +408,15 @@ export class AutopilotComponent { () => { this.app.debug(`Clear dodge mode.`); }, - (err: HttpErrorResponse) => { - this.app.debug(err); + (error: HttpErrorResponse) => { + if (error.status === 403) { + const msg = 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); + } } ); } @@ -353,24 +435,19 @@ export class AutopilotComponent { () => { this.app.debug(`Dodge port / starboard: ${value} deg.`); }, - (err: HttpErrorResponse) => { - this.app.debug(err); + (error: HttpErrorResponse) => { + if (error.status === 403) { + const msg = 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); + } } ); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - dragEventHandler(e: any, type: string) { - this.app.debug( - 'e:', - e, - 'type:', - type, - e.event.srcElement.clientLeft, - e.event.srcElement.clientTop - ); - } - setMode(mode: string) { if (mode) { // autopilot mode @@ -384,13 +461,29 @@ export class AutopilotComponent { let msg = `Error setting Autopilot mode!\n`; if (error.status === 403) { msg += 'Unauthorised: Please login.'; + this.app.showAlert(`Error (${error.status}):`, msg); + } else { + this.app.showMessage( + error.error?.message ?? 'Device returned an error!' + ); } - this.app.showAlert(`Error (${error.status}):`, msg); } ); } } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + dragEventHandler(e: any, type: string) { + this.app.debug( + 'e:', + e, + 'type:', + type, + e.event.srcElement.clientLeft, + e.event.srcElement.clientTop + ); + } + formatTargetValue(value: number) { if (typeof value === 'number') { return Convert.radiansToDegrees(value)?.toFixed(1);