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
|
|
15
|
@Component({
|
16
|
selector: 'openaire-deposit-publications',
|
17
|
template: `
|
18
|
<deposit-publications [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-publications>
|
19
|
`
|
20
|
})
|
21
|
|
22
|
export class OpenaireDepositPublicationsComponent {
|
23
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
24
|
properties:EnvProperties;
|
25
|
fetchZenodoInformation: FetchZenodoInformation;
|
26
|
|
27
|
piwikSiteId = null;
|
28
|
|
29
|
constructor ( private route: ActivatedRoute,
|
30
|
private _ΖenodoCommunitieService: ZenodoCommunitiesService,
|
31
|
private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) {
|
32
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._ΖenodoCommunitieService, this._searchZenodoCommunitiesService);
|
33
|
}
|
34
|
|
35
|
public ngOnInit() {
|
36
|
//this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
|
37
|
this.route.data
|
38
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
39
|
this.properties = data.envSpecific;
|
40
|
this.route.queryParams.subscribe(params => {
|
41
|
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
42
|
if(!communityId) {
|
43
|
communityId = params['communityId'];
|
44
|
}
|
45
|
|
46
|
this.piwikSiteId = PiwikHelper.siteIDs[communityId];
|
47
|
|
48
|
if(communityId) {
|
49
|
|
50
|
if (communityId != null && communityId != '') {
|
51
|
|
52
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI+communityId).subscribe (
|
53
|
community => {
|
54
|
var community = community;
|
55
|
var masterZenodoCommunityId = community.zenodoCommunity;
|
56
|
if(masterZenodoCommunityId){
|
57
|
this.fetchZenodoInformation.getZenodoCommunityNameAndUrlById(masterZenodoCommunityId, this.properties, this.zenodoInformation);
|
58
|
}
|
59
|
this.fetchZenodoInformation.searchNumberOfZCommunities(communityId, this.properties, this.zenodoInformation);
|
60
|
|
61
|
/*
|
62
|
if(masterZenodoCommunityId){
|
63
|
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+masterZenodoCommunityId, null).subscribe(
|
64
|
result => {
|
65
|
var masterZenodoCommunity = result;
|
66
|
this.zenodoInformation.name = masterZenodoCommunity.title;
|
67
|
this.zenodoInformation.url = masterZenodoCommunity.link;
|
68
|
},
|
69
|
error => {
|
70
|
console.log("Master Zenodo community'"+masterZenodoCommunityId+"' couldn't be loaded");
|
71
|
}
|
72
|
);
|
73
|
}
|
74
|
|
75
|
this._searchZenodoCommunitiesService.searchZCommunities(this.properties,communityId).subscribe (
|
76
|
result => {
|
77
|
var CommunityIds = result;
|
78
|
var totalResults = CommunityIds.length;
|
79
|
if(totalResults > 0) {
|
80
|
this.zenodoInformation.shareInZenodoUrl = "http://duffy.di.uoa.gr:4200/participate/share-zenodo?communityId="+communityId;
|
81
|
}
|
82
|
},
|
83
|
error => {
|
84
|
console.log("list of zenodo communities couldn't be loaded");
|
85
|
}
|
86
|
);
|
87
|
*/
|
88
|
},
|
89
|
error => {
|
90
|
//console.error("Community couldn't be loaded");
|
91
|
this.handleError("Error getting community with id: "+communityId, error);
|
92
|
}
|
93
|
);
|
94
|
}
|
95
|
}
|
96
|
});
|
97
|
});
|
98
|
}
|
99
|
|
100
|
private handleError(message: string, error) {
|
101
|
console.error("Deposit Publications Page: "+message, error);
|
102
|
}
|
103
|
}
|