1 |
57592
|
stefania.m
|
import { Component, DoCheck, OnInit, ViewEncapsulation } from '@angular/core';
|
2 |
|
|
import { DataService } from '../../services/data.service';
|
3 |
57732
|
stefania.m
|
import { CountryOverview, OverviewData } from '../../domain/overview-data';
|
4 |
58825
|
stefania.m
|
import {CountryOverviewData, EuropeData, SelectedCountry} from '../../domain/overview-map-data';
|
5 |
|
|
import {DataHandlerService} from '../../services/data-handler.service';
|
6 |
57592
|
stefania.m
|
|
7 |
|
|
@Component({
|
8 |
|
|
selector: 'app-home',
|
9 |
|
|
templateUrl: './home.component.html',
|
10 |
|
|
})
|
11 |
|
|
|
12 |
|
|
export class HomeComponent implements OnInit {
|
13 |
|
|
|
14 |
58825
|
stefania.m
|
// overviewData: OverviewData;
|
15 |
57592
|
stefania.m
|
|
16 |
58825
|
stefania.m
|
europeOverviewData: EuropeData;
|
17 |
57592
|
stefania.m
|
|
18 |
58825
|
stefania.m
|
selectedCountry: SelectedCountry = null;
|
19 |
|
|
selectedCountryData: CountryOverviewData = null;
|
20 |
57592
|
stefania.m
|
|
21 |
58825
|
stefania.m
|
// countrySelectedName: string = null;
|
22 |
|
|
// countrySelectedOverview: CountryOverview = null;
|
23 |
|
|
|
24 |
|
|
constructor(private dataService: DataService,
|
25 |
|
|
private dataHandlerService: DataHandlerService) { }
|
26 |
|
|
|
27 |
57592
|
stefania.m
|
ngOnInit(): void {
|
28 |
57746
|
stefania.m
|
|
29 |
58825
|
stefania.m
|
window.scroll(0, 0);
|
30 |
57746
|
stefania.m
|
|
31 |
58825
|
stefania.m
|
this.dataService.getEuropeOverviewData().subscribe(
|
32 |
|
|
rawData => {
|
33 |
|
|
this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
|
34 |
|
|
}, error => {
|
35 |
57592
|
stefania.m
|
console.log(error);
|
36 |
|
|
}
|
37 |
|
|
);
|
38 |
58825
|
stefania.m
|
|
39 |
|
|
// this.dataService.getOverviewData().subscribe(
|
40 |
|
|
// overviewData => {
|
41 |
|
|
// this.overviewData = overviewData;
|
42 |
|
|
// },
|
43 |
|
|
// error => {
|
44 |
|
|
// console.log(error);
|
45 |
|
|
// }
|
46 |
|
|
// );
|
47 |
57592
|
stefania.m
|
}
|
48 |
|
|
|
49 |
58825
|
stefania.m
|
countrySelected(selectedCountry: SelectedCountry) {
|
50 |
|
|
this.selectedCountry = selectedCountry;
|
51 |
|
|
this.selectedCountryData = null;
|
52 |
|
|
|
53 |
|
|
this.dataService.getCountryOverviewData(this.selectedCountry.code).subscribe(
|
54 |
|
|
rawData => {
|
55 |
|
|
this.selectedCountryData = this.dataHandlerService.convertRawDataToCountryOverviewData(rawData);
|
56 |
|
|
}, error => {
|
57 |
|
|
console.log(error);
|
58 |
|
|
}
|
59 |
|
|
);
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
// this.countrySelectedOverview = this.overviewData.countries.filter(x => x.country === this.selectedCountry.name)[0];
|
63 |
57732
|
stefania.m
|
// console.log('Country selected overview: ', this.countrySelectedOverview);
|
64 |
57592
|
stefania.m
|
}
|
65 |
|
|
|
66 |
|
|
deselectCountry() {
|
67 |
58825
|
stefania.m
|
|
68 |
|
|
this.selectedCountry = null;
|
69 |
|
|
this.selectedCountryData = null;
|
70 |
|
|
|
71 |
|
|
// this.countrySelectedName = null;
|
72 |
|
|
// this.countrySelectedOverview = null;
|
73 |
57592
|
stefania.m
|
}
|
74 |
|
|
}
|