1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { DataService } from '../../services/data.service';
|
3
|
import {CountryOverviewData, EuropeData, SelectedCountry} from '../../domain/overview-map-data';
|
4
|
import {DataHandlerService} from '../../services/data-handler.service';
|
5
|
|
6
|
@Component({
|
7
|
selector: 'app-home',
|
8
|
templateUrl: './home.component.html',
|
9
|
})
|
10
|
|
11
|
export class HomeComponent implements OnInit {
|
12
|
|
13
|
europeOverviewData: EuropeData;
|
14
|
|
15
|
selectedCountry: SelectedCountry = null;
|
16
|
selectedCountryData: CountryOverviewData = null;
|
17
|
|
18
|
leadingOpenScienceData: CountryOverviewData[];
|
19
|
|
20
|
constructor(private dataService: DataService,
|
21
|
private dataHandlerService: DataHandlerService) { }
|
22
|
|
23
|
ngOnInit(): void {
|
24
|
|
25
|
window.scroll(0, 0);
|
26
|
|
27
|
this.dataService.getEuropeOverviewData().subscribe(
|
28
|
rawData => {
|
29
|
this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
|
30
|
}, error => {
|
31
|
console.log(error);
|
32
|
}
|
33
|
);
|
34
|
|
35
|
this.dataService.getLeadingOpenScienceMobileData().subscribe(
|
36
|
rawData => {
|
37
|
this.leadingOpenScienceData = this.dataHandlerService.convertRawDataToLeadingOpenScienceData(rawData);
|
38
|
}, error => {
|
39
|
console.log(error);
|
40
|
}
|
41
|
);
|
42
|
}
|
43
|
|
44
|
countrySelected(selectedCountry: SelectedCountry) {
|
45
|
this.selectedCountry = selectedCountry;
|
46
|
this.selectedCountryData = null;
|
47
|
|
48
|
this.dataService.getCountryOverviewData(this.selectedCountry.code).subscribe(
|
49
|
rawData => {
|
50
|
this.selectedCountryData = this.dataHandlerService.convertRawDataToCountryOverviewData(rawData);
|
51
|
}, error => {
|
52
|
console.log(error);
|
53
|
}
|
54
|
);
|
55
|
}
|
56
|
|
57
|
deselectCountry() {
|
58
|
this.selectedCountry = null;
|
59
|
this.selectedCountryData = null;
|
60
|
}
|
61
|
}
|