argos/dmp-frontend/src/app/homepage/homepage.component.ts

51 lines
1.6 KiB
TypeScript
Raw Normal View History

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';
@Component({
selector: 'homepage',
templateUrl: './homepage.component.html',
styleUrls: ['./homepage.component.css'],
})
2017-12-19 18:34:00 +01:00
export class HomepageComponent implements OnInit {
2017-11-16 18:07:27 +01:00
2018-07-11 15:47:36 +02:00
public userInfo: any;
public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel();
2017-12-19 18:34:00 +01:00
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
2018-05-28 11:50:42 +02:00
}