1 |
58904
|
stefania.m
|
import { Component, OnInit } from '@angular/core';
|
2 |
57592
|
stefania.m
|
import { DataService } from '../../services/data.service';
|
3 |
58912
|
stefania.m
|
import { CountryOverviewData, EuropeData, SelectedCountry } from '../../domain/overview-map-data';
|
4 |
|
|
import { DataHandlerService } from '../../services/data-handler.service';
|
5 |
|
|
import { countries } from '../../domain/countries';
|
6 |
|
|
import { Router } from '@angular/router';
|
7 |
57592
|
stefania.m
|
|
8 |
|
|
@Component({
|
9 |
|
|
selector: 'app-home',
|
10 |
|
|
templateUrl: './home.component.html',
|
11 |
|
|
})
|
12 |
|
|
|
13 |
|
|
export class HomeComponent implements OnInit {
|
14 |
|
|
|
15 |
58825
|
stefania.m
|
europeOverviewData: EuropeData;
|
16 |
57592
|
stefania.m
|
|
17 |
58825
|
stefania.m
|
selectedCountry: SelectedCountry = null;
|
18 |
|
|
selectedCountryData: CountryOverviewData = null;
|
19 |
57592
|
stefania.m
|
|
20 |
58904
|
stefania.m
|
leadingOpenScienceData: CountryOverviewData[];
|
21 |
58825
|
stefania.m
|
|
22 |
58912
|
stefania.m
|
countriesCollection = countries;
|
23 |
|
|
keyword = 'name';
|
24 |
|
|
|
25 |
58825
|
stefania.m
|
constructor(private dataService: DataService,
|
26 |
58912
|
stefania.m
|
private dataHandlerService: DataHandlerService,
|
27 |
|
|
private router: Router) { }
|
28 |
58825
|
stefania.m
|
|
29 |
57592
|
stefania.m
|
ngOnInit(): void {
|
30 |
57746
|
stefania.m
|
|
31 |
58825
|
stefania.m
|
window.scroll(0, 0);
|
32 |
57746
|
stefania.m
|
|
33 |
58912
|
stefania.m
|
// const searchIcon = document.getElementById('search-icon');
|
34 |
|
|
// const inputContainer = document.getElementsByClassName('input-container')[0];
|
35 |
|
|
// inputContainer.insertAdjacentElement('afterbegin', searchIcon);
|
36 |
|
|
|
37 |
58825
|
stefania.m
|
this.dataService.getEuropeOverviewData().subscribe(
|
38 |
|
|
rawData => {
|
39 |
|
|
this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
|
40 |
|
|
}, error => {
|
41 |
57592
|
stefania.m
|
console.log(error);
|
42 |
|
|
}
|
43 |
|
|
);
|
44 |
58825
|
stefania.m
|
|
45 |
58904
|
stefania.m
|
this.dataService.getLeadingOpenScienceMobileData().subscribe(
|
46 |
|
|
rawData => {
|
47 |
|
|
this.leadingOpenScienceData = this.dataHandlerService.convertRawDataToLeadingOpenScienceData(rawData);
|
48 |
|
|
}, error => {
|
49 |
|
|
console.log(error);
|
50 |
|
|
}
|
51 |
|
|
);
|
52 |
57592
|
stefania.m
|
}
|
53 |
|
|
|
54 |
58825
|
stefania.m
|
countrySelected(selectedCountry: SelectedCountry) {
|
55 |
|
|
this.selectedCountry = selectedCountry;
|
56 |
|
|
this.selectedCountryData = null;
|
57 |
|
|
|
58 |
|
|
this.dataService.getCountryOverviewData(this.selectedCountry.code).subscribe(
|
59 |
|
|
rawData => {
|
60 |
|
|
this.selectedCountryData = this.dataHandlerService.convertRawDataToCountryOverviewData(rawData);
|
61 |
|
|
}, error => {
|
62 |
|
|
console.log(error);
|
63 |
|
|
}
|
64 |
|
|
);
|
65 |
57592
|
stefania.m
|
}
|
66 |
|
|
|
67 |
|
|
deselectCountry() {
|
68 |
58825
|
stefania.m
|
this.selectedCountry = null;
|
69 |
|
|
this.selectedCountryData = null;
|
70 |
57592
|
stefania.m
|
}
|
71 |
58912
|
stefania.m
|
|
72 |
|
|
|
73 |
|
|
selectCountryFromAutocompleteEvent(item) {
|
74 |
|
|
// do something with selected item
|
75 |
|
|
// console.log('country selected: ', item);
|
76 |
|
|
this.router.navigate([`/countryDashboard/${item.id}`]);
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
onChangeSearch(search: string) {
|
80 |
|
|
// fetch remote data from here
|
81 |
|
|
// And reassign the 'data' which is binded to 'data' property.
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
onFocused(e) {
|
85 |
|
|
// do something
|
86 |
|
|
}
|
87 |
57592
|
stefania.m
|
}
|