Project

General

Profile

1
import {Component, OnInit} from '@angular/core';
2
import {faqs} from './faqs';
3
import {ActivatedRoute, Router} from '@angular/router';
4
import {Meta, Title} from '@angular/platform-browser';
5
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
6
import {properties} from '../../environments/environment';
7
import {Subscription} from 'rxjs';
8
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
9
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
10

    
11
@Component({
12
  selector: 'about',
13
  templateUrl: 'about.component.html',
14
  styleUrls: ['about.component.css'],
15
})
16
export class AboutComponent implements OnInit {
17
  faqs: any[] = faqs;
18
  properties: EnvProperties = properties;
19
  description = "UsageCounts service is an OpenAIRE service built after the development of the Usage Statistics Service within OpenAIRE. UsageCounts forms metrics of usage activity of Open Access Repositories categorizing the data retrieved by country, number of downloads, number of views, number of repositories and all derivative quantitative open metrics, in a comprehensive way for all stakeholders. Architecture. ";
20
  title = "OpenAIRE - UsageCounts | About";
21
  subs: Subscription[] = [];
22
  constructor(private route: ActivatedRoute,
23
              private router: Router,
24
              private _title: Title, private _piwikService: PiwikService,
25
              private _meta: Meta, private seoService: SEOService) {
26
  }
27
  
28
  ngOnInit() {
29
    this._title.setTitle(this.title);
30
    this._meta.updateTag({content: this.description}, "name='description'");
31
    this._meta.updateTag({content: this.description}, "property='og:description'");
32
    this._meta.updateTag({content: this.title}, "property='og:title'");
33
    this._title.setTitle(this.title);
34
    let url = this.properties.domain + this.properties.baseLink + this.router.url;
35
    this.seoService.createLinkForCanonicalURL(url, false);
36
    this._meta.updateTag({content: url}, "property='og:url'");
37
    if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
38
      this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
39
    }
40
    this.subs.push(this.route.fragment.subscribe(fragment => {
41
      setTimeout(() => {
42
        this.goTo(fragment);
43
      }, 100);
44
    }));
45
  }
46
  
47
  goTo(id: string) {
48
    const yOffset = -100;
49
    const element = document.getElementById(id);
50
    if(element) {
51
      const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
52
      window.scrollTo({top: y, behavior: 'smooth'});
53
    }
54
  }
55
  public ngOnDestroy() {
56
    for (let sub of this.subs) {
57
      sub.unsubscribe();
58
    }
59
  }
60
}
(3-3/5)