monitor/src/app/htmlPages/organizations/organizationsPage.component.ts

71 lines
2.7 KiB
TypeScript

import {Component} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {HelperService} from "../../openaireLibrary/utils/helper/helper.service";
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
@Component({
selector: 'organizations',
template: `
<div class=" uk-section tm-middle uk-container uk-padding-remove-top uk-margin-top" id="tm-main">
<div class="uk-container uk-margin-bottom">
<div class="uk-article-title custom-article-title uk-margin-bottom"> Organizations related to the community
</div>
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
[texts]="pageContents['top']"></helper>
<affiliations [longView]="true" [getAffiliationsFromAPI]="true"></affiliations>
</div>
</div>
`
})
export class OrganizationsPageComponent {
properties:EnvProperties;
public pageContents = null;
public divContents = null;
public communityId = null;
constructor ( private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title,
private helper: HelperService) {}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.updateUrl(data.envSpecific.baseLink+this._router.url);
this.updateTitle("Organizations");
this.updateDescription("Organizations, open access");
//this.getDivContents();
this.getPageContents();
});
}
private updateDescription(description:string){
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
}
private updateTitle(title:string){
var _prefix ="OpenAIRE | ";
var _title = _prefix + ((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, this.communityId).subscribe(contents => {
this.pageContents = contents;
})
}
private getDivContents() {
this.helper.getDivHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
this.divContents = contents;
})
}
}