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