diff --git a/src/packages/commons/component/info-table/info-table.component.html b/src/packages/commons/component/info-table/info-table.component.html index bcc418e..d652743 100644 --- a/src/packages/commons/component/info-table/info-table.component.html +++ b/src/packages/commons/component/info-table/info-table.component.html @@ -5,7 +5,7 @@ -->
- - + + \ No newline at end of file diff --git a/src/packages/commons/component/info-table/info-table.component.scss b/src/packages/commons/component/info-table/info-table.component.scss index 2f34f21..4525d20 100644 --- a/src/packages/commons/component/info-table/info-table.component.scss +++ b/src/packages/commons/component/info-table/info-table.component.scss @@ -1,10 +1,4 @@ -.example-container { - display: flex; - flex-direction: column; - min-width: 300px; +.full-width { + width: 100%; } - - .mat-table { - overflow: auto; - max-height: 500px; - } \ No newline at end of file + \ No newline at end of file diff --git a/src/packages/infra/component/map/map.component.html b/src/packages/infra/component/map/map.component.html index 5070657..74a3288 100644 --- a/src/packages/infra/component/map/map.component.html +++ b/src/packages/infra/component/map/map.component.html @@ -22,12 +22,16 @@ Status: 기본 센서 데이터에서 저장한 metric으로.. -
????
+
+ service list +
-
?????
+
+ sensor list +
diff --git a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html index 2f16bc3..ffc5eac 100644 --- a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html +++ b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html @@ -18,9 +18,10 @@ - - - + + Yes + No + {{option}} diff --git a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts index 3f8f54e..9be683e 100644 --- a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts +++ b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts @@ -44,7 +44,6 @@ export class CrawlerAuthComponent implements OnInit, OnChanges { } ngOnChanges() { - if (this.selectedCrawler === null) { return; } this.getCrawlerAuthInputItems(); } diff --git a/src/packages/sensor/service/sensor.service.ts b/src/packages/sensor/service/sensor.service.ts index ac7078f..1973280 100644 --- a/src/packages/sensor/service/sensor.service.ts +++ b/src/packages/sensor/service/sensor.service.ts @@ -5,8 +5,10 @@ import 'rxjs/add/operator/map'; import { RPCService } from '@loafer/ng-rpc/service'; -import { Domain } from '../../domain/model'; import { PageParams, Page } from 'app/commons/model'; +import { SensorItem } from 'packages/sensor-item/model/SensorItem'; +import { Sensor } from '../model'; +import { Domain } from 'packages/domain/model'; @Injectable() @@ -22,5 +24,7 @@ export class SensorService { return this.rpcService.call('SensorService.readAllByDomain', domain, pageParams); } - + public regist(sensor: Sensor, sensorItems: SensorItem[]): Observable { + return null; + } } diff --git a/src/packages/sensor/store/index.ts b/src/packages/sensor/store/index.ts index ac21bb2..744de02 100644 --- a/src/packages/sensor/store/index.ts +++ b/src/packages/sensor/store/index.ts @@ -1,30 +1,39 @@ import { - createSelector, - createFeatureSelector, - ActionReducerMap, - } from '@ngrx/store'; + createSelector, + createFeatureSelector, + ActionReducerMap, +} from '@ngrx/store'; - import { StateSelector } from 'packages/core/ngrx/store'; +import { StateSelector } from 'packages/core/ngrx/store'; - import { MODULE } from '../sensor.constant'; +import { MODULE } from '../sensor.constant'; - import * as ReadAllByDomainStore from './list'; +import * as ReadAllByDomainStore from './list'; +import * as RegistStore from './regist'; - export interface State { - list: ReadAllByDomainStore.State; - } +export interface State { + list: ReadAllByDomainStore.State; + sensor: RegistStore.State; +} - export const REDUCERS = { - list: ReadAllByDomainStore.reducer, - }; +export const REDUCERS = { + list: ReadAllByDomainStore.reducer, + sensor: RegistStore.reducer, +}; - export const EFFECTS = [ - ReadAllByDomainStore.Effects, - ]; +export const EFFECTS = [ + ReadAllByDomainStore.Effects, + RegistStore.Effects, +]; - export const selectState = createFeatureSelector(MODULE.name); +export const sensorState = createFeatureSelector(MODULE.name); + +export const sensorListSelector = new StateSelector(createSelector( + sensorState, + (state: State) => state.list +)); +export const sensorSelector = new StateSelector(createSelector( + sensorState, + (state: State) => state.sensor +)); - export const sensorListSelector = new StateSelector(createSelector( - selectState, - (state: State) => state.list - )); diff --git a/src/packages/sensor/store/regist/index.ts b/src/packages/sensor/store/regist/index.ts new file mode 100644 index 0000000..f6da3fb --- /dev/null +++ b/src/packages/sensor/store/regist/index.ts @@ -0,0 +1,4 @@ +export * from './regist.action'; +export * from './regist.effect'; +export * from './regist.reducer'; +export * from './regist.state'; diff --git a/src/packages/sensor/store/regist/regist.action.ts b/src/packages/sensor/store/regist/regist.action.ts new file mode 100644 index 0000000..c246445 --- /dev/null +++ b/src/packages/sensor/store/regist/regist.action.ts @@ -0,0 +1,38 @@ +import { Action } from '@ngrx/store'; + +import { RPCClientError } from '@loafer/ng-rpc/protocol'; + +import { Domain } from 'packages/domain/model'; +import { PageParams, Page } from 'app/commons/model'; +import { Sensor } from '../../model'; +import { SensorItem } from 'packages/sensor-item/model/SensorItem'; + +export enum ActionType { + Regist = '[Sensor.Regist] Regist', + RegistSuccess = '[Sensor.RegistSuccess] RegistSuccess', + RegistFailure = '[Sensor.RegistFailure] RegistFailure', +} + +export class Regist implements Action { + readonly type = ActionType.Regist; + + constructor(public payload: { sensor: Sensor, sensorItems: SensorItem[]}) {} +} + +export class RegistSuccess implements Action { + readonly type = ActionType.RegistSuccess; + + constructor(public payload: Sensor) {} +} + +export class RegistFailure implements Action { + readonly type = ActionType.RegistFailure; + + constructor(public payload: RPCClientError) {} +} + +export type Actions = + | Regist + | RegistSuccess + | RegistFailure +; diff --git a/src/packages/sensor/store/regist/regist.effect.ts b/src/packages/sensor/store/regist/regist.effect.ts new file mode 100644 index 0000000..2c5d039 --- /dev/null +++ b/src/packages/sensor/store/regist/regist.effect.ts @@ -0,0 +1,49 @@ +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +import { Effect, Actions, ofType } from '@ngrx/effects'; +import { Action } from '@ngrx/store'; + +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; + +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/exhaustMap'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/take'; + +import { RPCClientError } from '@loafer/ng-rpc/protocol'; + +import { Sensor } from '../../model'; +import { SensorService } from '../../service/sensor.service'; + +import { + Regist, + RegistSuccess, + RegistFailure, + ActionType, +} from './regist.action'; + +@Injectable() +export class Effects { + + constructor( + private actions$: Actions, + private service: SensorService, + private router: Router + ) { } + + @Effect() + regist$: Observable = this.actions$ + .ofType(ActionType.Regist) + .map((action: Regist) => action.payload) + .switchMap(payload => this.service.regist(payload.sensor, payload.sensorItems)) + .map(list => { + return new RegistSuccess(list); + }) + .catch((error: RPCClientError) => { + return of(new RegistFailure(error)); + }); + +} diff --git a/src/packages/sensor/store/regist/regist.reducer.ts b/src/packages/sensor/store/regist/regist.reducer.ts new file mode 100644 index 0000000..113965c --- /dev/null +++ b/src/packages/sensor/store/regist/regist.reducer.ts @@ -0,0 +1,45 @@ +import { + Actions, + ActionType, + } from './regist.action'; + + import { + State, + initialState, + } from './regist.state'; + + import { Sensor } from '../../model'; + + export function reducer(state = initialState, action: Actions): State { + switch (action.type) { + case ActionType.Regist: { + return { + ...state, + error: null, + pending: true, + }; + } + + case ActionType.RegistSuccess: { + return { + ...state, + error: null, + pending: false, + sensor: action.payload + }; + } + + case ActionType.RegistFailure: { + return { + ...state, + error: action.payload, + pending: false, + sensor: null, + }; + } + + default: { + return state; + } + } + } diff --git a/src/packages/sensor/store/regist/regist.state.ts b/src/packages/sensor/store/regist/regist.state.ts new file mode 100644 index 0000000..f2edd69 --- /dev/null +++ b/src/packages/sensor/store/regist/regist.state.ts @@ -0,0 +1,16 @@ +import { RPCClientError } from '@loafer/ng-rpc/protocol'; + +import { Page } from 'app/commons/model'; +import { Sensor } from '../../model'; + +export interface State { + error: RPCClientError | null; + pending: boolean; + sensor: Sensor | null; +} + +export const initialState: State = { + error: null, + pending: false, + sensor: null, +}; diff --git a/src/packages/sensor/store/regist/regist.ts b/src/packages/sensor/store/regist/regist.ts new file mode 100644 index 0000000..f6da3fb --- /dev/null +++ b/src/packages/sensor/store/regist/regist.ts @@ -0,0 +1,4 @@ +export * from './regist.action'; +export * from './regist.effect'; +export * from './regist.reducer'; +export * from './regist.state';