2019-04-24 14:31:01 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
2020-03-16 14:09:46 +01:00
|
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
2020-07-01 14:11:57 +02:00
|
|
|
import {HostedByCollectedFrom} from "../../utils/result-preview/result-preview";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'availableOn',
|
|
|
|
template: `
|
2020-05-22 16:51:28 +02:00
|
|
|
<div class="download-from uk-height-max-large uk-overflow-auto uk-margin-small-bottom">
|
2020-03-16 14:09:46 +01:00
|
|
|
<div *ngFor="let available of availableOn.slice(0, showNum) let i=index"
|
|
|
|
class="uk-flex uk-flex-top"
|
|
|
|
[title]="available.bestAccessMode ? available.bestAccessMode : 'Not available'">
|
|
|
|
<span class="uk-margin-small-right">
|
|
|
|
<img [src]="available.icon">
|
|
|
|
</span>
|
2020-05-20 22:34:29 +02:00
|
|
|
<div class="uk-width-expand uk-padding-small uk-padding-remove-left uk-padding-remove-vertical">
|
2020-03-16 14:09:46 +01:00
|
|
|
<span *ngIf="available.downloadUrl.length > 1" class="title">
|
2020-07-02 11:54:36 +02:00
|
|
|
<span>{{available.downloadName}}</span>
|
|
|
|
<a *ngFor="let url of available.downloadUrl; let i=index;"
|
2020-03-16 14:09:46 +01:00
|
|
|
[href]="url" target="_blank">
|
|
|
|
[{{(i + 1) | number}}]
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<a *ngIf="available.downloadUrl.length === 1" [href]="available.downloadUrl[0]"
|
|
|
|
class="title" target="_blank">
|
|
|
|
{{available.downloadName}}
|
|
|
|
<span class="custom-external custom-icon space"></span>
|
|
|
|
</a>
|
2020-07-02 11:54:36 +02:00
|
|
|
<span *ngIf="!available.downloadUrl || available.downloadUrl.length === 0" class="title">
|
|
|
|
{{available.downloadName}}
|
|
|
|
</span>
|
2020-05-26 16:42:47 +02:00
|
|
|
<div *ngIf="removeUnknown(available.type) || available.year">
|
2020-03-16 14:09:46 +01:00
|
|
|
<span *ngIf="removeUnknown(available.type)" class="uk-text-capitalize">{{available.type}}</span>
|
|
|
|
<span *ngIf="removeUnknown(available.type) && available.year"> . </span>
|
|
|
|
<span *ngIf="available.year">{{available.year}}</span>
|
|
|
|
</div>
|
2020-05-26 16:42:47 +02:00
|
|
|
<div *ngIf="available.collectedName" class="provider">
|
2020-03-16 14:09:46 +01:00
|
|
|
<span>Provider: </span>
|
|
|
|
<a *ngIf="available.collectedId" routerLink="/search/dataprovider" [queryParams]="{datasourceId: available.collectedId}">
|
|
|
|
{{available.collectedName}}
|
|
|
|
</a>
|
|
|
|
<span *ngIf="!available.collectedId">
|
|
|
|
{{available.collectedName}}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-20 22:34:29 +02:00
|
|
|
<div *ngIf="showNum > threshold" class="uk-text-center uk-margin-bottom">
|
|
|
|
<a (click)="showNum = threshold;">
|
2018-05-16 17:42:42 +02:00
|
|
|
View less
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-03-16 14:09:46 +01:00
|
|
|
<!-- <div *ngIf="showNum == threshold && availableOn && availableOn.length > 5">...</div>-->
|
2020-05-20 22:34:29 +02:00
|
|
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5" class="uk-text-center uk-margin-bottom">
|
2018-05-16 17:42:42 +02:00
|
|
|
<a (click)="showNum = availableOn.length;">
|
|
|
|
View more
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class AvailableOnComponent {
|
2020-07-01 14:11:57 +02:00
|
|
|
@Input() availableOn: HostedByCollectedFrom[];
|
|
|
|
// {
|
|
|
|
// "downloadName": string, "downloadUrl": string[],
|
|
|
|
// "collectedName": string, "collectedId": string,
|
|
|
|
// "accessMode": string[], "bestAccessMode": string,
|
|
|
|
// "type": string, "year": string, icon: string
|
|
|
|
// }[];
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() properties: EnvProperties;
|
2020-07-01 14:11:57 +02:00
|
|
|
// public open = 'assets/common-assets/unlock.svg';
|
|
|
|
// public closed = 'assets/common-assets/lock.svg';
|
|
|
|
// public unknown = 'assets/common-assets/question.svg';
|
2020-03-16 14:09:46 +01:00
|
|
|
public threshold: number = 4;
|
|
|
|
public showNum: number = 4;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2020-07-01 14:11:57 +02:00
|
|
|
// this.availableOn.forEach(available => {
|
|
|
|
// if (available.bestAccessMode) {
|
|
|
|
// if (available.bestAccessMode.toLowerCase().indexOf('open') !== -1) {
|
|
|
|
// available.icon = this.open;
|
|
|
|
// } else if (available.bestAccessMode.toLowerCase().indexOf('not available') !== -1) {
|
|
|
|
// available.icon = this.unknown;
|
|
|
|
// } else {
|
|
|
|
// available.icon = this.closed;
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// available.icon = this.unknown;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// );
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public removeUnknown(value: string): string {
|
|
|
|
if(this.properties.environment === 'production') {
|
|
|
|
if (value.toLowerCase() === 'unknown') {
|
|
|
|
return null;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public scroll() {
|
|
|
|
HelperFunctions.scroll();
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|