2019-07-15 18:24:58 +02:00
|
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
|
|
|
|
|
|
import {PiwikHelper} from '../utils/piwikHelper';
|
|
|
|
|
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
|
|
|
|
|
|
|
|
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
|
|
|
|
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
|
|
|
|
|
import {CommunityService} from '../openaireLibrary/connect/community/community.service';
|
|
|
|
|
|
|
|
|
|
import {ZenodoInformationClass} from '../openaireLibrary/deposit/utils/zenodoInformation.class';
|
|
|
|
|
import {FetchZenodoInformation} from './utils/fetchZenodoInformation.class';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'openaire-search-deposit',
|
|
|
|
|
template: `
|
2019-07-18 13:41:22 +02:00
|
|
|
|
<search-dataproviders [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></search-dataproviders>
|
2019-07-15 18:24:58 +02:00
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export class OpenaireSearchDataprovidersToDepositComponent {
|
|
|
|
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
|
|
|
|
properties:EnvProperties;
|
|
|
|
|
fetchZenodoInformation: FetchZenodoInformation;
|
|
|
|
|
|
|
|
|
|
piwikSiteId = null;
|
|
|
|
|
|
|
|
|
|
constructor ( private route: ActivatedRoute,
|
|
|
|
|
private _ΖenodoCommunitieService: ZenodoCommunitiesService,
|
|
|
|
|
private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) {
|
|
|
|
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._ΖenodoCommunitieService, this._searchZenodoCommunitiesService);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
|
this.route.data
|
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
|
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
|
if(!communityId) {
|
|
|
|
|
communityId = params['communityId'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.piwikSiteId = PiwikHelper.siteIDs[communityId];
|
|
|
|
|
|
|
|
|
|
if(communityId) {
|
|
|
|
|
|
|
|
|
|
if (communityId != null && communityId != '') {
|
|
|
|
|
|
|
|
|
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI+communityId).subscribe (
|
|
|
|
|
community => {
|
|
|
|
|
var community = community;
|
|
|
|
|
var masterZenodoCommunityId = community.zenodoCommunity;
|
2019-07-16 13:24:55 +02:00
|
|
|
|
if (masterZenodoCommunityId) {
|
|
|
|
|
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage+communityId;
|
|
|
|
|
} else {
|
|
|
|
|
this.zenodoInformation.url = this.properties.zenodo;
|
|
|
|
|
this.zenodoInformation.name = "Zenodo";
|
|
|
|
|
} },
|
2019-07-15 18:24:58 +02:00
|
|
|
|
error => {
|
|
|
|
|
this.handleError("Error getting community with id: "+communityId, error);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-16 13:24:55 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleError(message: string, error) {
|
|
|
|
|
console.error("Deposit Publications Page: "+message, error);
|
|
|
|
|
}
|
|
|
|
|
}
|