2019-09-30 14:48:48 +02:00
import { Component } from '@angular/core' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { Meta , Title } from '@angular/platform-browser' ;
import { PiwikService } from '../openaireLibrary/utils/piwik/piwik.service' ;
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties' ;
import { HelperService } from "../openaireLibrary/utils/helper/helper.service" ;
import { SEOService } from "../openaireLibrary/sharedComponents/SEO/SEO.service" ;
2020-11-13 16:08:17 +01:00
import { properties } from "../../environments/environment" ;
import { Subscriber } from "rxjs" ;
2022-02-14 14:32:33 +01:00
import { Breadcrumb } from '../openaireLibrary/utils/breadcrumbs/breadcrumbs.component' ;
2022-05-09 12:39:45 +02:00
import { OpenaireEntities } from "../openaireLibrary/utils/properties/searchFields" ;
2019-09-30 14:48:48 +02:00
@Component ( {
selector : 'learn-how' ,
2020-06-03 23:55:32 +02:00
styleUrls : [ 'learn-how.component.css' ] ,
templateUrl : 'learn-how.component.html' ,
2019-09-30 14:48:48 +02:00
} )
export class LearnHowComponent {
public pageContents = null ;
public divContents = null ;
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
public url : string = null ;
2019-12-03 12:10:05 +01:00
public pageTitle : string = "OpenAIRE - Monitor | Learn How" ;
2020-11-16 17:28:16 +01:00
public description : string = "Learn the process: Use the Monitor Dashboard to view your research results, open science. See how it works. Simplify research tracking & monitoring " ;
2022-02-14 14:32:33 +01:00
public breadcrumbs : Breadcrumb [ ] = [ { name : 'home' , route : '/' } , { name : 'About' } ] ;
2022-05-09 12:39:45 +02:00
public entities = OpenaireEntities ;
public properties : EnvProperties = properties ;
2020-11-13 16:08:17 +01:00
subscriptions = [ ] ;
2019-09-30 14:48:48 +02:00
constructor (
private route : ActivatedRoute ,
private _router : Router ,
private _meta : Meta ,
private _title : Title ,
private seoService : SEOService ,
private _piwikService : PiwikService ,
2019-12-03 12:10:05 +01:00
private helper : HelperService ) {
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
public ngOnInit() {
2020-11-13 16:08:17 +01:00
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , this . pageTitle , this . properties . piwikSiteId ) . subscribe ( ) ) ;
}
this . url = this . properties . domain + this . properties . baseLink + this . _router . url ;
this . seoService . createLinkForCanonicalURL ( this . url ) ;
this . updateUrl ( this . url ) ;
this . updateTitle ( this . pageTitle ) ;
this . updateDescription ( "OpenAIRE - Monitor, Funders, Statistics, EC - Learn How" ) ; ` `
//this.getDivContents();
//this.getPageContents();
2019-09-30 14:48:48 +02:00
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
private getPageContents() {
2020-11-13 16:08:17 +01:00
this . subscriptions . push ( this . helper . getPageHelpContents ( this . properties , 'monitor' , this . _router . url ) . subscribe ( contents = > {
2019-09-30 14:48:48 +02:00
this . pageContents = contents ;
2020-11-13 16:08:17 +01:00
} ) ) ;
2019-09-30 14:48:48 +02:00
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
private getDivContents() {
2020-11-13 16:08:17 +01:00
this . subscriptions . push ( this . helper . getDivHelpContents ( this . properties , 'monitor' , this . _router . url ) . subscribe ( contents = > {
2019-09-30 14:48:48 +02:00
this . divContents = contents ;
2020-11-13 16:08:17 +01:00
} ) ) ;
2019-09-30 14:48:48 +02:00
}
2020-11-13 16:08:17 +01:00
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
2019-09-30 14:48:48 +02:00
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
private updateDescription ( description : string ) {
this . _meta . updateTag ( { content : description } , "name='description'" ) ;
this . _meta . updateTag ( { content : description } , "property='og:description'" ) ;
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
private updateTitle ( title : string ) {
var _title = ( ( title . length > 50 ) ? title . substring ( 0 , 50 ) : title ) ;
this . _title . setTitle ( _title ) ;
this . _meta . updateTag ( { content : _title } , "property='og:title'" ) ;
}
2020-06-03 23:55:32 +02:00
2019-09-30 14:48:48 +02:00
private updateUrl ( url : string ) {
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
}
}