77 lines
3.4 KiB
TypeScript
77 lines
3.4 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {HostedByCollectedFrom} from "../../utils/result-preview/result-preview";
|
|
import {properties} from "../../../../environments/environment";
|
|
|
|
@Component({
|
|
selector: 'availableOn',
|
|
template: `
|
|
<div *ngIf="availableOn" class="download-from uk-height-max-large uk-overflow-auto uk-margin-small-bottom">
|
|
<div *ngFor="let instance of availableOn.slice(0, showNum) let i=index"
|
|
class="uk-flex uk-flex-top"
|
|
[title]="instance.accessRight ? instance.accessRight : 'Not available'">
|
|
<span class="uk-margin-small-right">
|
|
<img [src]="instance.accessRightIcon" loading="lazy" [alt]="instance.accessRight" style="width:20px; height:20px">
|
|
</span>
|
|
<div class="uk-width-expand uk-padding-small uk-padding-remove-left uk-padding-remove-vertical">
|
|
<a *ngIf="instance.downloadUrl" [href]="instance.downloadUrl" target="_blank"
|
|
class="title">
|
|
{{instance.downloadNames.join("; ")}}
|
|
<span class="custom-external custom-icon space"></span>
|
|
</a>
|
|
<div *ngIf="instance.types?.length > 0 || instance.years?.length > 0">
|
|
<span *ngIf="instance.types?.length > 0" class="uk-text-capitalize">{{instance.types.join(" . ")}}</span>
|
|
<span *ngIf="instance.types?.length > 0 && instance.years?.length > 0"> . </span>
|
|
<span *ngIf="instance.years?.length > 0">{{instance.years.join(" . ")}}</span>
|
|
</div>
|
|
<div *ngIf="instance.collectedNamesAndIds?.size > 0">
|
|
<span>Providers: </span>
|
|
<a *ngFor="let collectedName of instance.collectedNamesAndIds.keys(); let i=index" [routerLink]="dataProviderUrl"
|
|
[queryParams]="{datasourceId: instance.collectedNamesAndIds.get(collectedName)}">
|
|
{{collectedName}}<ng-container *ngIf="(i !== (instance.collectedNamesAndIds.size - 1))">; </ng-container>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div *ngIf="showNum > threshold" class="uk-margin-bottom">
|
|
<a (click)="showNum = threshold;" class="uk-flex uk-flex-middle uk-flex-center">
|
|
<span>View less</span>
|
|
<span class="space uk-icon">
|
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="chevron-up">
|
|
<polyline fill="none" stroke="#000" stroke-width="1.03" points="4 13 10 7 16 13"></polyline>
|
|
</svg>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
<div *ngIf="showNum == threshold && availableOn && availableOn.length > 5" class="uk-margin-bottom">
|
|
<a (click)="showNum = availableOn.length;" class="uk-flex uk-flex-middle uk-flex-center">
|
|
<span>View more</span>
|
|
<span class="space uk-icon">
|
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="chevron-down">
|
|
<polyline fill="none" stroke="#000" stroke-width="1.03" points="16 7 10 13 4 7"></polyline>
|
|
</svg>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
`
|
|
})
|
|
|
|
export class AvailableOnComponent {
|
|
@Input() availableOn: HostedByCollectedFrom[];
|
|
public threshold: number = 4;
|
|
public showNum: number = 4;
|
|
public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
|
|
|
|
constructor() {
|
|
}
|
|
|
|
ngOnInit() {}
|
|
|
|
public removeUnknown(value: string): string {
|
|
if (value.toLowerCase() === 'unknown') {
|
|
return null;
|
|
}
|
|
return value;
|
|
}
|
|
}
|