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: `

{{instance.downloadNames.join("; ")}}
{{instance.types.join(" . ")}} . {{instance.years.join(" . ")}} . Peer-reviewed
License: {{instance.license}} {{instance.license}}
Full-Text: {{instance.fulltext}} {{instance.fulltext}}
Data sources: {{collectedName}};
` }) export class AvailableOnComponent { @Input() isMobile: boolean = false; @Input() inModal: 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; }