member_webapp/@overflow/probe/container/probe-list-container.component.ts
2018-05-28 18:58:13 +09:00

41 lines
1.4 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 ProbeEntityStore from '../store/entity/probe';
import { ProbeListContainerSelector } from '../store';
import { AuthContainerSelector } from '../../shared/auth/store';
import { DomainMember } from '@overflow/commons-typescript/model/domain';
@Component({
selector: 'of-probe-list-container',
templateUrl: './probe-list-container.component.html',
})
export class ProbeListContainerComponent implements OnInit {
probeHosts$: Observable<ProbeHost[]>;
pending$: Observable<boolean>;
error$: Observable<any>;
@Output() select = new EventEmitter();
constructor(
private store: Store<any>,
) {
}
ngOnInit() {
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending));
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
}
);
}
onSelect(probeHost: ProbeHost) {
this.select.emit(probeHost);
}
}