import { Component, OnInit, TemplateRef } from '@angular/core';
import { ReleasenotesService } from './releasenotes.service';
import { ReleaseNotes } from './releasenotes';
import { BsModalService, BsModalRef, ModalOptions } from 'ngx-bootstrap';
import { TopbarComponent } from '../topbar/topbar.component';

@Component({
  selector: 'app-releasenotes',
  templateUrl: './releasenotes.component.html',
  styleUrls: ['./releasenotes.component.css']
})
export class ReleasenotesComponent implements OnInit {
  modalRef: BsModalRef;
  config: ModalOptions = {
    /*backdrop: 'static',
    keyboard: false,
    animated: true,*/
    class: 'modal-dialog-centered',
    ignoreBackdropClick: false
  }
  constructor(private releaseNoteService: ReleasenotesService,
    private modalService: BsModalService, private topbar: TopbarComponent) { }
  releasenoteContent: string; releasenotes: ReleaseNotes[]
  ngOnInit() {
     this.getReleaseNotes();


  }
  getReleaseNotes() {
    this.releaseNoteService.Get().subscribe(res => {
     
      this.releasenotes = JSON.parse(res[0].j);
      console.log( this.releasenotes);
      console.log(this.releasenotes[0].content);
     this.releasenoteContent = this.releasenotes[0].content;
      this.topbar.releaseversion = this.releasenotes[0].version;
    })
  }
  openModal(template: TemplateRef<any>) {
    this.modalRef = this.modalService.show(template, this.config);
    const aa = document.getElementsByClassName('modal-content');    
    aa[0].classList.remove("modal-content");
  }
}
