41 lines
1.4 KiB
TypeScript
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 ProbeStore from '../store/entity/probe';
|
|
import { ProbeEntitySelector, ProbeListContainerSelector } 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[]>;
|
|
pending$: Observable<boolean>;
|
|
@Output() select = new EventEmitter();
|
|
|
|
constructor(private store: Store<ProbeStore.State>) {
|
|
this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll));
|
|
this.pending$ = store.pipe(select(ProbeListContainerSelector.selectPending));
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
}
|