Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend into SI-2860-aktuelle-Adresse-optimieren
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 ab364a7..45e59ee 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
@@ -48,7 +48,7 @@
unbox,
MarkAsPristineAction,
} from 'ngrx-forms';
-import { combineLatest, Observable } from 'rxjs';
+import { combineLatest, Observable, of } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, skipWhile, take, takeUntil, tap } from 'rxjs/operators';
import { StateEnum } from '@grid-failure-information-app/shared/constants/enums';
@@ -340,7 +340,7 @@
.subscribe((payload: any) => {
this.setFormStatePristine();
if (payload && payload.id) {
- this._router.navigateByUrl('/grid-failures/' + payload.id);
+ window.location.assign('/grid-failures/' + payload.id);
} else {
if (this._configService.getEnv('env') !== 'test') {
window.location.reload();
@@ -891,9 +891,7 @@
break;
case formState.controls.city.id:
- this.loadGridFailureDistricts(
- formState.value.city,
- formState.value.branch);
+ this.loadGridFailureDistricts(formState.value.city, formState.value.branch);
break;
case formState.controls.district.id:
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
index 336a2fa..4102866 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition.ts
@@ -12,7 +12,7 @@
********************************************************************************/
import { DateTimeCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/date-time-cell-renderer/date-time-cell-renderer.component';
import { IconCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component';
-import { dateTimeComparator } from '@grid-failure-information-app/shared/utility';
+import { dateTimeComparator, sortAlphaNum } from '@grid-failure-information-app/shared/utility';
import { stringInsensitiveComparator } from '@grid-failure-information-table-app/app/utilityHelpers';
export const GRID_FAILURE_COLDEF = [
@@ -205,7 +205,7 @@
colId: 'housenumber',
headerName: 'GridFailure.Housenumber',
sortable: true,
- comparator: stringInsensitiveComparator,
+ comparator: sortAlphaNum,
suppressMovable: true,
filter: 'setFilterComponent',
},
diff --git a/projects/grid-failure-information-app/src/app/shared/models/settings.model.ts b/projects/grid-failure-information-app/src/app/shared/models/settings.model.ts
index 282dc18..27abdc0 100644
--- a/projects/grid-failure-information-app/src/app/shared/models/settings.model.ts
+++ b/projects/grid-failure-information-app/src/app/shared/models/settings.model.ts
@@ -19,6 +19,7 @@
public overviewMapInitialLatitude: string = null;
public overviewMapInitialLongitude: string = null;
public visibilityConfiguration: VisibilityConfigurationInterface = null;
+ public dataExternInitialVisibility: string = null;
public constructor(data: any = null) {
Object.keys(data || {})
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.spec.ts b/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.spec.ts
index ef6b322..ef7905d 100644
--- a/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.spec.ts
@@ -12,6 +12,7 @@
********************************************************************************/
import * as utilityHelpers from '@grid-failure-information-app/shared/utility/utilityHelpers';
import { FailureHousenumber } from '@grid-failure-information-app/shared/models';
+import { VisibilityConfigurationInterface } from '@grid-failure-information-app/shared/interfaces/visibility-configuration.interface';
describe('utilityHelpers', () => {
it('should navigate to overview after call navigateHome', () => {
@@ -112,4 +113,15 @@
testValue = utilityHelpers.sortAlphaNum(inputFailureHousenumber, inputFailureHousenumber2);
expect(testValue).toBe(0);
});
+
+ it('should return true for detailFieldVisibility in case no config is provided', () => {
+ let config: VisibilityConfigurationInterface = null;
+ let testValue = utilityHelpers.determineDetailFieldVisibility(config, 'fieldVisibility', 'description');
+ expect(testValue).toBeTruthy();
+ });
+
+ it('should determine addressRelevan Branch', () => {
+ let testValue = utilityHelpers.getAddressRelevantBranch('S');
+ expect(testValue).toBe('S');
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.ts b/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.ts
index becb2c7..3345c1f 100644
--- a/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.ts
+++ b/projects/grid-failure-information-app/src/app/shared/utility/utilityHelpers.ts
@@ -127,6 +127,10 @@
firstInput = firstInput.housenumber;
secondInput = secondInput.housenumber;
}
+ // NULL or UNDEFINED handling
+ firstInput = !firstInput ? '0' : firstInput;
+ secondInput = !secondInput ? '0' : secondInput;
+
const removeA = /[^a-zA-Z]/g;
const removeNumber = /[^0-9]/g;
const firstInputNumber = parseInt(firstInput.replace(removeNumber, /^.+-/, /^.+ /, ''));
diff --git a/projects/grid-failure-information-map-app/src/app/app-config.service.ts b/projects/grid-failure-information-map-app/src/app/app-config.service.ts
index 96aea46..4810aee 100644
--- a/projects/grid-failure-information-map-app/src/app/app-config.service.ts
+++ b/projects/grid-failure-information-map-app/src/app/app-config.service.ts
@@ -12,6 +12,7 @@
********************************************************************************/
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
+import { MapOptions } from '@openk-libs/grid-failure-information-map/shared/models/map-options.model';
@Injectable({
providedIn: 'root',
@@ -20,6 +21,6 @@
constructor(private http: HttpClient) {}
getConfig() {
- return this.http.get('public-settings');
+ return this.http.get<MapOptions>('public-settings');
}
}
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
index 679f27e..2a39df8 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
@@ -14,9 +14,10 @@
import { GridFailureService } from '@grid-failure-information-map-app/app/grid-failure/grid-failure.service';
import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
import { of } from 'rxjs';
-import { GridFailure } from '@grid-failure-information-app/shared/models';
+import { GridFailure, Settings } from '@grid-failure-information-app/shared/models';
+import { VisibilityEnum } from '@grid-failure-information-app/shared/constants/enums';
-describe('GridFailureSandbox', () => {
+describe('GridFailureSandbox ', () => {
let sandbox: GridFailureSandbox;
let gridFailureService: GridFailureService;
let configService: AppConfigService;
@@ -24,17 +25,15 @@
let gridFailureMapList: GridFailure[] = [];
beforeEach(() => {
+ let config = new Settings();
+ config.dataExternInitialVisibility = VisibilityEnum.SHOW;
configService = {
- getConfig: () => of(new Object()),
+ getConfig: () => of(config),
} as any;
gridFailureService = {
- getGridFailureData: () => of(new Object()),
+ getGridFailureData: () => of([new GridFailure()]),
} as any;
- gridFailureMapListAll = [
- new GridFailure({postcode: '007'}),
- new GridFailure({postcode: '4711'}),
- new GridFailure({postcode: '0815'}),
- ];
+ gridFailureMapListAll = [new GridFailure({ postcode: '007' }), new GridFailure({ postcode: '4711' }), new GridFailure({ postcode: '0815' })];
gridFailureMapList = gridFailureMapListAll.map(i => Object.assign(i));
sandbox = new GridFailureSandbox(gridFailureService, configService);
(sandbox as any)._gridFailureMapListAll = gridFailureMapListAll;
@@ -45,12 +44,6 @@
expect(sandbox).toBeTruthy();
});
- it('should add two subscriptions', () => {
- const spy: any = spyOn(sandbox['_subscription'], 'add');
- sandbox.initSandbox();
- expect(spy).toHaveBeenCalledTimes(2);
- });
-
it('should unsubscribe subscriptions', () => {
const spy: any = spyOn(sandbox['_subscription'], 'unsubscribe');
sandbox.unsubscribe();
@@ -58,13 +51,15 @@
});
it('filterGridFailureMapList() should assign all gridfailure to map property ', () => {
+ sandbox.initSandbox();
sandbox.filterGridFailureMapList();
- expect(sandbox.gridFailureMapList.length).toEqual(gridFailureMapListAll.length);
+ expect(sandbox.gridFailureMapList.length).toEqual(1);
});
it('filterGridFailureMapList("") should assign all gridfailure to map property ', () => {
+ sandbox.initSandbox();
sandbox.filterGridFailureMapList('');
- expect(sandbox.gridFailureMapList.length).toEqual(gridFailureMapListAll.length);
+ expect(sandbox.gridFailureMapList.length).toEqual(1);
});
it('filterGridFailureMapList("007") should assign only one gridfailure to map property ', () => {
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
index cb114d8..0dfac51 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
@@ -12,48 +12,39 @@
********************************************************************************/
import { Injectable } from '@angular/core';
import { GridFailureService } from '@grid-failure-information-map-app/app/grid-failure/grid-failure.service';
-import { Subscription } from 'rxjs';
+import { Subscription, combineLatest } from 'rxjs';
import { MapOptions } from '@openk-libs/grid-failure-information-map/shared/models/map-options.model';
import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
import { take } from 'rxjs/operators';
import { GridFailure } from '@grid-failure-information-app/shared/models';
+import { VisibilityEnum } from '@grid-failure-information-app/shared/constants/enums';
@Injectable()
export class GridFailureSandbox {
public gridFailureMapList: GridFailure[] = [];
public mapOptions: MapOptions = new MapOptions();
- public postcode: string = '';
private _gridFailureMapListAll: GridFailure[] = [];
+ private _gridFailureMapListAllConfigured: GridFailure[] = [];
private _subscription: Subscription = new Subscription();
constructor(private _gridFailureService: GridFailureService, private _configService: AppConfigService) {}
public initSandbox() {
- this._subscription.add(
- this._configService
- .getConfig()
- .pipe(take(1))
- .subscribe((data: MapOptions) => {
- this.mapOptions = new MapOptions(data);
- this.mapOptions.extendMarkerInformation = true;
- })
- );
-
- this._subscription.add(
- this._gridFailureService
- .getGridFailureData()
- .pipe(take(1))
- .subscribe((data: GridFailure[]) => {
- this.gridFailureMapList = data;
- this._gridFailureMapListAll = data;
- })
- );
+ this._subscription = combineLatest([this._configService.getConfig(), this._gridFailureService.getGridFailureData()])
+ .pipe(take(1))
+ .subscribe(([config, data]) => {
+ this.mapOptions = new MapOptions(config);
+ this.mapOptions.extendMarkerInformation = true;
+ this.gridFailureMapList = config && config.dataExternInitialVisibility === VisibilityEnum.HIDE ? [] : data;
+ this._gridFailureMapListAll = data;
+ this._gridFailureMapListAllConfigured = config && config.dataExternInitialVisibility === VisibilityEnum.HIDE ? [] : data;
+ });
}
public filterGridFailureMapList(postcode: string = '') {
postcode = postcode.trim();
- this.gridFailureMapList = postcode.length > 0 ? this._gridFailureMapListAll.filter(y => y.postcode === postcode) : this._gridFailureMapListAll;
+ this.gridFailureMapList = postcode.length > 0 ? this._gridFailureMapListAll.filter(y => y.postcode === postcode) : this._gridFailureMapListAllConfigured;
}
public unsubscribe() {
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.ts
index ddefa01..ed4fba6 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.ts
@@ -1,26 +1,26 @@
/********************************************************************************
-* 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
-********************************************************************************/
+ * 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 { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
+import { GridFailure } from '@grid-failure-information-app/shared/models';
@Injectable({
- providedIn: 'root'
+ providedIn: 'root',
})
export class GridFailureService {
+ constructor(private _http: HttpClient) {}
- constructor(private _http: HttpClient) { }
-
- getGridFailureData(){
- return this._http.get('public-sit');
+ getGridFailureData() {
+ return this._http.get<GridFailure[]>('public-sit');
}
}
diff --git a/projects/grid-failure-information-table-app/src/app/app-config.service.ts b/projects/grid-failure-information-table-app/src/app/app-config.service.ts
index 96aea46..cef247c 100644
--- a/projects/grid-failure-information-table-app/src/app/app-config.service.ts
+++ b/projects/grid-failure-information-table-app/src/app/app-config.service.ts
@@ -12,6 +12,7 @@
********************************************************************************/
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
+import { Settings } from '@grid-failure-information-app/shared/models';
@Injectable({
providedIn: 'root',
@@ -20,6 +21,6 @@
constructor(private http: HttpClient) {}
getConfig() {
- return this.http.get('public-settings');
+ return this.http.get<Settings>('public-settings');
}
}
diff --git a/projects/grid-failure-information-table-app/src/app/app.component.spec.ts b/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
index 79a3fb9..3821ac2 100644
--- a/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
+++ b/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
@@ -16,8 +16,9 @@
import { GridFailure, Settings } from '@grid-failure-information-app/shared/models';
import { of } from 'rxjs';
import { DatePipe } from '@angular/common';
+import { VisibilityEnum } from '@grid-failure-information-app/shared/constants/enums';
-describe('AppComponent', () => {
+describe('AppComponent ', () => {
let component: TableComponent;
let service: AppTableService;
let configService: AppConfigService;
@@ -26,7 +27,7 @@
beforeEach(() => {
service = {
- loadGridFailureData: () => of(true),
+ loadGridFailureData: () => of([new GridFailure()]),
} as any;
configService = {
getConfig: () => of(true),
@@ -63,9 +64,16 @@
});
it('should assign all gridfailures to table', () => {
+ let config = new Settings();
+ config.dataExternInitialVisibility = VisibilityEnum.SHOW;
+ configService = {
+ getConfig: () => of(config),
+ } as any;
+ component = new TableComponent(service, configService, null);
component.postcode = '';
component['_datePipe'] = { transform: () => '18.09.2020 / 10:17' } as any;
- expect(component.gridFailures.length).toEqual(gridFailureMapListAll.length);
+ component.ngOnInit();
+ expect(component.gridFailures.length).toEqual(1);
});
it('should assign only gridfailures with postcode 007 to table', () => {
diff --git a/projects/grid-failure-information-table-app/src/app/app.component.ts b/projects/grid-failure-information-table-app/src/app/app.component.ts
index b8d2492..bccf565 100644
--- a/projects/grid-failure-information-table-app/src/app/app.component.ts
+++ b/projects/grid-failure-information-table-app/src/app/app.component.ts
@@ -16,7 +16,7 @@
import { APP_TABLE_COLDEF } from '@grid-failure-information-table-app/app/app-table-column-definition';
import { GridOptions } from 'ag-grid-community';
import { Globals } from '@grid-failure-information-app/shared/constants/globals';
-import { Subscription } from 'rxjs';
+import { Subscription, combineLatest } from 'rxjs';
import { DatePipe } from '@angular/common';
import { AppConfigService } from '@grid-failure-information-table-app/app/app-config.service';
import { take } from 'rxjs/operators';
@@ -38,7 +38,8 @@
public lastModDate: string;
private _gridApi;
- private _gridFailuresAll: GridFailure[];
+ private _gridFailuresAll: GridFailure[] = [];
+ private _gridFailuresAllConfigured: GridFailure[];
private _subscription: Subscription = new Subscription();
constructor(private _appTableService: AppTableService, private _configService: AppConfigService, private _datePipe: DatePipe) {
@@ -51,35 +52,29 @@
@Input() set postcode(value: string) {
value = value.trim();
let filterFunc = (x: GridFailure) => x.postcode === value || x.freetextPostcode === value;
- this.gridFailures = value.length > 0 ? this._gridFailuresAll.filter(filterFunc) : this._gridFailuresAll;
+ if (!!this._gridFailuresAll && this._gridFailuresAll.length > 0) {
+ this.gridFailures = value.length > 0 ? this._gridFailuresAll.filter(filterFunc) : this._gridFailuresAllConfigured;
+ }
}
ngOnInit() {
- this._subscription.add(
- this._configService
- .getConfig()
- .pipe(take(1))
- .subscribe((config: Settings) => {
- if (config && config.visibilityConfiguration) {
- APP_TABLE_COLDEF.forEach((column: any) => {
- column['hide'] = config.visibilityConfiguration.tableExternColumnVisibility[column['field']] === VisibilityEnum.HIDE;
- });
- this.columnDefs = APP_TABLE_COLDEF;
- }
- })
- );
- this._subscription.add(
- this._appTableService
- .loadGridFailureData()
- .pipe(take(1))
- .subscribe((data: GridFailure[]) => {
- this.gridFailures = data;
- this._gridFailuresAll = data;
- if (this._datePipe) {
- this.lastModDate = this._datePipe.transform(this._getLastModeDate(), Globals.DATE_TIME_FORMAT);
- }
- })
- );
+ this._subscription = combineLatest([this._configService.getConfig(), this._appTableService.loadGridFailureData()])
+ .pipe(take(1))
+ .subscribe(([config, data]) => {
+ if (config && config.visibilityConfiguration) {
+ APP_TABLE_COLDEF.forEach((column: any) => {
+ column['hide'] = config.visibilityConfiguration.tableExternColumnVisibility[column['field']] === VisibilityEnum.HIDE;
+ });
+ this.columnDefs = APP_TABLE_COLDEF;
+ }
+ this.gridFailures = config && config.dataExternInitialVisibility === VisibilityEnum.HIDE ? [] : data;
+ this._gridFailuresAll = data;
+ this._gridFailuresAllConfigured = config && config.dataExternInitialVisibility === VisibilityEnum.HIDE ? [] : data;
+ if (this._datePipe) {
+ this.lastModDate = this._datePipe.transform(this._getLastModeDate(), Globals.DATE_TIME_FORMAT);
+ }
+ });
+
this.gridOptions = {
localeText: Globals.LOCALE_TEXT,
};
@@ -96,8 +91,10 @@
}
private _getLastModeDate(): number {
- let modeDates: number[] = !!this._gridFailuresAll && this._gridFailuresAll.map(gf => Date.parse(gf.modDate));
- modeDates = modeDates.sort((a, b) => b - a); // sort timestamps descending
- return modeDates[0];
+ if (!!this._gridFailuresAll && this._gridFailuresAll.length > 0) {
+ let modeDates: number[] = this._gridFailuresAll.map(gf => Date.parse(gf.modDate));
+ modeDates = modeDates.sort((a, b) => b - a); // sort timestamps descending
+ return modeDates[0];
+ }
}
}
diff --git a/projects/openk/grid-failure-information-map/src/shared/models/map-options.model.ts b/projects/openk/grid-failure-information-map/src/shared/models/map-options.model.ts
index 031f129..ae5e3dd 100644
--- a/projects/openk/grid-failure-information-map/src/shared/models/map-options.model.ts
+++ b/projects/openk/grid-failure-information-map/src/shared/models/map-options.model.ts
@@ -21,6 +21,7 @@
public overviewMapInitialLatitude: string = null;
public overviewMapInitialLongitude: string = null;
public visibilityConfiguration: VisibilityConfigurationInterface = null;
+ public dataExternInitialVisibility: 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
index c1d8917..df78e04 100644
--- 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
@@ -11,6 +11,7 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import * as utilityHelpers from '@openk-libs/grid-failure-information-map/shared/utility/utilityHelpers';
+import { VisibilityConfigurationInterface } from '@openk-libs/grid-failure-information-map/shared/models/visibility-configuration.interface';
describe('utilityHelpers', () => {
it('should parse string to Integer via toInteger()', () => {
@@ -43,4 +44,10 @@
let testValue = utilityHelpers.convertISOToLocalDateTime(dateString);
expect(testValue).toBe('19.11.2020 / 14:13');
});
+
+ it('should return true for detailFieldVisibility in case no config is provided', () => {
+ let config: VisibilityConfigurationInterface = null;
+ let testValue = utilityHelpers.determineDetailFieldVisibility(config, 'fieldVisibility', 'description');
+ expect(testValue).toBeTruthy();
+ });
});