1
|
import {Component, Input} from '@angular/core';
|
2
|
import {SearchResult} from '../utils/entities/searchResult';
|
3
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
4
|
import {RouterHelper} from '../utils/routerHelper.class';
|
5
|
import {EnvProperties} from '../utils/properties/env-properties';
|
6
|
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
|
7
|
import {ActivatedRoute} from "@angular/router";
|
8
|
import {ResultPreview} from "../utils/result-preview/result-preview";
|
9
|
import {Subscriber} from "rxjs";
|
10
|
import {properties} from "../../../environments/environment";
|
11
|
|
12
|
@Component({
|
13
|
selector: 'deposit-result',
|
14
|
templateUrl:'searchResultsInDeposit.component.html'
|
15
|
})
|
16
|
|
17
|
export class SearchResultsInDepositComponent {
|
18
|
@Input() results: SearchResult[];
|
19
|
@Input() status: number;
|
20
|
@Input() type: string;
|
21
|
@Input() properties:EnvProperties;
|
22
|
|
23
|
|
24
|
public urlParam: string;
|
25
|
public linkToAdvancedSearchPage: string;
|
26
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
27
|
public routerHelper:RouterHelper = new RouterHelper();
|
28
|
public errorMessage: string = "No results found";
|
29
|
|
30
|
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
31
|
sub;
|
32
|
constructor (private route: ActivatedRoute) {}
|
33
|
ngOnDestroy() {
|
34
|
if (this.sub instanceof Subscriber) {
|
35
|
this.sub.unsubscribe();
|
36
|
}
|
37
|
}
|
38
|
ngOnInit() {
|
39
|
if(this.type == "publication") {
|
40
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
|
41
|
this.urlParam = "articleId";
|
42
|
} else if(this.type == "dataset") {
|
43
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
|
44
|
this.urlParam = "datasetId";
|
45
|
} else if(this.type == "software") {
|
46
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
|
47
|
this.urlParam = "softwareId";
|
48
|
} else if(this.type == "other") {
|
49
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps;
|
50
|
this.urlParam = "orpId";
|
51
|
} else if(this.type == "project") {
|
52
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
|
53
|
this.urlParam = "projectId";
|
54
|
} else if(this.type == "organization") {
|
55
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
|
56
|
this.urlParam = "organizationId";
|
57
|
} else if(this.type == "dataprovider") {
|
58
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
|
59
|
this.urlParam = "datasourceId";
|
60
|
}
|
61
|
|
62
|
this.properties = properties;
|
63
|
|
64
|
if (!this.zenodoInformation) {
|
65
|
this.zenodoInformation = new ZenodoInformationClass();
|
66
|
}
|
67
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
68
|
this.zenodoInformation.url = this.properties.zenodo;
|
69
|
}
|
70
|
if (!this.zenodoInformation.name) {
|
71
|
this.zenodoInformation.name = "Zenodo";
|
72
|
}
|
73
|
|
74
|
}
|
75
|
|
76
|
public quote(params: string):string {
|
77
|
return '"'+params+'"';
|
78
|
}
|
79
|
public getResultPreview(result: SearchResult): ResultPreview {
|
80
|
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type);
|
81
|
}
|
82
|
|
83
|
}
|