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

43 lines
1.4 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-27 14:17:07 +00:00
import * as ProbeEntityStore from '../store/entity/probe';
2018-05-27 09:12:20 +00:00
import { ProbeEntitySelector, ProbeListContainerSelector } from '../store';
2018-05-24 11:30:02 +00:00
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',
2018-05-27 14:17:07 +00:00
templateUrl: './probe-list-container.component.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-26 09:08:40 +00:00
pending$: Observable<boolean>;
2018-05-18 08:30:20 +00:00
@Output() select = new EventEmitter();
2018-05-27 14:17:07 +00:00
constructor(
private store: Store<ProbeEntityStore.State>,
) {
2018-05-27 09:12:20 +00:00
this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll));
2018-05-26 09:08:40 +00:00
this.pending$ = store.pipe(select(ProbeListContainerSelector.selectPending));
2018-05-24 11:30:02 +00:00
}
ngOnInit() {
this.store.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
2018-05-27 14:17:07 +00:00
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domain.id));
2018-05-24 11:30:02 +00:00
},
(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
}