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,UpdateStatusOrderInput, 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"; import { ViewNotesModalComponent } from './view-notes-modal.component'; import { identity } from 'rxjs'; import { idLocale } from 'ngx-bootstrap'; @Component({ selector: 'viewOrderStatus', templateUrl: './view-order-status.component.html', styleUrls: ['./view-order-status.component.less'], 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; @ViewChild('viewNotesModal', {static: true}) viewNotesModal: ViewNotesModalComponent @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() zIndex = new EventEmitter() // @Output() collectionOfCode = new EventEmitter(); @Input() orderId:number; @Input() scrollHeight: string @Input() type: string @Input() track: 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; color: any }> = new Array(); timeArray : Array<{ code: any; time: any; }> = new Array(); rowGroupMetadata: any; _ukLocale:any; onLoadTimeZone:string; _isLab: boolean; public statusFunction: Function; constructor( injector: Injector, private id:ActivatedRoute, private _controllerOrderPackageAppService: ControllerOrderPackagesListServiceProxy, private _orderStatusAppService: OrderStatusServiceProxy, private _orderStatusTypeAppService : OrderStatusTypeServiceProxy, private viewContainerRef: ViewContainerRef, private _orderAppService: OrderServiceProxy, ) { super(injector); } ngOnInit(){ this._ukLocale = abp.features.isEnabled('App.DateFormatFeature.UKLocale'); this._isLab = abp.features.isEnabled('App.RouteDetails'); let timezone; if(this.track != null){ // console.log(this.orderId) this._orderAppService.getOrderRouteLocation(this.orderId) .subscribe(result => { this.onLoadTimeZone = result timezone = result // console.log(this.onLoadTimeZone) }) } this.getOrderStatus(); // this.id.paramMap.subscribe(params => { // this.orderPackageId = Number(params.get('id')); // }); // this.getOrderPackageDetail(); // console.log(this.orderId) // this.getOrderStatus(this.orderId) // console.log(this.orderId) // this.getOrderStatus(); } ngAfterViewInit(){ this.statusFunction = this.getOrderStatus.bind(this) } getOrderStatus(event?: LazyLoadEvent){ // console.log(this.orderId) // console.log(this.onLoadTimeZone) this.collectionLongLatCode=[] this._controllerOrderPackageAppService.getOrderStatusTotalCount( this.orderId ).subscribe(totalCount =>{ this.orderStatusTotalCount = totalCount console.log(this.orderStatusTotalCount+ "total count") 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.getGroupedOrderStatus( undefined, undefined, this.orderId, undefined, undefined, undefined, localStorage.getItem('timeZone') != null ? localStorage.getItem('timeZone') : undefined, // this.onLoadTimeZone != null ? this.onLoadTimeZone : this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getSkipCount(this.paginator, event), this.primengTableHelper.getMaxResultCount(this.paginator, event), ).pipe().subscribe(statusResult => { this.orderStatuses=statusResult.items; 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; // console.log(this.orderStatuses) // console.log(statusResult) 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, index: any){ var bounds = new google.maps.LatLngBounds(); bounds.extend(new google.maps.LatLng({lat: lat, lng: long})); this.getParentComponent().map.fitBounds(bounds) this.zIndex.emit(index); this.getParentComponent().map.setZoom(19) } deleteStatus(desc:string,id:number){ this.message.confirm( this.l('Are you sure you want to delete ' + desc + ' Status from this order '+this.orderId+' ?'), '', isConfirmed => { if (isConfirmed) { this.spinnerService.show(); this._orderStatusAppService.deleteOrderDetailStatus(id,this.orderId).pipe(finalize(() => this.spinnerService.hide())).subscribe(statusResult => { var data = new UpdateStatusOrderInput(); data.orderId = this.orderId; this._orderStatusAppService.updateCurrentOrderDetailStatus(data).pipe(finalize(() => this.spinnerService.hide())).subscribe(statusResult => { this.notify.info('Status successfully deleted.'); this.spinnerService.hide(); this.getOrderStatus(); }); }); } } ); } }