Project

General

Profile

« Previous | Next » 

Revision 58825

Working on the new version of the oso. Work on the home page almost done

View differences:

home.component.ts
1 1
import { Component, DoCheck, OnInit, ViewEncapsulation } from '@angular/core';
2 2
import { DataService } from '../../services/data.service';
3 3
import { CountryOverview, OverviewData } from '../../domain/overview-data';
4
import {CountryOverviewData, EuropeData, SelectedCountry} from '../../domain/overview-map-data';
5
import {DataHandlerService} from '../../services/data-handler.service';
4 6

  
5 7
@Component({
6 8
  selector: 'app-home',
7 9
  templateUrl: './home.component.html',
8
  // styleUrls: ['./top-menu.component.css'],
9
  encapsulation: ViewEncapsulation.None
10 10
})
11 11

  
12 12
export class HomeComponent implements OnInit {
13 13

  
14
  overviewData: OverviewData;
14
  // overviewData: OverviewData;
15 15

  
16
  countrySelectedName: string = null;
17
  countrySelectedOverview: CountryOverview = null;
16
  europeOverviewData: EuropeData;
18 17

  
19
  constructor(private dataService: DataService) { }
18
  selectedCountry: SelectedCountry = null;
19
  selectedCountryData: CountryOverviewData = null;
20 20

  
21
  // countrySelectedName: string = null;
22
  // countrySelectedOverview: CountryOverview = null;
23

  
24
  constructor(private dataService: DataService,
25
              private dataHandlerService: DataHandlerService) { }
26

  
21 27
  ngOnInit(): void {
22 28

  
23
    window.scroll(0,0);
29
    window.scroll(0, 0);
24 30

  
25
    this.dataService.getOverviewData().subscribe(
26
      overviewData => {
27
        this.overviewData = overviewData;
28
      },
29
      error => {
31
    this.dataService.getEuropeOverviewData().subscribe(
32
      rawData => {
33
        this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
34
      }, error => {
30 35
        console.log(error);
31 36
      }
32 37
    );
38

  
39
    // this.dataService.getOverviewData().subscribe(
40
    //   overviewData => {
41
    //     this.overviewData = overviewData;
42
    //   },
43
    //   error => {
44
    //     console.log(error);
45
    //   }
46
    // );
33 47
  }
34 48

  
35
  countrySelected(countryName: string) {
36
    // console.log('Country selected: ', countryName);
37
    this.countrySelectedName = countryName;
38
    this.countrySelectedOverview = this.overviewData.countries.filter(x => x.country === this.countrySelectedName)[0];
49
  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];
39 63
    // console.log('Country selected overview: ', this.countrySelectedOverview);
40 64
  }
41 65

  
42 66
  deselectCountry() {
43
    this.countrySelectedName = null;
44
    this.countrySelectedOverview = null;
67

  
68
    this.selectedCountry = null;
69
    this.selectedCountryData = null;
70

  
71
    // this.countrySelectedName = null;
72
    // this.countrySelectedOverview = null;
45 73
  }
46 74
}

Also available in: Unified diff