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/i18n/general.de.json b/i18n/general.de.json
index 720de4c..39aa366 100644
--- a/i18n/general.de.json
+++ b/i18n/general.de.json
@@ -40,5 +40,6 @@
}
},
"Tools": "Tools",
- "MandatoryFieldError": "Es ist mindestens ein Pflichtfeld nicht gefüllt."
+ "MandatoryFieldError": "Es ist mindestens ein Pflichtfeld nicht gefüllt.",
+ "DifferentBranchesError": "Es sind unterschiedliche Sparten ausgewählt. Verdichtet werden können nur Meldungen aus der gleichen Sparte."
}
diff --git a/i18n/grid-failure.de.json b/i18n/grid-failure.de.json
index 75ffd6d..1a46184 100644
--- a/i18n/grid-failure.de.json
+++ b/i18n/grid-failure.de.json
@@ -3,7 +3,10 @@
"Title": "Übersicht Störungsmeldungen",
"New": "Neue Störungsmeldung anlegen",
"List": "Liste",
- "Map": "Karte"
+ "Map": "Karte",
+ "Condensation": "Verdichtung",
+ "ChoosedGridFailureInformations": "Ausgewählte Meldungen",
+ "CondenseChoosedGridFailureInformations": "Ausgewählte Meldungen verdichten"
},
"GridFailure": {
"Title": "Störungsmeldung",
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-api-client.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-api-client.ts
index d165316..1e54fa6 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-api-client.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-api-client.ts
@@ -102,4 +102,10 @@
public getGridFailureExpectedReasons(): Observable<FailureExpectedReason[]> {
return null;
}
+
+ @POST('/grid-failure-informations/condense')
+ @Adapter(GridFailureService.itemAdapter)
+ public postGridFailuresCondensation(@Body() list: string[]): Observable<GridFailure> {
+ return null;
+ }
}
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 d358a9e..cbc9d8e 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
@@ -11,7 +11,7 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { IconCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component';
-import * as moment from 'moment';
+import { valueDateTimeFormatter } from '@grid-failure-information-app/shared/utility/utilityHelpers';
export const GRID_FAILURE_COLDEF = [
{
@@ -37,7 +37,7 @@
headerName: 'GridFailure.InternExtern',
sortable: true,
filter: 'setFilterComponent',
- valueGetter: function(params) {
+ valueGetter: function (params) {
let result = '';
if (params.data.internExtern === 'I') {
result = 'intern';
@@ -85,18 +85,7 @@
sortable: true,
filter: 'setFilterComponent',
valueGetter: params => {
- if (params.data.failureBegin) {
- const date = new Date(params.data.failureBegin);
- date.setHours(date.getHours() + date.getTimezoneOffset() / 60);
- const day = date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
- const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1;
- const year = date.getFullYear();
- const hour = date.getHours() < 10 ? `0${date.getHours()}` : date.getHours();
- const minute = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
- return `${day}.${month}.${year} / ${hour}:${minute}`;
- } else {
- return '';
- }
+ return valueDateTimeFormatter(params.data.failureBegin);
},
},
{
@@ -105,18 +94,7 @@
sortable: true,
filter: 'setFilterComponent',
valueGetter: params => {
- if (params.data.failureEndPlanned) {
- const date = new Date(params.data.failureEndPlanned);
- date.setHours(date.getHours() + date.getTimezoneOffset() / 60);
- const day = date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
- const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1;
- const year = date.getFullYear();
- const hour = date.getHours() < 10 ? `0${date.getHours()}` : date.getHours();
- const minute = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
- return `${day}.${month}.${year} / ${hour}:${minute}`;
- } else {
- return '';
- }
+ return valueDateTimeFormatter(params.data.failureEndPlanned);
},
},
{
@@ -125,18 +103,7 @@
sortable: true,
filter: 'setFilterComponent',
valueGetter: params => {
- if (params.data.failureEndResupplied) {
- const date = new Date(params.data.failureEndResupplied);
- date.setHours(date.getHours() + date.getTimezoneOffset() / 60);
- const day = date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
- const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1;
- const year = date.getFullYear();
- const hour = date.getHours() < 10 ? `0${date.getHours()}` : date.getHours();
- const minute = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
- return `${day}.${month}.${year} / ${hour}:${minute}`;
- } else {
- return '';
- }
+ return valueDateTimeFormatter(params.data.failureEndResupplied);
},
},
{
@@ -204,6 +171,7 @@
filter: false,
suppressMenu: true,
suppressSizeToFit: true,
+ headerComponent: 'headerCellRendererComponent',
cellRendererFramework: IconCellRendererComponent,
},
];
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-for-condensation-column-definition.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-for-condensation-column-definition.ts
new file mode 100644
index 0000000..6ae3057
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list-for-condensation-column-definition.ts
@@ -0,0 +1,182 @@
+/********************************************************************************
+ * 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 { IconCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component';
+import { valueDateTimeFormatter } from '@grid-failure-information-app/shared/utility/utilityHelpers';
+
+export const GRID_FAILURE_FOR_CONDENSATION_COLDEF = [
+ {
+ field: 'failureClassification',
+ headerName: 'GridFailure.FailureClassification',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'failureType',
+ headerName: 'GridFailure.FailureType',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'responsibility',
+ headerName: 'GridFailure.Responsibility',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'internExtern', //Meldung durch
+ headerName: 'GridFailure.InternExtern',
+ sortable: true,
+ filter: 'setFilterComponent',
+ valueGetter: function (params) {
+ let result = '';
+ if (params.data.internExtern === 'I') {
+ result = 'intern';
+ } else if (params.data.internExtern === 'E') {
+ result = 'extern';
+ } else {
+ result = 'unbekannt';
+ }
+ return result;
+ },
+ },
+ {
+ field: 'statusIntern',
+ headerName: 'GridFailure.StatusIntern',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'statusExtern',
+ headerName: 'GridFailure.StatusExtern',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'branch',
+ headerName: 'GridFailure.Branch',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'voltageLevel',
+ headerName: 'GridFailure.VoltageLevel',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'pressureLevel',
+ headerName: 'GridFailure.PressureLevel',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'failureBegin',
+ headerName: 'GridFailure.FailureBegin',
+ sortable: true,
+ filter: 'setFilterComponent',
+ valueGetter: params => {
+ return valueDateTimeFormatter(params.data.failureBegin);
+ },
+ },
+ {
+ field: 'failureEndPlanned',
+ headerName: 'GridFailure.FailureEndPlanned',
+ sortable: true,
+ filter: 'setFilterComponent',
+ valueGetter: params => {
+ return valueDateTimeFormatter(params.data.failureEndPlanned);
+ },
+ },
+ {
+ field: 'failureEndResupplied',
+ headerName: 'GridFailure.FailureEndResupplied',
+ sortable: true,
+ filter: 'setFilterComponent',
+ valueGetter: params => {
+ return valueDateTimeFormatter(params.data.failureEndResupplied);
+ },
+ },
+ {
+ field: 'publicationText',
+ headerName: 'GridFailure.ProbableReason',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'internalRemark',
+ headerName: 'GridFailure.InternalRemark',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'postcode',
+ headerName: 'GridFailure.Postcode',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'city',
+ headerName: 'GridFailure.City',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'district',
+ headerName: 'GridFailure.District',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'street',
+ headerName: 'GridFailure.Street',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'housenumber',
+ headerName: 'GridFailure.Housenumber',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'stationDescription',
+ headerName: 'GridFailure.StationDescription',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'stationCoords',
+ headerName: 'GridFailure.StationCoords',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'radius',
+ headerName: 'GridFailure.Radius',
+ sortable: true,
+ filter: 'setFilterComponent',
+ },
+ {
+ field: 'tools',
+ headerName: ' ',
+ pinned: 'right',
+ maxWidth: 110,
+ minWidth: 110,
+ lockPosition: true,
+ sortable: false,
+ filter: false,
+ suppressMenu: true,
+ suppressSizeToFit: true,
+ cellRendererFramework: IconCellRendererComponent,
+ },
+];
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.html b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.html
index e2b88b5..91e3596 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.html
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.html
@@ -23,7 +23,7 @@
<button class="btn btn-primary non-outline" (click)="view = 'list'" [class.active]="view === 'list'">
{{ 'GridFailures.List' | translate }}
</button>
- <button class="btn btn-primary non-outline" (click)="view = 'map'" [class.active]="view === 'map'">
+ <button class="btn btn-primary non-outline" (click)="view = 'map'; clearGridFailureCondensation()" [class.active]="view === 'map'">
{{ 'GridFailures.Map' | translate }}
</button>
</div>
@@ -33,18 +33,53 @@
</div>
</div>
<div class="grid-failures-grid-wrapper" body>
- <ag-grid-angular
- *ngIf="view === 'list'; else map"
- autoResizeColumns
- class="ag-theme-balham"
- [gridOptions]="gridOptions"
- [columnDefs]="columnDefinition"
- [rowSelection]="'single'"
- [frameworkComponents]="frameworkComponents"
- [rowData]="sandbox.gridFailureList$ | async"
- [overlayNoRowsTemplate]="noRowsTemplate"
- >
- </ag-grid-angular>
+ <div class="grid-failure-information-condensation" *ngIf="view === 'list' && showCondensationTable">
+ <div class="diverse-condensation-options">
+ <label id="choosed-grid-failure-information-label">
+ {{ 'GridFailures.ChoosedGridFailureInformations' | translate }}
+ </label>
+ <div class="diverse-condensation-btns">
+ <button class="btn btn-primary diverse-btn" (click)="clearGridFailureCondensation()">
+ {{ 'CancelBtn' | translate }}
+ </button>
+ <button class="btn btn-primary diverse-btn" (click)="condenseChoosedGridFailureInformations()">
+ {{ 'GridFailures.CondenseChoosedGridFailureInformations' | translate }}
+ </button>
+ </div>
+ </div>
+ <ag-grid-angular
+ autoResizeColumns
+ class="ag-theme-balham"
+ [gridOptions]="gridOptionsCondensation"
+ [columnDefs]="condensationColumnDefinition"
+ [rowSelection]="'single'"
+ [frameworkComponents]="frameworkComponents"
+ [rowData]="sandbox.condensationList"
+ [overlayNoRowsTemplate]="noRowsTemplate"
+ >
+ </ag-grid-angular>
+ </div>
+
+ <div class="grid-failure-information-overview" *ngIf="view === 'list'; else map">
+ <div class="diverse-options" *ngIf="!showCondensationTable">
+ <button class="btn btn-primary diverse-btn" (click)="changeToSelectionMode()">
+ {{ 'GridFailures.Condensation' | translate }}
+ </button>
+ </div>
+ <ag-grid-angular
+ autoResizeColumns
+ class="ag-theme-balham"
+ [gridOptions]="gridOptions"
+ [columnDefs]="overviewColumnDefinition"
+ [rowSelection]="'single'"
+ [frameworkComponents]="frameworkComponents"
+ [rowData]="sandbox.gridFailureList$ | async"
+ [overlayNoRowsTemplate]="noRowsTemplate"
+ (gridReady)="onGridReady($event)"
+ >
+ </ag-grid-angular>
+ </div>
+
<ng-template #map>
<openk-grid-failure-information-map [mapData]="sandbox.gridFailureList$ | async"></openk-grid-failure-information-map>
</ng-template>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.scss b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.scss
index 800d309..624b024 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.scss
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.scss
@@ -18,6 +18,48 @@
justify-content: space-between;
}
+.grid-failure-information-overview {
+ position: relative;
+ height: 90%;
+}
+
+.grid-failure-information-condensation {
+ position: relative;
+ height: 30%;
+ margin-bottom: 65px;
+}
+
+.diverse-condensation-btns {
+ display: flex;
+ justify-content: flex-end;
+}
+
+.diverse-condensation-options {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border: 1px solid #bdc3c7;
+ background-color: #f5f7f7;
+ margin-bottom: 1px;
+ padding: 0px 7px 2px 7px;
+}
+
+#choosed-grid-failure-information-label {
+ align-self: flex-end;
+ margin-bottom: 12px;
+}
+
.non-outline {
box-shadow: none !important;
}
+.diverse-options {
+ display: flex;
+ justify-content: flex-end;
+ border: 1px solid #bdc3c7;
+ background-color: #f5f7f7;
+ margin-bottom: 1px;
+ padding: 0px 7px 2px 7px;
+}
+.diverse-btn {
+ margin: 10px 0px 5px 5px;
+}
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
index 0e8bf53..2644367 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
@@ -15,18 +15,30 @@
import { GridFailure } from '@grid-failure-information-app/shared/models';
import { GridFailureSandbox } from '@grid-failure-information-app/pages/grid-failure/grid-failure-list/grid-failure.sandbox';
import { Subscription } from 'rxjs';
+import { UtilService } from '@grid-failure-information-app/shared/utility';
describe('GridFailureListComponent ', () => {
let component: GridFailureListComponent;
let router: Router;
let sandbox: GridFailureSandbox;
let subscription: Subscription;
+ let utilService: UtilService;
beforeEach(() => {
router = { navigate() {} } as any;
- sandbox = { endSubscriptions() {} } as any;
+ sandbox = {
+ condensationList: [{ branch: 'F' }],
+ endSubscriptions() {},
+ clearGridFailureCondensation() {},
+ condenseCondensationList() {},
+ addItemToCondensationList() {},
+ removeItemFromCondensationList() {},
+ } as any;
+ utilService = {
+ displayNotification() {},
+ } as any;
subscription = { unsubscribe() {} } as any;
- component = new GridFailureListComponent(sandbox, router);
+ component = new GridFailureListComponent(sandbox, router, utilService);
});
it('should create', () => {
@@ -35,7 +47,7 @@
it('should initialize gridOptions context', () => {
component.ngOnInit();
- expect(component.gridOptions.context.icons.edit).toBeTruthy();
+ expect(component.gridOptions.context.icons.edit).toBeFalsy();
});
it('should call appropriate functions for edit event', () => {
@@ -45,10 +57,75 @@
expect(spy).toHaveBeenCalled();
});
+ it('should call appropriate functions for add event', () => {
+ sandbox.condensationList = [];
+ const spy1: any = spyOn(sandbox, 'addItemToCondensationList');
+ const spy2: any = spyOn((component as any)._utilService, 'displayNotification');
+ component.ngOnInit();
+ component.gridOptions.context.eventSubject.next({ type: 'add', data: new GridFailure() });
+ expect(spy1).toHaveBeenCalled();
+ component.ngOnInit();
+ let gridFailure: any = { branch: 'F' };
+ sandbox.condensationList = [gridFailure];
+ component.gridOptions.context.eventSubject.next({ type: 'add', data: gridFailure });
+ expect(spy1).toHaveBeenCalledTimes(3);
+ component.ngOnInit();
+ gridFailure = { branch: 'S' };
+ component.gridOptions.context.eventSubject.next({ type: 'add', data: gridFailure });
+ expect(spy2).toHaveBeenCalled();
+ });
+
+ it('should call appropriate functions for addAllItems event', () => {
+ const spy: any = spyOn(component, 'addCompleteTable');
+ component.ngOnInit();
+ component.gridOptions.context.eventSubject.next({ type: 'addAllItems', data: new GridFailure() });
+ expect(spy).toHaveBeenCalled();
+ });
+
+ it('should call appropriate functions for initialLoad event', () => {
+ const spy: any = spyOn(component as any, '_changeMode');
+ component.ngOnInit();
+ component.gridOptions.context.eventSubject.next({ type: 'initialLoad' });
+ expect(spy).toHaveBeenCalled();
+ });
+
+ it('should call appropriate functions for remove event', () => {
+ const spy: any = spyOn(sandbox, 'removeItemFromCondensationList');
+ component.ngOnInit();
+ component.gridOptionsCondensation.context.eventSubject.next({ type: 'remove', data: new GridFailure() });
+ expect(spy).toHaveBeenCalled();
+ });
+
it('should unsubscribe OnDestroy', () => {
const spy: any = spyOn(sandbox, 'endSubscriptions');
component['_subscription'] = new Subscription();
component.ngOnDestroy();
expect(spy).toHaveBeenCalled();
});
+
+ it('should call and check if condenseChoosedGridFailureInformations() works fine', () => {
+ const spy1: any = spyOn(component, 'clearGridFailureCondensation');
+ const spy2: any = spyOn(sandbox, 'condenseCondensationList');
+
+ component.condenseChoosedGridFailureInformations();
+
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ });
+
+ it('should call and check if onGridReady(params) works fine', () => {
+ component.onGridReady({ api: 'test' });
+
+ expect((component as any)._gridApi).toBe('test');
+ });
+
+ it('should call and check if changeToSelectionMode() works fine', () => {
+ const spy: any = spyOn(component.events$, 'next');
+ component.showCondensationTable = false;
+
+ component.changeToSelectionMode();
+
+ expect(component.showCondensationTable).toBeTruthy();
+ expect(spy).toHaveBeenCalledWith({ eventType: 'overviewTableSelectionMode' });
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
index b0fb1d6..5f95b92 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.ts
@@ -10,12 +10,18 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { Component, OnInit, OnDestroy } from '@angular/core';
-import { BaseList } from '@grid-failure-information-app/shared/components/base-components/base.list';
-import { SetFilterComponent } from '@grid-failure-information-app/shared/filters/ag-grid/set-filter/set-filter.component';
-import { GRID_FAILURE_COLDEF } from '@grid-failure-information-app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition';
-import { GridFailureSandbox } from '@grid-failure-information-app/pages/grid-failure/grid-failure-list/grid-failure.sandbox';
+import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
+import { GRID_FAILURE_COLDEF } from '@grid-failure-information-app/pages/grid-failure/grid-failure-list/grid-failure-list-column-definition';
+import { GRID_FAILURE_FOR_CONDENSATION_COLDEF } from '@grid-failure-information-app/app/pages/grid-failure/grid-failure-list/grid-failure-list-for-condensation-column-definition';
+import { GridFailureSandbox } from '@grid-failure-information-app/pages/grid-failure/grid-failure-list/grid-failure.sandbox';
+import { BaseList } from '@grid-failure-information-app/shared/components/base-components/base.list';
+import { HeaderCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component';
+import { ModeEnum, EventTypeEnum } from '@grid-failure-information-app/shared/constants/enums';
+import { SetFilterComponent } from '@grid-failure-information-app/shared/filters/ag-grid/set-filter/set-filter.component';
+import { UtilService } from '@grid-failure-information-app/shared/utility';
+import { GridApi, GridOptions } from 'ag-grid-community';
+import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
@@ -24,30 +30,123 @@
styleUrls: ['./grid-failure-list.component.scss'],
})
export class GridFailureListComponent extends BaseList implements OnInit, OnDestroy {
- public columnDefinition: any = GRID_FAILURE_COLDEF;
- public frameworkComponents: { setFilterComponent: any };
+ public overviewColumnDefinition: any = GRID_FAILURE_COLDEF;
+ public condensationColumnDefinition: any = GRID_FAILURE_FOR_CONDENSATION_COLDEF;
+ public frameworkComponents: any;
public view: any = 'list';
+ public showCondensationTable: boolean = false;
+ public enableSelectionMode: boolean = false;
+ public condensationEvents$: Subject<any> = new Subject();
+ public gridOptionsCondensation: GridOptions = {
+ context: {
+ eventSubject: this.condensationEvents$,
+ },
+ suppressLoadingOverlay: true,
+ };
- constructor(public sandbox: GridFailureSandbox, private _router: Router) {
+ private _gridApi: GridApi;
+ private _modeEnum = ModeEnum;
+ private _eventTypeEnum = EventTypeEnum;
+
+ constructor(public sandbox: GridFailureSandbox, private _router: Router, private _utilService: UtilService) {
super();
- this.frameworkComponents = { setFilterComponent: SetFilterComponent };
+ this.frameworkComponents = { setFilterComponent: SetFilterComponent, headerCellRendererComponent: HeaderCellRendererComponent };
}
- ngOnInit() {
- this.gridOptions.context = {
- ...this.gridOptions.context,
- icons: { edit: true },
- };
+ ngOnInit(): void {
+ this._setInitialGridOptions();
+ }
- this.gridOptions.context.eventSubject.pipe(takeUntil(this._endSubscriptions$)).subscribe(event => {
- if (event.type === 'edit' || event.type === 'readonly') {
- this._router.navigate(['/grid-failures', event.data.id]);
+ ngOnDestroy(): void {
+ this._endSubscriptions$.next(true);
+ this.sandbox.endSubscriptions();
+ this.clearGridFailureCondensation();
+ }
+
+ public onGridReady(params): void {
+ this._gridApi = params.api;
+ }
+
+ public clearGridFailureCondensation(): void {
+ this.sandbox.clearGridFailureCondensation();
+ this.showCondensationTable = false;
+ this.enableSelectionMode = false;
+ this._changeMode();
+ }
+
+ public condenseChoosedGridFailureInformations(): void {
+ if (this.sandbox.condensationList.length != 0) {
+ this.sandbox.condenseCondensationList();
+ this.clearGridFailureCondensation();
+ }
+ }
+
+ public addCompleteTable(): void {
+ let isNotificationAlreadyShown: boolean = false;
+ this._gridApi.forEachNodeAfterFilter(node => {
+ if (this.sandbox.condensationList.length == 0 || node.data.branch === this.sandbox.condensationList[0].branch) {
+ this.sandbox.addItemToCondensationList(node.data);
+ } else {
+ if (!isNotificationAlreadyShown) this._utilService.displayNotification('DifferentBranchesError', 'alert');
+ isNotificationAlreadyShown = true;
}
});
}
- ngOnDestroy() {
- this._endSubscriptions$.next(true);
- this.sandbox.endSubscriptions();
+ public changeToSelectionMode(): void {
+ this.showCondensationTable = true;
+ this.enableSelectionMode = true;
+ this._changeMode();
+ }
+
+ private _setInitialGridOptions(): void {
+ this.gridOptions.context = {
+ ...this.gridOptions.context,
+ icons: { edit: false, add: false },
+ };
+
+ this.gridOptions.context.eventSubject.pipe(takeUntil(this._endSubscriptions$)).subscribe(event => {
+ switch (event.type) {
+ case this._eventTypeEnum.Edit || this._eventTypeEnum.Readonly:
+ this._router.navigate(['/grid-failures', event.data.id]);
+ break;
+ case this._eventTypeEnum.Add:
+ if (this.sandbox.condensationList.length == 0 || event.data.branch === this.sandbox.condensationList[0].branch) {
+ this.sandbox.addItemToCondensationList(event.data);
+ } else {
+ this._utilService.displayNotification('DifferentBranchesError', 'alert');
+ }
+ break;
+ case this._eventTypeEnum.AddAllItems:
+ this.addCompleteTable();
+ break;
+ case this._eventTypeEnum.InitialLoad:
+ this._changeMode();
+ break;
+
+ default:
+ break;
+ }
+ });
+
+ this.gridOptionsCondensation.context = {
+ ...this.gridOptionsCondensation.context,
+ icons: { edit: false, add: false, remove: true },
+ };
+
+ this.gridOptionsCondensation.context.eventSubject.pipe(takeUntil(this._endSubscriptions$)).subscribe(event => {
+ if (event.type === this._eventTypeEnum.Remove) {
+ this.sandbox.removeItemFromCondensationList(event.data);
+ }
+ });
+ }
+
+ private _changeMode(): void {
+ this.showCondensationTable //später; auf anderes Flag beziehen -> enableSelectionMode
+ ? this.condensationEvents$.next({ eventType: this._modeEnum.CondensationTableSelectionMode })
+ : this.events$.next({ eventType: this._modeEnum.InitialMode });
+ this.showCondensationTable //später; auf anderes Flag beziehen -> enableSelectionMode
+ ? this.events$.next({ eventType: this._modeEnum.OverviewTableSelectionMode })
+ : this.events$.next({ eventType: this._modeEnum.InitialMode });
}
}
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.spec.ts
index d8efa58..c934c48 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.spec.ts
@@ -16,6 +16,7 @@
import { of } from 'rxjs';
import * as gridFailureActions from '@grid-failure-information-app/shared/store/actions/grid-failures.action';
import { Router } from '@angular/router';
+import { GridFailure } from '@grid-failure-information-app/shared/models/grid-failure.model';
describe('GridFailureSandbox', () => {
let service: GridFailureSandbox;
@@ -44,4 +45,30 @@
service.createGridFailure();
expect(spy).toHaveBeenCalledWith('/grid-failures/new');
});
+
+ it('should clear condensationList after calling clearGridFailureCondensation()', () => {
+ service.condensationList = [new GridFailure()];
+ service.clearGridFailureCondensation();
+ expect(service.condensationList.length).toBe(0);
+ });
+
+ it('should add item to condensationList if its not already in them after calling addItemToCondensationList()', () => {
+ service.condensationList = [];
+ service.addItemToCondensationList(new GridFailure());
+ expect(service.condensationList.length).toBe(1);
+ service.addItemToCondensationList(new GridFailure());
+ expect(service.condensationList.length).toBe(1);
+ });
+
+ it('should remove item from condensationList after calling removeItemFromCondensationList()', () => {
+ service.condensationList = [new GridFailure()];
+ service.removeItemFromCondensationList(new GridFailure());
+ expect(service.condensationList.length).toBe(0);
+ });
+
+ it('should condense condensationList after calling condenseCondensationList()', () => {
+ service.condensationList = [new GridFailure()];
+ service.condenseCondensationList();
+ expect(appState.dispatch).toHaveBeenCalledWith(gridFailureActions.postGridFailuresCondensation({ payload: [new GridFailure().id] }));
+ });
});
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
index 870f683..01ab6b5 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure.sandbox.ts
@@ -25,6 +25,7 @@
export class GridFailureSandbox extends BaseSandbox {
public gridFailureList$: Observable<GridFailure[]> = this.appState$.select(store.getGridFailuresData);
public gridFailureListLoading$: Observable<boolean> = this.appState$.select(store.getGridFailuresLoading);
+ public condensationList: GridFailure[] = new Array();
constructor(protected appState$: Store<store.State>, private _router: Router) {
super(appState$);
@@ -40,4 +41,28 @@
this.appState$.dispatch(new MarkAsTouchedAction(fromGridFailuresDetailFormReducer.FORM_ID));
this._router.navigateByUrl('/grid-failures/new');
}
+
+ public clearGridFailureCondensation(): void {
+ this.condensationList = [];
+ }
+
+ public addItemToCondensationList(data: GridFailure): void {
+ if (this.condensationList.find(item => item.id == data.id) != null || data.condensed === true) {
+ return;
+ } else {
+ this.condensationList = [...this.condensationList, data];
+ }
+ }
+
+ public removeItemFromCondensationList(data: GridFailure): void {
+ this.condensationList = this.condensationList.filter(item => item.id !== data.id);
+ }
+
+ public condenseCondensationList(): void {
+ const cl: string[] = new Array();
+ this.condensationList.forEach(item => {
+ cl.push(item.id);
+ });
+ this.appState$.dispatch(gridFailureActions.postGridFailuresCondensation({ payload: cl }));
+ }
}
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.html b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.html
new file mode 100644
index 0000000..4946c10
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.html
@@ -0,0 +1,17 @@
+<!-- /********************************************************************************
+ * 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
+ ********************************************************************************/ -->
+<div>
+ <button *ngIf="addIcon" (click)="clicked('addAllItems')" class="tool-icon">
+ <fa name="plus"></fa>
+ </button>
+</div>
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.scss b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.scss
new file mode 100644
index 0000000..c37e40b
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.scss
@@ -0,0 +1,12 @@
+/********************************************************************************
+ * 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
+ ********************************************************************************/
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.spec.ts b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.spec.ts
new file mode 100644
index 0000000..1c91394
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.spec.ts
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * 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, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ICellRendererParams } from 'ag-grid-community';
+import { HeaderCellRendererComponent } from './header-cell-renderer.component';
+
+describe('HeaderCellRendererComponent', () => {
+ let component: HeaderCellRendererComponent;
+
+ beforeEach(() => {
+ component = new HeaderCellRendererComponent();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.ts b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.ts
new file mode 100644
index 0000000..1ab1208
--- /dev/null
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component.ts
@@ -0,0 +1,55 @@
+/********************************************************************************
+ * 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 { Component } from '@angular/core';
+import { IHeaderAngularComp } from 'ag-grid-angular';
+import { ModeEnum } from '@grid-failure-information-app/shared/constants/enums';
+
+@Component({
+ selector: 'app-header-cell-renderer',
+ templateUrl: './header-cell-renderer.component.html',
+ styleUrls: ['./header-cell-renderer.component.scss'],
+})
+export class HeaderCellRendererComponent implements IHeaderAngularComp {
+ public addIcon = null;
+
+ private _params: any;
+ private _modeEnum = ModeEnum;
+
+ agInit(params): void {
+ this._params = params;
+ this._updateIcon();
+ if (params.context && params.context.icons) {
+ const contextIcons = params.context.icons;
+ this.addIcon = !!contextIcons && !!contextIcons.add;
+ }
+ }
+
+ public clicked(eventType: string): void {
+ this._params.context.eventSubject.next({ type: eventType, data: this._params.data });
+ }
+
+ private _updateIcon(): void {
+ this._params.context.eventSubject.subscribe((event: any) => {
+ switch (event.eventType) {
+ case this._modeEnum.InitialMode:
+ this.addIcon = false;
+ break;
+ case this._modeEnum.OverviewTableSelectionMode:
+ this.addIcon = true;
+ break;
+ default:
+ break;
+ }
+ });
+ }
+}
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 46cbc8c..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
@@ -20,3 +20,9 @@
<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>
\ No newline at end of file
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.spec.ts b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.spec.ts
index 479c7f5..c6613f8 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.spec.ts
@@ -27,20 +27,4 @@
it('should return false when calling refesh', () => {
expect(component.refresh()).toBeFalsy();
});
-
- it('should set icon properties appropriate when calling agInit with default params + icons undefined', () => {
- let p: ICellRendererParams = { data: { editable: true }, context: { icons: {} } } as any;
- component.agInit(p);
- expect(component.editIcon).toBeFalsy();
- expect(component.readonlyIcon).toBeFalsy();
- expect(component.deleteIcon).toBeFalsy();
- });
-
- it('should set icon properties appropriate when calling agInit with default params + icons true', () => {
- let p: ICellRendererParams = { data: { editable: true }, context: { icons: { edit: true, readonly: true, delete: true } } } as any;
- component.agInit(p);
- expect(component.editIcon).toBeTruthy();
- expect(component.readonlyIcon).toBeTruthy();
- expect(component.deleteIcon).toBeTruthy();
- });
});
diff --git a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.ts b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.ts
index ce3e3b6..7bac4c2 100644
--- a/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.ts
+++ b/projects/grid-failure-information-app/src/app/shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component.ts
@@ -10,39 +10,72 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
import { AgRendererComponent } from 'ag-grid-angular';
import { ICellRendererParams } from 'ag-grid-community';
+import { ModeEnum } from '@grid-failure-information-app/shared/constants/enums';
@Component({
selector: 'app-icon-cell-renderer',
templateUrl: './icon-cell-renderer.component.html',
styleUrls: ['./icon-cell-renderer.component.scss'],
})
-export class IconCellRendererComponent implements AgRendererComponent {
+export class IconCellRendererComponent implements AgRendererComponent, OnInit {
public editIcon = null;
public deleteIcon = null;
public readonlyIcon = null;
public editFlag = null;
-
+ public addIcon = null;
+ public removeIcon = null;
public params: any;
+ private _modeEnum = ModeEnum;
+
public agInit(params: ICellRendererParams): void {
this.params = params;
this.editFlag = params.data['editable'];
+ this._updateIcon();
if (params.context && params.context.icons) {
const contextIcons = params.context.icons;
this.editIcon = !!contextIcons && !!contextIcons.edit;
this.readonlyIcon = !!contextIcons && !!contextIcons.readonly;
this.deleteIcon = !!contextIcons && !!contextIcons.delete;
+ this.addIcon = !!contextIcons && !!contextIcons.add;
+ this.removeIcon = !!contextIcons && !!contextIcons.remove;
}
}
+ public ngOnInit(): void {
+ this.params.context.eventSubject.next({ type: 'initialLoad' });
+ }
+
public refresh(): boolean {
return false;
}
- public clicked(eventType: string) {
+ public clicked(eventType: string): void {
this.params.context.eventSubject.next({ type: eventType, data: this.params.data });
}
+
+ private _updateIcon(): void {
+ this.params.context.eventSubject.subscribe((event: any) => {
+ switch (event.eventType) {
+ case this._modeEnum.InitialMode:
+ this.editIcon = true;
+ this.addIcon = false;
+ this.removeIcon = false;
+ break;
+ case this._modeEnum.OverviewTableSelectionMode:
+ this.editIcon = false;
+ this.addIcon = !this.params.data.condensed;
+ break;
+ case this._modeEnum.CondensationTableSelectionMode:
+ this.editIcon = false;
+ this.removeIcon = true;
+ break;
+ default:
+ break;
+ }
+ });
+ }
}
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 6b72869..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
@@ -34,6 +34,7 @@
import { AgGridModule } from 'ag-grid-angular';
import { AngularFontAwesomeModule } from 'angular-font-awesome';
import { NgrxFormsModule } from 'ngrx-forms';
+import { HeaderCellRendererComponent } from '@grid-failure-information-app/shared/components/cell-renderer/header-cell-renderer/header-cell-renderer.component';
export const COMPONENTS = [
SpinnerComponent,
@@ -49,6 +50,7 @@
SafetyQueryDialogComponent,
BoolCellRendererComponent,
DateCellRendererComponent,
+ HeaderCellRendererComponent,
DateTimePickerComponent,
];
@@ -71,7 +73,14 @@
],
declarations: COMPONENTS,
exports: COMPONENTS,
- entryComponents: [PaginationComponent, IconCellRendererComponent, SafetyQueryDialogComponent, BoolCellRendererComponent, DateCellRendererComponent],
+ entryComponents: [
+ PaginationComponent,
+ IconCellRendererComponent,
+ SafetyQueryDialogComponent,
+ BoolCellRendererComponent,
+ DateCellRendererComponent,
+ HeaderCellRendererComponent,
+ ],
providers: [DatePipe],
})
export class ComponentsModule {}
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 08b4c8b..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
@@ -50,3 +50,17 @@
UPDATED = 'aktualisiert',
COMPLETED = 'abgeschlossen',
}
+export enum ModeEnum {
+ InitialMode = 'initialMode',
+ OverviewTableSelectionMode = 'overviewTableSelectionMode',
+ CondensationTableSelectionMode = 'condensationTableSelectionMode',
+}
+
+export enum EventTypeEnum {
+ Edit = 'edit',
+ Readonly = 'readonly',
+ Add = 'add',
+ AddAllItems = 'addAllItems',
+ InitialLoad = 'initialLoad',
+ Remove = 'remove',
+}
diff --git a/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts b/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts
index d419695..64b1714 100644
--- a/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts
+++ b/projects/grid-failure-information-app/src/app/shared/models/grid-failure.model.ts
@@ -15,6 +15,8 @@
public branch: string = null;
public branchColorCode: string = null;
public branchId: string = null;
+ public condensed: boolean = null;
+ public condensedCount: number = null;
public city: string = null;
public district: string = null;
public failureBegin: string = null;
diff --git a/projects/grid-failure-information-app/src/app/shared/store/actions/grid-failures.action.ts b/projects/grid-failure-information-app/src/app/shared/store/actions/grid-failures.action.ts
index 65cc525..6366c1a 100644
--- a/projects/grid-failure-information-app/src/app/shared/store/actions/grid-failures.action.ts
+++ b/projects/grid-failure-information-app/src/app/shared/store/actions/grid-failures.action.ts
@@ -81,3 +81,8 @@
props<{ payload: Array<FailureExpectedReason> }>()
);
export const loadGridFailureExpectedReasonsFail = createAction('[[GridFailureFailureExpectedReasons] Load Fail', props<{ payload: string }>());
+export const loadGridFailurePublicationTextsFail = createAction('[GridFailurePublicationTexts] Load Fail', props<{ payload: string }>());
+
+export const postGridFailuresCondensation = createAction('[GridFailures] Condense', props<{ payload: string[] }>());
+export const postGridFailuresCondensationSuccess = createAction('[GridFailures] Condense Success');
+export const postGridFailuresCondensationFail = createAction('[GridFailures] Condense Fail', props<{ payload: string }>());
diff --git a/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.ts b/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.ts
index 1e658b5..57b5490 100644
--- a/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.ts
+++ b/projects/grid-failure-information-app/src/app/shared/store/effects/grid-failures.effect.ts
@@ -168,5 +168,21 @@
)
);
+ postGridFailuresCondensation$: any = createEffect(() =>
+ this._actions$.pipe(
+ ofType(gridFailureActions.postGridFailuresCondensation),
+ map(action => action['payload']),
+ switchMap((payload: string[]) => {
+ return this._apiClient.postGridFailuresCondensation(payload).pipe(
+ map(() => {
+ this._store.dispatch(gridFailureActions.loadGridFailures());
+ return gridFailureActions.postGridFailuresCondensationSuccess();
+ }),
+ catchError(error => of(gridFailureActions.postGridFailuresCondensationFail({ payload: error })))
+ );
+ })
+ )
+ );
+
constructor(private _actions$: Actions, private _apiClient: GridFailureApiClient, private _store: Store<any>) {}
}
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 bbeb8f9..b733299 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
@@ -50,4 +50,10 @@
let testValue = utilityHelpers.localeDateString(dateString);
expect(testValue).toBe('1.12.2020');
});
+
+ it('should convert a string date with time to right format', () => {
+ const dateTimeString: string = '2021-01-19T00:00:00.000Z';
+ let testValue = utilityHelpers.valueDateTimeFormatter(dateTimeString);
+ expect(testValue).toBe('19.01.2021 / 00:00');
+ });
});
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 d845f3b..59deca7 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
@@ -67,3 +67,18 @@
return '';
}
}
+
+export function valueDateTimeFormatter(params: any) {
+ if (params) {
+ const date = new Date(params);
+ date.setHours(date.getHours() + date.getTimezoneOffset() / 60);
+ const day = date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
+ const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1;
+ const year = date.getFullYear();
+ const hour = date.getHours() < 10 ? `0${date.getHours()}` : date.getHours();
+ const minute = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
+ return `${day}.${month}.${year} / ${hour}:${minute}`;
+ } else {
+ return '';
+ }
+}
diff --git a/projects/grid-failure-information-app/src/styles.scss b/projects/grid-failure-information-app/src/styles.scss
index f772714..86257ac 100644
--- a/projects/grid-failure-information-app/src/styles.scss
+++ b/projects/grid-failure-information-app/src/styles.scss
@@ -7022,7 +7022,7 @@
ag-grid-angular {
width: 100%;
- height: calc(100vh - 210px);
+ height: 100%;
}
.ngrx-forms-valid[required],