member_webapp/@overflow/probe/container/probe-selector-container.component.ts

40 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-05-28 09:58:13 +00:00
import { Component, EventEmitter, Output, OnInit, Input } from '@angular/core';
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as ProbeEntityStore from '@overflow/probe/store/entity/probe';
import { ProbeListContainerSelector } from '@overflow/probe/store';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { DomainMember } from '@overflow/commons-typescript/model/domain';
@Component({
selector: 'of-probe-selector-container',
templateUrl: './probe-selector-container.component.html',
})
export class ProbeSelectorContainerComponent implements OnInit {
probeHosts$: Observable<ProbeHost[]>;
@Output() select = new EventEmitter();
@Input() probeHostID: number;
constructor(
private store: Store<any>,
) {
}
ngOnInit() {
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
}
);
}
onSelect(probeHost: ProbeHost) {
alert(probeHost.probe.displayName);
// this.select.emit(probeHost);
}
}