1. Add proper message (for connect or explore portal) for Zenodo repository in all deposit pages at the right side of each page.

2. Library: deposit/utils/zenodoInformation.class.ts: create class to describe zenodo information (name, url, shareInZenodoUrl - only for connect portal).


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@53973 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-11-26 15:44:32 +00:00
parent cbcd2beba5
commit eac05f14eb
11 changed files with 381 additions and 39 deletions

View File

@ -1,19 +1,67 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; 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({ @Component({
selector: 'openaire-deposit-by-subject-result', selector: 'openaire-deposit-by-subject-result',
template:`<deposit-by-subject-result [piwikSiteId]=piwikSiteId></deposit-by-subject-result>` template:`<deposit-by-subject-result [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-by-subject-result>`
}) })
export class OpenaireDepositBySubjectResultComponent { export class OpenaireDepositBySubjectResultComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties;
fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
constructor ( ) {
var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); constructor ( private route: ActivatedRoute,
this.piwikSiteId = PiwikHelper.siteIDs[communityId]; 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 => {
var communityId = params['communityId'];
if(!communityId){
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
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 => {
console.log("Community couldn't be loaded");
}
);
}
}
});
});
}
} }

View File

@ -8,13 +8,19 @@ import {DepositBySubjectResultsRoutingModule} from './depositBySubjectResult-rou
import {DepositBySubjectResultsModule } from '../../openaireLibrary/deposit/datasets/depositBySubjectResults.module'; import {DepositBySubjectResultsModule } from '../../openaireLibrary/deposit/datasets/depositBySubjectResults.module';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
DepositBySubjectResultsModule, DepositBySubjectResultsModule,
DepositBySubjectResultsRoutingModule DepositBySubjectResultsRoutingModule,
ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule
], ],
declarations: [ declarations: [
@ -24,6 +30,6 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
exports: [ exports: [
OpenaireDepositBySubjectResultComponent OpenaireDepositBySubjectResultComponent
], ],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled] providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService]
}) })
export class LibDepositBySubjectResultsModule { } export class LibDepositBySubjectResultsModule { }

View File

@ -1,21 +1,69 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; 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({ @Component({
selector: 'openaire-deposit-datasets', selector: 'openaire-deposit-datasets',
template: ` template: `
<deposit-datasets [piwikSiteId]=piwikSiteId> <deposit-datasets [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation">
</deposit-datasets> </deposit-datasets>
` `
}) })
export class OpenaireDepositDatasetsComponent { export class OpenaireDepositDatasetsComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties;
fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
constructor ( ) { constructor ( private route: ActivatedRoute,
var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); private _ΖenodoCommunitieService: ZenodoCommunitiesService,
this.piwikSiteId = PiwikHelper.siteIDs[communityId]; 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 => {
var communityId = params['communityId'];
if(!communityId){
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
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 => {
console.log("Community couldn't be loaded");
}
);
}
}
});
});
}
} }

View File

@ -7,12 +7,19 @@ import { OpenaireDepositDatasetsComponent } from './depositDatasets.component';
import {DepositDatasetsModule} from '../../openaireLibrary/deposit/datasets/depositDatasets.module'; import {DepositDatasetsModule} from '../../openaireLibrary/deposit/datasets/depositDatasets.module';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
DepositDatasetsModule, DepositDatasetsModule,
DepositDatasetsRoutingModule DepositDatasetsRoutingModule,
ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule
], ],
declarations: [ declarations: [
@ -22,6 +29,6 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
exports: [ exports: [
OpenaireDepositDatasetsComponent OpenaireDepositDatasetsComponent
], ],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled] providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService]
}) })
export class LibDepositDatasetsModule { } export class LibDepositDatasetsModule { }

View File

@ -1,21 +1,69 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; 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({ @Component({
selector: 'openaire-deposit-datasets-result', selector: 'openaire-deposit-datasets-result',
template: ` template: `
<deposit-datasets-result [piwikSiteId]=piwikSiteId></deposit-datasets-result> <deposit-datasets-result [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-datasets-result>
` `
}) })
export class OpenaireDepositDatasetsResultComponent { export class OpenaireDepositDatasetsResultComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties;
fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
constructor ( ) {
var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); constructor ( private route: ActivatedRoute,
this.piwikSiteId = PiwikHelper.siteIDs[communityId]; 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 => {
var communityId = params['communityId'];
if(!communityId){
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
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 => {
console.log("Community couldn't be loaded");
}
);
}
}
});
});
} }
} }

View File

@ -8,13 +8,19 @@ import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-rout
import {DepositDatasetsResultsModule} from '../../openaireLibrary/deposit/datasets/depositDatasetsResults.module'; import {DepositDatasetsResultsModule} from '../../openaireLibrary/deposit/datasets/depositDatasetsResults.module';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
DepositDatasetsResultsModule, DepositDatasetsResultsModule,
DepositDatasetsResultsRoutingModule DepositDatasetsResultsRoutingModule,
ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule
], ],
declarations: [ declarations: [
@ -24,6 +30,6 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
exports: [ exports: [
OpenaireDepositDatasetsResultComponent, OpenaireDepositDatasetsResultComponent,
], ],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled] providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService]
}) })
export class LibDepositDatasetsResultsModule { } export class LibDepositDatasetsResultsModule { }

View File

