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';
|
2023-02-21 15:10:21 +01:00
|
|
|
import {FullScreenModalComponent} from "../../utils/modal/full-screen-modal/full-screen-modal.component";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2023-01-13 07:32:16 +01:00
|
|
|
declare var UIkit;
|
2023-04-20 19:06:53 +02:00
|
|
|
import {RouterHelper} from "../../utils/routerHelper.class";
|
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-02-18 09:53:40 +01:00
|
|
|
<ng-container *ngIf="availableOn && availableOn.length > 0">
|
2023-10-11 11:46:10 +02:00
|
|
|
<div class="uk-flex uk-flex-middle"
|
|
|
|
[ngClass]="isMobile ? ('uk-flex-column ' + (!(usedBy == 'landing') ? 'uk-margin-left uk-margin-xsmall-bottom' : '')) : 'uk-grid uk-grid-small uk-child-width-auto'"
|
|
|
|
[attr.uk-grid]="!isMobile ? '' : null">
|
|
|
|
<div *ngIf="properties.environment != 'production' && availableOn[0].fulltext" class="uk-flex uk-flex-middle"
|
|
|
|
[ngClass]="isMobile ? 'uk-width-1-1' : 'uk-text-bolder'">
|
|
|
|
<a [href]="availableOn[0].fulltext" target="_blank"
|
|
|
|
class="uk-flex uk-flex-middle uk-button-link"
|
|
|
|
[ngClass]="isMobile ? ((usedBy == 'landing') ? 'uk-width-1-1 uk-padding-small uk-padding-remove-horizontal' : '') : 'uk-flex-center'">
|
|
|
|
<!-- <icon [flex]="true" [ratio]="0.7" name="download" visuallyHidden="download"></icon>-->
|
|
|
|
<icon name="download" visuallyHidden="donwload" [flex]="true" [ratio]="(isMobile && usedBy == 'landing') ? 1 : 0.8"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Full-Text</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="isMobile && (usedBy == 'landing') && availableOn[0].fulltext" class="uk-width-1-1"><hr></div>
|
|
|
|
<div *ngIf="availableOn[0].downloadUrl" [ngClass]="isMobile ? 'uk-width-1-1' : ''">
|
|
|
|
<div class="uk-flex uk-flex-middle" [ngClass]="isMobile ? ((usedBy == 'landing') ? 'uk-padding-small uk-padding-remove-horizontal' : '') : ''">
|
|
|
|
<span [class]="'uk-margin-xsmall-right ' + (availableOn[0].accessRightIcon == 'open_access' ? 'open-access' : 'closed-access')"
|
|
|
|
uk-tooltip [title]="getAccessLabel(availableOn[0].accessRight)">
|
|
|
|
<icon [name]="availableOn[0].accessRightIcon" [flex]="true" [ratio]="(isMobile && usedBy == 'landing') ? 1 : 0.8"></icon>
|
2023-02-21 15:10:21 +01:00
|
|
|
</span>
|
2023-10-11 11:46:10 +02:00
|
|
|
<ng-container *ngIf="!isMobile">
|
|
|
|
<a uk-tooltip="Source" target="_blank"
|
|
|
|
class="uk-flex uk-flex-middle uk-flex-center uk-button-link uk-text-bolder">
|
|
|
|
<span>{{sliceString(availableOn[0].downloadNames.join("; "), 20)}}</span>
|
|
|
|
<span>
|
|
|
|
<!-- <icon [flex]="true" [name]="'expand_' + (isOpen?'less':'more')"></icon>-->
|
|
|
|
<icon [flex]="true" [name]="(isOpen?'arrow_drop_up':'arrow_drop_down')"></icon>
|
|
|
|
</span>
|
|
|
|
</a>
|
2023-10-11 15:33:33 +02:00
|
|
|
<div #dropElement uk-drop="mode: click; pos: bottom-left; flip: false; shift: false" class="uk-drop download-drop">
|
2023-08-23 15:42:52 +02:00
|
|
|
<div class="uk-card uk-card-default uk-padding-small uk-padding-remove-horizontal uk-text-small uk-height-max-large uk-overflow-auto">
|
|
|
|
<ng-container *ngTemplateOutlet="availableOnList"></ng-container>
|
|
|
|
</div>
|
2023-07-25 18:09:09 +02:00
|
|
|
</div>
|
2023-10-11 11:46:10 +02:00
|
|
|
</ng-container>
|
|
|
|
|
|
|
|
<ng-container *ngIf="isMobile">
|
|
|
|
<a #toggle class="uk-flex uk-flex-between uk-flex-middle uk-flex-center uk-width-expand uk-button-link">
|
|
|
|
<span>{{sliceString(availableOn[0].downloadNames.join("; "), 20)}}</span>
|
|
|
|
<span>
|
|
|
|
<icon [flex]="true" ratio="1.5" name="arrow_right"></icon>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
<mobile-dropdown [toggle]="toggle">
|
|
|
|
<div class="uk-text-emphasis uk-text-bolder uk-text-center uk-padding-small uk-padding-remove-vertical uk-text-uppercase">
|
|
|
|
Sources
|
|
|
|
</div>
|
|
|
|
<div class="uk-text-small download-drop uk-padding uk-padding-remove-horizontal">
|
|
|
|
<ng-container *ngTemplateOutlet="availableOnList"></ng-container>
|
|
|
|
</div>
|
|
|
|
</mobile-dropdown>
|
|
|
|
</ng-container>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-13 07:32:16 +01:00
|
|
|
</div>
|
2023-01-09 17:35:28 +01:00
|
|
|
</ng-container>
|
2023-02-21 15:10:21 +01:00
|
|
|
|
|
|
|
<ng-template #availableOnList>
|
|
|
|
<div *ngFor="let instance of availableOn let i=index" class="download-drop-item uk-flex uk-flex-top">
|
|
|
|
<span
|
|
|
|
[class]="'uk-margin-small-right ' + (instance.accessRightIcon == 'open_access' ? 'open-access' : 'closed-access')"
|
2023-05-08 15:41:42 +02:00
|
|
|
uk-tooltip [title]="getAccessLabel(instance.accessRight)">
|
2023-02-21 15:10:21 +01:00
|
|
|
<icon [name]="instance.accessRightIcon" [flex]="true"></icon>
|
|
|
|
</span>
|
|
|
|
<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"
|
|
|
|
class="title uk-link-text uk-text-bold custom-external uk-display-inline-block">
|
|
|
|
{{instance.downloadNames.join("; ")}}
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<div *ngIf="instance.types?.length > 0 || instance.years?.length > 0" class="uk-text-meta">
|
|
|
|
<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.license" class="uk-text-meta uk-text-truncate" uk-tooltip [title]="instance.license">
|
|
|
|
License:
|
|
|
|
<a *ngIf="isUrl(instance.license); else elseBlock"
|
|
|
|
[href]="instance.license" target="_blank" class="custom-external uk-link-text">
|
|
|
|
{{instance.license}}
|
|
|
|
</a>
|
|
|
|
<ng-template #elseBlock> {{instance.license}}</ng-template>
|
|
|
|
</div>
|
2023-10-11 11:46:10 +02:00
|
|
|
<div *ngIf="properties.environment != 'production' && instance.fulltext" class="uk-text-meta uk-text-truncate" uk-tooltip [title]="instance.fulltext">
|
|
|
|
Full-Text:
|
|
|
|
<a *ngIf="isUrl(instance.fulltext); else elseBlock"
|
|
|
|
[href]="instance.fulltext" target="_blank" class="custom-external uk-link-text">
|
|
|
|
{{instance.fulltext}}
|
|
|
|
</a>
|
|
|
|
<ng-template #elseBlock> {{instance.fulltext}}</ng-template>
|
|
|
|
</div>
|
2023-02-21 15:10:21 +01:00
|
|
|
<div *ngIf="instance.collectedNamesAndIds?.size > 0" class="uk-text-meta">
|
2023-04-21 17:54:26 +02:00
|
|
|
<span>Data sources: </span>
|
2022-02-14 15:24:10 +01:00
|
|
|
<a *ngFor="let collectedName of getKeys(instance.collectedNamesAndIds); let i=index" [routerLink]="dataProviderUrl"
|
2023-04-20 19:06:53 +02:00
|
|
|
[queryParams]="addEoscPrevInParams({datasourceId: instance.collectedNamesAndIds.get(collectedName)})" class="uk-link-text">
|
2022-01-07 11:01:22 +01:00
|
|
|
{{collectedName}}<ng-container *ngIf="(i !== (instance.collectedNamesAndIds.size - 1))">; </ng-container>
|
2023-02-21 15:10:21 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class AvailableOnComponent {
|
2023-02-21 15:10:21 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
|
|
|
@Input() usedBy: "search" | "landing" = "search";
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2020-07-01 14:11:57 +02:00
|
|
|
@Input() availableOn: HostedByCollectedFrom[];
|
2023-02-17 18:40:05 +01:00
|
|
|
/** @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-04-20 19:06:53 +02:00
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
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)
|
|
|
|
}
|
2023-02-21 15:10:21 +01:00
|
|
|
|
2023-05-08 15:41:42 +02:00
|
|
|
public getAccessLabel(accessRight) : string {
|
|
|
|
if(accessRight) {
|
|
|
|
return (accessRight + (accessRight.toLowerCase().endsWith(" access") ? "" : " access"));
|
|
|
|
}
|
|
|
|
return "Not available access";
|
|
|
|
}
|
2023-04-20 19:06:53 +02:00
|
|
|
|
|
|
|
public addEoscPrevInParams(obj) {
|
|
|
|
if(properties.adminToolsPortalType == "eosc" && this.prevPath) {
|
2023-05-25 17:10:58 +02:00
|
|
|
let splitted: string[] = this.prevPath.split("?");
|
|
|
|
obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj);
|
|
|
|
if(splitted.length > 0) {
|
|
|
|
obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj);
|
|
|
|
}
|
2023-04-20 19:06:53 +02:00
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
2023-10-11 11:46:10 +02:00
|
|
|
|
|
|
|
protected readonly properties = properties;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|