From 8e5773b59099439e5dbf86c9d91fc8485d981ef0 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 2 May 2018 17:25:38 +0900 Subject: [PATCH] modify ing --- .../component/list/list.component.ts | 2 +- .../sensor-item/sensor-item-store.module.ts | 7 +- .../service/sensor-item-dependency.service.ts | 6 +- .../service/sensor-item.service.ts | 1 - src/packages/sensor-item/store/index.ts | 1 - .../sensor-item/store/key-list/list.action.ts | 4 +- .../sensor-item/store/key-list/list.effect.ts | 3 - .../sensor-item/store/key-list/list.state.ts | 2 +- .../component/detail/detail.component.ts | 6 +- .../target/component/list/list.component.ts | 10 ++- src/packages/target/service/target.service.ts | 2 +- .../target/store/modify/modify.action.ts | 3 +- .../target/store/modify/modify.effect.ts | 1 - .../target/store/modify/modify.reducer.ts | 72 +++++++++---------- .../target/store/modify/modify.state.ts | 2 +- src/packages/target/target-store.module.ts | 6 -- 16 files changed, 53 insertions(+), 75 deletions(-) diff --git a/src/packages/sensor-item/component/list/list.component.ts b/src/packages/sensor-item/component/list/list.component.ts index 22f7cf7..bc9a8ef 100644 --- a/src/packages/sensor-item/component/list/list.component.ts +++ b/src/packages/sensor-item/component/list/list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, AfterViewInit, AfterContentInit } from '@angular/core'; import { Router } from '@angular/router'; -import { MetaSensorDisplayItem } from 'packages/meta/sensor-display-item/model/MetaSensorDisplayItem'; +import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta'; @Component({ selector: 'of-sensor-item-list', diff --git a/src/packages/sensor-item/sensor-item-store.module.ts b/src/packages/sensor-item/sensor-item-store.module.ts index 2080777..14749a1 100644 --- a/src/packages/sensor-item/sensor-item-store.module.ts +++ b/src/packages/sensor-item/sensor-item-store.module.ts @@ -1,12 +1,7 @@ import { NgModule } from '@angular/core'; import { StoreModule } from '@ngrx/store'; -import { StoreDevtoolsModule } from '@ngrx/store-devtools'; -import { - StoreRouterConnectingModule, - RouterStateSerializer, -} from '@ngrx/router-store'; + import { EffectsModule } from '@ngrx/effects'; -import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store'; import { REDUCERS, diff --git a/src/packages/sensor-item/service/sensor-item-dependency.service.ts b/src/packages/sensor-item/service/sensor-item-dependency.service.ts index 62b93a3..b24c01a 100644 --- a/src/packages/sensor-item/service/sensor-item-dependency.service.ts +++ b/src/packages/sensor-item/service/sensor-item-dependency.service.ts @@ -2,9 +2,9 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { RPCService } from '@loafer/ng-rpc/service'; -import { SensorItemDependency } from '../model/SensorItemDependency'; -import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSensorItemKey'; -import { MetaSensorDisplayItem } from '../../meta/sensor-display-item/model/MetaSensorDisplayItem'; +import { SensorItemDependency } from '@overflow/commons-typescript/model/sensor-item'; +import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta'; +import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta'; diff --git a/src/packages/sensor-item/service/sensor-item.service.ts b/src/packages/sensor-item/service/sensor-item.service.ts index 5f7b74c..1feb01e 100644 --- a/src/packages/sensor-item/service/sensor-item.service.ts +++ b/src/packages/sensor-item/service/sensor-item.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs/Observable'; import { RPCService } from '@loafer/ng-rpc/service'; diff --git a/src/packages/sensor-item/store/index.ts b/src/packages/sensor-item/store/index.ts index 7104a63..05ab39d 100644 --- a/src/packages/sensor-item/store/index.ts +++ b/src/packages/sensor-item/store/index.ts @@ -1,7 +1,6 @@ import { createSelector, createFeatureSelector, - ActionReducerMap, } from '@ngrx/store'; import { StateSelector } from 'packages/core/ngrx/store'; diff --git a/src/packages/sensor-item/store/key-list/list.action.ts b/src/packages/sensor-item/store/key-list/list.action.ts index a16c853..f30ac37 100644 --- a/src/packages/sensor-item/store/key-list/list.action.ts +++ b/src/packages/sensor-item/store/key-list/list.action.ts @@ -1,8 +1,8 @@ import { Action } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; -import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSensorItemKey'; -import { MetaSensorDisplayItem } from 'packages/meta/sensor-display-item/model/MetaSensorDisplayItem'; +import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta'; +import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta'; export enum ActionType { diff --git a/src/packages/sensor-item/store/key-list/list.effect.ts b/src/packages/sensor-item/store/key-list/list.effect.ts index 53d75c9..68d9450 100644 --- a/src/packages/sensor-item/store/key-list/list.effect.ts +++ b/src/packages/sensor-item/store/key-list/list.effect.ts @@ -16,9 +16,6 @@ import 'rxjs/add/operator/take'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; -import { DomainMember } from 'packages/domain/model'; - - import { ReadAllByDisplayItem, ReadAllByDisplayItemSuccess, diff --git a/src/packages/sensor-item/store/key-list/list.state.ts b/src/packages/sensor-item/store/key-list/list.state.ts index e98a469..384d133 100644 --- a/src/packages/sensor-item/store/key-list/list.state.ts +++ b/src/packages/sensor-item/store/key-list/list.state.ts @@ -1,5 +1,5 @@ import { RPCClientError } from '@loafer/ng-rpc/protocol'; -import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSensorItemKey'; +import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta'; export interface State { diff --git a/src/packages/target/component/detail/detail.component.ts b/src/packages/target/component/detail/detail.component.ts index 814b8cd..6301b55 100644 --- a/src/packages/target/component/detail/detail.component.ts +++ b/src/packages/target/component/detail/detail.component.ts @@ -1,7 +1,7 @@ import { Component, ViewChild, OnInit, Input, AfterContentInit, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { Sensor } from 'packages/sensor/model'; -import { Infra } from 'packages/infra/model'; +import { Sensor } from '@overflow/commons-typescript/model/sensor'; +import { Infra } from '@overflow/commons-typescript/model/infra'; import { Store, select } from '@ngrx/store'; import { DetailSelector as InfraDetailSelector } from 'packages/infra/store'; import * as InfraDetailStore from 'packages/infra/store/detail'; @@ -12,7 +12,7 @@ import * as SensorListStore from 'packages/sensor/store/list'; import { PageParams, Page } from 'app/commons/model'; import { ModifySelector } from 'packages/target/store'; import * as TargetModifyStore from 'packages/target/store/modify'; -import { Target } from '../../model'; +import { Target } from '@overflow/commons-typescript/model/target'; @Component({ diff --git a/src/packages/target/component/list/list.component.ts b/src/packages/target/component/list/list.component.ts index b6f8718..d4be530 100644 --- a/src/packages/target/component/list/list.component.ts +++ b/src/packages/target/component/list/list.component.ts @@ -1,16 +1,14 @@ -import { Component, OnInit, AfterViewInit, AfterContentInit, Input, OnDestroy } from '@angular/core'; +import { Component, OnInit, AfterContentInit, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { Infra } from 'packages/infra/model'; +import { Infra } from '@overflow/commons-typescript/model/infra'; import { Store, select } from '@ngrx/store'; import { ListSelector } from 'packages/infra/store'; import * as InfraListStore from 'packages/infra/store/list'; import { Page, PageParams } from 'app/commons/model'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; -import { Probe } from 'packages/probe/model'; +import { Probe } from '@overflow/commons-typescript/model/probe'; -import * as ProbeDetailStore from 'packages/probe/store/detail'; -import { DetailSelector as ProbeDetailSelector } from 'packages/probe/store'; -import { Target } from '../../model'; +import { Target } from '@overflow/commons-typescript/model/target'; import { Subscription } from 'rxjs/Subscription'; diff --git a/src/packages/target/service/target.service.ts b/src/packages/target/service/target.service.ts index d1d8e82..d1b1fb8 100644 --- a/src/packages/target/service/target.service.ts +++ b/src/packages/target/service/target.service.ts @@ -5,7 +5,7 @@ import 'rxjs/add/operator/map'; import { RPCService } from '@loafer/ng-rpc/service'; -import { Target } from '../model'; +import { Target } from '@overflow/commons-typescript/model/target'; @Injectable() diff --git a/src/packages/target/store/modify/modify.action.ts b/src/packages/target/store/modify/modify.action.ts index 31b434e..0da9cd6 100644 --- a/src/packages/target/store/modify/modify.action.ts +++ b/src/packages/target/store/modify/modify.action.ts @@ -1,8 +1,7 @@ import { Action } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; - -import { Target } from '../../model'; +import { Target } from '@overflow/commons-typescript/model/target'; export enum ActionType { Modify = '[Target.modify] Modify', diff --git a/src/packages/target/store/modify/modify.effect.ts b/src/packages/target/store/modify/modify.effect.ts index e4135f1..bff3f13 100644 --- a/src/packages/target/store/modify/modify.effect.ts +++ b/src/packages/target/store/modify/modify.effect.ts @@ -13,7 +13,6 @@ import 'rxjs/add/operator/exhaustMap'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/take'; -import { Target } from '../../model'; import { TargetService } from '../../service/target.service'; import { diff --git a/src/packages/target/store/modify/modify.reducer.ts b/src/packages/target/store/modify/modify.reducer.ts index d498d1d..ad9a369 100644 --- a/src/packages/target/store/modify/modify.reducer.ts +++ b/src/packages/target/store/modify/modify.reducer.ts @@ -1,45 +1,43 @@ import { - Actions, - ActionType, - } from './modify.action'; + Actions, + ActionType, +} from './modify.action'; - import { - State, - initialState, - } from './modify.state'; +import { + State, + initialState, +} from './modify.state'; - import { Target } from '../../model'; +export function reducer(state = initialState, action: Actions): State { + switch (action.type) { + case ActionType.Modify: { + return { + ...state, + error: null, + pending: true, + }; + } - export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.Modify: { - return { - ...state, - error: null, - pending: true, - }; - } + case ActionType.ModifySuccess: { + return { + ...state, + error: null, + pending: false, + target: action.payload + }; + } - case ActionType.ModifySuccess: { - return { - ...state, - error: null, - pending: false, - target: action.payload - }; - } + case ActionType.ModifyFailure: { + return { + ...state, + error: action.payload, + pending: false, + target: null, + }; + } - case ActionType.ModifyFailure: { - return { - ...state, - error: action.payload, - pending: false, - target: null, - }; - } - - default: { - return state; - } + default: { + return state; } } +} diff --git a/src/packages/target/store/modify/modify.state.ts b/src/packages/target/store/modify/modify.state.ts index f6aad33..88eb818 100644 --- a/src/packages/target/store/modify/modify.state.ts +++ b/src/packages/target/store/modify/modify.state.ts @@ -1,5 +1,5 @@ import { RPCClientError } from '@loafer/ng-rpc/protocol'; -import { Target } from '../../model'; +import { Target } from '@overflow/commons-typescript/model/target'; export interface State { error: RPCClientError | null; diff --git a/src/packages/target/target-store.module.ts b/src/packages/target/target-store.module.ts index 3405870..0e972ef 100644 --- a/src/packages/target/target-store.module.ts +++ b/src/packages/target/target-store.module.ts @@ -1,12 +1,6 @@ import { NgModule } from '@angular/core'; import { StoreModule } from '@ngrx/store'; -import { StoreDevtoolsModule } from '@ngrx/store-devtools'; -import { - StoreRouterConnectingModule, - RouterStateSerializer, -} from '@ngrx/router-store'; import { EffectsModule } from '@ngrx/effects'; -import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store'; import { REDUCERS,