2019-07-18 18:03:37 +02:00
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2019-07-15 18:24:58 +02:00
|
|
|
|
|
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
2019-07-16 13:24:55 +02:00
|
|
|
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";
|
2019-07-18 13:41:22 +02:00
|
|
|
import {PiwikHelper} from "../utils/piwikHelper";
|
2019-07-15 18:24:58 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'openaire-deposit',
|
2019-07-18 18:03:37 +02:00
|
|
|
template: `
|
2019-07-22 11:19:34 +02:00
|
|
|
<deposit-first-page [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"
|
|
|
|
[communityId]="communityId"></deposit-first-page>
|
2019-07-15 18:24:58 +02:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class OpenaireDepositComponent {
|
|
|
|
properties:EnvProperties;
|
|
|
|
piwikSiteId = null;
|
2019-07-18 18:03:37 +02:00
|
|
|
public pageContents = null;
|
|
|
|
public divContents = null;
|
2019-07-22 11:19:34 +02:00
|
|
|
public communityId = null;
|
2019-07-18 18:03:37 +02:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
|
2019-07-16 13:24:55 +02:00
|
|
|
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
|
|
|
fetchZenodoInformation: FetchZenodoInformation;
|
|
|
|
|
|
|
|
constructor ( private route: ActivatedRoute,
|
|
|
|
private _zenodoCommunitieService: ZenodoCommunitiesService,
|
|
|
|
private _communityService: CommunityService,
|
2019-07-22 11:19:34 +02:00
|
|
|
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
|
2019-07-16 13:24:55 +02:00
|
|
|
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
|
2019-07-15 18:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2019-07-16 13:24:55 +02:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
this.route.queryParams.subscribe(params => {
|
2019-07-16 13:24:55 +02:00
|
|
|
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
if (!communityId) {
|
|
|
|
communityId = params['communityId'];
|
|
|
|
}
|
2019-07-18 18:03:37 +02:00
|
|
|
if (communityId != null && communityId != '') {
|
2019-07-22 11:19:34 +02:00
|
|
|
this.communityId = communityId;
|
2019-07-18 18:03:37 +02:00
|
|
|
this.piwikSiteId = PiwikHelper.siteIDs[communityId];
|
2019-07-16 13:24:55 +02:00
|
|
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI + communityId).subscribe(
|
|
|
|
community => {
|
|
|
|
let masterZenodoCommunityId = community.zenodoCommunity;
|
|
|
|
if (masterZenodoCommunityId) {
|
2019-07-31 12:42:45 +02:00
|
|
|
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
|
2019-07-16 13:24:55 +02:00
|
|
|
} 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";
|
|
|
|
}
|
2019-07-15 18:24:58 +02:00
|
|
|
});
|
2019-07-16 13:24:55 +02:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-18 18:03:37 +02:00
|
|
|
|
2019-07-15 18:24:58 +02:00
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Deposit First Page: "+message, error);
|
|
|
|
}
|
|
|
|
}
|