import { Component, OnInit, Input } from '@angular/core';
import { Observable } from 'rxjs';
import { Log } from 'src/app/models/log';
import { LogService } from './log.service';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-log',
  templateUrl: './log.component.html',
  styleUrls: ['./log.component.css']
})
export class LogComponent implements OnInit {
  @Input() log: Log = {
    id: 0,
    description: '',
    isDismissed: false,
    timestamp: '',
    wharfID: 0,
    logTypeID: 0
  };

  log$: Observable<Log[]> = new Observable<Log[]>();
  wharfId = 0;


  constructor(private logService: LogService, private route: ActivatedRoute) { }

  ngOnInit(): void {
    const wharfId = this.route.snapshot.paramMap.get('wharIid');
    this.log$ = this.logService.getLogs();
    this.wharfId = parseInt(JSON.parse(this.route.snapshot.paramMap.get('wharIid') || '{}'));
    console.log(this.log$)
  }

}
