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";
|
2021-01-13 19:30:25 +01:00
|
|
|
import {Session} from "../../login/utils/helper.class";
|
2021-02-11 11:20:10 +01:00
|
|
|
import {Identifier} from "../string-utils.class";
|
2022-05-04 12:57:13 +02:00
|
|
|
import {OpenaireEntities} from "../properties/searchFields";
|
2020-03-12 14:49:10 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'result-preview',
|
|
|
|
templateUrl: 'result-preview.component.html'
|
|
|
|
})
|
2021-02-26 15:30:10 +01:00
|
|
|
export class ResultPreviewComponent implements OnInit, OnChanges {
|
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;
|
2022-03-15 12:13:28 +01:00
|
|
|
@Input() isCard: boolean = false;
|
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;
|
2021-03-22 17:16:08 +01:00
|
|
|
@Input() externalUrl: string;
|
2020-07-22 15:39:35 +02:00
|
|
|
public type: string;
|
2020-05-21 16:18:52 +02:00
|
|
|
public beforeTitle: string[] = [];
|
2020-07-13 16:42:34 +02:00
|
|
|
public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
|
2021-02-10 10:05:37 +01:00
|
|
|
@Input() showOrcid: boolean = true;
|
2021-04-02 11:17:00 +02:00
|
|
|
@Input() showEnermaps: boolean = false;
|
2021-01-13 19:30:25 +01:00
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
ngOnInit(): void {
|
2021-02-26 15:30:10 +01:00
|
|
|
if(this.hasLink) {
|
|
|
|
if (this.result.resultType === "publication") {
|
|
|
|
this.urlParam = "articleId";
|
|
|
|
this.url = properties.searchLinkToPublication.split('?')[0];
|
|
|
|
} else if (this.result.resultType === "dataset") {
|
|
|
|
this.urlParam = "datasetId";
|
|
|
|
this.url = properties.searchLinkToDataset.split('?')[0];
|
|
|
|
} else if (this.result.resultType === "software") {
|
|
|
|
this.urlParam = "softwareId";
|
|
|
|
this.url = properties.searchLinkToSoftwareLanding.split('?')[0];
|
|
|
|
} else if (this.result.resultType === "other") {
|
|
|
|
this.urlParam = "orpId";
|
|
|
|
this.url = properties.searchLinkToOrp.split('?')[0];
|
|
|
|
} else if (this.result.resultType == "project") {
|
2021-03-08 16:32:33 +01:00
|
|
|
if(this.result.id) {
|
|
|
|
this.urlParam = "projectId";
|
|
|
|
}else if(this.result.code && this.result.funderShortname){
|
|
|
|
this.result.id = this.result.code;
|
|
|
|
this.urlParam = "grantId";
|
|
|
|
}
|
2021-02-26 15:30:10 +01:00
|
|
|
this.url = properties.searchLinkToProject.split('?')[0];
|
|
|
|
} else if (this.result.resultType == "organization") {
|
|
|
|
this.urlParam = "organizationId";
|
|
|
|
this.url = properties.searchLinkToOrganization.split('?')[0];
|
|
|
|
} else if (this.result.resultType == "dataprovider") {
|
|
|
|
this.urlParam = "datasourceId";
|
|
|
|
this.url = properties.searchLinkToDataProvider.split('?')[0];
|
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
|
|
|
}
|
2020-05-21 16:18:52 +02:00
|
|
|
this.initBeforeTitle();
|
2020-07-14 11:57:11 +02:00
|
|
|
if(this.result.languages) {
|
|
|
|
this.result.languages = this.removeUnknown(this.result.languages);
|
|
|
|
}
|
|
|
|
if(this.result.countries) {
|
|
|
|
this.result.countries = this.removeUnknown(this.result.countries);
|
|
|
|
}
|
2020-05-21 16:18:52 +02:00
|
|
|
}
|
|
|
|
|
2021-02-26 15:30:10 +01:00
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
|
if(changes.result && this.hasLink) {
|
|
|
|
this.checkPID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkPID() {
|
|
|
|
// if result has a pid use it as parameter instead of openaireId
|
2021-03-10 11:41:38 +01:00
|
|
|
let pid:Identifier =this.getPID();
|
2021-02-26 15:30:10 +01:00
|
|
|
if(pid){
|
|
|
|
this.urlParam = "pid";
|
2021-04-09 17:39:42 +02:00
|
|
|
this.result.id = pid.id;
|
2021-02-26 15:30:10 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 11:41:38 +01:00
|
|
|
getPID() {
|
|
|
|
return Identifier.getResultPIDFromIdentifiers(this.result.identifiers);
|
|
|
|
}
|
2022-04-13 12:50:55 +02:00
|
|
|
|
2020-05-21 16:18:52 +02:00
|
|
|
public initBeforeTitle() {
|
2020-07-17 11:29:57 +02: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
|
|
|
}
|
|
|
|
if(this.result.types) {
|
|
|
|
this.removeUnknown(this.removeDuplicates(this.result.types)).forEach(type => {
|
|
|
|
this.beforeTitle.push(type);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(this.result.year) {
|
|
|
|
this.beforeTitle.push(this.result.year.toString());
|
|
|
|
}
|
|
|
|
if(this.result.startYear && this.result.endYear) {
|
|
|
|
this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString());
|
|
|
|
}
|
2020-05-22 16:51:28 +02:00
|
|
|
if(this.result.provenanceAction) {
|
|
|
|
this.beforeTitle.push(this.result.provenanceAction);
|
|
|
|
}
|
2022-01-07 11:16:23 +01:00
|
|
|
if(this.result.relationName) {
|
|
|
|
this.beforeTitle.push(this.result.relationName);
|
|
|
|
}
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
|
|
public getTypeName(type: string): string {
|
|
|
|
if (type === "dataset") {
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
return this.openaireEntities.DATASET;
|
2020-03-12 14:49:10 +01:00
|
|
|
} else if (type === "other") {
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
return this.openaireEntities.OTHER_SINGULAR;
|
2020-03-12 14:49:10 +01:00
|
|
|
} else if (type === "dataprovider") {
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
return this.openaireEntities.DATASOURCE;
|
2022-05-13 14:57:31 +02:00
|
|
|
} else if (type === "service") {
|
|
|
|
return this.openaireEntities.SERVICE;
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
} else if (type === "publication") {
|
|
|
|
return this.openaireEntities.PUBLICATION;
|
|
|
|
} else if (type === "software") {
|
|
|
|
return this.openaireEntities.SOFTWARE_SINGULAR;
|
|
|
|
} else if (type === "result") {
|
|
|
|
return this.openaireEntities.RESULT;
|
2020-03-12 14:49:10 +01:00
|
|
|
} else {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public removeUnknown(array: string[]): string[] {
|
|
|
|
return array.filter(value => value.toLowerCase() !== 'unknown');
|
|
|
|
}
|
|
|
|
|
|
|
|
public removeDuplicates(array: string[]): string[] {
|
|
|
|
return array.filter(value => value.toLowerCase() !== this.result.resultType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public accessClass(accessMode: string): string {
|
|
|
|
if(accessMode.toLowerCase().indexOf('open') !== -1) {
|
2022-03-15 12:13:28 +01:00
|
|
|
return 'success';
|
2020-03-12 14:49:10 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
public onClick() {
|
2020-03-12 14:49:10 +01:00
|
|
|
if(this.modal) {
|
|
|
|
this.modal.cancel();
|
|
|
|
}
|
|
|
|
}
|
2021-03-08 16:32:33 +01:00
|
|
|
createParam(){
|
|
|
|
if(this.urlParam == "grantId" ){
|
|
|
|
return this.routerHelper.createQueryParams([this.urlParam,"funder"],[this.result.id,this.result.funderShortname])
|
|
|
|
|
|
|
|
}
|
|
|
|
return this.routerHelper.createQueryParam(this.urlParam,this.result.id)
|
|
|
|
|
|
|
|
}
|
2022-05-19 18:08:04 +02:00
|
|
|
|
|
|
|
public get isResultType() {
|
|
|
|
return this.result.resultType == "publication" || this.result.resultType == "dataset" ||
|
|
|
|
this.result.resultType == "software" || this.result.resultType == "other" || this.result.resultType == "result";
|
|
|
|
}
|
2020-03-13 16:06:22 +01:00
|
|
|
}
|