51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
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 '@app/services/auth/auth.service';
|
|
|
|
@Component({
|
|
selector: 'homepage',
|
|
templateUrl: './homepage.component.html',
|
|
styleUrls: ['./homepage.component.css'],
|
|
providers: []
|
|
})
|
|
export class HomepageComponent implements OnInit {
|
|
|
|
private userInfo: any;
|
|
private 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())
|
|
}
|
|
|
|
} |