75 lines
3.1 KiB
TypeScript
75 lines
3.1 KiB
TypeScript
|
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: `
|
|||
|
<!-- [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"-->
|
|||
|
<search-dataproviders></search-dataproviders>
|
|||
|
`
|
|||
|
})
|
|||
|
|
|||
|
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;
|
|||
|
if(masterZenodoCommunityId){
|
|||
|
this.fetchZenodoInformation.getZenodoCommunityNameAndUrlById(masterZenodoCommunityId, this.properties, this.zenodoInformation);
|
|||
|
}
|
|||
|
this.fetchZenodoInformation.searchNumberOfZCommunities(communityId, this.properties, this.zenodoInformation);
|
|||
|
},
|
|||
|
error => {
|
|||
|
this.handleError("Error getting community with id: "+communityId, error);
|
|||
|
}
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
private handleError(message: string, error) {
|
|||
|
console.error("Deposit Publications Page: "+message, error);
|
|||
|
}
|
|||
|
}
|