82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {Meta, Title} from '@angular/platform-browser';
|
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
|
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
|
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
|
|
|
|
@Component({
|
|
selector: 'content',
|
|
templateUrl: './contentPage.component.html'
|
|
})
|
|
export class ContentPageComponent {
|
|
|
|
properties: EnvProperties;
|
|
public pageContents = null;
|
|
public divContents = null;
|
|
|
|
public url: string = null;
|
|
public pageTitle: string = "OpenAIRE - Connect | Content Policy";
|
|
piwiksub: any;
|
|
|
|
constructor(private route: ActivatedRoute, private _router: Router,
|
|
private _meta: Meta,
|
|
private _title: Title,
|
|
private seoService: SEOService,
|
|
private _piwikService: PiwikService,
|
|
private helper: HelperService) {}
|
|
|
|
public ngOnInit() {
|
|
this.route.data
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
this.properties = data.envSpecific;
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
|
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe();
|
|
}
|
|
this.url = this.properties.baseLink + this._router.url;
|
|
this.seoService.createLinkForCanonicalURL(this.url);
|
|
this.updateUrl(this.url);
|
|
this.updateTitle(this.pageTitle);
|
|
this.updateDescription("content, open access");
|
|
|
|
//this.getDivContents();
|
|
this.getPageContents();
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
if(this.piwiksub) {
|
|
this.piwiksub.unsubscribe();
|
|
}
|
|
}
|
|
|
|
private updateDescription(description: string) {
|
|
this._meta.updateTag({content: description}, "name='description'");
|
|
this._meta.updateTag({content: description}, "property='og:description'");
|
|
}
|
|
|
|
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'");
|
|
}
|
|
|
|
private updateUrl(url: string) {
|
|
this._meta.updateTag({content: url}, "property='og:url'");
|
|
}
|
|
|
|
private getPageContents() {
|
|
this.helper.getPageHelpContents(this._router.url, this.properties, 'connect').subscribe(contents => {
|
|
this.pageContents = contents;
|
|
})
|
|
}
|
|
|
|
private getDivContents() {
|
|
this.helper.getDivHelpContents(this._router.url, this.properties, 'connect').subscribe(contents => {
|
|
this.divContents = contents;
|
|
})
|
|
}
|
|
}
|