2023-01-13 07:32:16 +01:00
|
|
|
import {Component, ElementRef, EventEmitter, Input, Output, ViewChild} from '@angular/core';
|
2020-07-01 14:11:57 +02:00
|
|
|
import {HostedByCollectedFrom} from "../../utils/result-preview/result-preview";
|
2020-07-13 16:42:34 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2023-01-13 14:57:26 +01:00
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2023-01-13 07:32:16 +01:00
|
|
|
declare var UIkit;
|
2023-02-17 18:40:05 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'availableOn',
|
|
|
|
template: `
|
2023-01-09 17:35:28 +01:00
|
|
|
<ng-container *ngIf="availableOn">
|
2023-02-17 18:40:05 +01:00
|
|
|
<div class="uk-flex uk-flex-middle">
|
2023-02-16 11:59:18 +01:00
|
|
|
<ng-container *ngIf="availableOn[0].downloadUrl">
|
2023-02-17 18:40:05 +01:00
|
|
|
<span *ngIf="source" class="uk-margin-xsmall-right">Source: </span>
|
|
|
|
<span
|
|
|
|
[class]="'uk-margin-xsmall-right ' + (availableOn[0].accessRightIcon == 'open_access' ? 'open-access' : 'closed-access')"
|
|
|
|
uk-tooltip [title]="availableOn[0].accessRight ? availableOn[0].accessRight : 'Not available'">
|
2023-02-13 14:51:15 +01:00
|
|
|
<icon [name]="availableOn[0].accessRightIcon" [flex]="true" [ratio]="0.8"></icon>
|
2023-01-13 07:32:16 +01:00
|
|
|
</span>
|
2023-02-16 11:59:18 +01:00
|
|
|
<a [href]="availableOn[0].downloadUrl" target="_blank"
|
2023-02-17 18:40:05 +01:00
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder custom-external">
|
2023-02-16 11:59:18 +01:00
|
|
|
<span>{{sliceString(availableOn[0].downloadNames.join("; "), 20)}}</span>
|
|
|
|
</a>
|
|
|
|
</ng-container>
|
2023-01-13 14:57:26 +01:00
|
|
|
<a class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<icon [flex]="true" [name]="'expand_' + (isOpen?'less':'more')"></icon>
|
|
|
|
</a>
|
2023-02-17 18:40:05 +01:00
|
|
|
<div #dropElement uk-drop="mode: click; pos: bottom-left;"
|
|
|
|
class="download-drop uk-card uk-card-default uk-padding-small uk-padding-remove-horizontal uk-text-small">
|
2023-01-13 14:57:26 +01:00
|
|
|
<div *ngFor="let instance of availableOn let i=index" class="download-drop-item uk-flex uk-flex-top">
|
2023-02-17 18:40:05 +01:00
|
|
|
<span
|
|
|
|
[class]="'uk-margin-small-right ' + (instance.accessRightIcon == 'open_access' ? 'open-access' : 'closed-access')"
|
|
|
|
uk-tooltip [title]="instance.accessRight ? instance.accessRight : 'Not available'">
|
2023-02-13 14:51:15 +01:00
|
|
|
<icon [name]="instance.accessRightIcon" [flex]="true"></icon>
|
2023-01-13 07:32:16 +01:00
|
|
|
</span>
|
2023-01-13 14:57:26 +01:00
|
|
|
<div class="uk-width-expand uk-padding-small uk-padding-remove-left uk-padding-remove-vertical">
|
|
|
|
<span class="uk-text-emphasis">
|
|
|
|
<a *ngIf="instance.downloadUrl" [href]="instance.downloadUrl" target="_blank"
|
2023-02-17 18:40:05 +01:00
|
|
|
class="title uk-link-text uk-text-bold custom-external uk-display-inline-block">
|
2023-01-13 14:57:26 +01:00
|
|
|
{{instance.downloadNames.join("; ")}}
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<div *ngIf="instance.types?.length > 0 || instance.years?.length > 0" class="uk-text-meta">
|
2023-02-17 18:40:05 +01:00
|
|
|
<span *ngIf="instance.types?.length > 0"
|
|
|
|
class="uk-text-capitalize">{{instance.types.join(" . ")}}</span>
|
2023-01-13 14:57:26 +01:00
|
|
|
<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.license" class="uk-text-meta uk-text-truncate" uk-tooltip [title]="instance.license">
|
|
|
|
License:
|
|
|
|
<a *ngIf="isUrl(instance.license); else elseBlock"
|
2023-02-17 18:40:05 +01:00
|
|
|
[href]="instance.license" target="_blank" class="custom-external uk-link-text">
|
2023-01-13 14:57:26 +01:00
|
|
|
{{instance.license}}
|
|
|
|
</a>
|
|
|
|
<ng-template #elseBlock> {{instance.license}}</ng-template>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="instance.collectedNamesAndIds?.size > 0" class="uk-text-meta">
|
|
|
|
<span>Providers: </span>
|
2023-02-17 18:40:05 +01:00
|
|
|
<a *ngFor="let collectedName of getKeys(instance.collectedNamesAndIds); let i=index"
|
|
|
|
[routerLink]="dataProviderUrl"
|
|
|
|
[queryParams]="{datasourceId: instance.collectedNamesAndIds.get(collectedName)}"
|
|
|
|
class="uk-link-text">
|
|
|
|
{{collectedName}}
|
|
|
|
<ng-container *ngIf="(i !== (instance.collectedNamesAndIds.size - 1))">;</ng-container>
|
2023-01-13 14:57:26 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
2023-01-13 07:32:16 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-09 17:35:28 +01:00
|
|
|
</ng-container>
|
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[];
|
2023-02-17 18:40:05 +01:00
|
|
|
@Input() source: boolean = true;
|
|
|
|
/** @deprecated */
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
|
|
|
@ViewChild("dropElement") dropElement: ElementRef;
|
2022-04-16 09:47:30 +02:00
|
|
|
public threshold: number = 1;
|
2020-07-13 16:42:34 +02:00
|
|
|
public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
|
2022-04-12 14:15:04 +02:00
|
|
|
public title: string = "Download from";
|
2023-02-17 18:40:05 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
constructor() {
|
|
|
|
}
|
2023-02-17 18:40:05 +01:00
|
|
|
|
2023-01-09 17:35:28 +01:00
|
|
|
ngOnInit() {
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2022-02-14 15:24:10 +01:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
public getKeys(map) {
|
2022-02-14 15:24:10 +01:00
|
|
|
return Array.from(map.keys());
|
|
|
|
}
|
2022-04-12 14:15:04 +02:00
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
public isUrl(str: string): boolean {
|
|
|
|
return str.startsWith('http://') || str.startsWith('https://') || str.startsWith('//') || str.startsWith('www.');
|
2023-01-13 07:32:16 +01:00
|
|
|
}
|
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
get isOpen() {
|
2023-01-13 07:32:16 +01:00
|
|
|
return (typeof document !== 'undefined') && this.dropElement && UIkit.drop(this.dropElement.nativeElement).isActive();
|
2022-06-09 15:45:39 +02:00
|
|
|
}
|
2023-01-13 14:57:26 +01:00
|
|
|
|
2023-02-17 18:40:05 +01:00
|
|
|
public sliceString(str: string, size: number) {
|
|
|
|
return StringUtils.sliceString(str, size)
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|