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

import {HsDialogComponent, HsDialogContainerService} from 'hslayers-ng';

import {MetadataDialogService} from './metadata-dialog.service';

@Component({
  selector: 'pra-metadata-dialog',
  templateUrl: './metadata-dialog.component.html' 
})

export class MetadataDialogComponent implements HsDialogComponent, OnInit {
  viewRef: ViewRef;
  data: DatasetDescriptor;

  constructor(
    public hsDialogContainerService: HsDialogContainerService,
    public metadataDialogService: MetadataDialogService
    ) {}

  ngOnInit() {
    this.data = this.metadataDialogService.loadDatasetMetadata(this.data.title);
  }

  close(): void {
    this.hsDialogContainerService.destroy(this);
  }
}

export type DatasetDescriptor = {
  title: string;
  coverage?: string;
  link?: string;
  lod?: string;
  source?: string;
  update?: string;
};
