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

import { MatSnackBar } from '@angular/material/snack-bar'

import { FullInfo } from '../info-data.service'
import { Downloader } from '../../openapi'

@Component({
  selector: 'gisaf-downloader',
  templateUrl: './downloader.component.html',
})
export class DownloaderComponent implements OnInit {
  @Input() source: FullInfo
  @Input() downloader: Downloader

  constructor(
    private snackBar: MatSnackBar,
  ) { }

  ngOnInit() {
  }

  execute() {
    window.open('/api/download/plugin/'
      + '/' + this.downloader.name
      + '/' + this.source.modelInfo.store
      + '/' + this.source.featureInfo.id)
  }
}
