From aa74b9b8191dee286c63092e1ede968ad59afbb6 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 19 Apr 2018 21:56:24 +0900 Subject: [PATCH] probe's target --- .../target/component/list/list.component.ts | 89 ++++--------------- src/packages/target/target.module.ts | 4 +- 2 files changed, 21 insertions(+), 72 deletions(-) diff --git a/src/packages/target/component/list/list.component.ts b/src/packages/target/component/list/list.component.ts index 4119190..22463d0 100644 --- a/src/packages/target/component/list/list.component.ts +++ b/src/packages/target/component/list/list.component.ts @@ -19,7 +19,6 @@ import { Target } from '../../model'; }) export class ListComponent implements OnInit, AfterContentInit { - probe$ = this.probeDetailStore.pipe(select(ProbeDetailSelector.select('probe'))); infras$ = this.infraListStore.pipe(select(ListSelector.select('page'))); infras: Infra[]; probe: Probe; @@ -30,85 +29,33 @@ export class ListComponent implements OnInit, AfterContentInit { private route: ActivatedRoute, private router: Router, private infraListStore: Store, - private probeDetailStore: Store, ) { } ngOnInit() { - // this.probe$.subscribe( - // (probe: Probe) => { - // if (probe) { - // console.log(probe); - // this.probe = probe; - // this.getInfras(probe); - // } - // }, - // (error: RPCClientError) => { - // console.log(error.response.message); - // } - // ); - // this.infras$.subscribe( - // (page: Page) => { - // if (!page) { - // return; - // } - // this.infras = page.content; - // }, - // (error: RPCClientError) => { - // console.log(error); - // } - // ); + this.infras$.subscribe( + (page: Page) => { + if (!page) { + return; + } + this.infras = page.content; + }, + (error: RPCClientError) => { + console.log(error); + } + ); } ngAfterContentInit() { - const probeId = this.route.snapshot.paramMap.get('id'); - this.getProbe(probeId); - - // Temporary - const infra1 = { - id: 1, - infraType: { - id: 1 - }, - target: { - id: 1, - displayName: 'FakeTarget1', - }, - }; - const infra2 = { - id: 2, - infraType: { - id: 3 - }, - target: { - id: 2, - displayName: 'FakeTarget2', - }, - }; - const infra3 = { - id: 3, - infraType: { - id: 2 - }, - target: { - id: 3, - displayName: 'FakeTarget3', - }, - }; - this.infras = []; - this.infras.push(infra1); - this.infras.push(infra2); - this.infras.push(infra3); + this.route.params.subscribe((params: any) => { + const probe = { + id: params['id'], + }; + this.getInfras(probe); + }); } - getProbe(probeId: string) { - this.probeDetailStore.dispatch( - new ProbeDetailStore.Read( - { id: probeId } - ) - ); - } getInfras(probe) { const pageParams: PageParams = { pageNo: '0', @@ -124,7 +71,7 @@ export class ListComponent implements OnInit, AfterContentInit { } onRowSelect(event) { - this.router.navigate(['sensors'], { queryParams: {target: event.data.id}}); + this.router.navigate(['sensors'], { queryParams: { target: event.data.id } }); } onAddSensor(target: Target) { diff --git a/src/packages/target/target.module.ts b/src/packages/target/target.module.ts index 4c0ed51..35e61ae 100644 --- a/src/packages/target/target.module.ts +++ b/src/packages/target/target.module.ts @@ -6,13 +6,15 @@ import { SERVICES } from './service'; import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module'; import { SensorModule } from '../sensor/sensor.module'; import { KeyValueModule } from 'app/commons/component/key-value/key-value.module'; +import { InfraModule } from '../infra/infra.module'; @NgModule({ imports: [ CommonModule, PrimeNGModules, SensorModule, - KeyValueModule + KeyValueModule, + InfraModule ], declarations: [ COMPONENTS,