import { Component, OnInit } from '@angular/core'; import { AccountService } from '../../accounts/accounts-services'; import { NotificationService } from '../../../_services/notification.service'; import { ReportingService } from '../reporting.service'; import { AuthenticationService } from '../../../_services/authentication.service'; import { LocalService } from '../../../_services/local.service'; @Component({ selector: 'app-heads-chart', templateUrl: './heads-chart.component.html', }) export class HeadsChartComponent implements OnInit { public preHeadsList: any[] = []; public heads1List: any[] = []; public heads2List: any[] = []; public loading = true; public data: any[] = []; constructor( public _accountService: AccountService, public _notificationService: NotificationService, public _reportingServices: ReportingService, public _authenticationService: AuthenticationService, private _localService: LocalService ) { } ngOnInit() { this.getPreHeads(); this.getEmployeelist(); } public getPreHeads() { this._accountService.getPreHeads().subscribe((res: any) => { if (res) { this.preHeadsList = res; } }, err => { }); } public getEmployeelist() { this._reportingServices.getHeadChartReport().subscribe( (response: any) => { console.log(response.res); this.loading = false; this.data = response.res; }, err => this.handleError(err) ); } private handleError(err: any) { if (err.status == 403) { this._authenticationService.logout(); } } public getHead1(e) { this._accountService.getHead1(e).subscribe((res: any) => { if (res) { this.heads1List = res; } }, err => { }); } public getHead2(e) { this._accountService.getHead2(e).subscribe((res: any) => { if (res) { this.heads2List = res; } }, err => { }); } }