1
|
import {Component, Input} from '@angular/core';
|
2
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
3
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
4
|
|
5
|
@Component({
|
6
|
selector: 'availableOn',
|
7
|
template: `
|
8
|
<div class="sideInfoTitle uk-margin-small-bottom">Download from</div>
|
9
|
<div class="download-from uk-height-max-large uk-overflow-auto">
|
10
|
<div *ngFor="let available of availableOn.slice(0, showNum) let i=index"
|
11
|
class="uk-flex uk-flex-top"
|
12
|
[title]="available.bestAccessMode ? available.bestAccessMode : 'Not available'">
|
13
|
<span class="uk-margin-small-right">
|
14
|
<img [src]="available.icon">
|
15
|
</span>
|
16
|
<div class="uk-width-expand">
|
17
|
<span *ngIf="available.downloadUrl.length > 1" class="title">
|
18
|
<span class="uk-text-bold">{{available.downloadName}}</span>
|
19
|
<a *ngFor="let url of available.downloadUrl; let i=index;">
|
20
|
[href]="url" target="_blank">
|
21
|
[{{(i + 1) | number}}]
|
22
|
</a>
|
23
|
</span>
|
24
|
<a *ngIf="available.downloadUrl.length === 1" [href]="available.downloadUrl[0]"
|
25
|
class="title" target="_blank">
|
26
|
{{available.downloadName}}
|
27
|
<span class="custom-external custom-icon space"></span>
|
28
|
</a>
|
29
|
<div *ngIf="removeUnknown(available.type) || available.year" class="uk-text-small">
|
30
|
<span *ngIf="removeUnknown(available.type)" class="uk-text-capitalize">{{available.type}}</span>
|
31
|
<span *ngIf="removeUnknown(available.type) && available.year"> . </span>
|
32
|
<span *ngIf="available.year">{{available.year}}</span>
|
33
|
</div>
|
34
|
<div *ngIf="available.collectedName" class="uk-text-small provider">
|
35
|
<span>Provider: </span>
|
36
|
<a *ngIf="available.collectedId" routerLink="/search/dataprovider" [queryParams]="{datasourceId: available.collectedId}">
|
37
|
{{available.collectedName}}
|
38
|
</a>
|
39
|
<span *ngIf="!available.collectedId">
|
40
|
{{available.collectedName}}
|
41
|
</span>
|
42
|
</div>
|
43
|
</div>
|
44
|
</div>
|
45
|
</div>
|
46
|
<div *ngIf="showNum > threshold" class="uk-text-right uk-margin-bottom">
|
47
|
<a (click)="showNum = threshold; scroll()">
|
48
|
View less
|
49
|
</a>
|
50
|
</div>
|
51
|
<!-- <div *ngIf="showNum == threshold && availableOn && availableOn.length > 5">...</div>-->
|
52
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5" class="uk-text-right uk-margin-bottom">
|
53
|
<a (click)="showNum = availableOn.length;">
|
54
|
View more
|
55
|
</a>
|
56
|
</div>
|
57
|
`
|
58
|
})
|
59
|
|
60
|
export class AvailableOnComponent {
|
61
|
@Input() availableOn: {
|
62
|
"downloadName": string, "downloadUrl": string[],
|
63
|
"collectedName": string, "collectedId": string,
|
64
|
"accessMode": string[], "bestAccessMode": string,
|
65
|
"type": string, "year": string, icon: string
|
66
|
}[];
|
67
|
@Input() properties: EnvProperties;
|
68
|
public open = '/assets/common-assets/unlock.svg';
|
69
|
public closed = '/assets/common-assets/lock.svg';
|
70
|
public unknown = '/assets/common-assets/question.svg';
|
71
|
public threshold: number = 4;
|
72
|
public showNum: number = 4;
|
73
|
|
74
|
constructor() {
|
75
|
}
|
76
|
|
77
|
ngOnInit() {
|
78
|
this.availableOn.forEach(available => {
|
79
|
if (available.bestAccessMode) {
|
80
|
if (available.bestAccessMode.toLowerCase().indexOf('open') !== -1) {
|
81
|
available.icon = this.open;
|
82
|
} else if (available.bestAccessMode.toLowerCase().indexOf('not available') !== -1) {
|
83
|
available.icon = this.unknown;
|
84
|
} else {
|
85
|
available.icon = this.closed;
|
86
|
}
|
87
|
} else {
|
88
|
available.icon = this.unknown;
|
89
|
}
|
90
|
}
|
91
|
);
|
92
|
}
|
93
|
|
94
|
public removeUnknown(value: string): string {
|
95
|
if(this.properties.environment === 'production') {
|
96
|
if (value.toLowerCase() === 'unknown') {
|
97
|
return null;
|
98
|
}
|
99
|
}
|
100
|
return value;
|
101
|
}
|
102
|
|
103
|
public scroll() {
|
104
|
HelperFunctions.scroll();
|
105
|
}
|
106
|
}
|