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

import { DataService } from '../../_services/data.service'

import { Attachment, FullInfo } from '../info-data.service'

@Component({
    selector: 'gisaf-info-attachments',
    templateUrl: './attachments.component.html',
    styleUrls: ['./attachments.component.css'],
    providers: [
        DataService,
    ],
})
export class AttachmentsComponent {
    @Input() source: FullInfo

    constructor(
        protected dataService: DataService,
    ) {
    }

    getLink(image: Attachment): string {
        return '/download/attachment/' + this.source.modelInfo.store + '/' + image.name + '/' + this.source.featureInfo.id
    }

    download(attachment: object) {
        window.open('/download/attachment/' + this.source.modelInfo.store + '/' + attachment['name'] + '/' + this.source.featureInfo.id)
    }
}
