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