import {Component} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {ConnectHelper} from "../openaireLibrary/connect/connectHelper"; import {ZenodoInformationClass} from "../openaireLibrary/deposit/utils/zenodoInformation.class"; import {FetchZenodoInformation} from "./utils/fetchZenodoInformation.class"; import {ZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service"; import {CommunityService} from "../openaireLibrary/connect/community/community.service"; import {SearchZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service"; import {HelperService} from "../openaireLibrary/utils/helper/helper.service"; import {PiwikHelper} from "../utils/piwikHelper"; @Component({ selector: 'openaire-deposit', template: ` ` }) export class OpenaireDepositComponent { properties:EnvProperties; piwikSiteId = null; public pageContents = null; public divContents = null; public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); fetchZenodoInformation: FetchZenodoInformation; constructor ( private route: ActivatedRoute, private _router: Router, private _zenodoCommunitieService: ZenodoCommunitiesService, private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService, private helper: HelperService) { this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, 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']; } if (communityId != null && communityId != '') { this.piwikSiteId = PiwikHelper.siteIDs[communityId]; this._communityService.getCommunity(this.properties, this.properties.communityAPI + communityId).subscribe( community => { //this.getDivContents(); this.getPageContents(communityId); let masterZenodoCommunityId = community.zenodoCommunity; if (masterZenodoCommunityId) { this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage+communityId; } else { this.zenodoInformation.url = this.properties.zenodo; this.zenodoInformation.name = "Zenodo"; } }, error => { this.handleError("Error getting community with id: " + communityId, error); } ); } if (!this.zenodoInformation.shareInZenodoUrl) { this.zenodoInformation.url = this.properties.zenodo; } if (!this.zenodoInformation.name) { this.zenodoInformation.name = "Zenodo"; } }); }); } public getPageContents(communityId: string) { this.helper.getPageHelpContents(this._router.url, this.properties, communityId).subscribe(contents => { this.pageContents = contents; }) } public getDivContents(communityId: string) { this.helper.getDivHelpContents(this._router.url, this.properties, communityId).subscribe(contents => { this.divContents = contents; }) } private handleError(message: string, error) { console.error("Deposit First Page: "+message, error); } }