import { Component, EventEmitter, Output, OnInit } from '@angular/core'; import { ProbeHost } from '@overflow/commons-typescript/model/probe'; import { Observable } from 'rxjs'; import { Store, select } from '@ngrx/store'; import * as ProbeStore from '../store/entity/probe'; import { ProbeSelector } from '../store'; import { AuthSelector } from '@overflow/member/store'; import { Domain } from '@overflow/commons-typescript/model/domain'; @Component({ selector: 'of-probe-list-container', templateUrl: './probe-list-container.html', }) export class ProbeListContainerComponent implements OnInit { probeHosts$: Observable; @Output() select = new EventEmitter(); constructor(private store: Store) { this.probeHosts$ = store.pipe(select(ProbeSelector.select('probeHosts'))); } ngOnInit() { this.store.select(AuthSelector.select('domain')).subscribe( (domain: Domain) => { this.store.dispatch(new ProbeStore.ReadAllByDomainID(domain.id)); }, (error) => { console.log(error); } ); } onSelect(probeHost: ProbeHost) { this.select.emit(probeHost); } }