2019-07-18 18:03:37 +02:00
|
|
|
import {Component} from '@angular/core';
|
2020-11-12 16:59:26 +01:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
2019-07-15 18:24:58 +02:00
|
|
|
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
2019-07-16 13:24:55 +02:00
|
|
|
import {ZenodoInformationClass} from "../openaireLibrary/deposit/utils/zenodoInformation.class";
|
|
|
|
import {FetchZenodoInformation} from "./utils/fetchZenodoInformation.class";
|
|
|
|
import {ZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service";
|
|
|
|
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
|
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-deposit',
|
2021-02-19 18:52:12 +01:00
|
|
|
template: `
|
2023-07-13 10:48:23 +02:00
|
|
|
<deposit-first-page [zenodoInformation]="zenodoInformation"
|
2022-06-22 14:39:29 +02:00
|
|
|
[communityId]="communityId" [assetsPath]="'assets/connect-assets'"></deposit-first-page>
|
2021-02-19 18:52:12 +01:00
|
|
|
`
|
2019-07-15 18:24:58 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export class OpenaireDepositComponent {
|
2021-02-19 18:52:12 +01:00
|
|
|
properties: EnvProperties = properties;
|
2019-07-18 18:03:37 +02:00
|
|
|
public pageContents = null;
|
|
|
|
public divContents = null;
|
2019-07-22 11:19:34 +02:00
|
|
|
public communityId = null;
|
2021-02-19 18:52:12 +01:00
|
|
|
|
2019-07-16 13:24:55 +02:00
|
|
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
|
|
|
fetchZenodoInformation: FetchZenodoInformation;
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
|
|
|
this.zenodoInformation.url = this.properties.zenodo;
|
|
|
|
}
|
|
|
|
if (!this.zenodoInformation.name) {
|
|
|
|
this.zenodoInformation.name = "Zenodo";
|
|
|
|
}
|
2019-07-15 18:24:58 +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();
|
2020-07-17 01:25:23 +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 First Page: " + message, error);
|
2019-07-15 18:24:58 +02:00
|
|
|
}
|
|
|
|
}
|