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

42 lines
1.4 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';
2018-05-26 09:08:40 +00:00
import { ProbeSelector, 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',
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-26 09:08:40 +00:00
pending$: Observable<boolean>;
error$: Observable<any>;
2018-05-25 09:18:06 +00:00
constructor(
private store: Store<ProbeStore.State>,
private route: ActivatedRoute,
) {
2018-05-26 09:08:40 +00:00
this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending));
this.error$ = this.store.pipe(select(ProbeSelector.selectError));
2018-05-25 09:18:06 +00:00
}
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
}