Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.gridFailureInformation.frontend into SI-161-Verdichtung-der-Meldungen
Signed-off-by: Dennis Schmitt <dennis.schmitt@pta.de>
diff --git a/angular.json b/angular.json
index f0029a8..7d1fdda 100644
--- a/angular.json
+++ b/angular.json
@@ -139,6 +139,7 @@
"e2e/*.ts",
"**/*.action.*",
"**/*.model.*",
+ "**/*.constants.*",
"**/*.module.*",
"**/*column-definition*",
"**/*api-client.*",
@@ -275,6 +276,7 @@
"e2e/*.ts",
"**/*.action.*",
"**/*.model.*",
+ "**/*.constants.*",
"**/*.module.*",
"**/*column-definition*",
"**/*api-client.*",
@@ -335,6 +337,7 @@
"e2e/*.ts",
"**/*.action.*",
"**/*.model.*",
+ "**/*.constants.*",
"**/*.module.*",
"**/*column-definition*",
"**/*api-client.*",
diff --git a/i18n/general.de.json b/i18n/general.de.json
index 669247d..39aa366 100644
--- a/i18n/general.de.json
+++ b/i18n/general.de.json
@@ -13,6 +13,8 @@
"NewBtn": "Neu",
"CancelBtn": "Abbrechen",
"BackBtn": "Zurück",
+ "QualifyBtn": "Qualifizieren",
+ "StornoBtn": "Stornieren",
"GridEmptyLabel": "Keine Daten vorhanden!",
"Filtering": "Filterung",
"Sorting": "Sortierung",
diff --git a/package.json b/package.json
index a3ce0ab..3ae73d5 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"start-map-app": "npm run build-map-library && ng serve grid-failure-information-map-app",
"start-main-app": "npm run build-map-library && npm run sy-pre-start && ng serve --proxy-config proxy.conf.json",
"start-integration": "npm run sy-pre-start && npm run build-map-library && ng serve --proxy-config proxy.conf-integration.json",
- "start-local": "npm run sy-pre-start && ng serve --proxy-config proxy.conf-local.json",
+ "start-local": "npm run sy-pre-start && npm run build-map-library && ng serve --proxy-config proxy.conf.json",
"test": "npm run sy-pre-test && ng test grid-failure-information-app",
"test-single-run": "npm run sy-pre-test && ng test grid-failure-information-app --watch=false",
"test-openk": "npm run sy-pre-test && ng test openk-grid-failure-information-map-lib",
@@ -31,7 +31,9 @@
"start-in-docker-feature-be": "npm run build-map-library && npm run sy-pre-start && ng serve --optimization=false --vendor-chunk --common-chunk --host=0.0.0.0 --disableHostCheck=true --proxy-config proxy-docker-feature-be.conf.json",
"start-elements-app": "http-server ./dist/grid-failure-information-app",
"create-map-output-elements-windows": "create-map-output-elements.sh",
- "create-map-output-elements-linux": "./create-map-output-elements.sh"
+ "create-map-output-elements-linux": "./create-map-output-elements.sh",
+ "si": "npm run start-integration",
+ "sl": "npm run start-local"
},
"private": true,
"dependencies": {
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 f2bd0f0..9ffcdc6 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
@@ -480,15 +480,35 @@
<button
*ngIf="gridFailureDetailsSandbox.saveEnabled"
type="button"
- class="btn btn-success person-buttons div-button"
+ class="btn btn-success left-button"
(click)="gridFailureDetailsSandbox.saveGridFailure()"
>
{{ 'SaveBtn' | translate }}
</button>
- <button type="button" class="btn btn-primary person-buttons div-button" (click)="gridFailureDetailsSandbox.cancel()">
+ <button type="button" class="btn btn-primary left-button" (click)="gridFailureDetailsSandbox.cancel()">
{{ 'CancelBtn' | translate }}
</button>
</div>
+ <div>
+ <!-- State Buttons -->
+ <ng-container *ngIf="gridFailureDetailsSandbox.saveEnabled">
+ <ng-container *ngIf="gridFailureDetailsSandbox.showQualifyButton">
+ <ng-template visibleByRight [acceptedRole]="RolesEnum.QUALIFIER">
+ <button type="button" class="btn btn-info right-button" (click)="gridFailureDetailsSandbox.setState(StateEnum.QUALIFIED)">
+ {{ 'QualifyBtn' | translate }}
+ </button>
+ </ng-template>
+ </ng-container>
+
+ <ng-container *ngIf="gridFailureDetailsSandbox.showStornoButton">
+ <ng-template visibleByRight [acceptedRole]="RolesEnum.QUALIFIER">
+ <button type="button" class="btn btn-warning right -button" (click)="gridFailureDetailsSandbox.setState(StateEnum.CANCELED)">
+ {{ 'StornoBtn' | translate }}
+ </button>
+ </ng-template>
+ </ng-container>
+ </ng-container>
+ </div>
</div>
</div>
</form>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.scss b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.scss
index 79a3544..3009ff6 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.scss
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.scss
@@ -42,9 +42,12 @@
padding-left: 16px;
width: 247px;
}
-.div-button {
+.left-button {
margin-left: 15px;
}
+.right-button {
+ margin-right: 15px;
+}
.editable {
background-color: white;
}
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
index 8810b12..7ea4328 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.ts
@@ -1,4 +1,3 @@
-import { OnDestroy } from '@angular/core';
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
@@ -13,11 +12,12 @@
********************************************************************************/
import { Component, OnInit } from '@angular/core';
import { GridFailureDetailsSandbox } from '@grid-failure-information-app/pages/grid-failure/grid-failure-details/grid-failure-details.sandbox';
-import { Observable } from 'rxjs';
+import { RolesEnum, StateEnum } from '@grid-failure-information-app/shared/constants/enums';
+import { Globals } from '@grid-failure-information-app/shared/constants/globals';
import { GridFailure } from '@grid-failure-information-app/shared/models/grid-failure.model';
import * as store from '@grid-failure-information-app/shared/store';
import { Store } from '@ngrx/store';
-import { Globals } from '@grid-failure-information-app/shared/constants/globals';
+import { Observable } from 'rxjs';
@Component({
selector: 'app-grid-failure-details',
@@ -26,8 +26,9 @@
})
export class GridFailureDetailsComponent implements OnInit {
public Globals = Globals;
+ public RolesEnum = RolesEnum;
+ public StateEnum = StateEnum;
public gridFailureVersions$: Observable<GridFailure[]> = this.appState$.select(store.getGridFailureVersionsData);
-
constructor(public gridFailureDetailsSandbox: GridFailureDetailsSandbox, protected appState$: Store<store.State>) {}
ngOnInit() {
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 193939f..545dc1f 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
@@ -19,6 +19,7 @@
import { ActionsSubject, Store } from '@ngrx/store';
import { of } from 'rxjs';
import { Router } from '@angular/router';
+import { StateEnum } from '@grid-failure-information-app/shared/constants/enums';
describe('GridFailureDetailsSandbox', () => {
let service: GridFailureDetailsSandbox;
@@ -194,7 +195,64 @@
gridFailure.versionNumber = 3;
const gridFailureVersions: GridFailure[] = [gridFailure];
spyOn(actionSubject, 'pipe').and.returnValue(of({ payload: gridFailureVersions }));
+ const spy = spyOn(service as any, '_showButtonsByState');
+
service.registerEvents();
expect(service.currentFormState).toBeDefined();
+ expect(spy).toHaveBeenCalled();
+ });
+
+ it('should show qualify button state is applied', () => {
+ const state = StateEnum.CREATED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showQualifyButton).toBeTruthy();
+ });
+
+ it('should show qualify button state is updated', () => {
+ const state = StateEnum.UPDATED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showQualifyButton).toBeTruthy();
+ });
+
+ it('should show qualify button state is scheduled', () => {
+ const state = StateEnum.PLANNED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showQualifyButton).toBeTruthy();
+ });
+
+ it('should show storno button state is applied', () => {
+ const state = StateEnum.CREATED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showStornoButton).toBeTruthy();
+ });
+
+ it('should show storno button state is updated', () => {
+ const state = StateEnum.UPDATED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showStornoButton).toBeTruthy();
+ });
+
+ it('should show storno button state is scheduled', () => {
+ const state = StateEnum.PLANNED;
+ (service as any)._showButtonsByState(state);
+ expect(service.showStornoButton).toBeTruthy();
+ });
+
+ it('should set the state in form to qualify and call save fuction', () => {
+ service.gridFailureInternalStates$ = { pipe: () => of({}), map: () => of({}) } as any;
+ spyOn(service.gridFailureInternalStates$, 'pipe').and.returnValue(of([{ status: StateEnum.QUALIFIED, id: '123' }]));
+ const spySave = spyOn(service, 'saveGridFailure');
+ service.setState(StateEnum.QUALIFIED);
+ expect(spySave).toHaveBeenCalled();
+ expect(dispatchSpy).toHaveBeenCalled();
+ });
+
+ it('should set the state in form to canceled and call save fuction', () => {
+ service.gridFailureInternalStates$ = { pipe: () => of({}), map: () => of({}) } as any;
+ spyOn(service.gridFailureInternalStates$, 'pipe').and.returnValue(of([{ status: StateEnum.CANCELED, id: '123' }]));
+ const spySave = spyOn(service, 'saveGridFailure');
+ service.setState(StateEnum.CANCELED);
+ expect(spySave).toHaveBeenCalled();
+ expect(dispatchSpy).toHaveBeenCalled();
});
});
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 93b1edb..aedcb9c 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
@@ -43,9 +43,13 @@
import { DisableAction, EnableAction, FormGroupState, NgrxValueConverter, ResetAction, SetValueAction } from 'ngrx-forms';
import { Observable } from 'rxjs';
import { take, takeUntil, map } from 'rxjs/operators';
+import { Globals } from '@grid-failure-information-app/shared/constants/globals';
+import { StateEnum } from '@grid-failure-information-app/shared/constants/enums';
@Injectable()
export class GridFailureDetailsSandbox extends BaseFormSandbox<GridFailure> {
+ public Globals = Globals;
+ public StateEnum = StateEnum;
public gridFailureDetailsFormState$: Observable<FormGroupState<GridFailure>> = this.appState$.select(store.getGridFailuresDetails);
public currentFormState: FormGroupState<GridFailure>;
public gridFailureClassifications$: Observable<FailureClassification[]> = this.appState$.select(store.getGridFailureClassificationsData);
@@ -66,8 +70,12 @@
public internExternEnum = InternExternEnum;
public saveEnabled: boolean = true;
public maxVersionNumber: number;
+ public showQualifyButton: boolean = false;
+ public showStornoButton: boolean = false;
private _gridFailureId: string;
+ private _qualifyState: FailureState;
+ private _cancelState: FailureState;
constructor(
protected appState$: Store<store.State>,
@@ -125,6 +133,20 @@
}
}
+ public setState(newState: string): void {
+ this.gridFailureInternalStates$
+ .pipe(
+ map(states => states.filter(item => item.status === newState)),
+ takeUntil(this._endSubscriptions$)
+ )
+ .subscribe(states => {
+ if (states && states.length > 0) {
+ this.appState$.dispatch(new SetValueAction(gridFailuresDetailFormReducer.INITIAL_STATE.controls.statusInternId.id, states[0].id));
+ this.saveGridFailure();
+ }
+ });
+ }
+
public clearGridFailureData(actionType: string): void {
switch (actionType) {
case this.datePickerResetEnum.FailureBegin:
@@ -191,9 +213,10 @@
}
public registerEvents(): void {
- this.gridFailureDetailsFormState$
- .pipe(takeUntil(this._endSubscriptions$))
- .subscribe((formState: FormGroupState<GridFailure>) => (this.currentFormState = formState));
+ this.gridFailureDetailsFormState$.pipe(takeUntil(this._endSubscriptions$)).subscribe((formState: FormGroupState<GridFailure>) => {
+ this.currentFormState = formState;
+ this._showButtonsByState(formState.value.statusIntern);
+ });
this._actionsSubject
.pipe(ofType(gridFailureActions.loadGridFailureVersionsSuccess), takeUntil(this._endSubscriptions$))
.map(action => action['payload'])
@@ -210,4 +233,19 @@
this.saveEnabled = true;
navigateHome(this._router);
}
+
+ private _showButtonsByState(state: string): void {
+ switch (state) {
+ case StateEnum.CREATED:
+ case StateEnum.UPDATED:
+ case StateEnum.PLANNED:
+ this.showQualifyButton = true;
+ this.showStornoButton = true;
+ break;
+ default:
+ this.showQualifyButton = false;
+ this.showStornoButton = false;
+ break;
+ }
+ }
}
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.module.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.module.ts
index ba584f9..045af88 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.module.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure.module.ts
@@ -26,7 +26,7 @@
import { NgrxFormsModule } from 'ngrx-forms';
import { FormsModule } from '@angular/forms';
import { AgGridModule } from 'ag-grid-angular';
-import { DirectivesModule } from '@grid-failure-information-app/shared/directives';
+import { DirectivesModule } from '@grid-failure-information-app/shared/directives/directives.module';
import { FiltersModule } from '@grid-failure-information-app/shared/filters/filters.module';
import { ContainersModule } from '@grid-failure-information-app/shared/containers/containers.module';
import { SetFilterComponent } from '@grid-failure-information-app/shared/filters/ag-grid/set-filter/set-filter.component';
diff --git a/projects/grid-failure-information-app/src/app/pages/imported-grid-failure/imported-grid-failure.module.ts b/projects/grid-failure-information-app/src/app/pages/imported-grid-failure/imported-grid-failure.module.ts
index cb66ea1..522b139 100644
--- a/projects/grid-failure-information-app/src/app/pages/imported-grid-failure/imported-grid-failure.module.ts
+++ b/projects/grid-failure-information-app/src/app/pages/imported-grid-failure/imported-grid-failure.module.ts
@@ -16,7 +16,7 @@
import { ComponentsModule } from '@grid-failure-information-app/shared/components/components.module';
import { TranslateModule } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
-import { DirectivesModule } from '@grid-failure-information-app/shared/directives';
+import { DirectivesModule } from '@grid-failure-information-app/shared/directives/directives.module';
import { ContainersModule } from '@grid-failure-information-app/shared/containers/containers.module';
import { ImportedGridFailureListComponent } from '@grid-failure-information-app/app/pages/imported-grid-failure/imported-grid-failure-list/imported-grid-failure-list.component';
import { ImportedGridFailureListSandbox } from '@grid-failure-information-app/app/pages/imported-grid-failure/imported-grid-failure-list/imported-grid-failure-list.sandbox';
diff --git a/projects/grid-failure-information-app/src/app/pages/logout/logout.module.ts b/projects/grid-failure-information-app/src/app/pages/logout/logout.module.ts
index 615669d..5f96612 100644
--- a/projects/grid-failure-information-app/src/app/pages/logout/logout.module.ts
+++ b/projects/grid-failure-information-app/src/app/pages/logout/logout.module.ts
@@ -16,7 +16,7 @@
import { ComponentsModule } from '@grid-failure-information-app/shared/components/components.module';
import { TranslateModule } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
-import { DirectivesModule } from '@grid-failure-information-app/shared/directives';
+import { DirectivesModule } from '@grid-failure-information-app/shared/directives/directives.module';
import { ContainersModule } from '@grid-failure-information-app/shared/containers/containers.module';
import { LogoutPageSandbox } from '@grid-failure-information-app/pages/logout/logout/logout.sandbox';
import { LogoutPageComponent } from '@grid-failure-information-app/pages/logout/logout/logout.component';
diff --git a/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorator.ts b/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorator.ts
index a6afe78..31b9822 100644
--- a/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorator.ts
+++ b/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorator.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,8 +11,8 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { RequestMethod } from '@angular/http';
-import { HttpService, MediaType } from './http.service';
-import { methodBuilder, paramBuilder } from './utils.service';
+import { HttpService, MediaType } from '@grid-failure-information-app/shared/async-services/http/http.service';
+import { methodBuilder, paramBuilder } from '@grid-failure-information-app/shared/async-services/http/utils.service';
/* *********************************************
* Class decorators
diff --git a/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorators.spec.ts b/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorators.spec.ts
new file mode 100644
index 0000000..1c54343
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/async-services/http/http.decorators.spec.ts
@@ -0,0 +1,101 @@
+/********************************************************************************
+ * 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 decorators from '@grid-failure-information-app/shared/async-services/http/http.decorator';
+import { MediaType } from '@grid-failure-information-app/shared/async-services/http/http.service';
+
+describe('Http Decorators', () => {
+ it('should return the given url in target if call BaseUrl decorator', () => {
+ const url = '/test';
+ const targetFunction: any = {
+ prototype: {
+ getBaseUrl() {
+ url;
+ },
+ },
+ };
+ const methodObject = decorators.BaseUrl(url)(targetFunction);
+ expect(methodObject).toBe(targetFunction);
+ expect(methodObject.prototype.getBaseUrl()).toBe(url);
+ });
+
+ it('should return the given url in target if call DefaultHeaders decorator', () => {
+ const headers: any = { test: 'test', property: 'property' };
+ const targetFunction: any = {
+ prototype: {
+ getDefaultHeaders() {
+ headers;
+ },
+ },
+ };
+ const methodObject = decorators.DefaultHeaders(headers)(targetFunction);
+ expect(methodObject).toBe(targetFunction);
+ expect(methodObject.prototype.getDefaultHeaders()).toBe(headers);
+ });
+
+ it('should build the descriptor headers as the headersDef if calling Headers decorator', () => {
+ const headersDef: any = { test: 'test', property: 'property' };
+ const target: any = {};
+ const propertyKey = 'key';
+ const descriptor: any = { headers: undefined };
+
+ const methodObject = decorators.Headers(headersDef)(target, propertyKey, descriptor);
+ expect(methodObject).toBe(descriptor);
+ expect(methodObject.headers).toBe(headersDef);
+ });
+
+ it('should build the descriptor and assign the JSON flag if calling Produces decorator with a JSON media type', () => {
+ const producesDef: any = MediaType.JSON;
+ const target: any = {};
+ const propertyKey = 'key';
+ const descriptor: any = { isJSON: false, isFormData: false };
+
+ const methodObject = decorators.Produces(producesDef)(target, propertyKey, descriptor);
+ expect(methodObject).toBe(descriptor);
+ expect(methodObject.isJSON).toBeTruthy();
+ expect(methodObject.isFormData).toBeFalsy();
+ });
+
+ it('should build the descriptor and assign the FORM_DATA flag if calling Produces decorator with a FORM_DATA media type', () => {
+ const producesDef: any = MediaType.FORM_DATA;
+ const target: any = {};
+ const propertyKey = 'key';
+ const descriptor: any = { isJSON: false, isFormData: false };
+
+ const methodObject = decorators.Produces(producesDef)(target, propertyKey, descriptor);
+ expect(methodObject).toBe(descriptor);
+ expect(methodObject.isJSON).toBeFalsy();
+ expect(methodObject.isFormData).toBeTruthy();
+ });
+
+ it('should build the descriptor and assign him the given adapter if calling Adapter decorator', () => {
+ const adapterFn: Function = new Function();
+ const target: any = {};
+ const propertyKey = 'key';
+ const descriptor: any = { adapter: undefined };
+
+ const methodObject = decorators.Adapter(adapterFn)(target, propertyKey, descriptor);
+ expect(methodObject).toBe(descriptor);
+ expect(methodObject.adapter).toBe(adapterFn);
+ });
+
+ it('should build the descriptor and assign him null if calling Adapter decorator without a function', () => {
+ const adapterFn: any = undefined;
+ const target: any = {};
+ const propertyKey = 'key';
+ const descriptor: any = { adapter: undefined };
+
+ const methodObject = decorators.Adapter(adapterFn)(target, propertyKey, descriptor);
+ expect(methodObject).toBe(descriptor);
+ expect(methodObject.adapter).toBe(null);
+ });
+});
diff --git a/projects/grid-failure-information-app/src/app/shared/async-services/http/utils.service.spec.ts b/projects/grid-failure-information-app/src/app/shared/async-services/http/utils.service.spec.ts
index 22c66c1..f180e1a 100644
--- a/projects/grid-failure-information-app/src/app/shared/async-services/http/utils.service.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/async-services/http/utils.service.spec.ts
@@ -22,10 +22,13 @@
test_property_Header_parameters: 'test_header',
};
- const descriptor = { value: function({}) {}, adapter: {} };
+ const descriptor = { value: () => {}, adapter: {} };
+
// 0->GET
const methodObject = utils.methodBuilder(0)('/testurl')(target, propertyKey, descriptor);
+
expect(methodObject).toBe(descriptor);
+ expect(typeof methodObject.value === 'function').toBe(true);
});
it('should call paramBuilder and return a descriptor', () => {
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/date-cell-renderer/date-cell-renderer.component.spec.ts b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/date-cell-renderer/date-cell-renderer.component.spec.ts
index 666a261..b7f5db1 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/date-cell-renderer/date-cell-renderer.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/date-cell-renderer/date-cell-renderer.component.spec.ts
@@ -40,9 +40,22 @@
expect(component.date).toEqual('test');
});
+ it('agInit sets date to value property of its parameter and sets isDate true if its a parsable number', () => {
+ component.agInit({ value: '5' });
+ expect(component.date).toEqual('5');
+ expect(component.isDate).toBeTruthy();
+ });
+
it('refresh sets date to value property of its parameter', () => {
const returnValue = component.refresh({ value: 'test' });
expect(component.date).toEqual('test');
expect(returnValue).toBe(true);
});
+
+ it('refresh sets date to value property of its parameter and sets isDate true if its a parsable number', () => {
+ const returnValue = component.refresh({ value: '5' });
+ expect(component.date).toEqual('5');
+ expect(returnValue).toBe(true);
+ expect(component.isDate).toBeTruthy();
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.html b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.html
index 422c3bd..6201489 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.html
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.html
@@ -11,25 +11,18 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<ng-template visibleByRight [elseTemplate]="readonlyRightsTemplate">
- <button *ngIf="editIcon" (click)="clicked('edit')" class="tool-icon">
- <fa name="edit"></fa>
- </button>
- <button *ngIf="readonlyIcon" (click)="clicked('readonly')" class="tool-icon">
- <fa name="eye"></fa>
- </button>
- <button *ngIf="deleteIcon" (click)="clicked('delete')" class="tool-icon">
- <fa name="trash"></fa>
- </button>
- <button *ngIf="addIcon" (click)="clicked('add')" class="tool-icon">
+<button *ngIf="editIcon" (click)="clicked('edit')" class="tool-icon">
+ <fa name="edit"></fa>
+</button>
+<button *ngIf="readonlyIcon" (click)="clicked('readonly')" class="tool-icon">
+ <fa name="eye"></fa>
+</button>
+<button *ngIf="deleteIcon" (click)="clicked('delete')" class="tool-icon">
+ <fa name="trash"></fa>
+</button>
+<button *ngIf="addIcon" (click)="clicked('add')" class="tool-icon">
<fa name="plus"></fa>
</button>
<button *ngIf="removeIcon" (click)="clicked('remove')" class="tool-icon">
<fa name="minus"></fa>
- </button>
-</ng-template>
-<ng-template #readonlyRightsTemplate>
- <button (click)="clicked('readonly')" class="tool-icon">
- <fa name="eye"></fa>
- </button>
-</ng-template>
+ </button>
\ No newline at end of file
diff --git a/projects/grid-failure-information-app/src/app/shared/components/components.module.ts b/projects/grid-failure-information-app/src/app/shared/components/components.module.ts
index 471826c..dec8c68 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/components.module.ts
+++ b/projects/grid-failure-information-app/src/app/shared/components/components.module.ts
@@ -27,7 +27,7 @@
import { PaginationComponent } from '@grid-failure-information-app/shared/components/pagination/pagination.component';
import { SpinnerComponent } from '@grid-failure-information-app/shared/components/spinner/spinner.component';
import { VersionInfo } from '@grid-failure-information-app/shared/components/version-info/version-info.component';
-import { DirectivesModule } from '@grid-failure-information-app/shared/directives/index';
+import { DirectivesModule } from '@grid-failure-information-app/shared/directives/directives.module';
import { PipesModule } from '@grid-failure-information-app/shared/pipes/pipes.module';
import { NgbDatepickerModule, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
diff --git a/projects/grid-failure-information-app/src/app/shared/components/pagination/pagination.component.spec.ts b/projects/grid-failure-information-app/src/app/shared/components/pagination/pagination.component.spec.ts
index ad7daae..d0f89aa 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/pagination/pagination.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/components/pagination/pagination.component.spec.ts
@@ -73,9 +73,6 @@
xit('check if setLastPage works', () => {
component.totalPages = 10;
component.setLastPage();
- // console.log(component.currentPageIndex);
- // console.log(component.pageEventItems[0]);
- // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
expect(component.currentPageIndex).toBe(5);
});
@@ -103,7 +100,6 @@
component.totalPages = 6;
component.setNextPage();
let isLastPageLastIcon = component.isLastPageLastIcon();
- // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
expect(isLastPageLastIcon).toBeFalsy();
});
});
diff --git a/projects/grid-failure-information-app/src/app/shared/constants/enums.ts b/projects/grid-failure-information-app/src/app/shared/constants/enums.ts
index 351d988..df913e0 100644
--- a/projects/grid-failure-information-app/src/app/shared/constants/enums.ts
+++ b/projects/grid-failure-information-app/src/app/shared/constants/enums.ts
@@ -33,6 +33,23 @@
I = 'Intern',
E = 'Extern',
}
+
+export enum RolesEnum {
+ ADMIN = 'grid-failure-admin',
+ CREATOR = 'grid-failure-creator',
+ PUBLISHER = 'grid-failure-publisher',
+ QUALIFIER = 'grid-failure-qualifier',
+}
+
+export enum StateEnum {
+ NEW = 'neu',
+ PLANNED = 'geplant',
+ CREATED = 'angelegt',
+ CANCELED = 'storniert',
+ QUALIFIED = 'qualifiziert',
+ UPDATED = 'aktualisiert',
+ COMPLETED = 'abgeschlossen',
+}
export enum ModeEnum {
InitialMode = 'initialMode',
OverviewTableSelectionMode = 'overviewTableSelectionMode',
diff --git a/projects/grid-failure-information-app/src/app/shared/constants/regex.constants.ts b/projects/grid-failure-information-app/src/app/shared/constants/regex.constants.ts
new file mode 100644
index 0000000..5fe8b1e
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/constants/regex.constants.ts
@@ -0,0 +1,183 @@
+/********************************************************************************
+ * 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
+ ********************************************************************************/
+
+/**
+ * Regular expression to use for validating digits only fields
+ */
+export const DIGITS_REGEXP: RegExp = /^[0-9]+$/;
+
+/**
+ * Regular expression to use for validating phone number fields
+ */
+export const PHONE_NUMBER_REGEXP: RegExp = /^[0-9\+\-/ ]+$/;
+
+/**
+ * Regular expression to use for validating personal name fields
+ */
+export const PERSONAL_NAME_REGEXP: RegExp = /^[a-zA-Z\s\-`äöüÄÖÜß]+$/;
+
+/**
+ * Regular expression to use for validating academic title fields
+ */
+export const ACAD_TITLE_REGEXP: RegExp = /[^0-9]+$/;
+
+/**
+ * Regular expression to use for validating po box fields
+ */
+export const PO_BOX_REGEXP: RegExp = /^[0-9a-zA-ZäöüÄÖÜß]+$/;
+
+/**
+ * Regular expression to use for validating location, city, street name fields
+ */
+export const LOCATION_NAME_REGEXP: RegExp = /^[0-9a-zA-ZäöüÄÖÜß\-.\/ ]+$/;
+
+/**
+ * Regular expression to use for validating street numbers.
+ * Allowed chars are 0-9, a-z, A-Z, äöüÄÖÜ.
+ */
+export const STREET_NUMBER_REGEXP: RegExp = /^[0-9a-zA-ZäöüÄÖÜß\-\/ ]+$/;
+
+/**
+ * Regular expression to use for validating zip code fields
+ */
+export const ZIP_CODE_REGEXP: RegExp = /^[0-9a-zA-zäöüÄÖÜß\-/^°!"§$%&()=?`\{\[\]\}´`+*~#',.;:_@€µ<>| ]+$/;
+
+/**
+ * Regular expression to validate a number string to contain only comma (where normally a dot is) with max 2 decimals.
+ */
+export const NUMBER_WITH_COMMA_TWO_DECIMALS: RegExp = /^\d+[,]?\d{0,2}$/;
+
+/**
+ * Regular expression to validate a number string to contain only comma (where normally a dot is) with decimals without limit.
+ */
+export const NUMBER_WITH_COMMA_X_DECIMALS: RegExp = /^\d+[,]?\d*$/;
+
+/**
+ * Regular expression to validate a number which constists only of integer numbers 0-9.
+ * No fraction digits or decimal separators allowed.
+ */
+export const INTEGER_REGEX: RegExp = /^[0-9]*$/;
+
+/*
+ * Regular expression for email addresses.
+ * Allowed characters for the local part are only letters, numbers and following special characters: ".", "-", "_".
+ * Allowed characters for the domain part are only letters, numbers and following special characters: ".", "-".
+ */
+export const EMAIL_REGEXP: RegExp = /^(([a-zA-ZäöüÄÖÜ0-9\-_\.])+)@(([a-zA-ZäöüÄÖÜ0-9\-]+\.)+[a-zA-Z]{2,})$/;
+
+/**
+ * Regular expression to use for numbers with max 2 decimal places while comma is allowed.
+ */
+export const COMMA_SEPARATED_NUMBER_WITH_TWO_DECIMAL_REGEXP: RegExp = /^((0|([1-9]\d*))([\,]\d{1,2})?)$/;
+
+/**
+ * Regular expression to use for insurant number with a capital letter and 9 digits.
+ */
+export const INSURANT_NUMBER_REGEXP: RegExp = /^[A-Z][0-9]{9}$/;
+
+/**
+ * Numbers with max. 2 decimal places while comma and negative values are allowed.
+ */
+export const NEGATIVE_AND_COMMA_SEPARATED_NUMBER_WITH_TWO_DECIMAL_REGEXP: RegExp = /^-?((0|([1-9]\d*))([\,]\d{1,2})?)$/;
+
+/**
+ * Numbers with max. 2 decimal places while comma and negative values are allowed.
+ */
+export const MULTI_LINE_TEXT: RegExp = /^[\w.\-,:_';`äöüÄÖÜß+?€!#*\n\s]+$/;
+
+/**
+ * Regular expression to use for numbers != 0.00 with max 2 comma seperated decimal places (negative numbers allowed)
+ */
+export const COMMA_SEPARATED_NUMBER_WITH_TWO_DECIMAL_REGEXP_NOT_ZERO: RegExp = /^[-]?(?=.*[1-9])\d*(?:\,\d{1,2})?\s*$/;
+
+/**
+ * Regular expression to use for validating barcodes
+ */
+export const BARCODE_REGEXP: RegExp = /^[0-9\+\-/ ]+$/;
+
+/**
+ * Regular expression to validate a number string to contain only comma
+ */
+export const COMMA_SEPARATED_NUMBER: RegExp = /^-?\d+,?\d*$/;
+
+/**
+ * Regular expression to validate a positive decimal number string to contain only comma and up to 2 decimal places
+ */
+export const COMMA_SEPARATED_POSITIVE_NUMBER_WITH_TWO_DECIMAL_REGEXP: RegExp = /^\d+,?\d{0,2}$/;
+
+/**
+ * Regular expression to use for numbers with max 2 decimal places while dot is allowed.
+ */
+export const DOT_SEPARATED_POSITIVE_NUMBER_WITH_TWO_DECIMAL_REGEXP: RegExp = /^\d+\.?\d{0,2}$/;
+
+/**
+ * Regular expression to validate against numbers and dots.
+ */
+export const NUMBERS_AND_DOTS: RegExp = /^[0-9.]+$/;
+
+/**
+ * Regular expression to validate against numbers and letters.
+ */
+export const LETTERS_AND_NUMBERS: RegExp = /^[0-9a-zA-Z]+$/;
+
+/**
+ * Regular expression to use for validating the LEGS field
+ */
+export const LETTERS_AND_NUMBERS_AND_UMLAUTS: RegExp = /^[0-9a-zA-ZäöüÄÖÜß]+$/;
+
+/**
+ * Regular expression to validate against digits, plus, minus, slash, space and dot.
+ */
+export const DIGITS_PLUS_MINUS_SLASH_SPACE_DOT: RegExp = /^[0-9\+\-/ \.]+$/;
+
+/**
+ * Regular expression to ckeck password guidelines.
+ * - must contain at least one digit
+ * - must contain at least one lower ca
+ * - must contain at least one upper case
+ * - must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict
+ * - must contain at least 8 from the mentioned characters
+ */
+export const PASSWORD_CHECK_REGEXP: RegExp = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/;
+
+/**
+ * Regular expression to match only digits and special characters (exclude all letters).
+ * Allowed symbols are described with intervals based on the ASCII Table.
+ */
+export const DIGITS_AND_SPECIAL_CHARACTERS: RegExp = /^[!-@[-`{-~]+$/;
+
+/**
+ * Regular expression to match a positive number string with dot decimal separator and unlimited digits after the sign
+ */
+export const POSITIVE_DOT_SEPARATED_NUMBER: RegExp = /^\d+.?\d*$/;
+
+/**
+ * Regular expression to match a tax identifaction number
+ * as being used in germany.
+ */
+export const TAX_IDENTIFACTION_NUMBER: RegExp = /^[a-zA-Z]{2}[0-9]{9}$/;
+
+/**
+ * Regular expression to match a positive number string with dot or comma decimal separator and unlimited digits after the sign.
+ */
+export const POSITIVE_DOT_OR_COMMA_SEPARATED_NUMBER: RegExp = /^\d+[,|\.]?\d*$/;
+
+/**
+ * Regular expression to match a positive number string with dot or comma decimal separator.
+ */
+export const POSITIVE_WITH_ONLY_ONE_DOT_OR_COMMA_SEPARATED_NUMBER: RegExp = /^[+]?\d+([,|\.]\d+)?$/;
+
+/**
+ * Regular expression to match a UUID version 4.
+ */
+export const UUID_V4: RegExp = /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/;
diff --git a/projects/grid-failure-information-app/src/app/shared/directives/index.ts b/projects/grid-failure-information-app/src/app/shared/directives/directives.module.ts
similarity index 83%
rename from projects/grid-failure-information-app/src/app/shared/directives/index.ts
rename to projects/grid-failure-information-app/src/app/shared/directives/directives.module.ts
index 34aebdd..d47a8a9 100644
--- a/projects/grid-failure-information-app/src/app/shared/directives/index.ts
+++ b/projects/grid-failure-information-app/src/app/shared/directives/directives.module.ts
@@ -10,18 +10,18 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { AgGridAngular } from 'ag-grid-angular';
-import { AutoResizeColumnsDirective } from '@grid-failure-information-app/shared/directives/agGrid/auto-resize-columns.directive';
-import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
-import { TranslateColumnDefinitionsDirective } from '@grid-failure-information-app/shared/directives/agGrid/translate-column-definitions.directive';
+import { NgModule } from '@angular/core';
+import { AutoResizeColumnsDirective } from '@grid-failure-information-app/shared/directives/agGrid/auto-resize-columns.directive';
import { ServerSideDirective } from '@grid-failure-information-app/shared/directives/agGrid/server-side.directive';
-import { FormDisableDirective } from '@grid-failure-information-app/shared/directives/form-disable.directive';
+import { TranslateColumnDefinitionsDirective } from '@grid-failure-information-app/shared/directives/agGrid/translate-column-definitions.directive';
import { VisibleByRightDirective } from '@grid-failure-information-app/shared/directives/visible-by-right';
+import { AgGridAngular } from 'ag-grid-angular';
+
@NgModule({
imports: [CommonModule],
- declarations: [AutoResizeColumnsDirective, TranslateColumnDefinitionsDirective, ServerSideDirective, FormDisableDirective, VisibleByRightDirective],
- exports: [AutoResizeColumnsDirective, TranslateColumnDefinitionsDirective, ServerSideDirective, FormDisableDirective, VisibleByRightDirective],
+ declarations: [AutoResizeColumnsDirective, TranslateColumnDefinitionsDirective, ServerSideDirective, VisibleByRightDirective],
+ exports: [AutoResizeColumnsDirective, TranslateColumnDefinitionsDirective, ServerSideDirective, VisibleByRightDirective],
entryComponents: [AgGridAngular],
})
diff --git a/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.spec.ts b/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.spec.ts
deleted file mode 100644
index dc3e959..0000000
--- a/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.spec.ts
+++ /dev/null
@@ -1,52 +0,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 { FormDisableDirective } from '@grid-failure-information-app/shared/directives/form-disable.directive';
-import { async } from '@angular/core/testing';
-import { of } from 'rxjs/observable/of';
-
-describe('FormDisableDirective', () => {
- let viewContainerRef: any;
- let appState: any;
- beforeEach(async(() => {
- viewContainerRef = {
- createEmbeddedView: () => {},
- clear: () => {},
- element: { nativeElement: { elements: [{ classList: {}, disabled: false, childNodes: [] }] } },
- };
-
- appState = {
- pipe: () => of(),
- dispatch: () => {},
- select: () => of({ roles: ['kon-reader'] }),
- map: () => of({ reader: true }),
- };
- }));
-
- it('should create an instance', () => {
- const directive = new FormDisableDirective(viewContainerRef as any, appState as any);
- expect(directive).toBeTruthy();
- });
-
- it('should traverse a DOM', () => {
- const directive = new FormDisableDirective(viewContainerRef as any, appState as any);
- const spy = spyOn(directive, '_traverseDOM' as any);
- directive.ngAfterViewInit();
- expect(spy).toHaveBeenCalled();
- });
-
- it('should disable form element', () => {
- const directive = new FormDisableDirective(viewContainerRef as any, appState as any);
- directive.ngAfterViewInit();
- expect(viewContainerRef.element.nativeElement.elements[0].disabled).toBe(true);
- });
-});
diff --git a/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.ts b/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.ts
deleted file mode 100644
index dea8fd0..0000000
--- a/projects/grid-failure-information-app/src/app/shared/directives/form-disable.directive.ts
+++ /dev/null
@@ -1,53 +0,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 { Directive, ViewContainerRef, AfterViewInit, OnDestroy } from '@angular/core';
-import { Store } from '@ngrx/store';
-import * as store from '@grid-failure-information-app/shared/store';
-import { Observable, Subject } from 'rxjs';
-import { User } from '@grid-failure-information-app/shared/models/user';
-import { PermissionsModel } from '@grid-failure-information-app/shared/models/permissions.model';
-import { takeUntil } from 'rxjs/operators';
-
-@Directive({
- selector: 'form',
-})
-export class FormDisableDirective implements AfterViewInit, OnDestroy {
- private _endSubscriptions$: Subject<boolean> = new Subject();
- private _permissions$: Observable<PermissionsModel> = this._appState$
- .select(store.getUser)
- .pipe(takeUntil(this._endSubscriptions$))
- .map((user: User) => {
- return new PermissionsModel(user.roles);
- });
-
- constructor(private _viewContainer: ViewContainerRef, private _appState$: Store<store.State>) {}
-
- ngAfterViewInit() {
- this._permissions$.subscribe(permissions => {
- this._traverseDOM(this._viewContainer.element.nativeElement.elements, permissions);
- });
- }
- ngOnDestroy() {
- this._endSubscriptions$.next(true);
- }
- private _traverseDOM(elements: any[], permissions: PermissionsModel): void {
- for (const element of elements) {
- const isCancelButton = !!Object.keys(element.classList || {}).find(
- item => element.classList[item] === 'cancel-button' || element.classList[item] === 'btn-sm'
- );
- element.disabled = element.disabled || (!isCancelButton && permissions.reader);
-
- this._traverseDOM(element.childNodes, permissions);
- }
- }
-}
diff --git a/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.spec.ts b/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.spec.ts
index 049e894..92c0c0c 100644
--- a/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.spec.ts
@@ -10,8 +10,9 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { VisibleByRightDirective } from '@grid-failure-information-app/shared/directives/visible-by-right';
import { async } from '@angular/core/testing';
+import { RolesEnum } from '@grid-failure-information-app/shared/constants/enums';
+import { VisibleByRightDirective } from '@grid-failure-information-app/shared/directives/visible-by-right';
import { of } from 'rxjs/observable/of';
describe('VisibleByRightDirective', () => {
@@ -28,8 +29,8 @@
appState = {
pipe: () => of(),
dispatch: () => {},
- select: () => of({ roles: ['kon-reader'] }),
- map: () => of({ reader: true }),
+ select: () => of({ roles: [RolesEnum.CREATOR] }),
+ map: () => of({ creator: true, publisher: false, admin: false, qualifier: false }),
};
}));
@@ -42,8 +43,8 @@
appState = {
pipe: () => of(),
dispatch: () => {},
- select: () => of({ roles: ['kon-admin'] }),
- map: () => of({ reader: true }),
+ select: () => of({ roles: [RolesEnum.ADMIN] }),
+ map: () => of({ creator: false, publisher: false, admin: true, qualifier: false }),
};
const directive = new VisibleByRightDirective(templateRef as any, viewContainerRef as any, appState as any);
@@ -52,26 +53,26 @@
expect(spy).toHaveBeenCalled();
});
- it('should create embedded view for other role than admin with an substitutional template', () => {
+ it('should create embedded view for role qualifier', () => {
appState = {
pipe: () => of(),
dispatch: () => {},
- select: () => of({ roles: ['kon-reader'] }),
- map: () => of({ reader: true }),
+ select: () => of({ roles: [RolesEnum.QUALIFIER] }),
+ map: () => of({ creator: false, publisher: false, admin: false, qualifier: true }),
};
const directive = new VisibleByRightDirective(templateRef as any, viewContainerRef as any, appState as any);
+ directive.acceptedRole = RolesEnum.QUALIFIER;
const spy = spyOn(directive['_viewContainer'], 'createEmbeddedView' as any);
- directive.elseTemplate = {} as any;
directive.ngOnInit();
expect(spy).toHaveBeenCalled();
});
- it('should create embedded view for other role than admin with an substitutional template', () => {
+ it('should clear view for another role than admin or qualifier', () => {
appState = {
pipe: () => of(),
dispatch: () => {},
- select: () => of({ roles: ['kon-reader'] }),
- map: () => of({ reader: true }),
+ select: () => of({ roles: [RolesEnum.PUBLISHER] }),
+ map: () => of({ creator: false, publisher: true, admin: false, qualifier: false }),
};
const directive = new VisibleByRightDirective(templateRef as any, viewContainerRef as any, appState as any);
const spy = spyOn(directive['_viewContainer'], 'clear' as any);
diff --git a/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.ts b/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.ts
index c7d67cf..8a09049 100644
--- a/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.ts
+++ b/projects/grid-failure-information-app/src/app/shared/directives/visible-by-right.ts
@@ -10,20 +10,20 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { Directive, ViewContainerRef, OnInit, TemplateRef, Input, OnDestroy } from '@angular/core';
-import { Store } from '@ngrx/store';
-import * as store from '@grid-failure-information-app/shared/store';
-import { Observable, Subject } from 'rxjs';
-import { User } from '@grid-failure-information-app/shared/models/user';
+import { Directive, Input, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
+import { RolesEnum } from '@grid-failure-information-app/shared/constants/enums';
import { PermissionsModel } from '@grid-failure-information-app/shared/models/permissions.model';
+import { User } from '@grid-failure-information-app/shared/models/user';
+import * as store from '@grid-failure-information-app/shared/store';
+import { Store } from '@ngrx/store';
+import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Directive({
selector: '[visibleByRight]',
})
export class VisibleByRightDirective implements OnInit, OnDestroy {
- @Input() elseTemplate: TemplateRef<any>;
- @Input() onlyForAdmin: boolean = false;
+ @Input() acceptedRole?: string = '';
private _endSubscriptions$: Subject<boolean> = new Subject();
private _permissions$: Observable<PermissionsModel> = this._appState$
.select(store.getUser)
@@ -34,10 +34,8 @@
ngOnInit() {
this._permissions$.subscribe(permissions => {
- if (permissions.admin || (!this.onlyForAdmin && permissions.writer)) {
+ if (permissions.admin || (permissions.qualifier && this.acceptedRole === RolesEnum.QUALIFIER)) {
this._viewContainer.createEmbeddedView(this._templateRef);
- } else if (!!this.elseTemplate) {
- this._viewContainer.createEmbeddedView(this.elseTemplate);
} else {
this._viewContainer.clear();
}
diff --git a/projects/grid-failure-information-app/src/app/shared/models/permissions.model.ts b/projects/grid-failure-information-app/src/app/shared/models/permissions.model.ts
index 47c19dd..b7cbcc2 100644
--- a/projects/grid-failure-information-app/src/app/shared/models/permissions.model.ts
+++ b/projects/grid-failure-information-app/src/app/shared/models/permissions.model.ts
@@ -10,10 +10,13 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
+import { RolesEnum } from '@grid-failure-information-app/shared/constants/enums';
+
export class PermissionsModel {
- public reader: boolean = false;
- public writer: boolean = false;
public admin: boolean = false;
+ public creator: boolean = false;
+ public publisher: boolean = false;
+ public qualifier: boolean = false;
/**
*Creates an instance of PermissionsModel.
@@ -24,14 +27,17 @@
if (!!data) {
data.forEach((permissionItem: string) => {
switch (permissionItem) {
- case 'kon-admin':
+ case RolesEnum.ADMIN:
this.admin = true;
break;
- case 'kon-writer':
- this.writer = true;
+ case RolesEnum.CREATOR:
+ this.creator = true;
break;
- case 'kon-reader':
- this.reader = true;
+ case RolesEnum.PUBLISHER:
+ this.publisher = true;
+ break;
+ case RolesEnum.QUALIFIER:
+ this.qualifier = true;
break;
default:
break;
diff --git a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.spec.ts b/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.spec.ts
deleted file mode 100644
index 2c3c65f..0000000
--- a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.spec.ts
+++ /dev/null
@@ -1,29 +0,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 { FormattedDatePipe } from './formatted-date.pipe';
-
-describe('Test FormattedDatePipe ', () => {
- const pipe = new FormattedDatePipe();
-
- it('should perform correct with different inputs ', () => {
- expect(pipe.transform('xxx')).toBe('xxx');
- expect(pipe.transform(null)).toBe(null);
- expect(pipe.transform('')).toBe('');
- expect(pipe.transform(undefined)).toBeNull();
-
- const dateTest = pipe.transform('19.11.2017 13:16');
- expect(dateTest.match('[0-3][0-9]\.[0-1][0-9]\.[0-9]{4}')).toBeTruthy();
-
- });
-});
diff --git a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.ts b/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.ts
deleted file mode 100644
index ba9c355..0000000
--- a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-date.pipe.ts
+++ /dev/null
@@ -1,49 +0,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 {Pipe, PipeTransform} from '@angular/core';
-import * as moment from 'moment';
-/**
- * Pipe to transform a string to a date
- */
-@Pipe({name: 'formattedDate'})
-export class FormattedDatePipe implements PipeTransform {
- /**
- * Constructor
- */
- constructor() {
- }
- /**
- * Transform a date that is passed as string into a date
- * @param value The date passed as string
- * @param format The date passed as string
- */
- transform(value: any, format: string = ''): string {
- // Try and parse the passed value.
- if ( value === undefined) {
- return null;
- }
- const momentDate = moment(value, 'DD.MM.YYYY');
-
- // If moment didn't understand the value, return it unformatted.
- if (!momentDate.isValid()) {
- return value;
- }
-
- // Otherwise, return the date formatted as requested.
- if (format) {
- return momentDate.format(format);
- }
- return momentDate.format('DD.MM.YYYY');
- }
-}
diff --git a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.spec.ts b/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.spec.ts
deleted file mode 100644
index 6152753..0000000
--- a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.spec.ts
+++ /dev/null
@@ -1,31 +0,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 { FormattedTimestampPipe } from './formatted-timestamp.pipe';
-
-describe('Test FormattedTimestampPipe ', () => {
- const pipe = new FormattedTimestampPipe();
-
- it('should perform correct with different inputs ', () => {
- expect(pipe.transform('xxx')).toBeNull();
- expect(pipe.transform(null)).toBe('');
- expect(pipe.transform('')).toBe('');
- expect(pipe.transform(undefined)).toBe('');
-
- expect(pipe.transform('19.11.2017 13:16', 'DD.MM.YYYY HH:mm')).toBe('19.11.2017 13:16');
-
- const dateTest = pipe.transform('19.11.2017 13:16');
- expect(dateTest.match('[0-3][0-9]\.[0-1][0-9]\.[0-9]{4} [0-2][0-9]:[0-5][0-9]')).toBeTruthy();
-
- });
-});
diff --git a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.ts b/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.ts
deleted file mode 100644
index c3ac374..0000000
--- a/projects/grid-failure-information-app/src/app/shared/pipes/formatted-timestamp.pipe.ts
+++ /dev/null
@@ -1,53 +0,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 { Pipe, PipeTransform } from '@angular/core';
-import * as moment from 'moment';
-
-@Pipe({
- name: 'formattedTimestamp'
-})
-export class FormattedTimestampPipe implements PipeTransform {
- transform(value: any, format: string = ''): string {
-
- if (value === '') {
- return '';
- }
-
- if (value === 'xxx') {
- return null;
- }
-
- if (value === null) {
- return '';
- }
-
- if (value === undefined) {
- return '';
- }
-
- // Try and parse the passed value.
- const momentDate = moment(value);
-
- // If moment didn't understand the value, return it unformatted.
- if (!momentDate.isValid()) {
- return value;
- }
-
- // Otherwise, return the date formatted as requested.
- if (format) {
- return momentDate.format(format);
- }
- return momentDate.format('DD.MM.YYYY HH:mm');
- }
-}
diff --git a/projects/grid-failure-information-app/src/app/shared/pipes/pipes.module.ts b/projects/grid-failure-information-app/src/app/shared/pipes/pipes.module.ts
index e6d29ea..b909054 100644
--- a/projects/grid-failure-information-app/src/app/shared/pipes/pipes.module.ts
+++ b/projects/grid-failure-information-app/src/app/shared/pipes/pipes.module.ts
@@ -11,14 +11,12 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { NgModule } from '@angular/core';
+import { NgbDateCustomParserFormatter } from '@grid-failure-information-app/shared/pipes/ngb-date-custom-parser-formatter';
import { SanitizeHtmlPipe } from '@grid-failure-information-app/shared/pipes/sanitizeHtml.pipe';
import { StringToDatePipe } from '@grid-failure-information-app/shared/pipes/string-to-date.pipe';
-import { FormattedTimestampPipe } from '@grid-failure-information-app/shared/pipes/formatted-timestamp.pipe';
import { UniquePipe } from '@grid-failure-information-app/shared/pipes/unique.pipe';
-import { FormattedDatePipe } from '@grid-failure-information-app/shared/pipes/formatted-date.pipe';
-import { NgbDateCustomParserFormatter } from '@grid-failure-information-app/shared/pipes/ngb-date-custom-parser-formatter';
-export const PIPES = [UniquePipe, SanitizeHtmlPipe, StringToDatePipe, StringToDatePipe, FormattedDatePipe, FormattedTimestampPipe];
+export const PIPES = [UniquePipe, SanitizeHtmlPipe, StringToDatePipe, StringToDatePipe];
@NgModule({
imports: [],
diff --git a/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.spec.ts b/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.spec.ts
index 7e6f2e4..5657891 100644
--- a/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.spec.ts
@@ -164,6 +164,15 @@
actions$.next(gridFailureActions.loadGridFailureBranches());
});
+ it('should equal loadGridFailureBranchesFail in response to getGridFailureBranches Error', done => {
+ spyOn(apiClient, 'getGridFailureBranches').and.returnValue(throwError('x'));
+ effects.getGridFailureBranches$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureBranchesFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureBranches());
+ });
+
it('should equal loadGridFailureClassifications after getGridFailureClassifications', done => {
apiResponse = [new FailureClassification({ id: '1' })];
spyOn(apiClient, 'getGridFailureClassifications').and.returnValue(of(apiResponse));
@@ -174,6 +183,15 @@
actions$.next(gridFailureActions.loadGridFailureClassifications());
});
+ it('should equal loadGridFailureClassificationsFail in response to getGridFailureClassifications Error', done => {
+ spyOn(apiClient, 'getGridFailureClassifications').and.returnValue(throwError('x'));
+ effects.getGridFailureClassifications$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureClassificationsFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureClassifications());
+ });
+
it('should equal loadGridFailureTypes after getGridFailureTypes', done => {
apiResponse = [new FailureType({ id: '1' })];
spyOn(apiClient, 'getGridFailureTypes').and.returnValue(of(apiResponse));
@@ -184,6 +202,15 @@
actions$.next(gridFailureActions.loadGridFailureTypes());
});
+ it('should equal loadGridFailureTypesFail in response to getGridFailureTypes Error', done => {
+ spyOn(apiClient, 'getGridFailureTypes').and.returnValue(throwError('x'));
+ effects.getGridFailureTypes$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureTypesFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureTypes());
+ });
+
it('should equal loadGridFailureStates after getGridFailureStates', done => {
apiResponse = [new FailureState({ id: '1' })];
spyOn(apiClient, 'getGridFailureStates').and.returnValue(of(apiResponse));
@@ -194,6 +221,15 @@
actions$.next(gridFailureActions.loadGridFailureStates());
});
+ it('should equal loadGridFailureStatesFail in response to getGridFailureStates Error', done => {
+ spyOn(apiClient, 'getGridFailureStates').and.returnValue(throwError('x'));
+ effects.getGridFailureStates$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureStatesFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureStates());
+ });
+
it('should equal loadGridFailureRadii after getGridFailureRadii', done => {
apiResponse = [new FailureRadius({ id: '1' })];
spyOn(apiClient, 'getGridFailureRadii').and.returnValue(of(apiResponse));
@@ -204,6 +240,15 @@
actions$.next(gridFailureActions.loadGridFailureRadii());
});
+ it('should equal loadGridFailureRadiiFail in response to getGridFailureRadii Error', done => {
+ spyOn(apiClient, 'getGridFailureRadii').and.returnValue(throwError('x'));
+ effects.getGridFailureRadii$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureRadiiFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureRadii());
+ });
+
it('should equal loadGridFailureExpectedReasons after getGridFailureExpectedReasons', done => {
apiResponse = [new FailureExpectedReason({ id: '1' })];
spyOn(apiClient, 'getGridFailureExpectedReasons').and.returnValue(of(apiResponse));
@@ -213,4 +258,13 @@
done();
actions$.next(gridFailureActions.loadGridFailureExpectedReasons());
});
+
+ it('should equal loadGridFailureExpectedReasonsFail in response to getGridFailureExpectedReasons Error', done => {
+ spyOn(apiClient, 'getGridFailureExpectedReasons').and.returnValue(throwError('x'));
+ effects.getGridFailureExpectedReasons$.pipe(take(1)).subscribe(result => {
+ expect(result).toEqual(gridFailureActions.loadGridFailureExpectedReasonsFail({ payload: 'x' }));
+ });
+ done();
+ actions$.next(gridFailureActions.loadGridFailureExpectedReasons());
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/index.ts b/projects/grid-failure-information-app/src/app/shared/utility/index.ts
index ea0bb05..00cdf25 100644
--- a/projects/grid-failure-information-app/src/app/shared/utility/index.ts
+++ b/projects/grid-failure-information-app/src/app/shared/utility/index.ts
@@ -13,4 +13,3 @@
export * from './utility.module';
export * from './utility.service';
export * from './utilityHelpers';
-export * from './validation.service';
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/utility.module.ts b/projects/grid-failure-information-app/src/app/shared/utility/utility.module.ts
index 8ef4046..bcdc4f2 100644
--- a/projects/grid-failure-information-app/src/app/shared/utility/utility.module.ts
+++ b/projects/grid-failure-information-app/src/app/shared/utility/utility.module.ts
@@ -11,7 +11,6 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { NgModule, ModuleWithProviders } from '@angular/core';
-import { ValidationService } from '@grid-failure-information-app/shared/utility/validation.service';
import { UtilService } from '@grid-failure-information-app/shared/utility/utility.service';
@NgModule()
@@ -20,7 +19,7 @@
return {
ngModule: UtilityModule,
- providers: [UtilService, ValidationService],
+ providers: [UtilService],
};
}
}
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/utility.service.spec.ts b/projects/grid-failure-information-app/src/app/shared/utility/utility.service.spec.ts
index cd957d2..e6b5a0a 100644
--- a/projects/grid-failure-information-app/src/app/shared/utility/utility.service.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/utility/utility.service.spec.ts
@@ -93,4 +93,28 @@
component.displayNotification(messageTranslationCode, type, titleTranslationCode);
expect(spyTranslation).toHaveBeenCalledWith(messageTranslationCode);
});
+
+ it('should set the lookup name with the lookup code if exists and call instant an many times the length of the data', () => {
+ const data = [
+ { name: 'danny', code: '123' },
+ { name: 'manny', code: '456' },
+ ];
+ const spyTranslation = spyOn(translateService, 'instant').and.returnValue({ '123': 'message 123', '456': 'message 456' });
+
+ const res = component.translateLookupData(data);
+ expect(spyTranslation).toHaveBeenCalledTimes(data.length);
+ expect(res).toEqual([
+ { name: 'message 123', code: '123' },
+ { name: 'message 456', code: '456' },
+ ]);
+ });
+
+ it('should dont set the lookup name if code not exists and should not call instant', () => {
+ const data = [{ name: 'danny' }, { name: 'manny' }];
+ const spyTranslation = spyOn(translateService, 'instant').and.returnValue({ '123': 'message 123', '456': 'message 456' });
+
+ const res = component.translateLookupData(data);
+ expect(spyTranslation).not.toHaveBeenCalled();
+ expect(res).toEqual(data);
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/validation.service.spec.ts b/projects/grid-failure-information-app/src/app/shared/utility/validation.service.spec.ts
deleted file mode 100644
index 935344b..0000000
--- a/projects/grid-failure-information-app/src/app/shared/utility/validation.service.spec.ts
+++ /dev/null
@@ -1,60 +0,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 { async } from '@angular/core/testing';
-import { ValidationService } from '@grid-failure-information-app/shared/utility';
-
-describe('ValidationService', () => {
- let component: ValidationService;
-
- beforeEach(async(() => {}));
-
- beforeEach(() => {
- component = new ValidationService();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- it('should return null if the mail is valid', () => {
- let formControl: any;
- formControl = { value: 'test@test.de' };
-
- const retsult = component.validateEmail(formControl);
- expect(retsult).toBe(null);
- });
-
- it('should return error message if the mail is not valid', () => {
- let formControl: any;
- formControl = { value: 'test&test.de' };
-
- const retsult = component.validateEmail(formControl);
- expect(retsult).not.toBe(null);
- });
-
- it('should return null if the value is numeric', () => {
- let formControl: any;
- formControl = { value: 222 };
-
- const retsult = component.numericRequired(formControl);
- expect(retsult).toBe(null);
- });
-
- it('should return error message if the value is not numeric', () => {
- let formControl: any;
- formControl = { value: 'test' };
-
- const retsult = component.numericRequired(formControl);
- expect(retsult).not.toBe(null);
- });
-});
diff --git a/projects/grid-failure-information-app/src/app/shared/utility/validation.service.ts b/projects/grid-failure-information-app/src/app/shared/utility/validation.service.ts
deleted file mode 100644
index ec93ea7..0000000
--- a/projects/grid-failure-information-app/src/app/shared/utility/validation.service.ts
+++ /dev/null
@@ -1,53 +0,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 {
- FormControl,
- FormGroup
-} from '@angular/forms';
-@Injectable()
-export class ValidationService {
-
- /**
- * Validates email address
- *
- * @param formControl
- */
- public validateEmail(formControl: FormControl): {[error: string]: any} {
- let EMAIL_REGEXP = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- return EMAIL_REGEXP.test(formControl.value) ? null : { validateEmail: { valid: false } };
- }
-
- /**
- * Validates required numeric values
- *
- * @param formControl
- */
- public numericRequired(formControl: FormControl): {[error: string]: any} {
- return (formControl.value && formControl.value > 0) ? null : { numericRequired: { valid: false } };
- }
-
- /**
- * Validates matching string values
- *
- * @param controlKey
- * @param matchingControlKey
- */
- public matchingPasswords(controlKey: string, matchingControlKey: string): {[error: string]: any} {
- return (group: FormGroup): {[key: string]: any} => {
- if (group.controls[controlKey].value !== group.controls[matchingControlKey].value) {
- return { mismatch: { valid: false } };
- }
- }
- }
-}
diff --git a/sonar-project.properties b/sonar-project.properties
index 5d483ef..597f300 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -10,7 +10,7 @@
sonar.sourceEncoding=UTF-8
sonar.sources=projects/grid-failure-information-app/src, projects/openk/grid-failure-information-map/src
-sonar.exclusions=**/node_modules/**,**/environments/**,e2e/*.ts,**/*.spec.ts,**/test-data/*.ts,**/testing/*.ts,**/assets/**/*,**/*.model.*,**/*.action.*,**/*.module.*,**/*column-definition*,**/*animation*,**/*api-client.*,**/styles.scss
+sonar.exclusions=**/node_modules/**,**/environments/**,e2e/*.ts,**/*.spec.ts,**/test-data/*.ts,**/testing/*.ts,**/assets/**/*,**/*.model.*,**/*.constants.*,**/*.action.*,**/*.module.*,**/*column-definition*,**/*animation*,**/*api-client.*,**/styles.scss
sonar.tests=projects/grid-failure-information-app/src, projects/openk/grid-failure-information-map/src
sonar.test.inclusions=**/*.spec.ts
sonar.test.exclusions=