member_webapp/@overflow/probe/container/probe-list-container.ts
2018-05-25 20:59:18 +09:00

39 lines
1.2 KiB
TypeScript

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<ProbeHost[]>;
@Output() select = new EventEmitter();
constructor(private store: Store<ProbeStore.State>) {
this.probeHosts$ = store.pipe(select(ProbeSelector.selectAll));
}
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);
}
}