import { Component, OnInit, Input } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { DashboardService } from '../../app/services/dashboard/dashboard.service'; import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel'; import { JsonSerializer } from '../utilities/JsonSerializer'; import { AuthService } from '../services/auth/auth.service'; @Component({ selector: 'homepage', templateUrl: './homepage.component.html', styleUrls: ['./homepage.component.css'], }) export class HomepageComponent implements OnInit { public userInfo: any; public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); constructor( private route: ActivatedRoute, private router: Router, private dashBoardService: DashboardService, private authentication: AuthService ) { this.dashboardStatisticsData.totalDataManagementPlanCount = 0; this.dashboardStatisticsData.totalDataSetCount = 0; this.dashboardStatisticsData.totalProjectCount = 0; } ngOnInit() { if (!this.isAuthenticated()) { this.dashBoardService.getStatistics().subscribe(results => { //let data = results['payload']; this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); }) } else { this.dashBoardService.getStatisticsSpecificuser().subscribe(results => { this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); }) } } public isAuthenticated(): boolean { return !(!this.authentication.current()) } }