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

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-05-25 09:18:06 +00:00
import { Component, EventEmitter, Output, OnInit } from '@angular/core';
2018-05-24 11:30:02 +00:00
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
2018-05-25 09:18:06 +00:00
import * as ProbeStore from '../store/entity/probe';
2018-05-24 11:30:02 +00:00
import { ProbeSelector } from '../store';
import { AuthSelector } from '@overflow/member/store';
import { Domain } from '@overflow/commons-typescript/model/domain';
2018-05-18 08:30:20 +00:00
@Component({
2018-05-24 11:30:02 +00:00
selector: 'of-probe-list-container',
templateUrl: './probe-list-container.html',
2018-05-18 08:30:20 +00:00
})
2018-05-25 09:18:06 +00:00
export class ProbeListContainerComponent implements OnInit {
2018-05-24 11:30:02 +00:00
probeHosts$: Observable<ProbeHost[]>;
2018-05-18 08:30:20 +00:00
@Output() select = new EventEmitter();
2018-05-24 11:30:02 +00:00
constructor(private store: Store<ProbeStore.State>) {
2018-05-25 11:59:18 +00:00
this.probeHosts$ = store.pipe(select(ProbeSelector.selectAll));
2018-05-24 11:30:02 +00:00
}
ngOnInit() {
this.store.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
this.store.dispatch(new ProbeStore.ReadAllByDomainID(domain.id));
},
(error) => {
console.log(error);
}
);
}
2018-05-25 09:18:06 +00:00
onSelect(probeHost: ProbeHost) {
this.select.emit(probeHost);
2018-05-18 08:30:20 +00:00
}
2018-05-25 09:18:06 +00:00
2018-05-18 08:30:20 +00:00
}