member_webapp/@overflow/probe/container/probe-list-container.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-05-24 11:30:02 +00:00
import { Component, EventEmitter, Output, OnInit, AfterContentInit } 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/probe';
import { ProbeSelector } from '../store';
import { AuthSelector } from '@overflow/member/store';
import { Domain } from '@overflow/commons-typescript/model/domain';
2018-05-18 08:30:20 +00:00
@Component({
2018-05-24 11:30:02 +00:00
selector: 'of-probe-list-container',
templateUrl: './probe-list-container.html',
2018-05-18 08:30:20 +00:00
})
2018-05-24 11:30:02 +00:00
export class ProbeListContainerComponent implements OnInit, AfterContentInit {
probeHosts$: Observable<ProbeHost[]>;
2018-05-18 08:30:20 +00:00
@Output() select = new EventEmitter();
2018-05-24 11:30:02 +00:00
constructor(private store: Store<ProbeStore.State>) {
this.probeHosts$ = store.pipe(select(ProbeSelector.select('probeHosts')));
}
onSelect(probeHost: ProbeHost) {
this.select.emit(probeHost);
}
ngOnInit() {
this.store.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
this.store.dispatch(new ProbeStore.ReadAllByDomainID(domain.id));
},
(error) => {
console.log(error);
}
);
}
ngAfterContentInit() {
2018-05-18 08:30:20 +00:00
}
}