import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, Input, ViewChildren, Output, EventEmitter, ViewContainerRef } 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 { OrderServiceProxy, OrderListDto, ControllerOrderPackagesListServiceProxy, OrderStatusServiceProxy, OrderStatusListDto, OrderStatusTypeServiceProxy } from '@shared/service-proxies/service-proxies'; // ControllerOrderPackagesListDto, 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, count, ignoreElements } from 'rxjs/operators'; import { formatDate } from "@angular/common"; @Component({ selector: 'viewOrderStatus', templateUrl: './view-order-status.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()], providers: [ControllerOrderPackagesListServiceProxy] }) export class ViewOrderStatusComponent extends AppComponentBase implements OnInit{ @ViewChild('dataTable', {static: true}) dataTable: Table; @ViewChild('paginator', {static: true}) paginator: Paginator; @Input() filters: { locationFilter : number; startDate: Date; endDate: Date } = < any > {}; filterText: string; @Output() viewOrderStatus = new EventEmitter(); @Output() longitudeFromOrderStatus = new EventEmitter(); @Output() latitudeFromOrderStatus = new EventEmitter(); @Output() collectionOfLongLatCode = new EventEmitter() // @Output() collectionOfCode = new EventEmitter(); @Input() orderId:number; @Input() scrollHeight: string @Input() type: string // @Output() statusEvent = new EventEmitter(); orderPackageId : number; // orderId:number orderPackageCustomer: string space=" "; latitude:number // orderPackage: ControllerOrderPackagesListDto = new ControllerOrderPackagesListDto(); orderStatuses: Array<{}> = new Array(); orderPackageDateAndTime: any orderStatusTypes: any formattedOrderPackageDateAndTime: any formattedOrderPackageStatusDateAndTime: any formattedOrderPackagePickupDetail: any formattedOrderPackageDeliveryDetail: any formattedOrderPackageStatusTime:any maxResultCount=1000; paginatorAccess: boolean event: LazyLoadEvent orderStatusTotalCount: any latitudeForMap: any longitudeForMap: any collection: Array = new Array(); collectionCode: Array = new Array(); mapAccess = false; collectionLongLatCode: Array<{ lat: any; long: any; code: any }> = new Array(); public statusFunction: Function; constructor( injector: Injector, private id:ActivatedRoute, private _controllerOrderPackageAppService: ControllerOrderPackagesListServiceProxy, private _orderStatusAppService: OrderStatusServiceProxy, private _orderStatusTypeAppService : OrderStatusTypeServiceProxy, private viewContainerRef: ViewContainerRef ) { super(injector); } ngOnInit(){ this.id.paramMap.subscribe(params => { this.orderPackageId = Number(params.get('id')); }); // this.getOrderPackageDetail(); // console.log(this.orderId) // this.getOrderStatus(this.orderId) } ngAfterViewInit(){ this.statusFunction = this.getOrderStatus.bind(this) } getOrderStatus(event?: LazyLoadEvent){ console.log(this.orderId) this._controllerOrderPackageAppService.getOrderStatusTotalCount( this.orderId ).subscribe(totalCount =>{ this.orderStatusTotalCount = totalCount if(this.orderStatusTotalCount > 10){ this.paginatorAccess = true console.log(this.paginatorAccess) if (this.primengTableHelper.shouldResetPaging(event)) { this.paginator.changePage(0); return; } this.spinnerService.show(); this._orderStatusAppService.getOrderStatus( undefined, undefined, this.orderId, undefined, undefined, undefined, this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getMaxResultCount(this.paginator, event), this.primengTableHelper.getSkipCount(this.paginator, event) ).pipe().subscribe(statusResult => { this.orderStatuses=statusResult.items; // this.formattedOrderPackageStatusTime=moment(statusResult.items['time']).utc().format('MM/DD/YYYY, h:mm a') this.primengTableHelper.totalRecordsCount = statusResult.totalCount; var bounds = new google.maps.LatLngBounds(); if(this.getParentComponent().map){ this.mapAccess= true for(let i=0 ; i this.spinnerService.hide())).subscribe(statusResult => { this.orderStatuses=statusResult.items; var bounds = new google.maps.LatLngBounds(); this.primengTableHelper.totalRecordsCount = statusResult.totalCount; if(this.getParentComponent().map){ this.mapAccess= true for(let i=0 ; i this.spinnerService.hide())).subscribe(result => { // this.orderStatusTypes=result.items; // }); // } mapZoom(lat: any , long: any){ var bounds = new google.maps.LatLngBounds(); bounds.extend(new google.maps.LatLng({lat: lat, lng: long})); this.getParentComponent().map.fitBounds(bounds) this.getParentComponent().map.setZoom(19) } }