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-datasets-result',
|
17
|
template: `
|
18
|
<deposit-datasets-result [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-datasets-result>
|
19
|
`
|
20
|
})
|
21
|
|
22
|
export class OpenaireDepositDatasetsResultComponent {
|
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.route.data
|
37
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
38
|
this.properties = data.envSpecific;
|
39
|
this.route.queryParams.subscribe(params => {
|
40
|
var communityId = params['communityId'];
|
41
|
if(!communityId){
|
42
|
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
|
43
|
}
|
44
|
this.piwikSiteId = PiwikHelper.siteIDs[communityId];
|
45
|
|
46
|
if(communityId) {
|
47
|
|
48
|
if (communityId != null && communityId != '') {
|
49
|
|
50
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI+communityId).subscribe (
|
51
|
community => {
|
52
|
var community = community;
|
53
|
var masterZenodoCommunityId = community.zenodoCommunity;
|
54
|
if(masterZenodoCommunityId){
|
55
|
this.fetchZenodoInformation.getZenodoCommunityNameAndUrlById(masterZenodoCommunityId, this.properties, this.zenodoInformation);
|
56
|
}
|
57
|
this.fetchZenodoInformation.searchNumberOfZCommunities(communityId, this.properties, this.zenodoInformation);
|
58
|
},
|
59
|
error => {
|
60
|
console.error("Community couldn't be loaded");
|
61
|
}
|
62
|
);
|
63
|
}
|
64
|
}
|
65
|
});
|
66
|
});
|
67
|
}
|
68
|
|
69
|
}
|