Skip to content

Commit bc8299c

Browse files
authored
feat: new freeboard-sk widget (#343)
1 parent ef5f523 commit bc8299c

6 files changed

+85
-16
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mxtommy/kip",
3-
"version": "2.8.3",
3+
"version": "2.8.4-beta.1",
44
"description": "An advanced and versatile marine instrumentation package to display Signal K data.",
55
"license": "MIT",
66
"author": {

src/app/core/services/widget-list.service.ts

+16-15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { WidgetAutopilotComponent } from "../../widgets/widget-autopilot/widget-
1717
import { WidgetSimpleLinearComponent } from "../../widgets/widget-simple-linear/widget-simple-linear.component";
1818
import { WidgetRaceTimerComponent } from '../../widgets/widget-race-timer/widget-race-timer.component';
1919
import { WidgetDataChartComponent } from '../../widgets/widget-data-chart/widget-data-chart.component';
20+
import { WidgetFreeboardskComponent } from '../../widgets/widget-freeboardsk/widget-freeboardsk.component';
2021

2122
class widgetInfo {
2223
name: string;
@@ -37,11 +38,6 @@ export class WidgetListService {
3738

3839
widgetList: widgetList = {
3940
'Basic': [
40-
{
41-
name: 'WidgetBlank',
42-
componentName: WidgetBlankComponent,
43-
description: 'Blank',
44-
},
4541
{
4642
name: 'WidgetNumeric',
4743
componentName: WidgetNumericComponent,
@@ -62,10 +58,15 @@ export class WidgetListService {
6258
componentName: WidgetBooleanSwitchComponent,
6359
description: 'Boolean Control Panel',
6460
},
61+
{
62+
name: 'WidgetBlank',
63+
componentName: WidgetBlankComponent,
64+
description: 'Blank',
65+
},
6566
{
6667
name: 'WidgetStateComponent',
6768
componentName: WidgetButtonComponent,
68-
description: 'Boolean Button/Switch',
69+
description: '(Deprecated) Boolean Button/Switch',
6970
}
7071
],
7172
'Gauge': [
@@ -88,7 +89,7 @@ export class WidgetListService {
8889
name: 'WidgetGaugeComponent',
8990
componentName: WidgetGaugeComponent,
9091
description: "Linear & Radial Steel Style"
91-
},
92+
}
9293
],
9394
'Component': [
9495
{
@@ -97,15 +98,20 @@ export class WidgetListService {
9798
description: 'Wind Steering Display',
9899
},
99100
{
100-
name: 'WidgetDataChart',
101-
componentName: WidgetDataChartComponent,
102-
description: 'Data Chart',
101+
name: 'WidgetFreeboardskComponent',
102+
componentName: WidgetFreeboardskComponent,
103+
description: 'Freeboard-SK Chart Plotter',
103104
},
104105
{
105106
name: 'WidgetAutopilotComponent',
106107
componentName: WidgetAutopilotComponent,
107108
description: 'Autopilot Head',
108109
},
110+
{
111+
name: 'WidgetDataChart',
112+
componentName: WidgetDataChartComponent,
113+
description: 'Data Chart',
114+
},
109115
{
110116
name: 'WidgetRaceTimerComponent',
111117
componentName: WidgetRaceTimerComponent,
@@ -115,11 +121,6 @@ export class WidgetListService {
115121
name: 'WidgetIframeComponent',
116122
componentName: WidgetIframeComponent,
117123
description: 'Embed Webpage',
118-
},
119-
{
120-
name: 'WidgetTutorial',
121-
componentName: WidgetTutorialComponent,
122-
description: 'Tutorial'
123124
}
124125
]
125126
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="iFrameWrapper">
2+
<iframe name="freeboard-sk" width="100%" height="100%" frameborder="0"
3+
[src]="widgetUrl | safe"
4+
sandbox="allow-same-origin allow-scripts allow-forms"></iframe>
5+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.iFrameWrapper {
2+
position: relative;
3+
width: 100%;
4+
height: 100%;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { WidgetFreeboardskComponent } from './widget-freeboardsk.component';
4+
5+
describe('WidgetFreeboardskComponent', () => {
6+
let component: WidgetFreeboardskComponent;
7+
let fixture: ComponentFixture<WidgetFreeboardskComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [WidgetFreeboardskComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(WidgetFreeboardskComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { AuthenticationService } from './../../core/services/authentication.service';
2+
import { AppSettingsService } from './../../core/services/app-settings.service';
3+
import { Component, OnDestroy, OnInit } from '@angular/core';
4+
import { BaseWidgetComponent } from '../../base-widget/base-widget.component';
5+
import { SafePipe } from "../../core/pipes/safe.pipe";
6+
import { Subscription } from 'rxjs';
7+
8+
@Component({
9+
selector: 'app-widget-freeboardsk',
10+
standalone: true,
11+
templateUrl: './widget-freeboardsk.component.html',
12+
styleUrl: './widget-freeboardsk.component.scss',
13+
imports: [SafePipe]
14+
})
15+
export class WidgetFreeboardskComponent extends BaseWidgetComponent implements OnInit, OnDestroy {
16+
public widgetUrl: string = null;
17+
private authTokenSubscription: Subscription = null;
18+
19+
constructor(private appSettings: AppSettingsService, private auth: AuthenticationService) {
20+
super();
21+
}
22+
23+
ngOnInit(): void {
24+
let loginToken: string = null;
25+
this.authTokenSubscription = this.auth.authToken$.subscribe(AuthServiceToken => {
26+
loginToken = AuthServiceToken.token;
27+
});
28+
29+
this.widgetUrl = `${this.appSettings.signalkUrl.url}/@signalk/freeboard-sk/?token=${loginToken}`;
30+
}
31+
32+
ngOnDestroy(): void {
33+
this.authTokenSubscription?.unsubscribe();
34+
}
35+
}

0 commit comments

Comments
 (0)