1
|
import {Component, Input} from '@angular/core';
|
2
|
import {SearchResult} from '../../utils/entities/searchResult';
|
3
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
4
|
|
5
|
@Component({
|
6
|
selector: 'search-result',
|
7
|
template: `
|
8
|
<ul class="uk-list uk-margin">
|
9
|
<div *ngIf="status == errorCodes.LOADING" class="uk-alert uk-alert-primary" role="alert">Loading...</div>
|
10
|
<div *ngIf="status == errorCodes.NONE" class="uk-alert uk-alert-primary" role="alert">No Results found</div>
|
11
|
<div *ngIf="status == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
12
|
<div *ngIf="status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
13
|
|
14
|
<li *ngFor="let result of results">
|
15
|
<h4 [class] = result.title.accessMode [title] = result.title.accessMode >
|
16
|
<a href="{{result['title'].url}}">
|
17
|
<p *ngIf="result['title'].name != undefined && result['title'].name != ''"
|
18
|
[innerHTML]="result['title'].name">
|
19
|
</p>
|
20
|
<p *ngIf="result['title'].name == undefined || result['title'].name == ''">
|
21
|
{{result['title'].url}}
|
22
|
</p>
|
23
|
</a>
|
24
|
</h4>
|
25
|
|
26
|
<div>
|
27
|
<span *ngIf="result['authors'] != undefined">
|
28
|
<span *ngFor="let author of result['authors'].slice(0,15)">
|
29
|
<a href="{{author['url']}}">
|
30
|
{{author['name']}};
|
31
|
</a>
|
32
|
</span>
|
33
|
<span *ngIf="result['authors'].length > 15">...</span>
|
34
|
</span>
|
35
|
<span *ngIf="result.year != undefined && result.year != ''">
|
36
|
({{result.year}})
|
37
|
</span>
|
38
|
</div>
|
39
|
|
40
|
<div *ngIf="result.publisher != undefined && result.publisher != ''">Publisher: {{result.publisher}}</div>
|
41
|
|
42
|
<div *ngIf="result.country != undefined && result.country != ''">Country: {{result.country}}</div>
|
43
|
|
44
|
<div *ngIf="result['projects'] != undefined">
|
45
|
<span> Projects: </span>
|
46
|
<span *ngFor="let project of result['projects'].slice(0,15) let i=index">
|
47
|
<a *ngIf="project.url != undefined" href="{{project.url}}">
|
48
|
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
|
49
|
| {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})
|
50
|
</a>
|
51
|
<p *ngIf="project.url == undefined">
|
52
|
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
|
53
|
| {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})
|
54
|
</p>
|
55
|
<span *ngIf="i < result['projects'].length-1"> ,</span>
|
56
|
</span>
|
57
|
<span *ngIf="result['projects'].length > 15">...</span>
|
58
|
</div>
|
59
|
|
60
|
<blockquote *ngIf="result.description != undefined && result.description != ''">
|
61
|
<div class="text-justify" [innerHTML]="result.description"></div>
|
62
|
</blockquote>
|
63
|
|
64
|
<mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
|
65
|
|
66
|
|
67
|
<div *ngIf="result['funders'] != undefined">
|
68
|
<span> Funders: </span>
|
69
|
<span *ngFor="let funder of result['funders'] let i=index">
|
70
|
|
71
|
<span *ngIf="funder.funderShortname">
|
72
|
{{funder.funderShortname}}
|
73
|
</span>
|
74
|
<span *ngIf="i < result['funders'].length-1"> ,</span>
|
75
|
</span>
|
76
|
</div>
|
77
|
<span *ngIf="result.startYear && result.endYear"> ({{result.startYear}} - {{result.endYear}})</span>
|
78
|
<div *ngIf="result['organizations'] != undefined && result['organizations'].length > 0">
|
79
|
<span> Organizations: </span>
|
80
|
<span *ngFor="let organization of result['organizations'] let i=index">
|
81
|
<a *ngIf="organization.url != undefined" href="{{organization.url}}">
|
82
|
{{organization.name}}
|
83
|
</a>
|
84
|
<span *ngIf="organization.url == undefined">
|
85
|
{{organization.name}}
|
86
|
</span>
|
87
|
<span *ngIf="i < result['organizations'].length-1"> ,</span>
|
88
|
</span>
|
89
|
</div>
|
90
|
|
91
|
<div *ngIf="result['type'] != undefined && result['type'] != ''">Type: {{result['type']}}</div>
|
92
|
<div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
|
93
|
<span>Website URL: </span>
|
94
|
<span>
|
95
|
<a class="custom-external" href="{{result['websiteURL']}}" target="_blank">
|
96
|
{{result['websiteURL']}}
|
97
|
</a>
|
98
|
</span>
|
99
|
</div>
|
100
|
<div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
|
101
|
<span>OAI-PMH URL: </span>
|
102
|
<span>
|
103
|
<a class="custom-external" href="{{result['OAIPMHURL']}}" target="_blank">
|
104
|
{{result['OAIPMHURL']}}
|
105
|
</a>
|
106
|
</span>
|
107
|
</div>
|
108
|
|
109
|
<div *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''">
|
110
|
Compatibility: {{result.compatibility}}
|
111
|
</div>
|
112
|
|
113
|
<div *ngIf="result['countries'] != undefined && result['countries'].length > 0">
|
114
|
Countries: {{result.countries}}
|
115
|
</div>
|
116
|
|
117
|
<hr>
|
118
|
</li>
|
119
|
</ul>
|
120
|
`
|
121
|
})
|
122
|
|
123
|
export class SearchResultComponent {
|
124
|
@Input() page: number;
|
125
|
@Input() totalResults: number;
|
126
|
@Input() results: SearchResult[];
|
127
|
@Input() status: number;
|
128
|
errorCodes:ErrorCodes = new ErrorCodes();
|
129
|
|
130
|
public errorMessage: string = "No results found";
|
131
|
|
132
|
constructor () {
|
133
|
|
134
|
}
|
135
|
|
136
|
ngOnInit() {
|
137
|
}
|
138
|
}
|