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