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

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-05-27 14:17:07 +00:00
import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
2018-05-25 09:18:06 +00:00
import { Observable } from 'rxjs';
2018-05-28 09:58:13 +00:00
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
2018-05-25 09:18:06 +00:00
import { Store, select } from '@ngrx/store';
import * as ProbeStore from '../store/entity/probe';
2018-05-28 09:58:13 +00:00
import { ProbeDetailContainerSelector } from '../store';
2018-05-25 09:18:06 +00:00
import { ActivatedRoute } from '@angular/router';
2018-05-18 08:30:20 +00:00
@Component({
selector: 'of-probe-detail-container',
2018-05-27 14:17:07 +00:00
templateUrl: './probe-detail-container.component.html',
2018-05-18 08:30:20 +00:00
})
2018-05-27 06:52:27 +00:00
export class ProbeDetailContainerComponent implements OnInit, OnChanges {
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-26 09:08:40 +00:00
pending$: Observable<boolean>;
error$: Observable<any>;
2018-05-25 09:18:06 +00:00
constructor(
2018-05-28 09:58:13 +00:00
private store: Store<any>,
2018-05-25 09:18:06 +00:00
private route: ActivatedRoute,
) {
}
ngOnInit() {
2018-05-28 09:58:13 +00:00
this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending));
this.error$ = this.store.pipe(select(ProbeDetailContainerSelector.selectError));
this.probeHost$ = this.store.pipe(select(ProbeDetailContainerSelector.selectOne(this.probeHostID)));
2018-05-27 06:52:27 +00:00
}
ngOnChanges(changes: SimpleChanges): void {
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
}