import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { CookieService } from 'ngx-cookie-service'; import { DashboardServicesService } from '../../../shared/services/dashboard-services.service'; import { IJobPlanSummary } from '../../../shared/core/IJobPlanSummary'; @Component({ selector: 'app-common-dashboard', templateUrl: './common-dashboard.component.html', styleUrls: ['./common-dashboard.component.css'], providers: [DashboardServicesService] }) export class CommonDashboardComponent implements OnInit { // Job plan summary totalJobPlanStatus: IJobPlanSummary[]; // Form data totalActiveForm: number; totalCompleteForm: number; totalArchive: number; totalDraft: number; totalJobPlans: number; constructor(private router: Router, private dashboardServicesService: DashboardServicesService,private cookieService: CookieService) { } ngOnInit() { // Get job plan summaries this.dashboardServicesService.GetTotalJobPlanStatus(+this.cookieService.get('CompanyId'), +this.cookieService.get('LoggedUserId')).subscribe( data => { this.totalJobPlanStatus = data; // console.log('Total Job Plan Status'); // console.log(this.totalJobPlanStatus); if (this.totalJobPlanStatus.length > 0) { this.totalActiveForm = this.totalJobPlanStatus[0].TotalActiveForm; this.totalCompleteForm = this.totalJobPlanStatus[0].TotalCompleteForm; this.totalArchive = this.totalJobPlanStatus[0].TotalArchive; this.totalDraft = this.totalJobPlanStatus[0].TotalDraft; this.totalJobPlans = this.totalJobPlanStatus[0].TotalJobPlans; } else { this.totalActiveForm = 0; this.totalCompleteForm = 0; this.totalArchive = 0; this.totalDraft = 0; this.totalJobPlans = 0; } } ); } goToUrl() { this.router.navigate(['/dataCollection']); } }