Project

General

Profile

« Previous | Next » 

Revision 60197

[Usage-Counts | Trunk]: Fix search bug on alalytics. Change loading

View differences:

home.component.ts
1
import {Component, OnInit, ViewChild} from '@angular/core';
1
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
2 2
import {ActivatedRoute, Router} from '@angular/router';
3 3
import {Meta, Title} from '@angular/platform-browser';
4 4
import {FullPageSliderComponent} from '../openaireLibrary/utils/full-page-slider/full-page-slider.component';
5 5
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
6
import {Subscription} from 'rxjs';
6
import {Subscriber, Subscription} from 'rxjs';
7 7
import {properties} from '../../environments/environment';
8 8
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
9 9
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
......
13 13
  templateUrl: 'home.component.html',
14 14
  styleUrls: ['home.component.css'],
15 15
})
16
export class HomeComponent implements OnInit{
16
export class HomeComponent implements OnInit, OnDestroy {
17 17
  
18 18
  public initSlide: number = 1;
19 19
  public fragments: string[] = ['', 'why', 'who', 'features'];
20
  @ViewChild("slider")
20
  @ViewChild('slider')
21 21
  public slider: FullPageSliderComponent;
22 22
  properties: EnvProperties = properties;
23

  
23
  
24 24
  subs: Subscription[] = [];
25
  
25 26
  constructor(private route: ActivatedRoute,
26 27
              private router: Router,
27 28
              private _title: Title, private _piwikService: PiwikService,
28 29
              private _meta: Meta, private seoService: SEOService
29
  ) {}
30
  ) {
31
  }
30 32
  
31
  ngOnInit()
32
  {
33
    let description = "UsageCounts service collects usage data from Open Science content providers repositories, journals, and other scientific data sources. Then, it aggregates them, delivering standardized activity reports about research usage and uptake. It complements existing citation mechanisms and assists institutional repository managers, research communities, research organizations, funders, and policy makers to track and evaluate research from an early stage.";
34
    let title = "OpenAIRE - UsageCounts";
33
  ngOnInit() {
34
    let description = 'UsageCounts service collects usage data from Open Science content providers repositories, journals, and other scientific data sources. Then, it aggregates them, delivering standardized activity reports about research usage and uptake. It complements existing citation mechanisms and assists institutional repository managers, research communities, research organizations, funders, and policy makers to track and evaluate research from an early stage.';
35
    let title = 'OpenAIRE - UsageCounts';
35 36
    this._title.setTitle(title);
36
    this._meta.updateTag({content: description}, "name='description'");
37
    this._meta.updateTag({content: description}, "property='og:description'");
38
    this._meta.updateTag({content: title}, "property='og:title'");
37
    this._meta.updateTag({content: description}, 'name=\'description\'');
38
    this._meta.updateTag({content: description}, 'property=\'og:description\'');
39
    this._meta.updateTag({content: title}, 'property=\'og:title\'');
39 40
    this._title.setTitle(title);
40 41
    let url = this.properties.domain + this.properties.baseLink + this.router.url;
41 42
    this.seoService.createLinkForCanonicalURL(url, false);
42
    this._meta.updateTag({content: url}, "property='og:url'");
43
    this._meta.updateTag({content: url}, 'property=\'og:url\'');
43 44
    if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
44 45
      this.subs.push(this._piwikService.trackView(this.properties, title).subscribe());
45 46
    }
46 47
    this.subs.push(this.route.fragment.subscribe(name => {
47
      if(name) {
48
      if (name) {
48 49
        let slide = this.fragments.findIndex(fragment => fragment === name) + 1;
49
        if(slide > 0) {
50
        if (slide > 0) {
50 51
          this.initSlide = slide;
51 52
        }
52 53
      }
53 54
    }));
54 55
    this.subs.push(this.slider.stateAsObservable.subscribe(state => {
55
      if(state == 1) {
56
      if (state == 1) {
56 57
        this.router.navigate(['/']);
57 58
      } else {
58 59
        this.router.navigate(['/'], {fragment: this.fragments[state - 1]});
59 60
      }
60 61
    }));
61 62
  }
63
  
62 64
  public ngOnDestroy() {
63
    for (let sub of this.subs) {
64
      sub.unsubscribe();
65
    }
65
    this.subs.forEach(subscription => {
66
      if (subscription instanceof Subscriber) {
67
        subscription.unsubscribe();
68
      }
69
    });
66 70
  }
67

  
71
  
68 72
}

Also available in: Unified diff