2021-02-26 15:30:10 +01:00
|
|
|
import {Component, Input, OnChanges, OnInit, SimpleChanges} from "@angular/core";
|
2020-03-12 14:49:10 +01:00
|
|
|
import {ResultPreview} from "./result-preview";
|
|
|
|
import {EnvProperties} from "../properties/env-properties";
|
|
|
|
import {RouterHelper} from "../routerHelper.class";
|
|
|
|
import {AlertModal} from "../modal/alert";
|
2020-06-29 15:15:52 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2022-06-03 12:01:55 +02:00
|
|
|
import {Identifier, StringUtils} from "../string-utils.class";
|
2022-05-04 12:57:13 +02:00
|
|
|
import {OpenaireEntities} from "../properties/searchFields";
|
2022-09-06 15:28:51 +02:00
|
|
|
import {HelperFunctions} from "../HelperFunctions.class";
|
2023-11-30 22:03:39 +01:00
|
|
|
import {NumberUtils} from '../number-utils.class';
|
2020-03-12 14:49:10 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'result-preview',
|
2022-08-02 11:43:39 +02:00
|
|
|
templateUrl: 'result-preview.component.html',
|
2023-02-16 15:33:40 +01:00
|
|
|
styleUrls: ['result-preview.component.less']
|
2020-03-12 14:49:10 +01:00
|
|
|
})
|
2021-02-26 15:30:10 +01:00
|
|
|
export class ResultPreviewComponent implements OnInit, OnChanges {
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2020-03-12 14:49:10 +01:00
|
|
|
@Input() result: ResultPreview;
|
|
|
|
@Input() properties: EnvProperties;
|
2022-05-04 12:57:13 +02:00
|
|
|
public openaireEntities = OpenaireEntities;
|
2020-03-12 14:49:10 +01:00
|
|
|
@Input() showSubjects: boolean = true;
|
|
|
|
@Input() showOrganizations: boolean = true;
|
|
|
|
@Input() modal: AlertModal = null;
|
2020-03-13 16:06:22 +01:00
|
|
|
@Input() promoteWebsiteURL: boolean = false;
|
2021-02-26 15:30:10 +01:00
|
|
|
@Input() hasLink: boolean = true;
|
2023-02-20 15:59:07 +01:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* */
|
2023-02-16 15:33:40 +01:00
|
|
|
@Input() isCard: boolean = false;
|
|
|
|
@Input() isMobile: boolean = false;
|
2023-11-30 22:03:39 +01:00
|
|
|
@Input() modifier: 'uk-card-default' | null = null;
|
2020-03-12 14:49:10 +01:00
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public urlParam: string;
|
2020-06-29 15:15:52 +02:00
|
|
|
public url: string;
|
2023-11-27 13:01:14 +01:00
|
|
|
@Input() customUrl: string;
|
2021-03-22 17:16:08 +01:00
|
|
|
@Input() externalUrl: string;
|
2021-02-10 10:05:37 +01:00
|
|
|
@Input() showOrcid: boolean = true;
|
2021-04-02 11:17:00 +02:00
|
|
|
@Input() showEnermaps: boolean = false;
|
2023-02-16 15:33:40 +01:00
|
|
|
@Input() provenanceActionVocabulary = null;
|
|
|
|
@Input() relationsVocabulary = null;
|
2023-05-12 14:55:22 +02:00
|
|
|
@Input() showInline: boolean = false; // do not open modal for "view more" when this is true
|
2023-06-07 10:09:43 +02:00
|
|
|
@Input() isDeletedByInferenceModal: boolean = false; // do not show action bar in results when in "Other versions" modal section
|
2023-11-27 13:01:14 +01:00
|
|
|
@Input() showEntityActions: boolean = true; // we can use this instead of the above as it is more generic
|
2023-02-20 15:59:07 +01:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
/* Metadata */
|
|
|
|
public type: string;
|
|
|
|
public types: string[];
|
|
|
|
public provenanceAction: string;
|
|
|
|
public relationName: string;
|
|
|
|
|
|
|
|
public linking: boolean = false;
|
|
|
|
public share: boolean = false;
|
|
|
|
public cite: boolean = false;
|
|
|
|
public orcid: boolean = false;
|
2023-02-22 13:43:31 +01:00
|
|
|
public deposit: boolean = false;
|
|
|
|
public embed: boolean = false;
|
2023-02-20 15:59:07 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
ngOnInit(): void {
|
2023-11-30 22:03:39 +01:00
|
|
|
if(this.isMobile) {
|
|
|
|
this.modifier = "uk-card-default";
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.hasLink) {
|
2021-02-26 15:30:10 +01:00
|
|
|
if (this.result.resultType === "publication") {
|
|
|
|
this.urlParam = "articleId";
|
|
|
|
this.url = properties.searchLinkToPublication.split('?')[0];
|
2023-02-17 18:40:05 +01:00
|
|
|
this.resultActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType === "dataset") {
|
|
|
|
this.urlParam = "datasetId";
|
|
|
|
this.url = properties.searchLinkToDataset.split('?')[0];
|
2023-02-17 18:40:05 +01:00
|
|
|
this.resultActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType === "software") {
|
|
|
|
this.urlParam = "softwareId";
|
|
|
|
this.url = properties.searchLinkToSoftwareLanding.split('?')[0];
|
2023-02-17 18:40:05 +01:00
|
|
|
this.resultActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType === "other") {
|
|
|
|
this.urlParam = "orpId";
|
|
|
|
this.url = properties.searchLinkToOrp.split('?')[0];
|
2023-02-17 18:40:05 +01:00
|
|
|
this.resultActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType == "project") {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.id) {
|
2021-03-08 16:32:33 +01:00
|
|
|
this.urlParam = "projectId";
|
2023-02-16 15:33:40 +01:00
|
|
|
} else if (this.result.code && this.result.funderShortname) {
|
2021-03-08 16:32:33 +01:00
|
|
|
this.result.id = this.result.code;
|
|
|
|
this.urlParam = "grantId";
|
|
|
|
}
|
2021-02-26 15:30:10 +01:00
|
|
|
this.url = properties.searchLinkToProject.split('?')[0];
|
2023-10-26 15:29:05 +02:00
|
|
|
if(this.result.id == "-1"){
|
|
|
|
//community projetcs - not yet loaded in the graph
|
|
|
|
this.url = null;
|
|
|
|
this.result.id = null;
|
|
|
|
}
|
2023-02-22 13:43:31 +01:00
|
|
|
this.projectActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType == "organization") {
|
|
|
|
this.urlParam = "organizationId";
|
|
|
|
this.url = properties.searchLinkToOrganization.split('?')[0];
|
2023-02-22 13:43:31 +01:00
|
|
|
this.organizationActions();
|
2021-02-26 15:30:10 +01:00
|
|
|
} else if (this.result.resultType == "dataprovider") {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.compatibilityUNKNOWN && properties.adminToolsPortalType == "eosc") {
|
2022-05-20 14:20:50 +02:00
|
|
|
this.urlParam = "serviceId";
|
|
|
|
this.url = properties.searchLinkToService.split('?')[0];
|
|
|
|
} else {
|
|
|
|
this.urlParam = "datasourceId";
|
|
|
|
this.url = properties.searchLinkToDataProvider.split('?')[0];
|
|
|
|
}
|
2023-02-22 13:43:31 +01:00
|
|
|
this.contentProviderActions();
|
2022-05-13 14:57:31 +02:00
|
|
|
} else if (this.result.resultType == "service") {
|
|
|
|
this.urlParam = "serviceId";
|
|
|
|
this.url = properties.searchLinkToService.split('?')[0];
|
2021-02-26 15:30:10 +01:00
|
|
|
} else {
|
|
|
|
this.urlParam = "id";
|
|
|
|
this.url = properties.searchLinkToResult.split('?')[0];
|
|
|
|
}
|
|
|
|
this.checkPID();
|
2021-02-11 11:20:10 +01:00
|
|
|
}
|
2023-02-17 18:40:05 +01:00
|
|
|
this.initMetadata();
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.languages) {
|
2020-07-14 11:57:11 +02:00
|
|
|
this.result.languages = this.removeUnknown(this.result.languages);
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.countries) {
|
2020-07-14 11:57:11 +02:00
|
|
|
this.result.countries = this.removeUnknown(this.result.countries);
|
|
|
|
}
|
2020-05-21 16:18:52 +02:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
resultActions() {
|
|
|
|
this.linking = true;
|
|
|
|
this.share = true;
|
|
|
|
this.cite = true;
|
2024-01-09 10:33:46 +01:00
|
|
|
this.orcid = (this.properties.adminToolsPortalType == 'explore' || this.properties.adminToolsPortalType == 'community' || this.properties.adminToolsPortalType == 'aggregator' || this.properties.dashboard == 'irish') &&
|
2023-02-17 18:40:05 +01:00
|
|
|
this.showOrcid && this.result.identifiers && this.result.identifiers.size > 0;
|
|
|
|
}
|
2023-02-22 13:43:31 +01:00
|
|
|
|
|
|
|
projectActions() {
|
|
|
|
this.linking = true;
|
|
|
|
this.share = true;
|
|
|
|
this.deposit = true;
|
|
|
|
this.embed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
organizationActions() {
|
|
|
|
this.share = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
contentProviderActions() {
|
|
|
|
this.share = true;
|
|
|
|
}
|
2023-02-20 15:59:07 +01:00
|
|
|
|
2021-02-26 15:30:10 +01:00
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (changes.result && this.hasLink) {
|
2021-02-26 15:30:10 +01:00
|
|
|
this.checkPID();
|
|
|
|
}
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2021-02-26 15:30:10 +01:00
|
|
|
checkPID() {
|
|
|
|
// if result has a pid use it as parameter instead of openaireId
|
2023-02-16 15:33:40 +01:00
|
|
|
let pid: Identifier = this.getPID();
|
|
|
|
if (pid) {
|
2021-02-26 15:30:10 +01:00
|
|
|
this.urlParam = "pid";
|
2021-04-09 17:39:42 +02:00
|
|
|
this.result.id = pid.id;
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2021-02-26 15:30:10 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2021-03-10 11:41:38 +01:00
|
|
|
getPID() {
|
2022-05-30 09:39:10 +02:00
|
|
|
return Identifier.getPIDFromIdentifiers(this.result.identifiers);
|
2021-03-10 11:41:38 +01:00
|
|
|
}
|
2022-04-13 12:50:55 +02:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
public initMetadata() {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.resultType && this.result.resultType !== 'dataprovider') {
|
2020-07-22 15:39:35 +02:00
|
|
|
this.type = this.getTypeName(this.result.resultType);
|
2020-05-21 16:18:52 +02:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.types) {
|
2023-02-17 18:40:05 +01:00
|
|
|
this.types = this.removeUnknown(this.removeDuplicates(this.result.types));
|
2020-05-21 16:18:52 +02:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.result.provenanceAction) {
|
2023-02-17 18:40:05 +01:00
|
|
|
this.provenanceAction = HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary, false);
|
2023-02-16 15:33:40 +01:00
|
|
|
}
|
|
|
|
if (this.result.relationName) {
|
2023-02-17 18:40:05 +01:00
|
|
|
this.relationName = HelperFunctions.getVocabularyLabel(this.result.relationName, this.relationsVocabulary);
|
2022-01-07 11:16:23 +01:00
|
|
|
}
|
|
|
|
// if(this.result.percentage) {
|
|
|
|
// this.beforeTitle.push((this.result.relation ? this.result.relation+": " : "") + this.result.percentage.toString() + "%");
|
|
|
|
// }
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
get hasActions() {
|
|
|
|
return this.linking || this.share || this.cite || this.orcid;
|
|
|
|
}
|
2023-02-20 15:59:07 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
public getTypeName(type: string): string {
|
2022-06-03 12:01:55 +02:00
|
|
|
return StringUtils.getEntityName(type, false);
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
public removeUnknown(array: string[]): string[] {
|
|
|
|
return array.filter(value => value.toLowerCase() !== 'unknown');
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
public removeDuplicates(array: string[]): string[] {
|
|
|
|
return array.filter(value => value.toLowerCase() !== this.result.resultType);
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
public accessClass(accessMode: string): string {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (accessMode.toLowerCase().indexOf('open') !== -1) {
|
2022-03-15 12:13:28 +01:00
|
|
|
return 'success';
|
2023-02-16 15:33:40 +01:00
|
|
|
} else if (accessMode.toLowerCase() === 'not available') {
|
2022-03-15 12:13:28 +01:00
|
|
|
return 'disabled'; // unknown
|
2020-03-12 14:49:10 +01:00
|
|
|
} else {
|
2022-03-15 12:13:28 +01:00
|
|
|
return 'disabled'; // closed
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
public onClick() {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.modal) {
|
2020-03-12 14:49:10 +01:00
|
|
|
this.modal.cancel();
|
|
|
|
}
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
|
|
|
|
createParam() {
|
|
|
|
if (this.urlParam == "grantId") {
|
|
|
|
return this.routerHelper.createQueryParams([this.urlParam, "funder"], [this.result.id, this.result.funderShortname])
|
2021-03-08 16:32:33 +01:00
|
|
|
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
return this.routerHelper.createQueryParam(this.urlParam, this.result.id)
|
2021-03-08 16:32:33 +01:00
|
|
|
|
|
|
|
}
|
2023-02-20 15:59:07 +01:00
|
|
|
|
2022-05-19 18:08:04 +02:00
|
|
|
public get isResultType() {
|
|
|
|
return this.result.resultType == "publication" || this.result.resultType == "dataset" ||
|
2023-02-16 15:33:40 +01:00
|
|
|
this.result.resultType == "software" || this.result.resultType == "other" || this.result.resultType == "result";
|
2022-05-19 18:08:04 +02:00
|
|
|
}
|
2023-05-02 11:00:40 +02:00
|
|
|
|
|
|
|
public formatNumber(num: number | string) {
|
|
|
|
let formatted = NumberUtils.roundNumber(+num);
|
|
|
|
return formatted.number + formatted.size;
|
|
|
|
}
|
2023-05-08 15:41:42 +02:00
|
|
|
|
2023-09-19 15:48:08 +02:00
|
|
|
public isNumber(value): boolean {
|
|
|
|
return typeof value === 'number';
|
|
|
|
}
|
|
|
|
|
2023-05-08 15:41:42 +02:00
|
|
|
public getAccessLabel(accessRight) : string {
|
|
|
|
if(accessRight) {
|
|
|
|
return (accessRight + (accessRight.toLowerCase().endsWith(" access") ? "" : " access"));
|
|
|
|
}
|
|
|
|
return "Not available access";
|
|
|
|
}
|
2023-04-20 19:06:53 +02:00
|
|
|
|
|
|
|
public addEoscPrevInParams(obj) {
|
|
|
|
if(properties.adminToolsPortalType == "eosc" && this.prevPath) {
|
2023-05-25 17:10:58 +02:00
|
|
|
let splitted: string[] = this.prevPath.split("?");
|
|
|
|
obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj);
|
|
|
|
if(splitted.length > 0) {
|
|
|
|
obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj);
|
|
|
|
}
|
2023-04-20 19:06:53 +02:00
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
2020-03-13 16:06:22 +01:00
|
|
|
}
|