106 lines
3.9 KiB
TypeScript
106 lines
3.9 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
|
|
|
@Component({
|
|
selector: 'availableOn',
|
|
template: `
|
|
<div class="download-from uk-height-max-large uk-overflow-auto uk-margin-small-bottom">
|
|
<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>
|
|
<div class="uk-width-expand uk-padding-small uk-padding-remove-left uk-padding-remove-vertical">
|
|
<span *ngIf="available.downloadUrl.length > 1" class="title">
|
|
<span class="uk-text-bold">{{available.downloadName}}</span>
|
|
<a *ngFor="let url of available.downloadUrl; let i=index;">
|
|
[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>
|
|
<div *ngIf="removeUnknown(available.type) || available.year" class="uk-text-small">
|
|
<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>
|
|
<div *ngIf="available.collectedName" class="uk-text-small provider">
|
|
<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>
|
|
<div *ngIf="showNum > threshold" class="uk-text-center uk-margin-bottom">
|
|
<a (click)="showNum = threshold;">
|
|
View less
|
|
</a>
|
|
</div>
|
|
<!-- <div *ngIf="showNum == threshold && availableOn && availableOn.length > 5">...</div>-->
|
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5" class="uk-text-center uk-margin-bottom">
|
|
<a (click)="showNum = availableOn.length;">
|
|
View more
|
|
</a>
|
|
</div>
|
|
`
|
|
})
|
|
|
|
export class AvailableOnComponent {
|
|
@Input() availableOn: {
|
|
"downloadName": string, "downloadUrl": string[],
|
|
"collectedName": string, "collectedId": string,
|
|
"accessMode": string[], "bestAccessMode": string,
|
|
"type": string, "year": string, icon: string
|
|
}[];
|
|
@Input() properties: EnvProperties;
|
|
public open = 'assets/common-assets/unlock.svg';
|
|
public closed = 'assets/common-assets/lock.svg';
|
|
public unknown = 'assets/common-assets/question.svg';
|
|
public threshold: number = 4;
|
|
public showNum: number = 4;
|
|
|
|
constructor() {
|
|
}
|
|
|
|
ngOnInit() {
|
|
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;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
public removeUnknown(value: string): string {
|
|
if(this.properties.environment === 'production') {
|
|
if (value.toLowerCase() === 'unknown') {
|
|
return null;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
|
|
public scroll() {
|
|
HelperFunctions.scroll();
|
|
}
|
|
}
|