Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend into SI-374
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
index 5839ebf..3470740 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.html
@@ -492,7 +492,7 @@
class="form-control"
[ngbTypeahead]="gridFailureDetailsSandbox.searchForStation"
[ngrxValueConverter]="gridFailureDetailsSandbox.stationValueConverter"
- (selectItem)="gridFailureDetailsSandbox.latLonMapping($event)"
+ (selectItem)="gridFailureDetailsSandbox.latLonMapping($event.item)"
id="stationDescription"
[ngrxFormControlState]="((gridFailureDetailsSandbox.gridFailureDetailsFormState$ | async)?.controls)['stationDescription']"
autocomplete="off"
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
index 0604c67..bf71a4b 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.spec.ts
@@ -345,7 +345,9 @@
value: gfdetail,
};
- const event = { item: { longitude: 1.24, latitude: 1.23 } };
+ const event = new FailureStation();
+ event.latitude = 1.24;
+ event.longitude = 1.23;
service.latLonMapping(event);
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
index c67ed3d..e6c3b29 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox.ts
@@ -353,10 +353,14 @@
public stationValueConverter: NgrxValueConverter<any | null, string | null> = stationToStationNameConverter;
- public latLonMapping(event) {
- !!event &&
+ public latLonMapping(failureStationData: FailureStation): void {
+ !!failureStationData &&
this.appState$.dispatch(
- new SetValueAction(this.currentFormState.id, { ...this.currentFormState.value, longitude: event.item.longitude, latitude: event.item.longitude })
+ new SetValueAction(this.currentFormState.id, {
+ ...this.currentFormState.value,
+ longitude: failureStationData.longitude,
+ latitude: failureStationData.latitude,
+ })
);
}
diff --git a/projects/openk/grid-failure-information-map/src/constants/globals.ts b/projects/openk/grid-failure-information-map/src/constants/globals.ts
index 88c5f9a..4839654 100644
--- a/projects/openk/grid-failure-information-map/src/constants/globals.ts
+++ b/projects/openk/grid-failure-information-map/src/constants/globals.ts
@@ -22,4 +22,7 @@
static MAP_ID = 'map';
static TITLE_ATTRIBUTION = '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>';
static TITLE_LAYER = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
+ static RADIUS_BORDER_COLOR = '#204d74';
+ static RADIUS_FILL_COLOR = '#337ab7';
+ static RADIUS_FILL_OPACITY = 0.3;
}
diff --git a/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.spec.ts b/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.spec.ts
index 250e315..1a0390b 100644
--- a/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.spec.ts
+++ b/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.spec.ts
@@ -28,14 +28,17 @@
it('should call _initMap() and _setMarker after calling ngAfterViewInit', async(() => {
const latitude: any = 123;
const longitude: any = 456;
- component.mapData = [{ latitude: latitude, longitude: longitude }];
+ const radius: any = 100;
+ component.mapData = [{ latitude: latitude, longitude: longitude, radius: radius }];
let spyMap: any = spyOn(L, 'map').and.returnValue('mockMap');
let spyTileLayer: any = spyOn(L, 'tileLayer').and.returnValue({ addTo() {} });
let spyMarker: any = spyOn(L, 'marker').and.returnValue({ addTo() {} });
+ let spyCircle: any = spyOn(L, 'circle').and.returnValue({ addTo() {} });
component.ngAfterViewInit();
expect((component as any)._map).toBe('mockMap');
expect(spyMap).toHaveBeenCalled();
expect(spyTileLayer).toHaveBeenCalled();
expect(spyMarker).toHaveBeenCalledWith([latitude, longitude], { icon: (component as any)._icon });
+ expect(spyCircle).toHaveBeenCalledWith([latitude, longitude], { color: '#204d74', fillColor: '#337ab7', fillOpacity: 0.3, radius: radius });
}));
});
diff --git a/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.ts b/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.ts
index a1948e2..35d636b 100644
--- a/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.ts
+++ b/projects/openk/grid-failure-information-map/src/lib/grid-failure-information-map.component.ts
@@ -54,12 +54,18 @@
tiles.addTo(this._map);
}
- private _setMarker() {
+ private _setMarker(): void {
!!this._map &&
!!this._mapData &&
this._mapData.forEach(gridFailure => {
if (gridFailure.latitude && gridFailure.longitude) {
L.marker([gridFailure.latitude, gridFailure.longitude], { icon: this._icon }).addTo(this._map);
+ L.circle([gridFailure.latitude, gridFailure.longitude], {
+ color: Globals.RADIUS_BORDER_COLOR,
+ fillColor: Globals.RADIUS_FILL_COLOR,
+ fillOpacity: Globals.RADIUS_FILL_OPACITY,
+ radius: gridFailure.radius,
+ }).addTo(this._map);
}
});
}