2019-07-15 18:14:27 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {SearchResult} from '../utils/entities/searchResult';
|
|
|
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
|
|
|
import {RouterHelper} from '../utils/routerHelper.class';
|
2019-07-16 13:24:13 +02:00
|
|
|
import {EnvProperties} from '../utils/properties/env-properties';
|
2019-07-15 18:14:27 +02:00
|
|
|
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
|
|
|
|
import {ActivatedRoute} from "@angular/router";
|
2020-03-13 16:06:22 +01:00
|
|
|
import {ResultPreview} from "../utils/result-preview/result-preview";
|
2020-11-11 15:43:13 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-11-18 17:06:27 +01:00
|
|
|
import {properties} from "../../../environments/environment";
|
2019-07-16 13:24:13 +02:00
|
|
|
|
2019-07-15 18:14:27 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'deposit-result',
|
|
|
|
templateUrl:'searchResultsInDeposit.component.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchResultsInDepositComponent {
|
|
|
|
@Input() results: SearchResult[];
|
|
|
|
@Input() status: number;
|
|
|
|
@Input() type: string;
|
2024-07-02 12:51:15 +02:00
|
|
|
@Input() properties:EnvProperties = properties;
|
2023-11-08 21:40:04 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
2019-07-15 18:14:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
public urlParam: string;
|
|
|
|
public linkToAdvancedSearchPage: string;
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
public errorMessage: string = "No results found";
|
|
|
|
|
2019-07-16 13:24:13 +02:00
|
|
|
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
2020-11-11 15:43:13 +01:00
|
|
|
sub;
|
2019-07-16 13:24:13 +02:00
|
|
|
constructor (private route: ActivatedRoute) {}
|
2020-11-11 15:43:13 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
if (this.sub instanceof Subscriber) {
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
2019-07-15 18:14:27 +02:00
|
|
|
ngOnInit() {
|
|
|
|
if(this.type == "publication") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
|
|
|
|
this.urlParam = "articleId";
|
|
|
|
} else if(this.type == "dataset") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
|
|
|
|
this.urlParam = "datasetId";
|
|
|
|
} else if(this.type == "software") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
|
|
|
|
this.urlParam = "softwareId";
|
|
|
|
} else if(this.type == "other") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps;
|
|
|
|
this.urlParam = "orpId";
|
|
|
|
} else if(this.type == "project") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
|
|
|
|
this.urlParam = "projectId";
|
|
|
|
} else if(this.type == "organization") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
|
|
|
|
this.urlParam = "organizationId";
|
|
|
|
} else if(this.type == "dataprovider") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
|
|
|
|
this.urlParam = "datasourceId";
|
|
|
|
}
|
|
|
|
|
2019-07-16 13:24:13 +02:00
|
|
|
if (!this.zenodoInformation) {
|
|
|
|
this.zenodoInformation = new ZenodoInformationClass();
|
2019-07-15 18:14:27 +02:00
|
|
|
}
|
2019-07-16 13:24:13 +02:00
|
|
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
|
|
|
this.zenodoInformation.url = this.properties.zenodo;
|
|
|
|
}
|
|
|
|
if (!this.zenodoInformation.name) {
|
|
|
|
this.zenodoInformation.name = "Zenodo";
|
|
|
|
}
|
2020-11-18 17:06:27 +01:00
|
|
|
|
2019-07-15 18:14:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public quote(params: string):string {
|
|
|
|
return '"'+params+'"';
|
|
|
|
}
|
2020-03-13 16:06:22 +01:00
|
|
|
public getResultPreview(result: SearchResult): ResultPreview {
|
|
|
|
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type);
|
|
|
|
}
|
|
|
|
|
2019-07-15 18:14:27 +02:00
|
|
|
}
|