2022-06-08 13:21:09 +02:00
|
|
|
import {Component} from '@angular/core';
|
2019-07-15 18:24:58 +02:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
|
|
|
|
|
|
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
|
|
|
import {CommunityService} from '../openaireLibrary/connect/community/community.service';
|
|
|
|
|
|
|
|
import {ZenodoInformationClass} from '../openaireLibrary/deposit/utils/zenodoInformation.class';
|
|
|
|
import {FetchZenodoInformation} from './utils/fetchZenodoInformation.class';
|
2020-11-12 16:59:26 +01:00
|
|
|
import {Subscriber, Subscription} from "rxjs";
|
2020-07-17 01:25:23 +02:00
|
|
|
import {properties} from "../../environments/environment";
|
2019-07-15 18:24:58 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'openaire-search-deposit',
|
|
|
|
template: `
|
2023-07-13 10:48:23 +02:00
|
|
|
<deposit-search-dataproviders [zenodoInformation]="zenodoInformation"
|
2022-07-27 12:50:33 +02:00
|
|
|
[communityId]="communityId" [searchForm]="{dark: false, class: 'search-form'}"></deposit-search-dataproviders>
|
2021-02-19 18:52:12 +01:00
|
|
|
`
|
2019-07-15 18:24:58 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export class OpenaireSearchDataprovidersToDepositComponent {
|
|
|
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
2021-02-19 18:52:12 +01:00
|
|
|
properties: EnvProperties = properties;
|
2019-07-15 18:24:58 +02:00
|
|
|
fetchZenodoInformation: FetchZenodoInformation;
|
2019-07-31 12:42:45 +02:00
|
|
|
communityId: string = null;
|
2021-02-19 18:52:12 +01:00
|
|
|
|
2020-07-17 01:25:23 +02:00
|
|
|
subs: Subscription[] = [];
|
2021-02-19 18:52:12 +01:00
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
|
|
private _zenodoCommunitieService: ZenodoCommunitiesService,
|
2023-07-14 13:54:58 +02:00
|
|
|
private _communityService: CommunityService) {
|
|
|
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService);
|
2019-07-15 18:24:58 +02:00
|
|
|
}
|
2021-02-19 18:52:12 +01:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
public ngOnInit() {
|
2021-02-19 18:52:12 +01:00
|
|
|
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
|
|
|
|
community => {
|
|
|
|
if(community) {
|
|
|
|
this.communityId = community.communityId;
|
|
|
|
let masterZenodoCommunityId = community.zenodoCommunity;
|
2023-07-17 11:09:49 +02:00
|
|
|
if (masterZenodoCommunityId || (community.otherZenodoCommunities && community.otherZenodoCommunities.length > 0)) {
|
2021-02-19 18:52:12 +01:00
|
|
|
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
|
|
|
|
} else {
|
|
|
|
this.zenodoInformation.url = this.properties.zenodo;
|
|
|
|
this.zenodoInformation.name = "Zenodo";
|
|
|
|
}
|
2020-07-17 01:25:23 +02:00
|
|
|
}
|
|
|
|
}
|
2021-02-19 18:52:12 +01:00
|
|
|
));
|
|
|
|
|
|
|
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
|
|
|
this.zenodoInformation.url = this.properties.zenodo;
|
|
|
|
}
|
|
|
|
if (!this.zenodoInformation.name) {
|
|
|
|
this.zenodoInformation.name = "Zenodo";
|
|
|
|
}
|
2020-07-17 01:25:23 +02:00
|
|
|
}
|
2021-02-19 18:52:12 +01:00
|
|
|
|
2020-07-17 01:25:23 +02:00
|
|
|
public ngOnDestroy() {
|
|
|
|
for (let sub of this.subs) {
|
2021-02-19 18:52:12 +01:00
|
|
|
if (sub instanceof Subscriber) {
|
2020-11-12 16:59:26 +01:00
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
2020-07-17 01:25:23 +02:00
|
|
|
}
|
2020-11-12 16:59:26 +01:00
|
|
|
this.fetchZenodoInformation.clearSubscriptions();
|
2019-07-15 18:24:58 +02:00
|
|
|
}
|
2021-02-19 18:52:12 +01:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
private handleError(message: string, error) {
|
2021-02-19 18:52:12 +01:00
|
|
|
console.error("Deposit Publications Page: " + message, error);
|
2019-07-15 18:24:58 +02:00
|
|
|
}
|
|
|
|
}
|