Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend into SI-375
diff --git a/package.json b/package.json
index 43f0e7b..e65e1f2 100644
--- a/package.json
+++ b/package.json
@@ -93,7 +93,7 @@
"codelyzer": "5.2.2",
"concat": "1.0.3",
"fs-extra": "8.1.0",
- "http-server": "0.12.1",
+ "http-server": "0.12.3",
"jasmine-core": "3.5.0",
"json-concat": "0.0.1",
"karma": "4.4.1",
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 b012a93..043d775 100644
--- a/projects/openk/grid-failure-information-map/src/constants/globals.ts
+++ b/projects/openk/grid-failure-information-map/src/constants/globals.ts
@@ -26,6 +26,13 @@
static RADIUS_BORDER_COLOR = '#204d74';
static RADIUS_FILL_COLOR = '#337ab7';
static RADIUS_FILL_OPACITY = 0.3;
+ static STRONG_BEGIN_TAG = '<strong>';
+ static STRONG_END_TAG = '</strong>';
+ static GRID_FAILURE_BEGIN = 'Störungsbeginn:';
+ static GRID_FAILURE_END_PLANNED = 'Voraussichtliches Ende:';
+ static GRID_FAILURE_EXPECTED_REASON = 'Voraussichtlicher Grund:';
+ static GRID_FAILURE_BRANCH = 'Sparte:';
+ static BREAK_TAG = '<br/>';
public static PROPERTIES_TO_BOX: string[] = ['addressPolygonPoints'];
}
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 369e311..a862a64 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
@@ -10,7 +10,6 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-
import { GridFailureInformationMapComponent } from '@openk-libs/grid-failure-information-map/lib/grid-failure-information-map.component';
import * as L from 'leaflet';
import { async } from '@angular/core/testing';
@@ -29,10 +28,15 @@
const latitude: any = 123;
const longitude: any = 456;
const radius: any = 100;
+ const marker: any = {};
component.mapData = [{ latitude: latitude, longitude: longitude, radius: radius }];
let spyMap: any = spyOn(L, 'map').and.returnValue({ remove() {} });
let spyTileLayer: any = spyOn(L, 'tileLayer').and.returnValue({ addTo() {} });
- let spyMarker: any = spyOn(L, 'marker').and.returnValue({ addTo() {} });
+ let spyMarker: any = spyOn(L, 'marker').and.returnValue({
+ addTo() {
+ return { bindTooltip: () => {} };
+ },
+ });
let spyCircle: any = spyOn(L, 'circle').and.returnValue({ addTo() {} });
component.ngAfterViewInit();
component.mapData = [{ latitude: latitude, longitude: longitude, 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 995fa84..c02ce1f 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
@@ -14,7 +14,9 @@
import * as L from 'leaflet';
import { Globals } from '@openk-libs/grid-failure-information-map/constants/globals';
import { GridFailureCoordinates } from '@openk-libs/grid-failure-information-map/shared/models/grid-failure-coordinates.model';
+import { convertISOToLocalDateTime } from '@openk-libs/grid-failure-information-map/shared/utility/utilityHelpers';
import { unbox } from 'ngrx-forms';
+import { ofType } from '@ngrx/effects';
@Component({
selector: 'openk-grid-failure-information-map',
@@ -81,7 +83,17 @@
if (!!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);
+ const currentMarker = L.marker([gridFailure.latitude, gridFailure.longitude], { icon: this._icon }).addTo(this._map);
+ currentMarker.bindTooltip(
+ `${Globals.STRONG_BEGIN_TAG}${Globals.GRID_FAILURE_BEGIN}${Globals.STRONG_END_TAG} ${convertISOToLocalDateTime(gridFailure.failureBegin)}${
+ Globals.BREAK_TAG
+ }
+ ${Globals.STRONG_BEGIN_TAG}${Globals.GRID_FAILURE_END_PLANNED}${Globals.STRONG_END_TAG} ${convertISOToLocalDateTime(
+ gridFailure.failureEndPlanned
+ )} ${Globals.BREAK_TAG}
+ ${Globals.STRONG_BEGIN_TAG}${Globals.GRID_FAILURE_EXPECTED_REASON}${Globals.STRONG_END_TAG} ${gridFailure.expectedReasonText} ${Globals.BREAK_TAG}
+ ${Globals.STRONG_BEGIN_TAG}${Globals.GRID_FAILURE_BRANCH}${Globals.STRONG_END_TAG} ${gridFailure.branch}`
+ );
this._drawPolygonOrCircle(gridFailure);
}
});
diff --git a/projects/openk/grid-failure-information-map/src/shared/models/grid-failure-coordinates.model.ts b/projects/openk/grid-failure-information-map/src/shared/models/grid-failure-coordinates.model.ts
index fb606bb..932ba8f 100644
--- a/projects/openk/grid-failure-information-map/src/shared/models/grid-failure-coordinates.model.ts
+++ b/projects/openk/grid-failure-information-map/src/shared/models/grid-failure-coordinates.model.ts
@@ -15,10 +15,14 @@
export class GridFailureCoordinates {
public id: string = null;
- public radius: number = null;
public longitude: number = null;
public latitude: number = null;
+ public radius: number = null;
public addressPolygonPoints: Array<[Number, Number]> = null;
+ public failureBegin: string = null;
+ public failureEndPlanned: string = null;
+ public expectedReasonText: string = null;
+ public branch: string = null;
public constructor(data: any = null) {
Object.keys(data || {})
diff --git a/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.spec.ts b/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.spec.ts
new file mode 100644
index 0000000..c1d8917
--- /dev/null
+++ b/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.spec.ts
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+import * as utilityHelpers from '@openk-libs/grid-failure-information-map/shared/utility/utilityHelpers';
+
+describe('utilityHelpers', () => {
+ it('should parse string to Integer via toInteger()', () => {
+ let testValue = utilityHelpers.toInteger('1');
+ expect(testValue).toBe(parseInt(`${1}`, 10));
+ });
+
+ it('should return true if a value is a number', () => {
+ let testValue = utilityHelpers.isNumber('1');
+ expect(testValue).toBe(true);
+ });
+
+ it('should return false if a value is not a number', () => {
+ let testValue = utilityHelpers.isNumber('a');
+ expect(testValue).toBe(false);
+ });
+
+ it('should pad the number if a value is a number', () => {
+ let testValue = utilityHelpers.padNumber(1);
+ expect(testValue).toBe('01');
+ });
+
+ it('should return empty string if a value is not a number', () => {
+ let testValue = utilityHelpers.padNumber(null);
+ expect(testValue).toBe('');
+ });
+
+ it('should convert ISO time to local time', () => {
+ const dateString: string = '2020-11-19T14:13:15.666Z';
+ let testValue = utilityHelpers.convertISOToLocalDateTime(dateString);
+ expect(testValue).toBe('19.11.2020 / 14:13');
+ });
+});
diff --git a/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.ts b/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.ts
new file mode 100644
index 0000000..5ff1d2a
--- /dev/null
+++ b/projects/openk/grid-failure-information-map/src/shared/utility/utilityHelpers.ts
@@ -0,0 +1,38 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+
+// Convert datetime from ISO to local string
+export function convertISOToLocalDateTime(value: string): string {
+ if (value) {
+ const date: Date = new Date(value);
+ return date.toLocaleDateString() + ' / ' + padNumber(date.getHours() + date.getTimezoneOffset() / 60) + ':' + padNumber(date.getMinutes());
+ } else {
+ return '';
+ }
+}
+
+export function padNumber(value: number) {
+ if (isNumber(value)) {
+ return `0${value}`.slice(-2);
+ } else {
+ return '';
+ }
+}
+
+export function isNumber(value: any): value is number {
+ return !isNaN(toInteger(value));
+}
+
+export function toInteger(value: any): number {
+ return parseInt(`${value}`, 10);
+}