165 lines
6.4 KiB
TypeScript
165 lines
6.4 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {PluginBaseComponent} from "../../utils/base-plugin.component";
|
|
import {ConfigurationService} from '../../../../../openaireLibrary/utils/configuration/configuration.service';
|
|
import {CommunityService} from '../../../../../openaireLibrary/connect/community/community.service';
|
|
import {SearchCommunityProjectsService} from '../../../../../openaireLibrary/connect/projects/searchProjects.service';
|
|
import {SearchCommunityDataprovidersService} from '../../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
|
|
import {ZenodoCommunitiesService} from '../../../../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
|
import {ConnectHelper} from '../../../../../openaireLibrary/connect/connectHelper';
|
|
import {User} from '../../../../../openaireLibrary/login/utils/helper.class';
|
|
|
|
@Component({
|
|
selector: 'plugin-gateway-information',
|
|
templateUrl: 'plugin-gateway-information.component.html',
|
|
styleUrls: ['plugin-gateway-information.component.less']
|
|
})
|
|
export class PluginGatewayInformationComponent extends PluginBaseComponent{
|
|
community = null;
|
|
portal = null;
|
|
params: any = {};
|
|
|
|
projectTotal = null;
|
|
contentProviderTotal = null;
|
|
projectsCalculated: boolean = false;
|
|
contentProvidersCalculated: boolean = false;
|
|
zenodoCommunityIdS = [];
|
|
masterZenodoCommunity = null;
|
|
|
|
searchLinkToProjects: string = null;
|
|
searchLinkToDataProviders: string = null;
|
|
shareInZenodoPage: string = null;
|
|
|
|
displayedAllSubjects = [];
|
|
displayedSubjects = [];
|
|
displayedSdg = [];
|
|
displayedFos = [];
|
|
|
|
private user: User;
|
|
|
|
constructor(private config: ConfigurationService,
|
|
private communityService: CommunityService,
|
|
private searchCommunityProjectsService: SearchCommunityProjectsService,
|
|
private searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
|
|
private zenodoCommunitiesService: ZenodoCommunitiesService) {
|
|
super()
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.searchLinkToProjects = this.properties.searchLinkToProjects;
|
|
this.searchLinkToDataProviders = this.properties.searchLinkToDataProviders;
|
|
this.shareInZenodoPage = this.properties.shareInZenodoPage;
|
|
|
|
this.subscriptions.push(this.config.portalAsObservable.subscribe(
|
|
res => {
|
|
console.log(res);
|
|
this.portal = res;
|
|
},
|
|
error => {
|
|
console.log(error);
|
|
}
|
|
));
|
|
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(
|
|
community => {
|
|
console.log(community);
|
|
this.community = community;
|
|
if(community && !ConnectHelper.isPrivate(community, this.user)) {
|
|
this.displayedSubjects = community.subjects;
|
|
this.displayedSdg = community.sdg;
|
|
this.displayedFos = community.fos;
|
|
this.displayedSubjects.forEach(element => {
|
|
this.displayedAllSubjects.push({value: element, type: 'resultsubject'});
|
|
});
|
|
this.displayedSdg.forEach(element => {
|
|
this.displayedAllSubjects.push({value: element, type: 'sdg'});
|
|
});
|
|
this.displayedFos.forEach(element => {
|
|
this.displayedAllSubjects.push({value: element, type: 'fos'});
|
|
});
|
|
if (this.properties.environment == "development") {
|
|
this.params = {communityId: community.communityId};
|
|
}
|
|
if (this.community.zenodoCommunity) {
|
|
this.subscriptions.push(this.zenodoCommunitiesService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity).subscribe(
|
|
res => {
|
|
this.masterZenodoCommunity = res;
|
|
},
|
|
error => {
|
|
console.log(error);
|
|
}
|
|
));
|
|
}
|
|
this.zenodoCommunityIdS = this.community.otherZenodoCommunities;
|
|
}
|
|
}
|
|
));
|
|
// Double check below: is `this.community.communityId` correct? the other way was through @input communityID from ConnectHelper service - domain
|
|
this.subscriptions.push(this.searchCommunityProjectsService.countTotalProjects(this.properties, this.community.communityId).subscribe(
|
|
res => {
|
|
this.projectTotal = res;
|
|
},
|
|
error => {
|
|
console.log(error);
|
|
},
|
|
() => {
|
|
this.projectsCalculated = true;
|
|
}
|
|
));
|
|
// Double check below: is `this.community.communityId` correct? the other way was through @input communityID from ConnectHelper service - domain
|
|
this.subscriptions.push(this.searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.community.communityId).subscribe(
|
|
res => {
|
|
this.contentProviderTotal = res;
|
|
},
|
|
error => {
|
|
console.log(error);
|
|
},
|
|
() => {
|
|
this.contentProvidersCalculated = true;
|
|
}
|
|
));
|
|
}
|
|
|
|
isEntityEnabled(entity: string) {
|
|
return this.portal.entities.some(x => x['pid'] == entity && x['isEnabled'] === true);
|
|
}
|
|
|
|
isRouteEnabled(route: string) {
|
|
return this.portal.pages.some(x => x['route'] == route && x['isEnabled'] === true);
|
|
}
|
|
|
|
buildProjectsTooltip(): string {
|
|
let tooltipContent: string = "<div>";
|
|
|
|
if (this.projectTotal != null && this.projectTotal > 0 && this.isEntityEnabled('project') && this.isRouteEnabled(this.searchLinkToProjects)) {
|
|
tooltipContent += "<span class='uk-text-bold'>Projects</span>";
|
|
}
|
|
|
|
tooltipContent += " have been selected as relevant for your community by the gateway curators.";
|
|
tooltipContent += "</div>";
|
|
|
|
return tooltipContent;
|
|
}
|
|
|
|
public buildContentProvidersTooltip(): string {
|
|
let tooltipContent: string = "<div>";
|
|
|
|
if (this.contentProviderTotal != null && this.contentProviderTotal > 0 && this.isEntityEnabled('datasource') && this.isRouteEnabled(this.searchLinkToDataProviders)) {
|
|
tooltipContent += "<span class='uk-text-bold'>Content Providers</span>";
|
|
}
|
|
|
|
tooltipContent += " have been selected as relevant for your community by the gateway curators.";
|
|
tooltipContent += "</div>";
|
|
|
|
return tooltipContent;
|
|
}
|
|
|
|
public buildZenodoCommunitiesTooltip(): string {
|
|
let tooltipContent: string = "<div>";
|
|
|
|
tooltipContent += "<span class='uk-text-bold'>Zenodo</span> is a catch-all repository for OpenAIRE.";
|
|
tooltipContent += "<div class='uk-margin-small-top'>A <span class='uk-text-bold'>Zenodo Community</span> is created and curated by Zenodo users.</div>";
|
|
tooltipContent += "</div>";
|
|
|
|
return tooltipContent;
|
|
}
|
|
}
|