| /* |
| ****************************************************************************** |
| * 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(); |
| |
| isCancelClosedFilterButtons: boolean; |
| |
| ngOnInit() { |
| super.ngOnInit(); |
| if (this.sessionContext.getStatusMainFilter() !== null) { |
| this.statusMainFilter = this.sessionContext.getStatusMainFilter(); |
| } |
| this.initAgGrid(); |
| Observable.fromEvent(window, 'resize').debounceTime(100).subscribe(() => this.windowHeight = window.innerHeight); |
| const rowsCount = Math.round(this.calcGridHeight() / this.gridOptions.rowHeight); |
| this.gridOptions.cacheBlockSize = rowsCount; |
| } |
| |
| 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, error); |
| }); |
| |
| await this.reminderService.getExpiredReminders().subscribe(expiredrems => { |
| this.sessionContext.setExpiredReminders(expiredrems); |
| }, error => { |
| console.log(error); |
| this.toasterMessageService.showError(ErrorType.retrieve, error); |
| }); |
| |
| this.sessionContext.setStatusMainFilter(this.statusMainFilter); |
| } |
| |
| setDirty() { |
| this.settingsIsDirty = true; |
| this.sessionContext.setFilterDirtyState(true); |
| } |
| |
| |
| |
| changeAllSelection(): void { |
| if (this.selectAll) { |
| for (const info of this.gridmeasures) { |
| info.selected = true; |
| } |
| } else { |
| for (const info of this.gridmeasures) { |
| info.selected = false; |
| } |
| } |
| } |
| } |