1
|
import {Component, Input, ElementRef} from '@angular/core';
|
2
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
3
|
|
4
|
@Component({
|
5
|
selector: 'availableOn',
|
6
|
template: `
|
7
|
<dl class="uk-description-list-line">
|
8
|
<dt class="title">Available On</dt>
|
9
|
<dd class="line" *ngFor="let available of availableOn let i=index" >
|
10
|
<div *ngIf="i<5 || showAll">
|
11
|
<div class="{{available['bestAccessMode']}}">
|
12
|
<span *ngIf="available.downloadUrl.length > 1"
|
13
|
class="custom-external custom-icon">
|
14
|
{{available.downloadName}}
|
15
|
<span *ngFor="let url of available.downloadUrl; let i=index;">
|
16
|
<a href="{{url}}" target="_blank"
|
17
|
[attr.uk-tooltip]="available.accessMode[i] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
18
|
[title]="available.accessMode[i]">
|
19
|
[{{i+1}}]
|
20
|
</a>
|
21
|
</span>
|
22
|
</span>
|
23
|
<a class="custom-external custom-icon"
|
24
|
*ngIf="available['downloadUrl'].length == 1"
|
25
|
href="{{available['downloadUrl']}}"
|
26
|
target="_blank"
|
27
|
[attr.uk-tooltip]="available['bestAccessMode'] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
28
|
[title]="available['bestAccessMode']">
|
29
|
{{available.downloadName}}
|
30
|
</a>
|
31
|
<span *ngIf="available.collectedName" class="uk-text-bold">via</span>
|
32
|
<a *ngIf="available.collectedName"
|
33
|
[queryParams]="{datasourceId: available.collectedId}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
34
|
{{available.collectedName}}
|
35
|
</a>
|
36
|
<span *ngIf="available.type || available.year">(<span *ngIf="available.type">{{available.type}}, </span><span *ngIf="available.year">{{available.year}}</span>)</span>
|
37
|
</div>
|
38
|
</div>
|
39
|
</dd>
|
40
|
<dd *ngIf="showAll" class="uk-text-right">
|
41
|
<a (click)="showAll = !showAll; scroll()">
|
42
|
View less
|
43
|
</a>
|
44
|
</dd>
|
45
|
<dd *ngIf="!showAll && availableOn.length > 5">...</dd>
|
46
|
<dd *ngIf="!showAll && availableOn.length > 5" class="uk-text-right">
|
47
|
<a (click)="showAll = !showAll;">
|
48
|
View more
|
49
|
</a>
|
50
|
</dd>
|
51
|
</dl>
|
52
|
`
|
53
|
})
|
54
|
|
55
|
export class AvailableOnComponent {
|
56
|
@Input() availableOn: { "downloadName": string, "downloadUrl": string[],
|
57
|
"collectedName": string, "collectedId": string,
|
58
|
"accessMode": string[], "bestAccessMode": string,
|
59
|
"type": string, "year":string }[];
|
60
|
|
61
|
public showAll: boolean = false;
|
62
|
|
63
|
constructor (private element: ElementRef) {}
|
64
|
|
65
|
ngOnInit() {}
|
66
|
|
67
|
public scroll() {
|
68
|
console.info("scroll into view");
|
69
|
if (typeof document !== 'undefined') {
|
70
|
this.element.nativeElement.scrollIntoView();
|
71
|
}
|
72
|
}
|
73
|
}
|