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

43 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-05-25 09:18:06 +00:00
import { Component, EventEmitter, Output, OnInit } from '@angular/core';
2018-05-24 11:30:02 +00:00
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
2018-05-27 14:17:07 +00:00
import * as ProbeEntityStore from '../store/entity/probe';
2018-05-28 09:58:13 +00:00
import { ProbeListContainerSelector } from '../store';
import { AuthContainerSelector } from '../../shared/auth/store';
import { DomainMember } 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',
2018-05-27 14:17:07 +00:00
templateUrl: './probe-list-container.component.html',
2018-05-18 08:30:20 +00:00
})
2018-05-25 09:18:06 +00:00
export class ProbeListContainerComponent implements OnInit {
2018-05-24 11:30:02 +00:00
probeHosts$: Observable<ProbeHost[]>;
2018-05-26 09:08:40 +00:00
pending$: Observable<boolean>;
2018-05-28 09:58:13 +00:00
error$: Observable<any>;
2018-05-18 08:30:20 +00:00
@Output() select = new EventEmitter();
2018-05-27 14:17:07 +00:00
constructor(
2018-05-28 09:58:13 +00:00
private store: Store<any>,
2018-05-27 14:17:07 +00:00
) {
2018-05-24 11:30:02 +00:00
}
ngOnInit() {
2018-05-28 09:58:13 +00:00
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending));
2018-05-29 12:18:43 +00:00
this.error$ = this.store.pipe(select(ProbeListContainerSelector.selectError));
2018-05-28 09:58:13 +00:00
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
2018-05-24 11:30:02 +00:00
}
);
}
2018-05-25 09:18:06 +00:00
onSelect(probeHost: ProbeHost) {
this.select.emit(probeHost);
2018-05-18 08:30:20 +00:00
}
2018-05-25 09:18:06 +00:00
2018-05-18 08:30:20 +00:00
}