| /* |
| ****************************************************************************** |
| * Copyright 2018 PTA GmbH. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| ****************************************************************************** |
| */ |
| import { Component } from '@angular/core'; |
| import { AbstractListComponent } from '../common-components/abstract-list/abstract-list.component'; |
| import { ErrorType } from '../../common/enums'; |
| import { Globals } from './../../common/globals'; |
| import { OnInit } from '@angular/core'; |
| import { Observable } from '../../../../node_modules/rxjs/Rx'; |
| import { GridOptions } from 'ag-grid/dist/lib/entities/gridOptions'; |
| import { GridMeasuresAgGridConfiguration } from './grid-measures-ag-grid-configuration'; |
| |
| @Component({ |
| selector: 'app-grid-measures', |
| templateUrl: './grid-measures.component.html', |
| styleUrls: ['./grid-measures.component.css', '../common-components/abstract-list/abstract-list.component.css'], |
| }) |
| |
| export class GridMeasuresComponent extends AbstractListComponent implements OnInit { |
| Globals = Globals; |
| gridmeasures: any; |
| currentDate = new Date(); |
| windowHeight: number = window.innerHeight; |
| isCancelClosedFilterButtons: boolean; |
| |
| ngOnInit() { |
| super.ngOnInit(); |
| if (this.sessionContext.getStatusMainFilter() !== null) { |
| this.statusMainFilter = this.sessionContext.getStatusMainFilter(); |
| } |
| |
| Observable.fromEvent(window, 'resize').debounceTime(100).subscribe(() => this.windowHeight = window.innerHeight); |
| } |
| |
| initAgGrid() { |
| const localGridOptions = <GridOptions>{ |
| columnDefs: GridMeasuresAgGridConfiguration.createColumnDefs(this.sessionContext) |
| }; |
| this.gridOptions = Object.assign(this.globalGridOptions, localGridOptions); |
| } |
| |
| async retrieveData() { |
| |
| if (this.statusMainFilter.item.onlyUsersGMsDesired === true) { |
| this.statusMainFilter.item.isCanceledStatusActive = false; |
| this.statusMainFilter.item.isClosedStatusActive = false; |
| } |
| |
| await this.reminderService.getCurrentReminders().subscribe(currentrems => { |
| this.sessionContext.setCurrentReminders(currentrems); |
| }, error => { |
| console.log(error); |
| this.toasterMessageService.showError(ErrorType.retrieve, this.gridId, error); |
| }); |
| |
| await this.reminderService.getExpiredReminders().subscribe(expiredrems => { |
| this.sessionContext.setExpiredReminders(expiredrems); |
| }, error => { |
| console.log(error); |
| this.toasterMessageService.showError(ErrorType.retrieve, this.gridId, error); |
| }); |
| |
| this.gridMeasureService.getGridMeasures(this.statusMainFilter).subscribe(gms => { |
| this.gridmeasures = gms; |
| this.showSpinner = false; |
| }, error => { |
| console.log(error); |
| this.toasterMessageService.showError(ErrorType.retrieve, this.gridId, error); |
| }); |
| |
| this.sessionContext.setStatusMainFilter(this.statusMainFilter); |
| |
| if (this.gridApi) { |
| setTimeout(() => { |
| this.gridApi.setFilterModel(this.filteringSearchText); |
| this.gridApi.onFilterChanged(); |
| }, 1000); |
| } |
| } |
| |
| setDirty() { |
| this.settingsIsDirty = true; |
| this.sessionContext.setFilterDirtyState(true); |
| } |
| |
| calcGridHeight(): number { |
| const gridOffset = document.getElementsByTagName('ag-grid-angular')[0].getBoundingClientRect().top; |
| const appOffset = 130; |
| |
| return this.windowHeight - appOffset - gridOffset; |
| } |
| |
| changeAllSelection(): void { |
| if (this.selectAll) { |
| for (const info of this.gridmeasures) { |
| info.selected = true; |
| } |
| } else { |
| for (const info of this.gridmeasures) { |
| info.selected = false; |
| } |
| } |
| } |
| } |