import {Component, ElementRef, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {HostedByCollectedFrom} from "../../utils/result-preview/result-preview"; import {properties} from "../../../../environments/environment"; import {StringUtils} from '../../utils/string-utils.class'; import {FullScreenModalComponent} from "../../utils/modal/full-screen-modal/full-screen-modal.component"; declare var UIkit; import {RouterHelper} from "../../utils/routerHelper.class"; @Component({ selector: 'availableOn', template: ` 0"> Full-Text {{sliceString(availableOn[0].downloadNames.join("; "), 20)}} {{sliceString(availableOn[0].downloadNames.join("; "), 20)}} Sources {{instance.downloadNames.join("; ")}} 0 || instance.years?.length > 0" class="uk-text-meta"> 0" class="uk-text-capitalize">{{instance.types.join(" . ")}} 0 && instance.years?.length > 0"> . 0">{{instance.years.join(" . ")}} License: {{instance.license}} {{instance.license}} Full-Text: {{instance.fulltext}} {{instance.fulltext}} 0" class="uk-text-meta"> Data sources: {{collectedName}}; ` }) export class AvailableOnComponent { @Input() isMobile: boolean = false; @Input() usedBy: "search" | "landing" = "search"; @Input() prevPath: string = ""; @Input() availableOn: HostedByCollectedFrom[]; /** @deprecated */ @Output() viewAllClicked = new EventEmitter(); @ViewChild("dropElement") dropElement: ElementRef; public threshold: number = 1; public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0]; public title: string = "Download from"; public routerHelper:RouterHelper = new RouterHelper(); constructor() { } ngOnInit() { } public getKeys(map) { return Array.from(map.keys()); } public isUrl(str: string): boolean { return str.startsWith('http://') || str.startsWith('https://') || str.startsWith('//') || str.startsWith('www.'); } get isOpen() { return (typeof document !== 'undefined') && this.dropElement && UIkit.drop(this.dropElement.nativeElement).isActive(); } public sliceString(str: string, size: number) { return StringUtils.sliceString(str, size) } public getAccessLabel(accessRight) : string { if(accessRight) { return (accessRight + (accessRight.toLowerCase().endsWith(" access") ? "" : " access")); } return "Not available access"; } public addEoscPrevInParams(obj) { if(properties.adminToolsPortalType == "eosc" && this.prevPath) { 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); } } return obj; } protected readonly properties = properties; }