import { Component, Input, ChangeDetectionStrategy } from '@angular/core';

import { RendererConfig } from '../../../metamodel/model';
import { getHost } from "../../utils";

interface LinkConfig extends RendererConfig {
    display: string;
    text: string;
    icon: string;
}

@Component({
    selector: 'app-download',
    templateUrl: 'download.component.html',
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class DownloadComponent {
    @Input() value: string;
    @Input() datasetName: string;
    @Input() config: LinkConfig;

    getHref(): string {
        return getHost() + '/download-file/' + this.datasetName + '/' + this.value;
    }
}