[Trunk | Connect]: Bug fix in deposit pages: Get information for zenodo communities in connect components.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@56571 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-07-16 11:24:55 +00:00
parent eb9db84e45
commit ecc6ac9b36
3 changed files with 69 additions and 11 deletions

View File

@ -2,29 +2,74 @@ import {Component, Input} from '@angular/core';
import {ActivatedRoute} 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";
@Component({
selector: 'openaire-deposit',
template: `
<deposit-first-page></deposit-first-page>
<deposit-first-page [zenodoInformation]="zenodoInformation"></deposit-first-page>
`
})
export class OpenaireDepositComponent {
properties:EnvProperties;
piwikSiteId = null;
constructor ( private route: ActivatedRoute ) {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
fetchZenodoInformation: FetchZenodoInformation;
constructor ( private route: ActivatedRoute,
private _zenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
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 => {
this.route.queryParams.subscribe(params => {
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if (!communityId) {
communityId = params['communityId'];
}
if (communityId) {
if (communityId != null && communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI + communityId).subscribe(
community => {
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";
}
});
});
}

View File

@ -11,6 +11,10 @@ import {OpenaireDepositComponent} from "./deposit.component";
import {DepositRoutingModule} from "./deposit-routing.module";
import {DepositFirstPageModule} from "../openaireLibrary/deposit/depositFirstPage.module";
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";
@NgModule({
imports: [
CommonModule, FormsModule,
@ -22,6 +26,7 @@ import {DepositFirstPageModule} from "../openaireLibrary/deposit/depositFirstPag
exports: [
OpenaireDepositComponent,
],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled]
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled,
ZenodoCommunitiesService, CommunityService, SearchZenodoCommunitiesService]
})
export class LibDepositModule { }

View File

@ -16,7 +16,7 @@ import {FetchZenodoInformation} from './utils/fetchZenodoInformation.class';
selector: 'openaire-search-deposit',
template: `
<!-- [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"-->
<search-dataproviders></search-dataproviders>
<search-dataproviders [zenodoInformation]="zenodoInformation"></search-dataproviders>
`
})
@ -53,17 +53,25 @@ export class OpenaireSearchDataprovidersToDepositComponent {
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);
},
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";
}
});
});
}