2019-06-07 15:03:33 +02:00
|
|
|
import {Component, Input} 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 {AffiliationService} from "../openaireLibrary/connect/affiliations/affiliation.service";
|
|
|
|
import {Affiliation} from "../openaireLibrary/utils/entities/CuratorInfo";
|
|
|
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
2019-08-02 16:56:03 +02:00
|
|
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
|
|
|
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
|
|
|
|
import {PiwikHelper} from "../utils/piwikHelper";
|
2020-11-12 16:59:26 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-11-30 18:04:05 +01:00
|
|
|
import {properties} from "../../environments/environment";
|
2019-06-07 15:03:33 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'affiliations',
|
|
|
|
templateUrl: './affiliations.component.html'
|
|
|
|
})
|
|
|
|
export class AffiliationsComponent {
|
|
|
|
@Input() getAffiliationsFromAPI: boolean = false;
|
2019-08-26 14:21:13 +02:00
|
|
|
@Input() longView: boolean = false;
|
2019-06-10 17:48:29 +02:00
|
|
|
@Input() communityFirstPage: boolean = false;
|
2019-06-07 15:03:33 +02:00
|
|
|
@Input() affiliationsInSlider: number = 5;
|
|
|
|
@Input() affiliations: Affiliation[] = [];
|
2019-06-08 19:24:03 +02:00
|
|
|
@Input() sliderOptions = '';
|
|
|
|
@Input() arrows = true;
|
2019-06-07 15:03:33 +02:00
|
|
|
|
2019-06-10 17:48:29 +02:00
|
|
|
public showLoading: boolean = false;
|
|
|
|
|
2019-06-07 15:03:33 +02:00
|
|
|
communityId: string;
|
|
|
|
properties:EnvProperties;
|
|
|
|
|
2020-11-12 16:59:26 +01:00
|
|
|
subscriptions = [];
|
2019-08-02 16:56:03 +02:00
|
|
|
public url: string = null;
|
|
|
|
public pageTitle: string = "Related Organizations";
|
|
|
|
|
2019-06-07 15:03:33 +02:00
|
|
|
constructor ( private route: ActivatedRoute, private _router: Router,
|
2019-08-02 16:56:03 +02:00
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
|
|
|
private seoService: SEOService,
|
|
|
|
private _piwikService: PiwikService,
|
2019-06-07 15:03:33 +02:00
|
|
|
private affiliationService: AffiliationService) {}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
|
2020-11-30 18:04:05 +01:00
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(
|
|
|
|
communityId => {
|
|
|
|
this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
|
|
|
|
if(!this.communityId) {
|
|
|
|
this.communityId = communityId['communityId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
this.properties = properties;
|
|
|
|
if(this.longView) {
|
|
|
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
2022-06-08 13:21:09 +02:00
|
|
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId)).subscribe());
|
2020-11-30 18:04:05 +01:00
|
|
|
}
|
|
|
|
this.url = this.properties.domain + this._router.url;
|
|
|
|
this.seoService.createLinkForCanonicalURL(this.url);
|
|
|
|
this.updateUrl(this.url);
|
|
|
|
this.updateTitle(this.pageTitle);
|
|
|
|
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, organizations");
|
|
|
|
}
|
|
|
|
if(this.getAffiliationsFromAPI) {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.affiliationService.initAffiliations(this.communityId);
|
|
|
|
this.subscriptions.push(this.affiliationService.affiliations.subscribe(
|
|
|
|
affiliations => {
|
|
|
|
this.affiliations = affiliations;
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.error("Affiliations Component: Error getting affiliations for community with id: " + this.communityId, error);
|
|
|
|
this.showLoading = false;
|
2019-06-07 15:03:33 +02:00
|
|
|
}
|
2020-11-30 18:04:05 +01:00
|
|
|
));
|
|
|
|
}
|
2020-11-12 16:59:26 +01:00
|
|
|
}));
|
2020-11-30 18:04:05 +01:00
|
|
|
|
2019-06-07 15:03:33 +02:00
|
|
|
}
|
2019-08-02 16:56:03 +02:00
|
|
|
|
2020-11-12 16:59:26 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.affiliationService.clearSubscriptions();
|
2019-08-02 16:56:03 +02:00
|
|
|
}
|
2021-03-04 14:46:40 +01:00
|
|
|
|
2019-08-02 16:56:03 +02:00
|
|
|
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'");
|
|
|
|
}
|
2019-06-07 15:03:33 +02:00
|
|
|
}
|