2021-01-07 18:01:02 +01:00
import { Component , HostListener , OnDestroy , OnInit } from '@angular/core' ;
2020-11-16 13:50:52 +01:00
import { Meta , Title } from '@angular/platform-browser' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties' ;
import { properties } from '../../environments/environment' ;
2021-01-07 18:01:02 +01:00
import { Subscriber , Subscription } from 'rxjs' ;
2020-11-16 13:50:52 +01:00
import { PiwikService } from '../openaireLibrary/utils/piwik/piwik.service' ;
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service' ;
2020-06-15 17:26:14 +02:00
@Component ( {
selector : 'resources' ,
templateUrl : 'resources.component.html' ,
styleUrls : [ 'resources.component.css' ] ,
} )
2021-01-07 18:01:02 +01:00
export class ResourcesComponent implements OnInit , OnDestroy {
2020-11-16 13:50:52 +01:00
properties : EnvProperties = properties ;
description = "OpenAIRE Provide. The resources of the OpenAIRE UsageCounts Service are available through the OpenAIRE PROVIDE product, which is serving the content providers. APIs and Reports." ;
title = "OpenAIRE - UsageCounts | Resources" ;
subs : Subscription [ ] = [ ] ;
2020-11-30 12:02:20 +01:00
large : boolean = false ;
2020-11-16 13:50:52 +01:00
constructor ( private router : Router ,
private _title : Title , private _piwikService : PiwikService ,
private _meta : Meta , private seoService : SEOService ,
2020-09-16 11:33:56 +02:00
private route : ActivatedRoute ) {
2020-09-14 17:09:23 +02:00
}
2020-11-30 12:02:20 +01:00
@HostListener ( 'window:resize' , [ '$event' ] )
onResize ( event ) {
if ( event . target . innerWidth > 959 && this . large === false ) {
this . large = true ;
} else if ( event . target . innerWidth < 960 && this . large === true ) {
this . large = false ;
}
}
2020-09-14 17:09:23 +02:00
ngOnInit() {
2020-11-30 12:10:06 +01:00
if ( typeof window !== 'undefined' ) {
this . large = window . innerWidth > 959 ;
}
2020-11-16 13:50:52 +01:00
this . _title . setTitle ( this . title ) ;
this . _meta . updateTag ( { content : this.description } , "name='description'" ) ;
this . _meta . updateTag ( { content : this.description } , "property='og:description'" ) ;
this . _meta . updateTag ( { content : this.title } , "property='og:title'" ) ;
this . _title . setTitle ( this . title ) ;
let url = this . properties . domain + this . properties . baseLink + this . router . url ;
this . seoService . createLinkForCanonicalURL ( url , false ) ;
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
this . subs . push ( this . _piwikService . trackView ( this . properties , this . title ) . subscribe ( ) ) ;
}
2020-09-14 17:09:23 +02:00
}
2021-01-07 18:01:02 +01:00
public ngOnDestroy() {
this . subs . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
}
2020-06-15 17:26:14 +02:00
}