2018-05-25 09:18:06 +00:00
|
|
|
import { Component, OnInit, Input, AfterViewInit, Output, EventEmitter } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import * as ProbeStore from '../store/entity/probe';
|
|
|
|
import { ProbeSelector } from '../store';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
2018-05-25 11:02:27 +00:00
|
|
|
import { RPCClientError } from '@loafer/ng-rpc';
|
2018-05-18 08:30:20 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-probe-detail-container',
|
|
|
|
templateUrl: './probe-detail-container.html',
|
|
|
|
})
|
2018-05-25 09:18:06 +00:00
|
|
|
export class ProbeDetailContainerComponent implements OnInit {
|
2018-05-18 08:30:20 +00:00
|
|
|
|
2018-05-25 09:18:06 +00:00
|
|
|
@Input() probeHostID;
|
|
|
|
@Output() discovery = new EventEmitter<number>();
|
|
|
|
probeHosts$: Observable<ProbeHost[]>;
|
2018-05-25 11:02:27 +00:00
|
|
|
error$: Observable<RPCClientError>;
|
2018-05-25 09:18:06 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private store: Store<ProbeStore.State>,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
) {
|
|
|
|
this.probeHosts$ = store.pipe(select(ProbeSelector.select('probeHosts')));
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.store.dispatch(new ProbeStore.Read(this.probeHostID));
|
|
|
|
}
|
|
|
|
|
|
|
|
onModify(probeHost: ProbeHost) {
|
|
|
|
this.store.dispatch(new ProbeStore.Modify(probeHost.probe));
|
|
|
|
}
|
|
|
|
|
|
|
|
onDiscovery(probeHostID: number) {
|
|
|
|
this.discovery.emit(probeHostID);
|
|
|
|
}
|
2018-05-18 08:30:20 +00:00
|
|
|
}
|