import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, Input, ViewChildren } 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 { UnassignedPackageServiceProxy} 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, filter } from 'rxjs/operators'; import * as _ from 'lodash'; @Component({ selector: 'unassigned-packages', templateUrl: './unassigned.component.html', encapsulation: ViewEncapsulation.None, // styleUrls: ['./kpi-box.component.less'], animations: [appModuleAnimation()], providers: [UnassignedPackageServiceProxy] }) export class UnassignedPackagesComponent extends AppComponentBase implements OnInit{ @ViewChild('dataTable', {static: true}) dataTable: Table; @ViewChild('paginator', {static: true}) paginator: Paginator; @Input() filters: { locationFilter : number; startDate: Date; endDate: Date; }; locationFilter: number; startDate: Date; event: this; routeIds = []; routeId: any; unassignedDetails : any; constructor( injector: Injector, private _unassignedList: UnassignedPackageServiceProxy, private activatedRoute: ActivatedRoute ) { super(injector); } ngOnInit(): void { this.getUnassignedRoutes(); } getUnassignedRoutes(): void { this.activatedRoute.paramMap.subscribe(params => { this.locationFilter = +params.get("location"); this.startDate = new Date(params.get("loadDate")); }); // this.startDate = new Date(this.startDate.toString()); // this.filters.endDate = new Date(this.filters.endDate.toString()); //let startDate = moment(moment(this.startDate).format('YYYY-MM-DD HH:mm:ss')); //let endDate = moment(moment(this.filters.endDate).format('YYYY-MM-DD HH:mm:ss')); // let startDateA = startDate['_i'].split(' '); // startDateA = startDateA[0] + ' ' + '23:59:59'; // let endDateA = endDate['_i'].split(' '); // endDateA = endDateA[0] + ' ' + '23:59:59'; // let startDate2 = moment.utc(moment(startDateA).toISOString()); // let endDate2 = moment.utc(moment(endDateA).toISOString()); this.spinnerService.show(); this._unassignedList.getUnassignedRoutes( this.locationFilter, moment(this.startDate), moment(this.startDate), undefined, undefined, undefined ).subscribe(result => { // this.unassignedDetails = _.groupBy(result, function(d) // { // return d.routeId // }); for (var key in result) { this.routeIds.push(result[key].routeId); } }); } getUnassignedOrders(event): void { this.routeId = event.originalEvent.target.innerText.split(':').pop(); this._unassignedList.getUnassignedOrders( this.routeId, undefined, undefined, undefined ).subscribe(result => { this.primengTableHelper.records = result; }); } }