member_webapp/@overflow/probe/container/probe-detail-container.ts
2018-05-25 20:59:18 +09:00

40 lines
1.2 KiB
TypeScript

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';
import { RPCClientError } from '@loafer/ng-rpc';
@Component({
selector: 'of-probe-detail-container',
templateUrl: './probe-detail-container.html',
})
export class ProbeDetailContainerComponent implements OnInit {
@Input() probeHostID;
@Output() discovery = new EventEmitter<number>();
probeHost$: Observable<ProbeHost>;
error$: Observable<RPCClientError>;
constructor(
private store: Store<ProbeStore.State>,
private route: ActivatedRoute,
) {
this.probeHost$ = store.pipe(select(ProbeSelector.selectOne(this.probeHostID)));
}
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);
}
}