1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { UsageStatsSummary } from '../../../domain/typeScriptClasses';
|
3
|
import { AuthenticationService } from '../../../services/authentication.service';
|
4
|
import { StatisticsService } from '../../../services/statistics.service';
|
5
|
import { Router } from '@angular/router';
|
6
|
|
7
|
@Component ({
|
8
|
selector: 'app-landing',
|
9
|
templateUrl: './home.component.html',
|
10
|
styleUrls: ['../../../../assets/css/landingpage/theme.css','../../../../assets/css/landingpage/custom.css','../../../../assets/css/landingpage/custom-provide.css'],
|
11
|
})
|
12
|
|
13
|
export class HomeComponent implements OnInit {
|
14
|
|
15
|
statisticsNumbers: UsageStatsSummary;
|
16
|
inBeta: boolean;
|
17
|
|
18
|
|
19
|
constructor(private authService: AuthenticationService,
|
20
|
private statsService: StatisticsService,
|
21
|
private router: Router) { }
|
22
|
|
23
|
ngOnInit() {
|
24
|
this.getStatisticsNumbers();
|
25
|
|
26
|
const baseUrl = window.location.origin;
|
27
|
this.inBeta = ( baseUrl.includes('beta') || baseUrl.includes('athenarc') );
|
28
|
|
29
|
let body = document.getElementsByTagName('body')[0];
|
30
|
body.classList.remove("dashboard");
|
31
|
body.classList.add("landing");
|
32
|
}
|
33
|
|
34
|
|
35
|
login() {
|
36
|
this.authService.loginWithState();
|
37
|
}
|
38
|
|
39
|
getStatisticsNumbers() {
|
40
|
this.statsService.getStatisticsNumbers().subscribe(
|
41
|
res => {
|
42
|
this.statisticsNumbers = res;
|
43
|
// this.statisticsNumbers.lastYearUsagestats = JSON.parse(res['lastYearUsagestats'].toString());
|
44
|
},
|
45
|
error => console.log(error),
|
46
|
() => {
|
47
|
console.log('statisticsNumbers is', JSON.stringify(this.statisticsNumbers));
|
48
|
}
|
49
|
);
|
50
|
}
|
51
|
|
52
|
goToPage(pageUrl: string) {
|
53
|
if (this.authService.getIsUserLoggedIn()) {
|
54
|
this.router.navigate([pageUrl]);
|
55
|
} else {
|
56
|
this.authService.redirectUrl = pageUrl;
|
57
|
this.login();
|
58
|
}
|
59
|
}
|
60
|
|
61
|
}
|