import {Component, Input, ViewChild} from "@angular/core"; import {EnvProperties} from "../../utils/properties/env-properties"; import {properties} from "../../../../environments/environment"; import {OpenaireEntities} from "../../utils/properties/searchFields"; import {Organization, Project} from "../../utils/result-preview/result-preview"; import {RouterHelper} from "../../utils/routerHelper.class"; @Component({ selector: 'entity-metadata', template: `
Open Access Mandate for {{openaireEntities.PUBLICATIONS}} and {{openaireEntities.DATASETS}} Open Access Mandate for {{openaireEntities.PUBLICATIONS}} Open Access Mandate for {{openaireEntities.DATASETS}} {{entityType}} {{removeUnknown(types, true).join(' , ')}} {{year}} From {{startYear}} Until {{endYear}} {{startYear}} - {{endYear}} From {{startDate | date: 'dd MMM yyyy'}} Until {{endDate | date: 'dd MMM yyyy'}} {{startDate | date: 'dd MMM yyyy'}} (Started) - {{endDate | date: 'dd MMM yyyy'}} {{currentDate >= endDate ? '(Ended)' : '(Ending)'}} {{status}} (M{{calcCurrentMonth}}) {{date | date: 'dd MMM yyyy': 'UTC'}} Embargo end date: {{embargoEndDate | date: 'dd MMM yyyy'}} Under curation {{removeUnknown(countries).join(', ')}} {{removeUnknown(languages).join(', ')}} {{removeUnknown(programmingLanguages).join(', ')}} Compatibility: {{compatibility.info}} {{compatibility.name}} {{compatibility.info}} {{compatibility.info}} in OpenAIRE {{compatibility.name}} Compatibility: {{compatibilityString}} OpenAIRE Text Mining Thematic Publicly funded Funded by: {{showInline ? projectNames.join(', ') : projectNames.slice(0, projectsLimit).join(', ')}} +{{projects.length - projectsLimit | number}} projects View less Partners: {{showInline ? organizationNames.join(', ') : organizationNames.slice(0, organizationsLimit).join(', ')}} +{{organizations.length - organizationsLimit | number}} partners View less {{subjects.slice(0, 3).join(', ')}} {{provenanceAction}} {{relationName}}
{{item.name}}{{i == organizations.length - 1 ? '' : ','}}
{{item['funderShortname'] ? item['funderShortname'] : item['funderName']}} [no funder available] | {{ item['acronym'] ? item['acronym'] : item['title']}} {{i == projects.length - 1 ? '' : ','}}
`, styleUrls: ['entity-metadata.component.less'] }) export class EntityMetadataComponent { @Input() isMobile: boolean = false; @Input() entityType: string; @Input() types: string[]; @Input() year: string; // search result @Input() startDate: number; // project landing @Input() startYear: string; // search result @Input() endDate: number; // project landing @Input() endYear: string; // search result @Input() currentDate: number; // project landing @Input() status: string; // project landing @Input() openAccessMandatePublications: boolean // project landing @Input() openAccessMandateDatasets: boolean // project landing @Input() date: Date; @Input() embargoEndDate: Date | string; @Input() underCuration: boolean = false; @Input() publisher; // showPublisher component @Input() journal; // showPublisher component @Input() countries; @Input() languages; @Input() programmingLanguages; @Input() compatibilityString: string; @Input() compatibility; // data provider landing @Input() aggregationStatus; // data provider landing @Input() thematic: boolean; // data provider landing @Input() type; // data provider landing @Input() provenanceAction: string; // search result @Input() relationName: string; // search result @Input() publiclyFunded: boolean; // search result @Input() projects: Project[]; @Input() organizations: Organization[]; @Input() subjects: string[]; @Input() prevPath: string = ""; @ViewChild('partnersModal') partnersModal; @ViewChild('projectsModal') projectsModal; organizationsLimit: number = 5; projectsLimit: number = 3; showInline: boolean = false; lessBtn: boolean = false; properties: EnvProperties = properties; public openaireEntities = OpenaireEntities; public routerHelper: RouterHelper = new RouterHelper(); public removeUnknown(array: string[], type: boolean = false): string[] { if (type) { return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown'); } else { return array.filter(value => value.toLowerCase() !== 'unknown'); } } public removeDuplicates(array: string[]): string[] { return array.filter(value => value.toLowerCase() !== this.entityType); } public buildCurationTooltip(): string { let tooltipContent: string = "
"; tooltipContent += "
Record in preview
"; tooltipContent += "

Bibliographic record accepted by the system, but not yet processed by
OpenAIRE tools for information quality improvement and de-duplication

"; tooltipContent += "
"; return tooltipContent; } get projectNames(): string[] { if (this.projects && this.projects.length > 0) { return this.projects.map(project => { let value = project.funderShortname ? project.funderShortname : project.funderName; if (project.acronym || project.title) { value = (value ? value + ' | ' : '') + (project.acronym ? project.acronym : (project.title.length > 25 ? (project.title.slice(0, 25) + '...'): project.title)); } // if(project.code) { // value = value + ' (' + project.code + ')'; // } return value; }); } return []; } get organizationNames(): string[] { if (this.organizations && this.organizations.length > 0) { return this.organizations.map(organization => organization.name); } return []; } public addEoscPrevInParams(obj) { if(properties.adminToolsPortalType == "eosc" && this.prevPath) { return this.routerHelper.addQueryParam("pv", this.prevPath, obj); } return obj; } public viewAllPartnersClick() { if(this.organizations.length <= this.organizationsLimit * 2) { this.showInline = true; this.lessBtn = true; } else { this.openPartnersModal(); } } public openPartnersModal() { if (this.isMobile) { this.partnersModal.okButton = false; this.partnersModal.title = "Partners"; this.partnersModal.open(); } else { this.partnersModal.cancelButton = false; this.partnersModal.okButton = false; this.partnersModal.alertTitle = "Partners"; this.partnersModal.open(); } } public viewAllProjectsClick() { if(this.projects.length <= this.projectsLimit * 2) { this.showInline = true; this.lessBtn = true; } else { this.openProjectsModal(); } } public openProjectsModal() { if (this.isMobile) { this.projectsModal.okButton = false; this.projectsModal.title = "Projects"; this.projectsModal.open(); } else { this.projectsModal.cancelButton = false; this.projectsModal.okButton = false; this.projectsModal.alertTitle = "Projects"; this.projectsModal.open(); } } public get calcCurrentMonth() { let currentDate = new Date(this.currentDate); let startDate = new Date(this.startDate); var months; months = (currentDate.getFullYear() - startDate.getFullYear()) * 12; months -= startDate.getMonth(); months += currentDate.getMonth(); if(startDate.getDate() > currentDate.getDate()) { months--; } return months <= 0 ? 0 : months+1; } }