2018-03-01 10:14:10 +01:00
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
2017-11-16 18:07:27 +01:00
|
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
2017-12-15 12:52:11 +01:00
|
|
|
import { DashboardService } from '../../app/services/dashboard/dashboard.service';
|
|
|
|
import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel';
|
|
|
|
import { JsonSerializer } from '../utilities/JsonSerializer';
|
2018-05-14 08:44:35 +02:00
|
|
|
import { AuthService } from '../services/auth/auth.service';
|
2017-11-16 15:27:40 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'homepage',
|
|
|
|
templateUrl: './homepage.component.html',
|
|
|
|
styleUrls: ['./homepage.component.css'],
|
2017-12-19 18:34:00 +01:00
|
|
|
providers: []
|
2017-11-16 15:27:40 +01:00
|
|
|
})
|
2017-12-19 18:34:00 +01:00
|
|
|
export class HomepageComponent implements OnInit {
|
2017-11-16 18:07:27 +01:00
|
|
|
|
|
|
|
private userInfo: any;
|
2017-12-19 18:34:00 +01:00
|
|
|
private dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
2018-02-02 15:07:25 +01:00
|
|
|
private dashBoardService: DashboardService,
|
|
|
|
private authentication: AuthService
|
2017-12-19 18:34:00 +01:00
|
|
|
) {
|
2017-12-15 12:52:11 +01:00
|
|
|
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
|
|
|
this.dashboardStatisticsData.totalDataSetCount = 0;
|
|
|
|
this.dashboardStatisticsData.totalProjectCount = 0;
|
2017-11-16 18:07:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-19 18:34:00 +01:00
|
|
|
ngOnInit() {
|
|
|
|
|
2018-03-01 10:14:10 +01:00
|
|
|
if (!this.isAuthenticated()) {
|
2018-02-02 15:07:25 +01:00
|
|
|
this.dashBoardService.getStatistics().subscribe(results => {
|
|
|
|
//let data = results['payload'];
|
|
|
|
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
|
|
|
})
|
2018-03-01 10:14:10 +01:00
|
|
|
} else {
|
2018-02-02 15:07:25 +01:00
|
|
|
this.dashBoardService.getStatisticsSpecificuser().subscribe(results => {
|
|
|
|
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
|
|
|
})
|
|
|
|
}
|
2018-03-01 10:14:10 +01:00
|
|
|
|
2017-11-16 18:07:27 +01:00
|
|
|
|
2017-12-14 17:43:57 +01:00
|
|
|
}
|
2017-11-16 18:07:27 +01:00
|
|
|
|
2018-02-02 15:07:25 +01:00
|
|
|
public isAuthenticated(): boolean {
|
2018-03-01 10:14:10 +01:00
|
|
|
return !(!this.authentication.current())
|
|
|
|
}
|
2018-02-02 15:07:25 +01:00
|
|
|
|
2017-11-16 18:07:27 +01:00
|
|
|
}
|