import { Component, Injector, OnInit, ViewChild, ViewEncapsulation, Input, OnChanges, 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 { 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 status_icon from './status_icon.json'; import { ControllerRoutesService } from '@app/sprintship/controller/routes/croutes.service'; import { ControllerHeaderFlyoutComponent } from '@app/shared/layout/flyout/controller-header/controller-header-flyout.component'; @Component({ selector: 'kpi-laboratory', templateUrl: './kpi-laboratory.component.html', encapsulation: ViewEncapsulation.None, styleUrls: ['./kpi-laboratory.component.less'], animations: [appModuleAnimation()], providers: [ControllerRoutesService] }) export class KpiLaboratoryComponent extends AppComponentBase implements OnInit { hide : boolean; @ViewChild('controllerHeaderFlyoutComponent', { static: false }) controllerHeaderFlyoutComponent: ControllerHeaderFlyoutComponent; @Input('statistics') statistics: { total_routes: number, total_stops: number }; status_value: any; completed_stops: number; total_stops: number; completed_routes: number; total_routes: number; completed_callins: number; total_callins: number; total_incidents: number; unassigned_routes: number; unassigned_stops: number; assigned_not_check_in: number; late_past_20: number; late_past_30: number; unassigned_routes_ids: any; not_check_in_routes_ids: any; completed_route_ids: any; unassigned_stop_ids: any; completed_stops_id: any; completed_call_in_stops_ids: any; active_unassigned: boolean; active_notcheckin: boolean; active_completedroutes: boolean; constructor( injector: Injector, private _routeService: RouteServiceProxy, private _cRoutesService: ControllerRoutesService, private viewContainerRef: ViewContainerRef ) { super(injector); this.total_routes = 0; this.total_stops = 0; this.total_callins = 0; this.completed_routes = 0; this.completed_stops = 0; this.completed_callins = 0; this.total_incidents = 0; this.unassigned_routes = 0; this.unassigned_stops = 0; this.assigned_not_check_in = 0; this.late_past_20 = 0; this.late_past_30 = 0; this.unassigned_routes_ids = []; this.not_check_in_routes_ids = []; this.completed_route_ids = []; this.unassigned_stop_ids = []; this.completed_stops_id = []; this.completed_call_in_stops_ids = []; this.active_unassigned = false; this.active_notcheckin = false; this.active_completedroutes = false; } ngOnInit(): void { } onShown(): void { } getParentComponent() { return this.viewContainerRef['_data'].componentView.component.viewContainerRef['_view'].component } getStatistics(result: any): void { this.total_routes = result.total_routes; this.total_stops = result.total_stops; this.total_callins = result.total_callins; this.completed_routes = result.total_completed_routes; this.completed_stops = result.completed_stops; this.completed_callins = result.completed_callins; this.unassigned_routes = result.total_unassigned_routes; this.unassigned_stops = result.total_unassigned_stops; this.assigned_not_check_in = result.total_not_checkin; this.late_past_20 = result.total_twenty_minutes; this.late_past_30 = result.total_thirty_minutes; this.unassigned_routes_ids = result.unassigned_routes_ids; this.not_check_in_routes_ids = result.not_check_in_routes_ids; this.completed_route_ids = result.completed_route_ids; this.unassigned_stop_ids = result.unassigned_stop_ids; this.completed_stops_id = result.completed_stops_id; this.completed_call_in_stops_ids = result.completed_call_in_stops_ids; } ngOnChanges(): void { } clearFilter(): void { $('.filter-right').removeClass('active'); this.getParentComponent().filters.routeIds = []; this.active_unassigned = false; this.active_completedroutes = false; this.active_notcheckin = false; // this.getParentComponent().filterRoutes(); } filterKPI(boxType: string, obj: any): void { console.log($('.kpi-box-value a')); console.log($(this)) $('.filter-right').removeClass('active'); this.getParentComponent().kpiClick = true; switch (boxType) { case 'UNASSIGNED_ROUTES': this.active_completedroutes = false; this.active_notcheckin = false; this.getParentComponent().staticTabs.tabs[0].active = true; if(this.unassigned_routes > 0) { if(this.active_unassigned == false) { $('.filter-right-routes-unassigned').addClass('active'); this.getParentComponent().filters.routeIds = this.unassigned_routes_ids; this.getParentComponent().filterRoutes(); this.active_unassigned = true; } else { this.active_unassigned = false; this.getParentComponent().filters.routeIds = []; this.getParentComponent().filterRoutes(); } this.getParentComponent().staticTabs.tabs[0].active = true; } break; case 'NOT_CHECK_IN': this.active_unassigned = false; this.active_completedroutes = false; this.getParentComponent().staticTabs.tabs[0].active = true; if(this.assigned_not_check_in > 0) { if(this.active_notcheckin == false) { $('.filter-right-routes-notcheckin').addClass('active'); this.getParentComponent().filters.routeIds = this.not_check_in_routes_ids; this.getParentComponent().filterRoutes(); this.active_notcheckin = true; } else { this.getParentComponent().filters.routeIds = []; this.getParentComponent().filterRoutes(); this.active_notcheckin = false; } } break; case 'COMPLETED_ROUTES': this.active_unassigned = false; this.active_notcheckin = false; this.getParentComponent().staticTabs.tabs[0].active = true; if(this.completed_routes > 0) { if(this.active_completedroutes == false) { $('.filter-right-routes-completed').addClass('active'); this.getParentComponent().filters.routeIds = this.completed_route_ids; this.getParentComponent().filterRoutes(); this.active_completedroutes = true; } else { this.getParentComponent().filters.routeIds = []; this.getParentComponent().filterRoutes(); this.active_completedroutes = false; } } break; case 'UNASSIGNED_ORDERS': let data = this.unassigned_stop_ids; this.getParentComponent().staticTabs.tabs[2].active = true; this.getParentComponent().filters.orderIds = data; this.getParentComponent().filterStops(data); break; case 'COMPLETED_STOPS': let dataCs = this.completed_stops_id; this.getParentComponent().staticTabs.tabs[2].active = true; this.getParentComponent().filters.orderIds = dataCs; this.getParentComponent().filterStops(dataCs); break; case 'COMPLETED_CALLIN': let dataCCs = this.completed_call_in_stops_ids; this.getParentComponent().staticTabs.tabs[2].active = true; this.getParentComponent().filters.orderIds = dataCCs; this.getParentComponent().filterStops(dataCCs); break; default: this.getParentComponent().staticTabs.tabs[0].active = true; this.getParentComponent().filters.routeIds = []; this.getParentComponent().filterRoutes(); break; } this.getParentComponent().kpiClick = false; console.log('DONE'); } }