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'; declare var UIkit; @Component({ selector: 'availableOn', template: `
Source: {{sliceString(availableOn[0].downloadNames.join("; "), 20)}}
{{instance.downloadNames.join("; ")}}
{{instance.types.join(" . ")}} . {{instance.years.join(" . ")}}
License: {{instance.license}} {{instance.license}}
` }) export class AvailableOnComponent { @Input() availableOn: HostedByCollectedFrom[]; @Input() source: boolean = true; /** @deprecated */ @Output() viewAllClicked = new EventEmitter(); @ViewChild("dropElement") dropElement: ElementRef; public threshold: number = 1; public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0]; public title: string = "Download from"; 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) } }