From bfb3f7a59c8fed80c70a7795461d2705533da6fc Mon Sep 17 00:00:00 2001 From: insanity Date: Mon, 30 Apr 2018 19:59:32 +0900 Subject: [PATCH] test --- .../infra/component/map/map.component.ts | 2 +- .../component/detail/detail.component.html | 14 +++++- .../component/detail/detail.component.ts | 48 ++++++++++++++++++- src/packages/target/service/target.service.ts | 18 +------ src/packages/target/store/index.ts | 12 ++--- src/packages/target/store/modify/index.ts | 4 ++ .../target/store/modify/modify.action.ts | 35 ++++++++++++++ .../modify.effect.spec.ts} | 2 +- .../modify.effect.ts} | 23 +++++---- .../modify.reducer.ts} | 14 +++--- .../modify.state.ts} | 5 +- src/packages/target/store/target/index.ts | 4 -- .../target/store/target/target.action.ts | 36 -------------- 13 files changed, 128 insertions(+), 89 deletions(-) create mode 100644 src/packages/target/store/modify/index.ts create mode 100644 src/packages/target/store/modify/modify.action.ts rename src/packages/target/store/{target/target.effect.spec.ts => modify/modify.effect.spec.ts} (87%) rename src/packages/target/store/{target/target.effect.ts => modify/modify.effect.ts} (62%) rename src/packages/target/store/{target/target.reducer.ts => modify/modify.reducer.ts} (70%) rename src/packages/target/store/{target/target.state.ts => modify/modify.state.ts} (84%) delete mode 100644 src/packages/target/store/target/index.ts delete mode 100644 src/packages/target/store/target/target.action.ts diff --git a/src/packages/infra/component/map/map.component.ts b/src/packages/infra/component/map/map.component.ts index a749cfd..08d9ca0 100644 --- a/src/packages/infra/component/map/map.component.ts +++ b/src/packages/infra/component/map/map.component.ts @@ -430,7 +430,7 @@ export class MapComponent implements OnInit, AfterContentInit { if (nodeType === 'probe') { this.router.navigate(['probe', event.node.obj.id, 'info']); } else if (nodeType === 'host' || nodeType === 'service') { - this.router.navigate(['sensors'], { queryParams: { target: event.node.obj.target.id } }); + this.router.navigate(['target', event.node.obj.id, 'info']); } else if (nodeType === 'sensor') { this.router.navigate(['sensor', event.node.obj.id, 'info']); } diff --git a/src/packages/target/component/detail/detail.component.html b/src/packages/target/component/detail/detail.component.html index 8b85d86..9b00fd9 100644 --- a/src/packages/target/component/detail/detail.component.html +++ b/src/packages/target/component/detail/detail.component.html @@ -1,13 +1,25 @@
+
+ +
+
+ +
+ + + + + +
+
Status Up
- diff --git a/src/packages/target/component/detail/detail.component.ts b/src/packages/target/component/detail/detail.component.ts index 712ccb6..1ca336d 100644 --- a/src/packages/target/component/detail/detail.component.ts +++ b/src/packages/target/component/detail/detail.component.ts @@ -7,10 +7,11 @@ import { DetailSelector as InfraDetailSelector } from 'packages/infra/store'; import * as InfraDetailStore from 'packages/infra/store/detail'; import { Subscription } from 'rxjs/Subscription'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; - import { sensorListSelector } from 'packages/sensor/store'; import * as SensorListStore from 'packages/sensor/store/list'; import { PageParams, Page } from 'app/commons/model'; +// import { target } from 'packages/target/store'; +// import * as SensorListStore from 'packages/sensor/store/list'; @Component({ @@ -24,6 +25,8 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { sensorsSubscription$: Subscription; sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page'))); + targetSubscription$: Subscription; + infraId = null; infra: Infra; sensors: Sensor[]; @@ -107,6 +110,47 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { onPaging(e) { this.getSensors(e.page); -} + } + + onRowSelect(event) { + this.router.navigate(['sensor', event.data.id, 'info']); + } + + onTraceroute() { + alert('지원 예정'); + } + + + onDisplayNameChange(value: string) { + console.log(value); + // if (value === this.probe.displayName) { + // return; + // } + // this.probe.displayName = value; + // this.modifyStore.dispatch( + // new ModifyStore.Modify(this.probe) + // ); + + // const modifySuccessSubscription$: Subscription = this.modifySuccess$.subscribe( + // (probe: Probe) => { + // if (probe) { + // this.msgs = []; + // this.msgs.push({ severity: 'success', summary: 'Succeed', detail: 'Probe name has changed.' }); + // } + // if (modifySuccessSubscription$) { + // modifySuccessSubscription$.unsubscribe(); + // } + // }, + // (error: RPCClientError) => { + // console.log(error.response.message); + // } + // ); + } + + onDisplayNameChangeKeypress(event, value) { + if (event.key === 'Enter') { + this.onDisplayNameChange(value); + } + } } diff --git a/src/packages/target/service/target.service.ts b/src/packages/target/service/target.service.ts index 23819fd..d1d8e82 100644 --- a/src/packages/target/service/target.service.ts +++ b/src/packages/target/service/target.service.ts @@ -6,7 +6,6 @@ import 'rxjs/add/operator/map'; import { RPCService } from '@loafer/ng-rpc/service'; import { Target } from '../model'; -import { Domain } from '../../domain/model'; @Injectable() @@ -18,21 +17,8 @@ export class TargetService { } - public readAllByDomain(domain: Domain): Observable { - const body = { - domain: domain, - }; - - return this.rpcService.call('TargetService.readAllByDomain', domain); + public modify(target: Target): Observable { + return this.rpcService.call('TargetService.modify', target); } -// public readAllByProbe(domain: Domain): Observable { -// const body = { -// domain: domain, -// }; - -// return this.rpcService.call('TargetService.readAllByDomain', domain); -// } - - } diff --git a/src/packages/target/store/index.ts b/src/packages/target/store/index.ts index 4b59232..71b656c 100644 --- a/src/packages/target/store/index.ts +++ b/src/packages/target/store/index.ts @@ -8,23 +8,23 @@ import { import { MODULE } from '../target.constant'; - import * as TargetStore from './target'; + import * as TargetModifyStore from './modify'; export interface State { - readallbydomain: TargetStore.State; + modify: TargetModifyStore.State; } export const REDUCERS = { - readallbydomain: TargetStore.reducer, + modify: TargetModifyStore.reducer, }; export const EFFECTS = [ - TargetStore.Effects, + TargetModifyStore.Effects, ]; export const selectTargetState = createFeatureSelector(MODULE.name); - export const ReadAllByDomainSelector = new StateSelector(createSelector( + export const ReadAllByDomainSelector = new StateSelector(createSelector( selectTargetState, - (state: State) => state.readallbydomain + (state: State) => state.modify )); diff --git a/src/packages/target/store/modify/index.ts b/src/packages/target/store/modify/index.ts new file mode 100644 index 0000000..9f23ca0 --- /dev/null +++ b/src/packages/target/store/modify/index.ts @@ -0,0 +1,4 @@ +export * from './modify.action'; +export * from './modify.effect'; +export * from './modify.reducer'; +export * from './modify.state'; diff --git a/src/packages/target/store/modify/modify.action.ts b/src/packages/target/store/modify/modify.action.ts new file mode 100644 index 0000000..31b434e --- /dev/null +++ b/src/packages/target/store/modify/modify.action.ts @@ -0,0 +1,35 @@ +import { Action } from '@ngrx/store'; + +import { RPCClientError } from '@loafer/ng-rpc/protocol'; + +import { Target } from '../../model'; + +export enum ActionType { + Modify = '[Target.modify] Modify', + ModifySuccess = '[Target.modify] ModifySuccess', + ModifyFailure = '[Target.modify] ModifyFailure', +} + +export class Modify implements Action { + readonly type = ActionType.Modify; + + constructor(public payload: Target) {} +} + +export class ModifySuccess implements Action { + readonly type = ActionType.ModifySuccess; + + constructor(public payload: Target) {} +} + +export class ModifyFailure implements Action { + readonly type = ActionType.ModifyFailure; + + constructor(public payload: RPCClientError) {} +} + +export type Actions = + | Modify + | ModifySuccess + | ModifyFailure +; diff --git a/src/packages/target/store/target/target.effect.spec.ts b/src/packages/target/store/modify/modify.effect.spec.ts similarity index 87% rename from src/packages/target/store/target/target.effect.spec.ts rename to src/packages/target/store/modify/modify.effect.spec.ts index 5135b37..b064f15 100644 --- a/src/packages/target/store/target/target.effect.spec.ts +++ b/src/packages/target/store/modify/modify.effect.spec.ts @@ -1,6 +1,6 @@ import { TestBed, inject } from '@angular/core/testing'; -import { Effects } from './target.effect'; +import { Effects } from './modify.effect'; describe('Target.Effects', () => { beforeEach(() => { diff --git a/src/packages/target/store/target/target.effect.ts b/src/packages/target/store/modify/modify.effect.ts similarity index 62% rename from src/packages/target/store/target/target.effect.ts rename to src/packages/target/store/modify/modify.effect.ts index 15cf3c4..e4135f1 100644 --- a/src/packages/target/store/target/target.effect.ts +++ b/src/packages/target/store/modify/modify.effect.ts @@ -17,11 +17,11 @@ import { Target } from '../../model'; import { TargetService } from '../../service/target.service'; import { - ReadAllByDomain, - ReadAllByDomainSuccess, - ReadAllByDomainFailure, + Modify, + ModifySuccess, + ModifyFailure, ActionType, -} from './target.action'; +} from './modify.action'; @Injectable() export class Effects { @@ -33,14 +33,13 @@ export class Effects { ) { } @Effect() - readAllByMember$: Observable = this.actions$ - .ofType(ActionType.ReadAllByDomain) - .map((action: ReadAllByDomain) => action.payload) - .exhaustMap(domain => - this.targetService - .readAllByDomain(domain) - .map(targets => new ReadAllByDomainSuccess(targets)) - .catch(error => of(new ReadAllByDomainFailure(error))) + modify$: Observable = this.actions$ + .ofType(ActionType.Modify) + .map((action: Modify) => action.payload) + .exhaustMap(target => + this.targetService.modify(target) + .map(targets => new ModifySuccess(targets)) + .catch(error => of(new ModifyFailure(error))) ); } diff --git a/src/packages/target/store/target/target.reducer.ts b/src/packages/target/store/modify/modify.reducer.ts similarity index 70% rename from src/packages/target/store/target/target.reducer.ts rename to src/packages/target/store/modify/modify.reducer.ts index 73ba5a6..d498d1d 100644 --- a/src/packages/target/store/target/target.reducer.ts +++ b/src/packages/target/store/modify/modify.reducer.ts @@ -1,18 +1,18 @@ import { Actions, ActionType, - } from './target.action'; + } from './modify.action'; import { State, initialState, - } from './target.state'; + } from './modify.state'; import { Target } from '../../model'; export function reducer(state = initialState, action: Actions): State { switch (action.type) { - case ActionType.ReadAllByDomain: { + case ActionType.Modify: { return { ...state, error: null, @@ -20,21 +20,21 @@ import { }; } - case ActionType.ReadAllByDomainSuccess: { + case ActionType.ModifySuccess: { return { ...state, error: null, pending: false, - targets: action.payload + target: action.payload }; } - case ActionType.ReadAllByDomainFailure: { + case ActionType.ModifyFailure: { return { ...state, error: action.payload, pending: false, - targets: null, + target: null, }; } diff --git a/src/packages/target/store/target/target.state.ts b/src/packages/target/store/modify/modify.state.ts similarity index 84% rename from src/packages/target/store/target/target.state.ts rename to src/packages/target/store/modify/modify.state.ts index c4ac364..f6aad33 100644 --- a/src/packages/target/store/target/target.state.ts +++ b/src/packages/target/store/modify/modify.state.ts @@ -1,15 +1,14 @@ import { RPCClientError } from '@loafer/ng-rpc/protocol'; - import { Target } from '../../model'; export interface State { error: RPCClientError | null; pending: boolean; - targets: Target[] | null; + target: Target | null; } export const initialState: State = { error: null, pending: false, - targets: null, + target: null, }; diff --git a/src/packages/target/store/target/index.ts b/src/packages/target/store/target/index.ts deleted file mode 100644 index 3332134..0000000 --- a/src/packages/target/store/target/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './target.action'; -export * from './target.effect'; -export * from './target.reducer'; -export * from './target.state'; diff --git a/src/packages/target/store/target/target.action.ts b/src/packages/target/store/target/target.action.ts deleted file mode 100644 index 843395a..0000000 --- a/src/packages/target/store/target/target.action.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc/protocol'; - -import { Target } from '../../model'; -import { Domain } from '../../../domain/model'; - -export enum ActionType { - ReadAllByDomain = '[Target.ReadAllByDomain] ReadAllByDomain', - ReadAllByDomainSuccess = '[Target.ReadAllByDomainSuccess] ReadAllByDomainSuccess', - ReadAllByDomainFailure = '[Target.ReadAllByDomainFailure] ReadAllByDomainFailure', -} - -export class ReadAllByDomain implements Action { - readonly type = ActionType.ReadAllByDomain; - - constructor(public payload: Domain) {} -} - -export class ReadAllByDomainSuccess implements Action { - readonly type = ActionType.ReadAllByDomainSuccess; - - constructor(public payload: Target[]) {} -} - -export class ReadAllByDomainFailure implements Action { - readonly type = ActionType.ReadAllByDomainFailure; - - constructor(public payload: RPCClientError) {} -} - -export type Actions = - | ReadAllByDomain - | ReadAllByDomainSuccess - | ReadAllByDomainFailure -;