1
|
import {Component, Input} from '@angular/core';
|
2
|
import {ActivatedRoute} from '@angular/router';
|
3
|
|
4
|
import {PiwikHelper} from '../utils/piwikHelper';
|
5
|
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
6
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
7
|
|
8
|
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
9
|
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
|
10
|
import {CommunityService} from '../openaireLibrary/connect/community/community.service';
|
11
|
|
12
|
import {ZenodoInformationClass} from '../openaireLibrary/deposit/utils/zenodoInformation.class';
|
13
|
import {FetchZenodoInformation} from './utils/fetchZenodoInformation.class';
|
14
|
import {Subscriber, Subscription} from "rxjs";
|
15
|
import {properties} from "../../environments/environment";
|
16
|
|
17
|
@Component({
|
18
|
selector: 'openaire-search-deposit',
|
19
|
template: `
|
20
|
<deposit-search-dataproviders [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"
|
21
|
[communityId]="communityId"></deposit-search-dataproviders>
|
22
|
`
|
23
|
})
|
24
|
|
25
|
export class OpenaireSearchDataprovidersToDepositComponent {
|
26
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
27
|
properties: EnvProperties = properties;
|
28
|
fetchZenodoInformation: FetchZenodoInformation;
|
29
|
|
30
|
piwikSiteId = null;
|
31
|
communityId: string = null;
|
32
|
|
33
|
subs: Subscription[] = [];
|
34
|
|
35
|
constructor(private route: ActivatedRoute,
|
36
|
private _zenodoCommunitieService: ZenodoCommunitiesService,
|
37
|
private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
|
38
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
|
39
|
}
|
40
|
|
41
|
public ngOnInit() {
|
42
|
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
|
43
|
community => {
|
44
|
if(community) {
|
45
|
this.communityId = community.communityId;
|
46
|
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, this.properties.environment);
|
47
|
let masterZenodoCommunityId = community.zenodoCommunity;
|
48
|
if (masterZenodoCommunityId) {
|
49
|
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
|
50
|
} else {
|
51
|
this.zenodoInformation.url = this.properties.zenodo;
|
52
|
this.zenodoInformation.name = "Zenodo";
|
53
|
}
|
54
|
}
|
55
|
}
|
56
|
));
|
57
|
|
58
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
59
|
this.zenodoInformation.url = this.properties.zenodo;
|
60
|
}
|
61
|
if (!this.zenodoInformation.name) {
|
62
|
this.zenodoInformation.name = "Zenodo";
|
63
|
}
|
64
|
}
|
65
|
|
66
|
public ngOnDestroy() {
|
67
|
for (let sub of this.subs) {
|
68
|
if (sub instanceof Subscriber) {
|
69
|
sub.unsubscribe();
|
70
|
}
|
71
|
}
|
72
|
this.fetchZenodoInformation.clearSubscriptions();
|
73
|
}
|
74
|
|
75
|
private handleError(message: string, error) {
|
76
|
console.error("Deposit Publications Page: " + message, error);
|
77
|
}
|
78
|
}
|