import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, Input, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppConsts } from '@shared/AppConsts';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import { RouteListDto, RouteServiceProxy } from '@shared/service-proxies/service-proxies';

import * as moment from 'moment';
import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent';
import { Paginator } from 'primeng/components/paginator/paginator';
import { Table } from 'primeng/components/table/table';
import { HttpClient } from '@angular/common/http';
import { finalize } from 'rxjs/operators';
import * as _ from 'lodash';
declare var $: any;
declare var jquery:any;
@Component({
    selector: 'table-details',
    templateUrl: 'table-details.component.html',
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()]
})

export class TableComponents extends AppComponentBase implements OnInit, OnDestroy {

    @Input() headers;
    @Input() details;
    @Input() columns;
    @Input() filters: {
        locationFilter: number;
        statusFilter: number;
        typeFilter: number;
        startDate: Date;
        endDate: Date;
    } = <any>{};
	constructor(
        injector: Injector,
        private _routeService: RouteServiceProxy
        
    ) {
        super(injector);
    }

    ngOnInit(): void {
       this.primengTableHelper.defaultRecordsCountPerPage = 10;
       this.primengTableHelper.records = this.details.items;
       this.primengTableHelper.totalRecordsCount = Object.keys(this.details.items).length;
       console.log('FILTERS VALUE: ');
       console.log(this.filters);

    }

    ngOnDestroy(): void {

    }
    populateTable()
    {
       console.log(this.filters);
       this.primengTableHelper.defaultRecordsCountPerPage = 10;
       this.primengTableHelper.records = this.details.items;
       this.primengTableHelper.totalRecordsCount = Object.keys(this.details.items).length;
    }
}