@ -1,19 +1,99 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; 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({ @Component({
selector: 'openaire-deposit-publications', selector: 'openaire-deposit-publications',
template: ` template: `
<deposit-publications [piwikSiteId]=piwikSiteId></deposit-publications> <deposit-publications [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-publications>
` `
}) })
export class OpenaireDepositPublicationsComponent { export class OpenaireDepositPublicationsComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties;
fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
constructor ( ) {
var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); constructor ( private route: ActivatedRoute,
this.piwikSiteId = PiwikHelper.siteIDs[communityId]; private _ΖenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) {
//var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
//this.piwikSiteId = PiwikHelper.siteIDs[communityId];
this.fetchZenodoInformation = new FetchZenodoInformation(this._ΖenodoCommunitieService, this._searchZenodoCommunitiesService);
} }
} public ngOnInit() {
//this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
var communityId = params['communityId'];
if(!communityId){
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
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);
/*
if(masterZenodoCommunityId){
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+masterZenodoCommunityId, null).subscribe(
result => {
var masterZenodoCommunity = result;
this.zenodoInformation.name = masterZenodoCommunity.title;
this.zenodoInformation.url = masterZenodoCommunity.link;
},
error => {
console.log("Master Zenodo community'"+masterZenodoCommunityId+"' couldn't be loaded");
}
);
}
this._searchZenodoCommunitiesService.searchZCommunities(this.properties,communityId).subscribe (
result => {
var CommunityIds = result;
var totalResults = CommunityIds.length;
if(totalResults > 0) {
this.zenodoInformation.shareInZenodoUrl = "http://duffy.di.uoa.gr:4200/participate/share-zenodo?communityId="+communityId;
}
},
error => {
console.log("list of zenodo communities couldn't be loaded");
}
);
*/
},
error => {
console.log("Community couldn't be loaded");
}
);
}
}
});
});
}
}

View File

@ -8,12 +8,18 @@ import {DepositPublicationsRoutingModule} from './depositPublications-routing.mo
import {DepositPublicationsModule} from '../../openaireLibrary/deposit/publications/depositPublications.module'; import {DepositPublicationsModule} from '../../openaireLibrary/deposit/publications/depositPublications.module';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
DepositPublicationsModule, DepositPublicationsModule,
DepositPublicationsRoutingModule DepositPublicationsRoutingModule,
ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule
], ],
declarations: [ declarations: [
OpenaireDepositPublicationsComponent OpenaireDepositPublicationsComponent
@ -21,6 +27,6 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
exports: [ exports: [
OpenaireDepositPublicationsComponent, OpenaireDepositPublicationsComponent,
], ],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled] providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService]
}) })
export class LibDepositPublicationsModule { } export class LibDepositPublicationsModule { }

View File

@ -1,20 +1,67 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; 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({ @Component({
selector: 'openaire-deposit-publications-result', selector: 'openaire-deposit-publications-result',
template: ` template: `
<deposit-publications-result [piwikSiteId]=piwikSiteId></deposit-publications-result> <deposit-publications-result [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"></deposit-publications-result>
` `
}) })
export class OpenaireDepositPublicationsResultComponent { export class OpenaireDepositPublicationsResultComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties;
fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
constructor ( ) {
var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); constructor ( private route: ActivatedRoute,
this.piwikSiteId = PiwikHelper.siteIDs[communityId]; 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 => {
var communityId = params['communityId'];
if(!communityId){
communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
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 => {
console.log("Community couldn't be loaded");
}
);
}
}
});
});
}
} }

View File

@ -8,12 +8,18 @@ import {DepositPublicationsResultRoutingModule} from './depositPublicationsResul
import {DepositPublicationsResultsModule} from '../../openaireLibrary/deposit/publications/depositPublicationsResults.module'; import {DepositPublicationsResultsModule} from '../../openaireLibrary/deposit/publications/depositPublicationsResults.module';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
DepositPublicationsResultsModule, DepositPublicationsResultsModule,
DepositPublicationsResultRoutingModule DepositPublicationsResultRoutingModule,
ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule
], ],
declarations: [ declarations: [
OpenaireDepositPublicationsResultComponent OpenaireDepositPublicationsResultComponent
@ -21,6 +27,6 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
exports: [ exports: [
OpenaireDepositPublicationsResultComponent OpenaireDepositPublicationsResultComponent
], ],
providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled] providers: [FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService]
}) })
export class LibDepositPublicationsResultsModule { } export class LibDepositPublicationsResultsModule { }

View File

@ -0,0 +1,40 @@
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 {ZenodoInformationClass} from '../../openaireLibrary/deposit/utils/zenodoInformation.class';
export class FetchZenodoInformation {
constructor ( private _ΖenodoCommunitieService: ZenodoCommunitiesService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) { }
public ngOnDestroy() { }
public getZenodoCommunityNameAndUrlById(masterZenodoCommunityId: string, properties:EnvProperties, zenodoInformation: ZenodoInformationClass){
this._ΖenodoCommunitieService.getZenodoCommunityById(properties, properties.zenodoCommunities+masterZenodoCommunityId, null).subscribe(
result => {
var masterZenodoCommunity = result;
//zenodoInformation.name = masterZenodoCommunity.title;
zenodoInformation.url = masterZenodoCommunity.link;
},
error => {
console.log("Master Zenodo community'"+masterZenodoCommunityId+"' couldn't be loaded");
}
);
}
public searchNumberOfZCommunities(communityId: string, properties: EnvProperties, zenodoInformation: ZenodoInformationClass) {
this._searchZenodoCommunitiesService.searchZCommunities(properties,communityId).subscribe (
result => {
var CommunityIds = result;
var totalResults = CommunityIds.length;
if(totalResults > 0) {
zenodoInformation.shareInZenodoUrl = "http://duffy.di.uoa.gr:4200/participate/share-zenodo?communityId="+communityId;
}
},
error => {
console.log("list of zenodo communities couldn't be loaded");
}
);
}
}