member_webapp/@overflow/probe/container/probe-detail-container.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

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 12:41:29 +00:00
@Input() probeHostID: number;
2018-05-25 09:18:06 +00:00
@Output() discovery = new EventEmitter<number>();
2018-05-25 11:59:18 +00:00
probeHost$: 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,
) {
}
ngOnInit() {
2018-05-25 12:41:29 +00:00
this.probeHost$ = this.store.pipe(select(ProbeSelector.selectOne(this.probeHostID)));
2018-05-25 09:18:06 +00:00
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
}