Project

General

Profile

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

    
11
@Component({
12
  selector: 'resources',
13
  templateUrl: 'resources.component.html',
14
  styleUrls: ['resources.component.css'],
15
})
16
export class ResourcesComponent implements OnInit, OnDestroy {
17
  properties:EnvProperties;
18
  subs: Subscription[] = [];
19
  description = "Start building with OpenAIRE APIs. How to access the graph?  XML Metadata  schema and documentation.";
20
  title = "OpenAIRE - Research Graph | Resources";
21
  public breadcrumbs: Breadcrumb[] = [
22
    {
23
      name: 'home',
24
      route: '/'
25
    },
26
    {
27
      name: 'resources'
28
    }
29
  ];
30
  
31
  constructor(private _title: Title, private route: ActivatedRoute, private _router: Router,
32
              private _piwikService:PiwikService,
33
              private _meta: Meta,  private seoService: SEOService) {
34
  }
35
  
36
  ngOnInit() {
37
    this.properties = properties;
38
    this._title.setTitle(this.title);
39
    this._meta.updateTag({content:this.description},"name='description'");
40
    this._meta.updateTag({content:this.description},"property='og:description'");
41
    this._meta.updateTag({content:this.title},"property='og:title'");
42
    var url = this.properties.domain + this.properties.baseLink+this._router.url;
43
    this.seoService.createLinkForCanonicalURL(url, false);
44
    this._meta.updateTag({content:url},"property='og:url'");
45
    if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
46
      this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
47
    }
48
  }
49
  
50
  public ngOnDestroy() {
51
    this.subs.forEach(sub => {
52
      if(sub instanceof Subscription) {
53
        sub.unsubscribe();
54
      }
55
    });
56
  }
57
}
(5-5/6)