diff --git a/@overflow/probe/component/list/list.component.ts b/@overflow/probe/component/list/list.component.ts index 803899e..501ca13 100644 --- a/@overflow/probe/component/list/list.component.ts +++ b/@overflow/probe/component/list/list.component.ts @@ -1,87 +1,19 @@ -import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild, OnDestroy, Output, EventEmitter } from '@angular/core'; -import { Store, select } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { Domain } from '@overflow/commons-typescript/model/domain'; -import { AuthSelector } from '@overflow/member/store'; - -import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; -import * as ProbeStore from '../../store/probe'; -import { ProbeSelector } from '../../store'; -import { Subscription } from 'rxjs/Subscription'; +import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild, OnDestroy, Output, EventEmitter, Input } from '@angular/core'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; @Component({ selector: 'of-probe-list', templateUrl: './list.component.html', }) -export class ProbeListComponent implements OnInit, AfterContentInit, OnDestroy { - probeHostsSubscription$: Subscription; - probeHosts$ = this.store.pipe(select(ProbeSelector.select('probes'))); - probeHosts: ProbeHost[]; +export class ProbeListComponent { + @Output() select = new EventEmitter(); + @Input() probeHosts: ProbeHost[]; - @Output() select = new EventEmitter(); - - constructor( - private store: Store - ) { - } - - ngOnInit() { - this.probeHostsSubscription$ = this.probeHosts$.subscribe( - (probeHosts: ProbeHost[]) => { - this.probeHosts = probeHosts; - }, - (error: RPCClientError) => { - console.log(error.response.message); - } - ); - } - - ngAfterContentInit() { - this.store.select(AuthSelector.select('domain')).subscribe( - (domain: Domain) => { - this.store.dispatch(new ProbeStore.ReadAllByDomainID(domain.id)); - }, - (error) => { - console.log(error); - } - ); - - // temp - // const probeHost: ProbeHost = { - // id: 1, - // probe: { - // id: 1, - // displayName: 'ddd', - // cidr: 'dddd', - // authorizeDate: new Date(), - // authorizeMember: { - // name: 'ddd' - // } - // }, - // host: { - // id: 1, - // ipv4: 'aaaa', - // os: { - // vendor: { - // name: 'dd' - // } - // }, - // } - // }; - // this.probeHosts = []; - // this.probeHosts.push(probeHost); - - } - - ngOnDestroy() { - if (this.probeHostsSubscription$) { - this.probeHostsSubscription$.unsubscribe(); - } + constructor() { } onRowSelect(event) { - this.select.emit(event.data.probe); + this.select.emit(event.data); } getUptime(probe: Probe) { diff --git a/@overflow/probe/container/probe-list-container.html b/@overflow/probe/container/probe-list-container.html index 5212b22..faf16b2 100644 --- a/@overflow/probe/container/probe-list-container.html +++ b/@overflow/probe/container/probe-list-container.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/@overflow/probe/container/probe-list-container.ts b/@overflow/probe/container/probe-list-container.ts index 67eee65..71bf0dc 100644 --- a/@overflow/probe/container/probe-list-container.ts +++ b/@overflow/probe/container/probe-list-container.ts @@ -1,14 +1,41 @@ -import { Component, EventEmitter, Output } from '@angular/core'; -import { Probe } from '@overflow/commons-typescript/model/probe'; +import { Component, EventEmitter, Output, OnInit, AfterContentInit } from '@angular/core'; +import { ProbeHost } from '@overflow/commons-typescript/model/probe'; +import { Observable } from 'rxjs'; +import { Store, select } from '@ngrx/store'; +import * as ProbeStore from '../store/probe'; +import { ProbeSelector } from '../store'; +import { AuthSelector } from '@overflow/member/store'; +import { Domain } from '@overflow/commons-typescript/model/domain'; @Component({ - selector: 'of-probe-list-container', - templateUrl: './probe-list-container.html', + selector: 'of-probe-list-container', + templateUrl: './probe-list-container.html', }) -export class ProbeListContainerComponent { +export class ProbeListContainerComponent implements OnInit, AfterContentInit { + + probeHosts$: Observable; @Output() select = new EventEmitter(); - onSelect(probe: Probe) { - this.select.emit(probe); + constructor(private store: Store) { + this.probeHosts$ = store.pipe(select(ProbeSelector.select('probeHosts'))); + } + + onSelect(probeHost: ProbeHost) { + this.select.emit(probeHost); + } + + ngOnInit() { + this.store.select(AuthSelector.select('domain')).subscribe( + (domain: Domain) => { + this.store.dispatch(new ProbeStore.ReadAllByDomainID(domain.id)); + }, + (error) => { + console.log(error); + } + ); + } + + ngAfterContentInit() { + } } diff --git a/@overflow/probe/store/index.ts b/@overflow/probe/store/index.ts index 526b25e..5e333f6 100644 --- a/@overflow/probe/store/index.ts +++ b/@overflow/probe/store/index.ts @@ -28,3 +28,4 @@ export const ProbeSelector = new StateSelector(createSelector( selectProbeState, (state: State) => state.probes )); + diff --git a/src/environments/environment.ts b/src/environments/environment.ts index a586811..7f890ba 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -7,7 +7,7 @@ export const environment = { production: false, restBaseURL: 'http://192.168.1.50:19080/webapp', webappRPCConfig: { - url: 'ws://192.168.1.50:19090/webapp', + url: 'ws://192.168.1.101:19090/webapp', reconnectInterval: 5000, reconnectRetry: 10, },