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 {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
|
|
|
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";
|
|
|
|
import {SearchZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service";
|
2019-07-18 13:41:22 +02:00
|
|
|
import {PiwikHelper} from "../utils/piwikHelper";
|
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: `
|
|
|
|
<deposit-first-page [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"
|
2019-07-22 11:19:34 +02:00
|
|
|
[communityId]="communityId"></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-15 18:24:58 +02:00
|
|
|
piwikSiteId = null;
|
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,
|
|
|
|
private _communityService: CommunityService,
|
|
|
|
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
|
2019-07-16 13:24:55 +02:00
|
|
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
|
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.piwikSiteId = PiwikHelper.getSiteId(this.communityId, this.properties.environment);
|
|
|
|
this.communityId = community.communityId
|
|
|
|
let masterZenodoCommunityId = community.zenodoCommunity;
|
|
|
|
if (masterZenodoCommunityId) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|