From fd369d3519a0e434c5e864c879b970835e050b17 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 1 Jun 2018 19:27:27 +0900 Subject: [PATCH] ing --- @overflow/alert/alert-store.module.ts | 19 ---- @overflow/alert/alert.module.ts | 5 - @overflow/alert/store/index.ts | 0 @overflow/core/ngrx/store/index.ts | 1 - @overflow/core/ngrx/store/selectors.ts | 16 ---- @overflow/infra/component/index.ts | 16 ++-- ...html => infra-host-summary.component.html} | 0 ...ent.ts => infra-host-summary.component.ts} | 6 +- ...omponent.html => infra-map.component.html} | 0 ...nt.spec.ts => infra-map.component.spec.ts} | 12 +-- ...ap.component.ts => infra-map.component.ts} | 92 ++++++------------- ...tml => infra-probe-summary.component.html} | 0 ...nt.ts => infra-probe-summary.component.ts} | 6 +- ...l => infra-service-summary.component.html} | 0 ....ts => infra-service-summary.component.ts} | 8 +- @overflow/infra/infra-store.module.ts | 19 ---- @overflow/infra/infra.module.ts | 2 - @overflow/infra/store/detail/detail.action.ts | 35 ------- .../infra/store/detail/detail.effect.spec.ts | 15 --- @overflow/infra/store/detail/detail.effect.ts | 49 ---------- .../infra/store/detail/detail.reducer.ts | 38 -------- @overflow/infra/store/detail/detail.state.ts | 16 ---- @overflow/infra/store/detail/index.ts | 4 - @overflow/infra/store/index.ts | 38 -------- @overflow/infra/store/list/index.ts | 4 - @overflow/infra/store/list/list.action.ts | 63 ------------- .../infra/store/list/list.effect.spec.ts | 15 --- @overflow/infra/store/list/list.effect.ts | 64 ------------- @overflow/infra/store/list/list.reducer.ts | 65 ------------- @overflow/infra/store/list/list.state.ts | 17 ---- @overflow/notification/store/index.ts | 2 - @overflow/probe/probe-store.module.ts | 24 ----- .../store/container/probe-detail/index.ts | 2 - .../probe-detail/probe-detail.reducer.ts | 31 ------- .../probe-detail/probe-detail.state.ts | 19 ---- .../probe/store/container/probe-list/index.ts | 2 - .../probe-list/probe-list.reducer.ts | 31 ------- .../container/probe-list/probe-list.state.ts | 21 ----- .../store/container/probe-selector/index.ts | 2 - .../probe-selector/probe-selector.reducer.ts | 31 ------- .../probe-selector/probe-selector.state.ts | 21 ----- @overflow/probe/store/entity/probe/index.ts | 2 - .../probe/store/entity/probe/probe.action.ts | 83 ----------------- .../probe/store/entity/probe/probe.effect.ts | 81 ---------------- @overflow/probe/store/index.ts | 47 ---------- .../sensor-item/sensor-item-store.module.ts | 19 ---- @overflow/sensor-item/sensor-item.module.ts | 2 - @overflow/sensor-item/store/index.ts | 29 ------ @overflow/sensor-item/store/key-list/index.ts | 4 - .../sensor-item/store/key-list/list.action.ts | 37 -------- .../store/key-list/list.effect.spec.ts | 15 --- .../sensor-item/store/key-list/list.effect.ts | 48 ---------- .../store/key-list/list.reducer.ts | 43 --------- .../sensor-item/store/key-list/list.state.ts | 15 --- .../sensor-list-container.component.ts | 6 +- .../sensor-setting-container.component.ts | 1 - @overflow/sensor/sensor-store.module.ts | 23 ----- @overflow/sensor/sensor.module.ts | 2 - .../store/container/sensor-list/index.ts | 2 - .../sensor-list/sensor-list.reducer.ts | 58 ------------ .../sensor-list/sensor-list.state.ts | 26 ------ @overflow/sensor/store/entity/sensor/index.ts | 2 - .../store/entity/sensor/sensor.action.ts | 85 ----------------- .../store/entity/sensor/sensor.effect.ts | 78 ---------------- @overflow/sensor/store/index.ts | 30 ------ .../component/detail/detail.component.ts | 33 +++---- .../target/component/list/list.component.ts | 11 ++- @overflow/target/store/index.ts | 30 ------ @overflow/target/store/modify/index.ts | 4 - .../target/store/modify/modify.action.ts | 34 ------- .../target/store/modify/modify.effect.spec.ts | 15 --- .../target/store/modify/modify.effect.ts | 44 --------- .../target/store/modify/modify.reducer.ts | 43 --------- @overflow/target/store/modify/modify.state.ts | 14 --- @overflow/target/target-store.module.ts | 18 ---- 75 files changed, 77 insertions(+), 1718 deletions(-) delete mode 100644 @overflow/alert/alert-store.module.ts delete mode 100644 @overflow/alert/store/index.ts delete mode 100644 @overflow/core/ngrx/store/index.ts delete mode 100644 @overflow/core/ngrx/store/selectors.ts rename @overflow/infra/component/{host-summary/host-summary.component.html => infra-host-summary.component.html} (100%) rename @overflow/infra/component/{host-summary/host-summary.component.ts => infra-host-summary.component.ts} (65%) rename @overflow/infra/component/{map/map.component.html => infra-map.component.html} (100%) rename @overflow/infra/component/{map/map.component.spec.ts => infra-map.component.spec.ts} (55%) rename @overflow/infra/component/{map/map.component.ts => infra-map.component.ts} (88%) rename @overflow/infra/component/{probe-summary/probe-summary.component.html => infra-probe-summary.component.html} (100%) rename @overflow/infra/component/{probe-summary/probe-summary.component.ts => infra-probe-summary.component.ts} (87%) rename @overflow/infra/component/{service-summary/service-summary.component.html => infra-service-summary.component.html} (100%) rename @overflow/infra/component/{service-summary/service-summary.component.ts => infra-service-summary.component.ts} (60%) delete mode 100644 @overflow/infra/infra-store.module.ts delete mode 100644 @overflow/infra/store/detail/detail.action.ts delete mode 100644 @overflow/infra/store/detail/detail.effect.spec.ts delete mode 100644 @overflow/infra/store/detail/detail.effect.ts delete mode 100644 @overflow/infra/store/detail/detail.reducer.ts delete mode 100644 @overflow/infra/store/detail/detail.state.ts delete mode 100644 @overflow/infra/store/detail/index.ts delete mode 100644 @overflow/infra/store/index.ts delete mode 100644 @overflow/infra/store/list/index.ts delete mode 100644 @overflow/infra/store/list/list.action.ts delete mode 100644 @overflow/infra/store/list/list.effect.spec.ts delete mode 100644 @overflow/infra/store/list/list.effect.ts delete mode 100644 @overflow/infra/store/list/list.reducer.ts delete mode 100644 @overflow/infra/store/list/list.state.ts delete mode 100644 @overflow/probe/probe-store.module.ts delete mode 100644 @overflow/probe/store/container/probe-detail/index.ts delete mode 100644 @overflow/probe/store/container/probe-detail/probe-detail.reducer.ts delete mode 100644 @overflow/probe/store/container/probe-detail/probe-detail.state.ts delete mode 100644 @overflow/probe/store/container/probe-list/index.ts delete mode 100644 @overflow/probe/store/container/probe-list/probe-list.reducer.ts delete mode 100644 @overflow/probe/store/container/probe-list/probe-list.state.ts delete mode 100644 @overflow/probe/store/container/probe-selector/index.ts delete mode 100644 @overflow/probe/store/container/probe-selector/probe-selector.reducer.ts delete mode 100644 @overflow/probe/store/container/probe-selector/probe-selector.state.ts delete mode 100644 @overflow/probe/store/entity/probe/index.ts delete mode 100644 @overflow/probe/store/entity/probe/probe.action.ts delete mode 100644 @overflow/probe/store/entity/probe/probe.effect.ts delete mode 100644 @overflow/probe/store/index.ts delete mode 100644 @overflow/sensor-item/sensor-item-store.module.ts delete mode 100644 @overflow/sensor-item/store/index.ts delete mode 100644 @overflow/sensor-item/store/key-list/index.ts delete mode 100644 @overflow/sensor-item/store/key-list/list.action.ts delete mode 100644 @overflow/sensor-item/store/key-list/list.effect.spec.ts delete mode 100644 @overflow/sensor-item/store/key-list/list.effect.ts delete mode 100644 @overflow/sensor-item/store/key-list/list.reducer.ts delete mode 100644 @overflow/sensor-item/store/key-list/list.state.ts delete mode 100644 @overflow/sensor/sensor-store.module.ts delete mode 100644 @overflow/sensor/store/container/sensor-list/index.ts delete mode 100644 @overflow/sensor/store/container/sensor-list/sensor-list.reducer.ts delete mode 100644 @overflow/sensor/store/container/sensor-list/sensor-list.state.ts delete mode 100644 @overflow/sensor/store/entity/sensor/index.ts delete mode 100644 @overflow/sensor/store/entity/sensor/sensor.action.ts delete mode 100644 @overflow/sensor/store/entity/sensor/sensor.effect.ts delete mode 100644 @overflow/sensor/store/index.ts delete mode 100644 @overflow/target/store/index.ts delete mode 100644 @overflow/target/store/modify/index.ts delete mode 100644 @overflow/target/store/modify/modify.action.ts delete mode 100644 @overflow/target/store/modify/modify.effect.spec.ts delete mode 100644 @overflow/target/store/modify/modify.effect.ts delete mode 100644 @overflow/target/store/modify/modify.reducer.ts delete mode 100644 @overflow/target/store/modify/modify.state.ts delete mode 100644 @overflow/target/target-store.module.ts diff --git a/@overflow/alert/alert-store.module.ts b/@overflow/alert/alert-store.module.ts deleted file mode 100644 index 9f698df..0000000 --- a/@overflow/alert/alert-store.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -// import { NgModule } from '@angular/core'; -// import { StoreModule } from '@ngrx/store'; - -// import { EffectsModule } from '@ngrx/effects'; - -// import { -// REDUCERS, -// EFFECTS, -// } from './store'; - -// import { MODULE } from './alert.constant'; - -// @NgModule({ -// imports: [ -// StoreModule.forFeature(MODULE.name, REDUCERS), -// EffectsModule.forFeature(EFFECTS), -// ], -// }) -// export class DiscoveryStoreModule { } diff --git a/@overflow/alert/alert.module.ts b/@overflow/alert/alert.module.ts index 8b7c9b9..f70fbb8 100644 --- a/@overflow/alert/alert.module.ts +++ b/@overflow/alert/alert.module.ts @@ -2,11 +2,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; - -// import { InputChipModule } from '@overflow/commons/component/input-chip/input-chip.module'; - -// import { DiscoveryStoreModule } from './discovery-store.module'; -// import { DiscoveryRPCModule } from './discovery-rpc.module'; import { AlertLoggerModule } from './alert-logger.module'; import { COMPONENTS } from './component'; diff --git a/@overflow/alert/store/index.ts b/@overflow/alert/store/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/@overflow/core/ngrx/store/index.ts b/@overflow/core/ngrx/store/index.ts deleted file mode 100644 index 8c9698f..0000000 --- a/@overflow/core/ngrx/store/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './selectors'; diff --git a/@overflow/core/ngrx/store/selectors.ts b/@overflow/core/ngrx/store/selectors.ts deleted file mode 100644 index 7f4e1f6..0000000 --- a/@overflow/core/ngrx/store/selectors.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - createSelector, - MemoizedSelector, -} from '@ngrx/store'; - -export class StateSelector { - public constructor(private _selector: MemoizedSelector) { - } - - public select = (propertyPath: string) => createSelector(this._selector, (state: State) => { - return propertyPath.split('.').reduce( - (prev, curr) => { - return prev ? prev[curr] : undefined; - }, state); - }) -} diff --git a/@overflow/infra/component/index.ts b/@overflow/infra/component/index.ts index 6d2d9cb..c3c1206 100644 --- a/@overflow/infra/component/index.ts +++ b/@overflow/infra/component/index.ts @@ -1,11 +1,11 @@ -import { MapComponent } from './map/map.component'; -// import { ProbeSummaryComponent } from './probe-summary/probe-summary.component'; -import { HostSummaryComponent } from './host-summary/host-summary.component'; -import { ServiceSummaryComponent } from './service-summary/service-summary.component'; +import { InfraMapComponent } from './infra-map.component'; +// import { InfraProbeSummaryComponent } from './infra-probe-summary.component'; +import { InfraHostSummaryComponent } from './infra-host-summary.component'; +import { InfraServiceSummaryComponent } from './infra-service-summary.component'; export const COMPONENTS = [ - MapComponent, - // ProbeSummaryComponent, - HostSummaryComponent, - ServiceSummaryComponent + InfraMapComponent, + // InfraProbeSummaryComponent, + InfraHostSummaryComponent, + InfraServiceSummaryComponent ]; diff --git a/@overflow/infra/component/host-summary/host-summary.component.html b/@overflow/infra/component/infra-host-summary.component.html similarity index 100% rename from @overflow/infra/component/host-summary/host-summary.component.html rename to @overflow/infra/component/infra-host-summary.component.html diff --git a/@overflow/infra/component/host-summary/host-summary.component.ts b/@overflow/infra/component/infra-host-summary.component.ts similarity index 65% rename from @overflow/infra/component/host-summary/host-summary.component.ts rename to @overflow/infra/component/infra-host-summary.component.ts index 33c59ee..e67b874 100644 --- a/@overflow/infra/component/host-summary/host-summary.component.ts +++ b/@overflow/infra/component/infra-host-summary.component.ts @@ -3,10 +3,10 @@ import { InfraHost } from '@overflow/commons-typescript/model/infra'; @Component({ - selector: 'of-host-summary', - templateUrl: './host-summary.component.html', + selector: 'of-infra-host-summary', + templateUrl: './infra-host-summary.component.html', }) -export class HostSummaryComponent implements OnInit, AfterContentInit, OnChanges { +export class InfraHostSummaryComponent implements OnInit, AfterContentInit, OnChanges { @Input() host: InfraHost; @Input() visible: boolean; diff --git a/@overflow/infra/component/map/map.component.html b/@overflow/infra/component/infra-map.component.html similarity index 100% rename from @overflow/infra/component/map/map.component.html rename to @overflow/infra/component/infra-map.component.html diff --git a/@overflow/infra/component/map/map.component.spec.ts b/@overflow/infra/component/infra-map.component.spec.ts similarity index 55% rename from @overflow/infra/component/map/map.component.spec.ts rename to @overflow/infra/component/infra-map.component.spec.ts index 62c3b6b..3c85763 100644 --- a/@overflow/infra/component/map/map.component.spec.ts +++ b/@overflow/infra/component/infra-map.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { MapComponent } from './map.component'; +import { InfraMapComponent } from './infra-map.component'; -describe('MapComponent', () => { - let component: MapComponent; - let fixture: ComponentFixture; +describe('InfraMapComponent', () => { + let component: InfraMapComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [MapComponent] + declarations: [InfraMapComponent] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(MapComponent); + fixture = TestBed.createComponent(InfraMapComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/@overflow/infra/component/map/map.component.ts b/@overflow/infra/component/infra-map.component.ts similarity index 88% rename from @overflow/infra/component/map/map.component.ts rename to @overflow/infra/component/infra-map.component.ts index 555696a..33ba6b6 100644 --- a/@overflow/infra/component/map/map.component.ts +++ b/@overflow/infra/component/infra-map.component.ts @@ -4,18 +4,17 @@ import { AfterContentInit, ViewChild } from '@angular/core'; -import { Router } from '@angular/router'; + +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; + import { TreeNode, MenuItem, ContextMenu } from 'primeng/primeng'; import { Store, select } from '@ngrx/store'; -import * as ListStore from '../../store/list'; -import { ListSelector } from '../../store'; import { Target } from '@overflow/commons-typescript/model/target'; import { Infra, InfraHost, InfraService } from '@overflow/commons-typescript/model/infra'; import { Domain, DomainMember } from '@overflow/commons-typescript/model/domain'; import { AuthSelector } from '@overflow/shared/auth/store'; -// import { sensorListSelector } from '@overflow/sensor/store'; - import { Sensor } from '@overflow/commons-typescript/model/sensor'; @@ -28,12 +27,15 @@ interface HostData { @Component({ selector: 'of-infra-map', - templateUrl: './map.component.html' + templateUrl: './infra-map.component.html' }) -export class MapComponent implements OnInit, AfterContentInit { +export class InfraMapComponent implements OnInit, AfterContentInit { + infras$: Observable; + pending$: Observable; + error$: Observable; + infraTree: TreeNode[] = []; - infras$ = this.listStore.pipe(select(ListSelector.select('page'))); // sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page'))); display = false; loading = false; @@ -60,55 +62,21 @@ export class MapComponent implements OnInit, AfterContentInit { sensorSettingDisplay = false; target: Target = null; - constructor(private router: Router, - private listStore: Store, - ) { } + constructor( + private store: Store, + private infraService: InfraService, + ) { + + } + ngOnInit() { + + this.initContextMenu(); + } ngAfterContentInit() { - this.listStore.select(AuthSelector.selectDomainMember).subscribe( - (domainMember: DomainMember) => { - - // const pageParams: PageParams = { - // pageNo: '0', - // countPerPage: '99999', - // sortCol: 'id', - // sortDirection: 'descending' - // }; - - // this.listStore.dispatch(new ListStore.ReadAllByDomain({ domain: domain, pageParams: pageParams })); - }, - (error) => { - console.log(error); - } - ); } - ngOnInit() { - // this.infras$.subscribe( - // (page: Page) => { - // if (page !== null) { - // this.totalList = page.content; - // this.infraTree = this.generateInfraHostData(); - // } - // }, - // (error: RPCClientError) => { - // console.log(error.response.message); - // }); - - // this.sensors$.subscribe( - // (page: Page) => { - // if (page !== null) { - // const sensorList = page.content; - // this.addTreeForSensor(sensorList); - // } - // }, - // (error: RPCClientError) => { - // console.log(error.response.message); - // } - // ); - this.initContextMenu(); - } initContextMenu() { this.contextMenuProbe = [ @@ -385,7 +353,7 @@ export class MapComponent implements OnInit, AfterContentInit { showDialog() { // this.display = true; - this.router.navigateByUrl('/discovery'); + // this.router.navigateByUrl('/discovery'); } // closeDialog() { @@ -414,15 +382,15 @@ export class MapComponent implements OnInit, AfterContentInit { } onNodeSelect(event) { - const nodeType = event.node.type; - this.selectedNode = event.node; - if (nodeType === 'probe') { - this.router.navigate(['probe', event.node.obj.id, 'info']); - } else if (nodeType === 'host' || nodeType === 'service') { - this.router.navigate(['target', event.node.obj.id, 'info']); - } else if (nodeType === 'sensor') { - this.router.navigate(['sensor', event.node.obj.id, 'info']); - } + // const nodeType = event.node.type; + // this.selectedNode = event.node; + // if (nodeType === 'probe') { + // this.router.navigate(['probe', event.node.obj.id, 'info']); + // } else if (nodeType === 'host' || nodeType === 'service') { + // this.router.navigate(['target', event.node.obj.id, 'info']); + // } else if (nodeType === 'sensor') { + // this.router.navigate(['sensor', event.node.obj.id, 'info']); + // } } viewInfo() { diff --git a/@overflow/infra/component/probe-summary/probe-summary.component.html b/@overflow/infra/component/infra-probe-summary.component.html similarity index 100% rename from @overflow/infra/component/probe-summary/probe-summary.component.html rename to @overflow/infra/component/infra-probe-summary.component.html diff --git a/@overflow/infra/component/probe-summary/probe-summary.component.ts b/@overflow/infra/component/infra-probe-summary.component.ts similarity index 87% rename from @overflow/infra/component/probe-summary/probe-summary.component.ts rename to @overflow/infra/component/infra-probe-summary.component.ts index b51b476..b68f667 100644 --- a/@overflow/infra/component/probe-summary/probe-summary.component.ts +++ b/@overflow/infra/component/infra-probe-summary.component.ts @@ -8,10 +8,10 @@ // @Component({ -// selector: 'of-probe-summary', -// templateUrl: './probe-summary.component.html', +// selector: 'of-infra-probe-summary', +// templateUrl: './infra-probe-summary.component.html', // }) -// export class ProbeSummaryComponent implements OnInit, AfterContentInit, OnChanges { +// export class InfraProbeSummaryComponent implements OnInit, AfterContentInit, OnChanges { // @Input() probe: Object; // @Input() visible: boolean; diff --git a/@overflow/infra/component/service-summary/service-summary.component.html b/@overflow/infra/component/infra-service-summary.component.html similarity index 100% rename from @overflow/infra/component/service-summary/service-summary.component.html rename to @overflow/infra/component/infra-service-summary.component.html diff --git a/@overflow/infra/component/service-summary/service-summary.component.ts b/@overflow/infra/component/infra-service-summary.component.ts similarity index 60% rename from @overflow/infra/component/service-summary/service-summary.component.ts rename to @overflow/infra/component/infra-service-summary.component.ts index e02954e..a5c8999 100644 --- a/@overflow/infra/component/service-summary/service-summary.component.ts +++ b/@overflow/infra/component/infra-service-summary.component.ts @@ -1,13 +1,13 @@ import { Component, OnInit, AfterContentInit, Input, OnChanges } from '@angular/core'; import { InfraHost } from '@overflow/commons-typescript/model/infra'; -import { InfraService } from '../../service/infra.service'; +import { InfraService } from '../service/infra.service'; @Component({ - selector: 'of-service-summary', - templateUrl: './service-summary.component.html', + selector: 'of-infra-service-summary', + templateUrl: './infra-service-summary.component.html', }) -export class ServiceSummaryComponent implements OnInit, AfterContentInit, OnChanges { +export class InfraServiceSummaryComponent implements OnInit, AfterContentInit, OnChanges { @Input() service: InfraService; @Input() visible: boolean; diff --git a/@overflow/infra/infra-store.module.ts b/@overflow/infra/infra-store.module.ts deleted file mode 100644 index efcb0bc..0000000 --- a/@overflow/infra/infra-store.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; -import { StoreModule } from '@ngrx/store'; - -import { EffectsModule } from '@ngrx/effects'; - -import { - REDUCERS, - EFFECTS, -} from './store'; - -import { MODULE } from './infra.constant'; - -@NgModule({ - imports: [ - StoreModule.forFeature(MODULE.name, REDUCERS), - EffectsModule.forFeature(EFFECTS), - ], -}) -export class InfraStoreModule { } diff --git a/@overflow/infra/infra.module.ts b/@overflow/infra/infra.module.ts index 4211cfc..1d3b048 100644 --- a/@overflow/infra/infra.module.ts +++ b/@overflow/infra/infra.module.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { InfraStoreModule } from './infra-store.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; import { FormsModule } from '@angular/forms'; @@ -13,7 +12,6 @@ import { UIModule } from '@overflow/shared/ui/ui.module'; @NgModule({ imports: [ CommonModule, - InfraStoreModule, FormsModule, UIModule, DiscoveryModule, diff --git a/@overflow/infra/store/detail/detail.action.ts b/@overflow/infra/store/detail/detail.action.ts deleted file mode 100644 index 91fbda0..0000000 --- a/@overflow/infra/store/detail/detail.action.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Action } from '@ngrx/store'; -import { RPCClientError } from '@loafer/ng-rpc'; -import { Infra } from '@overflow/commons-typescript/model/infra'; - -export enum ActionType { - Read = '[Infra.list] Read', - ReadSuccess = '[Infra.list] ReadSuccess', - ReadFailure = '[Infra.list] ReadFailure', -} - -export class Read implements Action { - readonly type = ActionType.Read; - - constructor(public payload: { id: string }) { } -} - -export class ReadSuccess implements Action { - readonly type = ActionType.ReadSuccess; - - constructor(public payload: Infra) { } -} - -export class ReadFailure implements Action { - readonly type = ActionType.ReadFailure; - - constructor(public payload: RPCClientError) { } -} - - - -export type Actions = - | Read - | ReadSuccess - | ReadFailure - ; diff --git a/@overflow/infra/store/detail/detail.effect.spec.ts b/@overflow/infra/store/detail/detail.effect.spec.ts deleted file mode 100644 index a77b6b1..0000000 --- a/@overflow/infra/store/detail/detail.effect.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { Effects } from './list.effect'; - -describe('list.Effects', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [Effects] - }); - }); - - it('should be created', inject([Effects], (effects: Effects) => { - expect(effects).toBeTruthy(); - })); -}); diff --git a/@overflow/infra/store/detail/detail.effect.ts b/@overflow/infra/store/detail/detail.effect.ts deleted file mode 100644 index 56517b5..0000000 --- a/@overflow/infra/store/detail/detail.effect.ts +++ /dev/null @@ -1,49 +0,0 @@ -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'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; - -import { - Read, - ReadSuccess, - ReadFailure, - ActionType, -} from './detail.action'; -import { InfraService } from '../../service/infra.service'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private infraService: InfraService, - private router: Router - ) { } - - @Effect() - read$: Observable = this.actions$ - .ofType(ActionType.Read) - .map((action: Read) => action.payload) - .switchMap(payload => this.infraService.read(payload.id)) - .map(infra => { - return new ReadSuccess(infra); - }) - .catch((error: RPCClientError) => { - return of(new ReadFailure(error)); - }); - -} diff --git a/@overflow/infra/store/detail/detail.reducer.ts b/@overflow/infra/store/detail/detail.reducer.ts deleted file mode 100644 index 5aa2ac9..0000000 --- a/@overflow/infra/store/detail/detail.reducer.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Actions, ActionType } from './detail.action'; -import { State, initialState } from './detail.state'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.Read: { - return { - ...state, - error: null, - isPending: true, - }; - } - - case ActionType.ReadSuccess: { - return { - ...state, - error: null, - isPending: false, - infra: action.payload - }; - } - - case ActionType.ReadFailure: { - return { - ...state, - error: action.payload, - isPending: false, - infra: null - }; - } - - default: { - return state; - } - } -} diff --git a/@overflow/infra/store/detail/detail.state.ts b/@overflow/infra/store/detail/detail.state.ts deleted file mode 100644 index 472e948..0000000 --- a/@overflow/infra/store/detail/detail.state.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; - -export interface State { - error: RPCClientError | null; - isPending: boolean; - infra: Infra | null; -} - -export const initialState: State = { - error: null, - isPending: false, - infra: null, -}; - diff --git a/@overflow/infra/store/detail/index.ts b/@overflow/infra/store/detail/index.ts deleted file mode 100644 index 23ae8ab..0000000 --- a/@overflow/infra/store/detail/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './detail.action'; -export * from './detail.effect'; -export * from './detail.reducer'; -export * from './detail.state'; diff --git a/@overflow/infra/store/index.ts b/@overflow/infra/store/index.ts deleted file mode 100644 index 0a1e7ea..0000000 --- a/@overflow/infra/store/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - createSelector, - createFeatureSelector, - ActionReducerMap, -} from '@ngrx/store'; - -import { MODULE } from '../infra.constant'; - -import * as ListStore from './list'; -import * as DetailStore from './detail'; -import { StateSelector } from '@overflow/core/ngrx/store'; - -export interface State { - list: ListStore.State; - sensor: DetailStore.State; -} - -export const REDUCERS = { - list: ListStore.reducer, - sensor: DetailStore.reducer -}; - -export const EFFECTS = [ - ListStore.Effects, - DetailStore.Effects -]; - -export const selectInfraState = createFeatureSelector(MODULE.name); - -export const ListSelector = new StateSelector(createSelector( - selectInfraState, - (state: State) => state.list -)); - -export const DetailSelector = new StateSelector(createSelector( - selectInfraState, - (state: State) => state.sensor -)); diff --git a/@overflow/infra/store/list/index.ts b/@overflow/infra/store/list/index.ts deleted file mode 100644 index 7fd86e0..0000000 --- a/@overflow/infra/store/list/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './list.action'; -export * from './list.effect'; -export * from './list.reducer'; -export * from './list.state'; diff --git a/@overflow/infra/store/list/list.action.ts b/@overflow/infra/store/list/list.action.ts deleted file mode 100644 index a7bd8a8..0000000 --- a/@overflow/infra/store/list/list.action.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc'; - -// import { PageParams, Page } from 'app/commons/model'; -import { Domain } from '@overflow/commons-typescript/model/domain'; -import { Probe } from '@overflow/commons-typescript/model/probe'; - -export enum ActionType { - ReadAllByDomain = '[Infra.list] ReadAllByDomain', - ReadAllByDomainSuccess = '[Infra.list] ReadAllByDomainSuccess', - ReadAllByDomainFailure = '[Infra.list] ReadAllByDomainFailure', - - ReadAllByProbe = '[Infra.list] ReadAllByProbe', - ReadAllByProbeSuccess = '[Infra.list] ReadAllByProbeSuccess', - ReadAllByProbeFailure = '[Infra.list] ReadAllByProbeFailure', -} - -export class ReadAllByDomain implements Action { - readonly type = ActionType.ReadAllByDomain; - - // constructor(public payload: { domain: Domain, pageParams: PageParams }) { } -} - -export class ReadAllByDomainSuccess implements Action { - readonly type = ActionType.ReadAllByDomainSuccess; - - // constructor(public payload: Page) { } -} - -export class ReadAllByDomainFailure implements Action { - readonly type = ActionType.ReadAllByDomainFailure; - - constructor(public payload: RPCClientError) { } -} - -export class ReadAllByProbe implements Action { - readonly type = ActionType.ReadAllByProbe; - - // constructor(public payload: { probe: Probe, pageParams: PageParams }) { } -} - -export class ReadAllByProbeSuccess implements Action { - readonly type = ActionType.ReadAllByProbeSuccess; - - // constructor(public payload: Page) { } -} - -export class ReadAllByProbeFailure implements Action { - readonly type = ActionType.ReadAllByProbeFailure; - - constructor(public payload: RPCClientError) { } -} - - -export type Actions = - | ReadAllByDomain - | ReadAllByDomainSuccess - | ReadAllByDomainFailure - | ReadAllByProbe - | ReadAllByProbeSuccess - | ReadAllByProbeFailure - ; diff --git a/@overflow/infra/store/list/list.effect.spec.ts b/@overflow/infra/store/list/list.effect.spec.ts deleted file mode 100644 index a77b6b1..0000000 --- a/@overflow/infra/store/list/list.effect.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { Effects } from './list.effect'; - -describe('list.Effects', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [Effects] - }); - }); - - it('should be created', inject([Effects], (effects: Effects) => { - expect(effects).toBeTruthy(); - })); -}); diff --git a/@overflow/infra/store/list/list.effect.ts b/@overflow/infra/store/list/list.effect.ts deleted file mode 100644 index 52cec6c..0000000 --- a/@overflow/infra/store/list/list.effect.ts +++ /dev/null @@ -1,64 +0,0 @@ -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'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; -import { InfraService } from '../../service/infra.service'; - -import { - ReadAllByDomain, - ReadAllByDomainSuccess, - ReadAllByDomainFailure, - ReadAllByProbe, - ReadAllByProbeSuccess, - ReadAllByProbeFailure, - ActionType, -} from './list.action'; -import { Domain } from '@overflow/commons-typescript/model/domain'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private infraService: InfraService, - private router: Router - ) { } - - // @Effect() - // readAllByDomain$: Observable = this.actions$ - // .ofType(ActionType.ReadAllByDomain) - // .map((action: ReadAllByDomain) => action.payload) - // .switchMap(payload => this.infraService.readAllByDomain(payload.domain, payload.pageParams)) - // .map(page => { - // return new ReadAllByDomainSuccess(page); - // }) - // .catch((error: RPCClientError) => { - // return of(new ReadAllByDomainFailure(error)); - // }); - - // @Effect() - // readAllByProbe$: Observable = this.actions$ - // .ofType(ActionType.ReadAllByProbe) - // .map((action: ReadAllByProbe) => action.payload) - // .switchMap(payload => this.infraService.readAllByProbe(payload.probe, payload.pageParams)) - // .map(page => { - // return new ReadAllByProbeSuccess(page); - // }) - // .catch((error: RPCClientError) => { - // return of(new ReadAllByProbeFailure(error)); - // }); -} diff --git a/@overflow/infra/store/list/list.reducer.ts b/@overflow/infra/store/list/list.reducer.ts deleted file mode 100644 index ff4cc22..0000000 --- a/@overflow/infra/store/list/list.reducer.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Actions, ActionType } from './list.action'; - -import { State, initialState } from './list.state'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDomain: { - return { - ...state, - error: null, - isPending: true, - }; - } - - case ActionType.ReadAllByDomainSuccess: { - return { - ...state, - error: null, - isPending: false, - // page: action.payload - }; - } - - case ActionType.ReadAllByDomainFailure: { - return { - ...state, - error: action.payload, - isPending: false, - // page: null - }; - } - - case ActionType.ReadAllByProbe: { - return { - ...state, - error: null, - isPending: true, - }; - } - - case ActionType.ReadAllByProbeSuccess: { - return { - ...state, - error: null, - isPending: false, - // page: action.payload - }; - } - - case ActionType.ReadAllByProbeFailure: { - return { - ...state, - error: action.payload, - isPending: false, - // page: null - }; - } - - default: { - return state; - } - } -} diff --git a/@overflow/infra/store/list/list.state.ts b/@overflow/infra/store/list/list.state.ts deleted file mode 100644 index 6d5b14a..0000000 --- a/@overflow/infra/store/list/list.state.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; - -import { Infra } from '@overflow/commons-typescript/model/infra'; -// import { Page } from 'app/commons/model'; - -export interface State { - error: RPCClientError | null; - isPending: boolean; - // page: Page | null; -} - -export const initialState: State = { - error: null, - isPending: false, - // page: null, -}; - diff --git a/@overflow/notification/store/index.ts b/@overflow/notification/store/index.ts index d06a1ef..b8d6a61 100644 --- a/@overflow/notification/store/index.ts +++ b/@overflow/notification/store/index.ts @@ -3,8 +3,6 @@ import { createFeatureSelector, } from '@ngrx/store'; -import { StateSelector } from '@overflow/core/ngrx/store'; - import { MODULE } from '../notification.constant'; import * as NotificationEntityStore from './entity/notification'; diff --git a/@overflow/probe/probe-store.module.ts b/@overflow/probe/probe-store.module.ts deleted file mode 100644 index 50f957b..0000000 --- a/@overflow/probe/probe-store.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -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, - EFFECTS, -} from './store'; - -import { MODULE } from './probe.constant'; - -@NgModule({ - imports: [ - StoreModule.forFeature(MODULE.name, REDUCERS), - EffectsModule.forFeature(EFFECTS), - ], -}) -export class ProbeStoreModule { } diff --git a/@overflow/probe/store/container/probe-detail/index.ts b/@overflow/probe/store/container/probe-detail/index.ts deleted file mode 100644 index f603af8..0000000 --- a/@overflow/probe/store/container/probe-detail/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './probe-detail.reducer'; -export * from './probe-detail.state'; diff --git a/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts b/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts deleted file mode 100644 index 18e4519..0000000 --- a/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ActionType, Actions } from '../../entity/probe'; -import { - State, - initialState, - probeListContainerAdapter -} from './probe-detail.state'; - -import { Probe } from '@overflow/commons-typescript/model/probe'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.Read: { - return { - ...state, - pending: true, - }; - } - - case ActionType.ReadSuccess: { - return probeListContainerAdapter.setOne(action.payload, {...state, pending: false}); - } - - case ActionType.ReadFailure: { - return probeListContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - default: { - return state; - } - } -} diff --git a/@overflow/probe/store/container/probe-detail/probe-detail.state.ts b/@overflow/probe/store/container/probe-detail/probe-detail.state.ts deleted file mode 100644 index 5f8896a..0000000 --- a/@overflow/probe/store/container/probe-detail/probe-detail.state.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { Selector, createSelector } from '@ngrx/store'; -import { createEntityAdapter, EntityState } from '@loafer/ng-entity'; - -export const probeListContainerAdapter = createEntityAdapter(); -export interface State extends EntityState { - pending: boolean; -} -export const initialState: State = probeListContainerAdapter.getInitialState({ - pending: false, -}); - -export function getSelectors(selector: Selector) { - return { - ...probeListContainerAdapter.getSelectors(selector), - selectPending: createSelector(selector, (state: State) => state.pending), - }; -} diff --git a/@overflow/probe/store/container/probe-list/index.ts b/@overflow/probe/store/container/probe-list/index.ts deleted file mode 100644 index f022bff..0000000 --- a/@overflow/probe/store/container/probe-list/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './probe-list.reducer'; -export * from './probe-list.state'; diff --git a/@overflow/probe/store/container/probe-list/probe-list.reducer.ts b/@overflow/probe/store/container/probe-list/probe-list.reducer.ts deleted file mode 100644 index ced893e..0000000 --- a/@overflow/probe/store/container/probe-list/probe-list.reducer.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ActionType, Actions } from '../../entity/probe'; -import { - State, - initialState, - probeListContainerAdapter -} from './probe-list.state'; - -import { Probe } from '@overflow/commons-typescript/model/probe'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDomainID: { - return { - ...state, - pending: true, - }; - } - - case ActionType.ReadAllByDomainIDSuccess: { - return probeListContainerAdapter.setAll(action.payload, {...state, pending: false}); - } - - case ActionType.ReadAllByDomainIDFailure: { - return probeListContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - default: { - return state; - } - } -} diff --git a/@overflow/probe/store/container/probe-list/probe-list.state.ts b/@overflow/probe/store/container/probe-list/probe-list.state.ts deleted file mode 100644 index d3de23c..0000000 --- a/@overflow/probe/store/container/probe-list/probe-list.state.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { Selector, createSelector } from '@ngrx/store'; -import { createEntityAdapter, EntityState } from '@loafer/ng-entity'; - -export const probeListContainerAdapter = createEntityAdapter(); -export interface State extends EntityState { - pending: boolean; -} -export const initialState: State = probeListContainerAdapter.getInitialState({ - pending: false, -}); - -export function getSelectors(selector: Selector) { - return { - ...probeListContainerAdapter.getSelectors(selector), - selectPending: createSelector(selector, (state: State) => state.pending), - }; -} - - diff --git a/@overflow/probe/store/container/probe-selector/index.ts b/@overflow/probe/store/container/probe-selector/index.ts deleted file mode 100644 index a6667d6..0000000 --- a/@overflow/probe/store/container/probe-selector/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './probe-selector.reducer'; -export * from './probe-selector.state'; diff --git a/@overflow/probe/store/container/probe-selector/probe-selector.reducer.ts b/@overflow/probe/store/container/probe-selector/probe-selector.reducer.ts deleted file mode 100644 index 462438b..0000000 --- a/@overflow/probe/store/container/probe-selector/probe-selector.reducer.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ActionType, Actions } from '../../entity/probe'; -import { - State, - initialState, - probeSelectorContainerAdapter -} from './probe-selector.state'; - -import { Probe } from '@overflow/commons-typescript/model/probe'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDomainID: { - return { - ...state, - pending: true, - }; - } - - case ActionType.ReadAllByDomainIDSuccess: { - return probeSelectorContainerAdapter.setAll(action.payload, {...state, pending: false}); - } - - case ActionType.ReadAllByDomainIDFailure: { - return probeSelectorContainerAdapter.setError(action.payload, {...state, pending: false}); - } - - default: { - return state; - } - } -} diff --git a/@overflow/probe/store/container/probe-selector/probe-selector.state.ts b/@overflow/probe/store/container/probe-selector/probe-selector.state.ts deleted file mode 100644 index 27efd23..0000000 --- a/@overflow/probe/store/container/probe-selector/probe-selector.state.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { Selector, createSelector } from '@ngrx/store'; -import { createEntityAdapter, EntityState } from '@loafer/ng-entity'; - -export const probeSelectorContainerAdapter = createEntityAdapter(); -export interface State extends EntityState { - pending: boolean; -} -export const initialState: State = probeSelectorContainerAdapter.getInitialState({ - pending: false, -}); - -export function getSelectors(selector: Selector) { - return { - ...probeSelectorContainerAdapter.getSelectors(selector), - selectPending: createSelector(selector, (state: State) => state.pending), - }; -} - - diff --git a/@overflow/probe/store/entity/probe/index.ts b/@overflow/probe/store/entity/probe/index.ts deleted file mode 100644 index 6d98072..0000000 --- a/@overflow/probe/store/entity/probe/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './probe.action'; -export * from './probe.effect'; diff --git a/@overflow/probe/store/entity/probe/probe.action.ts b/@overflow/probe/store/entity/probe/probe.action.ts deleted file mode 100644 index 0bb31d7..0000000 --- a/@overflow/probe/store/entity/probe/probe.action.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { Action } from '@ngrx/store'; -import { RPCClientError } from '@loafer/ng-rpc'; -import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; - -export enum ActionType { - ReadAllByDomainID = '[probe.list] ReadAllByDomainID', - ReadAllByDomainIDSuccess = '[probe.list] ReadAllByDomainIDSuccess', - ReadAllByDomainIDFailure = '[probe.list] ReadAllByDomainIDFailure', - - Read = '[probe.detail] Read', - ReadSuccess = '[probe.detail] ReadSuccess', - ReadFailure = '[probe.detail] ReadFailure', - - Modify = '[probe.detail] Modify', - ModifySuccess = '[probe.detail] ModifySuccess', - ModifyFailure = '[probe.detail] ModifyFailure', -} - -export class ReadAllByDomainID implements Action { - readonly type = ActionType.ReadAllByDomainID; - - constructor(public payload: number) {} -} - -export class ReadAllByDomainIDSuccess implements Action { - readonly type = ActionType.ReadAllByDomainIDSuccess; - - constructor(public payload: ProbeHost[]) {} -} - -export class ReadAllByDomainIDFailure implements Action { - readonly type = ActionType.ReadAllByDomainIDFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Read implements Action { - readonly type = ActionType.Read; - - constructor(public payload: number) {} -} - -export class ReadSuccess implements Action { - readonly type = ActionType.ReadSuccess; - - constructor(public payload: ProbeHost) {} -} - -export class ReadFailure implements Action { - readonly type = ActionType.ReadFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Modify implements Action { - readonly type = ActionType.Modify; - - constructor(public payload: Probe) {} -} - -export class ModifySuccess implements Action { - readonly type = ActionType.ModifySuccess; - - constructor(public payload: ProbeHost) {} -} - -export class ModifyFailure implements Action { - readonly type = ActionType.ModifyFailure; - - constructor(public payload: RPCClientError) {} -} - -export type Actions = - | ReadAllByDomainID - | ReadAllByDomainIDSuccess - | ReadAllByDomainIDFailure - | Read - | ReadSuccess - | ReadFailure - | Modify - | ModifySuccess - | ModifyFailure -; diff --git a/@overflow/probe/store/entity/probe/probe.effect.ts b/@overflow/probe/store/entity/probe/probe.effect.ts deleted file mode 100644 index b912fe7..0000000 --- a/@overflow/probe/store/entity/probe/probe.effect.ts +++ /dev/null @@ -1,81 +0,0 @@ -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/switchMap'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/take'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { Domain } from '@overflow/commons-typescript/model/domain'; -import { Probe } from '@overflow/commons-typescript/model/probe'; - -import { - ReadAllByDomainID, - ReadAllByDomainIDFailure, - ReadAllByDomainIDSuccess, - Read, - ReadSuccess, - ReadFailure, - Modify, - ModifySuccess, - ModifyFailure, - ActionType -} from './probe.action'; -import { ProbeHostService } from '../../../service/probe-host.service'; -import { ProbeService } from '../../../service/probe.service'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private probeHostService: ProbeHostService, - private probeService: ProbeService, - private router: Router - ) { } - - @Effect() - ReadAllByDomainID$: Observable = this.actions$ - .ofType(ActionType.ReadAllByDomainID) - .map((action: ReadAllByDomainID) => action.payload) - .switchMap(payload => this.probeHostService.readAllByDomainID(payload)) - .map(probeHosts => { - return new ReadAllByDomainIDSuccess(probeHosts); - }) - .catch((error: RPCClientError) => { - return of(new ReadAllByDomainIDFailure(error)); - }); - - @Effect() - Read$: Observable = this.actions$ - .ofType(ActionType.Read) - .map((action: Read) => action.payload) - .switchMap(payload => this.probeHostService.read(payload)) - .map(probeHost => { - return new ReadSuccess(probeHost); - }) - .catch((error: RPCClientError) => { - return of(new ReadFailure(error)); - }); - - @Effect() - Modify$: Observable = this.actions$ - .ofType(ActionType.Modify) - .map((action: Modify) => action.payload) - .switchMap(payload => this.probeService.modify(payload)) - .map(probe => { - return new ModifySuccess(probe); - }) - .catch((error: RPCClientError) => { - return of(new ModifyFailure(error)); - }); -} diff --git a/@overflow/probe/store/index.ts b/@overflow/probe/store/index.ts deleted file mode 100644 index ba13e76..0000000 --- a/@overflow/probe/store/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - createSelector, - createFeatureSelector, - ActionReducerMap, -} from '@ngrx/store'; - -import { StateSelector } from '@overflow/core/ngrx/store'; - -import { MODULE } from '../probe.constant'; - -import * as ProbeEntityStore from './entity/probe'; -import * as ProbeListContainerStore from './container/probe-list'; -import * as ProbeDetailContainerStore from './container/probe-detail'; -import * as ProbeSelectorContainerStore from './container/probe-selector'; - -export interface State { - probe_list_container: ProbeListContainerStore.State; - probe_detail_container: ProbeDetailContainerStore.State; - probe_selector_container: ProbeSelectorContainerStore.State; -} - -export const REDUCERS = { - probe_list_container: ProbeListContainerStore.reducer, - probe_detail_container: ProbeDetailContainerStore.reducer, - probe_selector_container: ProbeSelectorContainerStore.reducer -}; - -export const EFFECTS = [ - ProbeEntityStore.Effects, -]; - -export const selectState = createFeatureSelector(MODULE.name); - -export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector( - selectState, - (state: State) => state.probe_list_container -)); - -export const ProbeDetailContainerSelector = ProbeDetailContainerStore.getSelectors(createSelector( - selectState, - (state: State) => state.probe_detail_container -)); - -export const ProbeSelectorContainerSelector = ProbeSelectorContainerStore.getSelectors(createSelector( - selectState, - (state: State) => state.probe_selector_container -)); diff --git a/@overflow/sensor-item/sensor-item-store.module.ts b/@overflow/sensor-item/sensor-item-store.module.ts deleted file mode 100644 index 14749a1..0000000 --- a/@overflow/sensor-item/sensor-item-store.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; -import { StoreModule } from '@ngrx/store'; - -import { EffectsModule } from '@ngrx/effects'; - -import { - REDUCERS, - EFFECTS, -} from './store'; - -import { MODULE } from './sensor-item.constant'; - -@NgModule({ - imports: [ - StoreModule.forFeature(MODULE.name, REDUCERS), - EffectsModule.forFeature(EFFECTS), - ], -}) -export class SensorItemStoreModule { } diff --git a/@overflow/sensor-item/sensor-item.module.ts b/@overflow/sensor-item/sensor-item.module.ts index d7eb985..26b2dc6 100644 --- a/@overflow/sensor-item/sensor-item.module.ts +++ b/@overflow/sensor-item/sensor-item.module.ts @@ -4,14 +4,12 @@ import { CommonModule } from '@angular/common'; import { UIModule } from '@overflow/shared/ui/ui.module'; import { COMPONENTS } from './component'; -import { SensorItemStoreModule } from './sensor-item-store.module'; import { SERVICES } from './service'; @NgModule({ imports: [ CommonModule, UIModule, - SensorItemStoreModule, ], declarations: [ COMPONENTS, diff --git a/@overflow/sensor-item/store/index.ts b/@overflow/sensor-item/store/index.ts deleted file mode 100644 index f4356b6..0000000 --- a/@overflow/sensor-item/store/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - createSelector, - createFeatureSelector, -} from '@ngrx/store'; - -import { StateSelector } from '@overflow/core/ngrx/store'; - - -import * as ListStore from './key-list'; -import { MODULE } from '../sensor-item.constant'; - -export interface State { - list: ListStore.State; -} - -export const REDUCERS = { - list: ListStore.reducer, -}; - -export const EFFECTS = [ - ListStore.Effects, -]; - -export const selectState = createFeatureSelector(MODULE.name); - -export const ReadSensorItemKeySelector = new StateSelector(createSelector( - selectState, - (state: State) => state.list -)); diff --git a/@overflow/sensor-item/store/key-list/index.ts b/@overflow/sensor-item/store/key-list/index.ts deleted file mode 100644 index 7fd86e0..0000000 --- a/@overflow/sensor-item/store/key-list/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './list.action'; -export * from './list.effect'; -export * from './list.reducer'; -export * from './list.state'; diff --git a/@overflow/sensor-item/store/key-list/list.action.ts b/@overflow/sensor-item/store/key-list/list.action.ts deleted file mode 100644 index 7f61b1d..0000000 --- a/@overflow/sensor-item/store/key-list/list.action.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta'; -import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta'; - - -export enum ActionType { - ReadAllByDisplayItem = '[meta.sensor-display-key-list] ReadAllByDisplayItem', - ReadAllByDisplayItemSuccess = '[meta.sensor-display-key-list] ReadAllByDisplayItemSuccess', - ReadAllByDisplayItemFailure = '[meta.sensor-display-key-list] ReadAllByDisplayItemFailure', -} - -export class ReadAllByDisplayItem implements Action { - readonly type = ActionType.ReadAllByDisplayItem; - - constructor(public payload: MetaSensorDisplayItem) {} -} - -export class ReadAllByDisplayItemSuccess implements Action { - readonly type = ActionType.ReadAllByDisplayItemSuccess; - - constructor(public payload: MetaSensorItemKey[]) {} -} - -export class ReadAllByDisplayItemFailure implements Action { - readonly type = ActionType.ReadAllByDisplayItemFailure; - - constructor(public payload: RPCClientError) {} -} - -export type Actions = - | ReadAllByDisplayItem - | ReadAllByDisplayItemSuccess - | ReadAllByDisplayItemFailure - -; diff --git a/@overflow/sensor-item/store/key-list/list.effect.spec.ts b/@overflow/sensor-item/store/key-list/list.effect.spec.ts deleted file mode 100644 index d8f6227..0000000 --- a/@overflow/sensor-item/store/key-list/list.effect.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { Effects } from './list.effect'; - -describe('List.Effects', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [Effects] - }); - }); - - it('should be created', inject([Effects], (effects: Effects) => { - expect(effects).toBeTruthy(); - })); -}); diff --git a/@overflow/sensor-item/store/key-list/list.effect.ts b/@overflow/sensor-item/store/key-list/list.effect.ts deleted file mode 100644 index e168d12..0000000 --- a/@overflow/sensor-item/store/key-list/list.effect.ts +++ /dev/null @@ -1,48 +0,0 @@ -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/switchMap'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/take'; - -import { RPCClientError } from '@loafer/ng-rpc'; - -import { - ReadAllByDisplayItem, - ReadAllByDisplayItemSuccess, - ReadAllByDisplayItemFailure, - ActionType, -} from './list.action'; -import { SensorItemDependencyService } from '../../service/sensor-item-dependency.service'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private service: SensorItemDependencyService, - private router: Router - ) { } - - @Effect() - readAllByDisplayItem$: Observable = this.actions$ - .ofType(ActionType.ReadAllByDisplayItem) - .map((action: ReadAllByDisplayItem) => action.payload) - .switchMap(payload => this.service.readAllByDisplayItem(payload)) - .map(list => { - return new ReadAllByDisplayItemSuccess(list); - }) - .catch((error: RPCClientError) => { - return of(new ReadAllByDisplayItemFailure(error)); - }); - -} diff --git a/@overflow/sensor-item/store/key-list/list.reducer.ts b/@overflow/sensor-item/store/key-list/list.reducer.ts deleted file mode 100644 index 769743b..0000000 --- a/@overflow/sensor-item/store/key-list/list.reducer.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { - Actions, - ActionType, -} from './list.action'; - -import { - State, - initialState, -} from './list.state'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDisplayItem: { - return { - ...state, - error: null, - pending: true, - }; - } - - case ActionType.ReadAllByDisplayItemSuccess: { - return { - ...state, - error: null, - pending: false, - list: action.payload - }; - } - - case ActionType.ReadAllByDisplayItemFailure: { - return { - ...state, - error: action.payload, - pending: false, - list: null, - }; - } - - default: { - return state; - } - } -} diff --git a/@overflow/sensor-item/store/key-list/list.state.ts b/@overflow/sensor-item/store/key-list/list.state.ts deleted file mode 100644 index c738a67..0000000 --- a/@overflow/sensor-item/store/key-list/list.state.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; -import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta'; - - -export interface State { - error: RPCClientError | null; - pending: boolean; - list: MetaSensorItemKey[] | null; -} - -export const initialState: State = { - error: null, - pending: false, - list: null, -}; diff --git a/@overflow/sensor/container/sensor-list-container.component.ts b/@overflow/sensor/container/sensor-list-container.component.ts index 524ce23..f81220a 100644 --- a/@overflow/sensor/container/sensor-list-container.component.ts +++ b/@overflow/sensor/container/sensor-list-container.component.ts @@ -2,8 +2,6 @@ import { Component, EventEmitter, Output, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Store, select } from '@ngrx/store'; import { Sensor } from '@overflow/commons-typescript/model/sensor'; -import * as SensorEntityStore from '../store/entity/sensor'; -import { SensorListContainerSelector } from '../store'; import { AuthSelector } from '@overflow/shared/auth/store'; import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams'; import { Page } from '@overflow/commons-typescript/model/commons/Page'; @@ -27,7 +25,7 @@ export class SensorListContainerComponent implements OnInit { } ngOnInit() { - this.page$ = this.store.pipe(select(SensorListContainerSelector.selectPage)); + // this.page$ = this.store.pipe(select(SensorListContainerSelector.selectPage)); // this.page$ = this.store.pipe(select(SensorListContainerSelector.selectPage)); this.getSensors(); @@ -42,7 +40,7 @@ export class SensorListContainerComponent implements OnInit { sortCol: 'id', sortDirection: 'descending', }; - this.store.dispatch(new SensorEntityStore.ReadAllByDomainID({ domainID: domainMember.domain.id, pageParams })); + // this.store.dispatch(new SensorEntityStore.ReadAllByDomainID({ domainID: domainMember.domain.id, pageParams })); } ); } diff --git a/@overflow/sensor/container/sensor-setting-container.component.ts b/@overflow/sensor/container/sensor-setting-container.component.ts index 126eed5..5277b0d 100644 --- a/@overflow/sensor/container/sensor-setting-container.component.ts +++ b/@overflow/sensor/container/sensor-setting-container.component.ts @@ -2,7 +2,6 @@ import { Component, EventEmitter, Output, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Store, select } from '@ngrx/store'; import { Sensor } from '@overflow/commons-typescript/model/sensor'; -import * as SensorEntityStore from '../store/entity/sensor'; @Component({ selector: 'of-sensor-setting-container', diff --git a/@overflow/sensor/sensor-store.module.ts b/@overflow/sensor/sensor-store.module.ts deleted file mode 100644 index 939e5ac..0000000 --- a/@overflow/sensor/sensor-store.module.ts +++ /dev/null @@ -1,23 +0,0 @@ -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 { - REDUCERS, - EFFECTS, -} from './store'; - -import { MODULE } from './sensor.constant'; - -@NgModule({ - imports: [ - StoreModule.forFeature(MODULE.name, REDUCERS), - EffectsModule.forFeature(EFFECTS), - ], -}) -export class SensorStoreModule { } diff --git a/@overflow/sensor/sensor.module.ts b/@overflow/sensor/sensor.module.ts index dc24d4f..0dde472 100644 --- a/@overflow/sensor/sensor.module.ts +++ b/@overflow/sensor/sensor.module.ts @@ -6,7 +6,6 @@ import { UIModule } from '@overflow/shared/ui/ui.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; -import { SensorStoreModule } from './sensor-store.module'; import { SensorItemModule } from '../sensor-item/sensor-item.module'; import { CONTAINER_COMPONENTS } from './container'; // import { MetaCrawlerModule } from '../meta/crawler/crawler.module'; @@ -18,7 +17,6 @@ import { CONTAINER_COMPONENTS } from './container'; CommonModule, FormsModule, UIModule, - SensorStoreModule, SensorItemModule, ], declarations: [ diff --git a/@overflow/sensor/store/container/sensor-list/index.ts b/@overflow/sensor/store/container/sensor-list/index.ts deleted file mode 100644 index 835388c..0000000 --- a/@overflow/sensor/store/container/sensor-list/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './sensor-list.reducer'; -export * from './sensor-list.state'; diff --git a/@overflow/sensor/store/container/sensor-list/sensor-list.reducer.ts b/@overflow/sensor/store/container/sensor-list/sensor-list.reducer.ts deleted file mode 100644 index 100f3c7..0000000 --- a/@overflow/sensor/store/container/sensor-list/sensor-list.reducer.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ActionType, Actions } from '../../entity/sensor'; -import { - State, - initialState, - sensorListContainerAdapter, -} from './sensor-list.state'; - -export function reducer(state = initialState, action: Actions): State { - switch (action.type) { - case ActionType.ReadAllByDomainID: { - return { - ...state, - pending: true, - }; - } - - case ActionType.ReadAllByDomainIDSuccess: { - return sensorListContainerAdapter.setAll(action.payload.content, { ...state, page: action.payload, pending: false }); - } - - case ActionType.ReadAllByDomainIDFailure: { - return sensorListContainerAdapter.setError(action.payload, { ...state, page: null, pending: false }); - } - - case ActionType.Read: { - return { - ...state, - error: null, - }; - } - - case ActionType.ReadSuccess: { - return sensorListContainerAdapter.setOne(action.payload, { ...state, page: null, pending: false }); - } - - case ActionType.ReadFailure: { - return sensorListContainerAdapter.setError(action.payload, { ...state, pending: false }); - } - - case ActionType.Modify: { - return { - ...state, - error: null, - }; - } - - case ActionType.ModifySuccess: { - return sensorListContainerAdapter.upsertOne(action.payload, state); - } - - case ActionType.ModifyFailure: { - return sensorListContainerAdapter.setError(action.payload, state); - } - - default: - return state; - } -} diff --git a/@overflow/sensor/store/container/sensor-list/sensor-list.state.ts b/@overflow/sensor/store/container/sensor-list/sensor-list.state.ts deleted file mode 100644 index a8f2a64..0000000 --- a/@overflow/sensor/store/container/sensor-list/sensor-list.state.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; - -import { Sensor } from '@overflow/commons-typescript/model/sensor'; -import { Selector, createSelector } from '@ngrx/store'; -import { createEntityAdapter, EntityState } from '@loafer/ng-entity'; -import { Page } from '@overflow/commons-typescript/model/commons/Page'; - -export const sensorListContainerAdapter = createEntityAdapter(); -export interface State extends EntityState { - page: Page; - pending: boolean; -} -export const initialState: State = sensorListContainerAdapter.getInitialState({ - page: null, - pending: false, -}); - -export function getSelectors(selector: Selector) { - return { - ...sensorListContainerAdapter.getSelectors(selector), - selectPending: createSelector(selector, (state: State) => state.pending), - selectPage: createSelector(selector, (state: State) => { - return state.page; - }) - }; -} diff --git a/@overflow/sensor/store/entity/sensor/index.ts b/@overflow/sensor/store/entity/sensor/index.ts deleted file mode 100644 index 7dd9e29..0000000 --- a/@overflow/sensor/store/entity/sensor/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './sensor.action'; -export * from './sensor.effect'; diff --git a/@overflow/sensor/store/entity/sensor/sensor.action.ts b/@overflow/sensor/store/entity/sensor/sensor.action.ts deleted file mode 100644 index 7bf04a2..0000000 --- a/@overflow/sensor/store/entity/sensor/sensor.action.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { Action } from '@ngrx/store'; -import { RPCClientError } from '@loafer/ng-rpc'; -import { Sensor } from '@overflow/commons-typescript/model/sensor'; -import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams'; -import { Page } from '@overflow/commons-typescript/model/commons/Page'; - -export enum ActionType { - ReadAllByDomainID = '[Sensor.list] ReadAllByDomainID', - ReadAllByDomainIDSuccess = '[Sensor.list] ReadAllByDomainIDSuccess', - ReadAllByDomainIDFailure = '[Sensor.list] ReadAllByDomainIDFailure', - - Read = '[Sensor.detail] Read', - ReadSuccess = '[Sensor.detail] ReadSuccess', - ReadFailure = '[Sensor.detail] ReadFailure', - - Modify = '[Sensor.detail] Modify', - ModifySuccess = '[Sensor.detail] ModifySuccess', - ModifyFailure = '[Sensor.detail] ModifyFailure', -} - -export class ReadAllByDomainID implements Action { - readonly type = ActionType.ReadAllByDomainID; - - constructor(public payload: {domainID: number, pageParams: PageParams}) {} -} - -export class ReadAllByDomainIDSuccess implements Action { - readonly type = ActionType.ReadAllByDomainIDSuccess; - - constructor(public payload: Page) {} -} - -export class ReadAllByDomainIDFailure implements Action { - readonly type = ActionType.ReadAllByDomainIDFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Read implements Action { - readonly type = ActionType.Read; - - constructor(public payload: number) {} -} - -export class ReadSuccess implements Action { - readonly type = ActionType.ReadSuccess; - - constructor(public payload: Sensor) {} -} - -export class ReadFailure implements Action { - readonly type = ActionType.ReadFailure; - - constructor(public payload: RPCClientError) {} -} - -export class Modify implements Action { - readonly type = ActionType.Modify; - - constructor(public payload: Sensor) {} -} - -export class ModifySuccess implements Action { - readonly type = ActionType.ModifySuccess; - - constructor(public payload: Sensor) {} -} - -export class ModifyFailure implements Action { - readonly type = ActionType.ModifyFailure; - - constructor(public payload: RPCClientError) {} -} - -export type Actions = - | ReadAllByDomainID - | ReadAllByDomainIDSuccess - | ReadAllByDomainIDFailure - | Read - | ReadSuccess - | ReadFailure - | Modify - | ModifySuccess - | ModifyFailure -; diff --git a/@overflow/sensor/store/entity/sensor/sensor.effect.ts b/@overflow/sensor/store/entity/sensor/sensor.effect.ts deleted file mode 100644 index 1185820..0000000 --- a/@overflow/sensor/store/entity/sensor/sensor.effect.ts +++ /dev/null @@ -1,78 +0,0 @@ -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/switchMap'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/take'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { Sensor } from '@overflow/commons-typescript/model/sensor'; - -import { - ReadAllByDomainID, - ReadAllByDomainIDFailure, - ReadAllByDomainIDSuccess, - Read, - ReadSuccess, - ReadFailure, - Modify, - ModifySuccess, - ModifyFailure, - ActionType -} from './sensor.action'; -import { SensorService } from '../../../service/sensor.service'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private sensorService: SensorService, - private router: Router - ) { } - - @Effect() - ReadAllByDomainID$: Observable = this.actions$ - .ofType(ActionType.ReadAllByDomainID) - .map((action: ReadAllByDomainID) => action.payload) - .switchMap(payload => this.sensorService.readAllByDomainID(payload.domainID, payload.pageParams)) - .map(page => { - return new ReadAllByDomainIDSuccess(page); - }) - .catch((error: RPCClientError) => { - return of(new ReadAllByDomainIDFailure(error)); - }); - - // @Effect() - // Read$: Observable = this.actions$ - // .ofType(ActionType.Read) - // .map((action: Read) => action.payload) - // .switchMap(payload => this.sensorHostService.read(payload)) - // .map(sensorHost => { - // return new ReadSuccess(sensorHost); - // }) - // .catch((error: RPCClientError) => { - // return of(new ReadFailure(error)); - // }); - - // @Effect() - // Modify$: Observable = this.actions$ - // .ofType(ActionType.Modify) - // .map((action: Modify) => action.payload) - // .switchMap(payload => this.sensorService.modify(payload)) - // .map(sensor => { - // return new ModifySuccess(sensor); - // }) - // .catch((error: RPCClientError) => { - // return of(new ModifyFailure(error)); - // }); -} diff --git a/@overflow/sensor/store/index.ts b/@overflow/sensor/store/index.ts deleted file mode 100644 index aab82ae..0000000 --- a/@overflow/sensor/store/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - createSelector, - createFeatureSelector, -} from '@ngrx/store'; - -import { MODULE } from '../sensor.constant'; - -import * as SensorEntityStore from './entity/sensor'; -import * as SensorListContainerStore from './container/sensor-list'; - -export interface State { - sensor_list: SensorListContainerStore.State; -} - -export const REDUCERS = { - sensor_list: SensorListContainerStore.reducer, -}; - -export const EFFECTS = [ - SensorEntityStore.Effects, -]; - -export const selectState = createFeatureSelector(MODULE.name); - -export const SensorListContainerSelector = SensorListContainerStore.getSelectors(createSelector( - selectState, - (state: State) => { - return state.sensor_list; - } -)); diff --git a/@overflow/target/component/detail/detail.component.ts b/@overflow/target/component/detail/detail.component.ts index df0a878..bfab400 100644 --- a/@overflow/target/component/detail/detail.component.ts +++ b/@overflow/target/component/detail/detail.component.ts @@ -1,16 +1,15 @@ import { Component, ViewChild, OnInit, Input, AfterContentInit, OnDestroy } from '@angular/core'; +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; + import { Router, ActivatedRoute } from '@angular/router'; 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 '@overflow/infra/store'; -import * as InfraDetailStore from '@overflow/infra/store/detail'; -import { Subscription } from 'rxjs/Subscription'; + import { RPCClientError } from '@loafer/ng-rpc'; // import * as SensorListStore from '@overflow/sensor/store/list'; // import { PageParams, Page } from 'app/commons/model'; -import { ModifySelector } from '@overflow/target/store'; -import * as TargetModifyStore from '@overflow/target/store/modify'; import { Target } from '@overflow/commons-typescript/model/target'; @@ -20,11 +19,11 @@ import { Target } from '@overflow/commons-typescript/model/target'; }) export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { + infra$: Observable; infraSubscription$: Subscription; - infra$ = this.infraDetailStore.pipe(select(InfraDetailSelector.select('infra'))); sensorsSubscription$: Subscription; // sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page'))); - target$ = this.targetModifyStore.pipe(select(ModifySelector.select('target'))); + target$: Observable; infraId = null; infra: Infra; @@ -39,9 +38,7 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { constructor( private router: Router, private route: ActivatedRoute, - private infraDetailStore: Store, - // private sensorListStore: Store, - private targetModifyStore: Store + private store: Store, ) { } ngOnInit() { @@ -79,11 +76,11 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { } getInfra() { - this.infraDetailStore.dispatch( - new InfraDetailStore.Read( - { id: this.infraId } - ) - ); + // this.infraDetailStore.dispatch( + // new InfraDetailStore.Read( + // { id: this.infraId } + // ) + // ); } getSensors(pageIndex) { @@ -127,9 +124,9 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy { } const target = this.infra.target; target.displayName = value; - this.targetModifyStore.dispatch( - new TargetModifyStore.Modify(target) - ); + // this.targetModifyStore.dispatch( + // new TargetModifyStore.Modify(target) + // ); const modifySuccessSubscription$: Subscription = this.target$.subscribe( (t: Target) => { diff --git a/@overflow/target/component/list/list.component.ts b/@overflow/target/component/list/list.component.ts index 7aa4caa..bbb89ee 100644 --- a/@overflow/target/component/list/list.component.ts +++ b/@overflow/target/component/list/list.component.ts @@ -1,15 +1,16 @@ import { Component, OnInit, AfterContentInit, OnDestroy } from '@angular/core'; +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; + import { Router, ActivatedRoute } from '@angular/router'; import { Infra } from '@overflow/commons-typescript/model/infra'; import { Store, select } from '@ngrx/store'; -import { ListSelector } from '@overflow/infra/store'; -import * as InfraListStore from '@overflow/infra/store/list'; // import { Page, PageParams } from 'app/commons/model'; import { RPCClientError } from '@loafer/ng-rpc'; import { Probe } from '@overflow/commons-typescript/model/probe'; import { Target } from '@overflow/commons-typescript/model/target'; -import { Subscription } from 'rxjs/Subscription'; + @Component({ @@ -19,7 +20,7 @@ import { Subscription } from 'rxjs/Subscription'; export class ListComponent implements OnInit, AfterContentInit, OnDestroy { infrasSubscription$: Subscription; - infras$ = this.infraListStore.pipe(select(ListSelector.select('page'))); + infras$: Observable; infras: Infra[]; probe: Probe; target: Target = null; @@ -32,7 +33,7 @@ export class ListComponent implements OnInit, AfterContentInit, OnDestroy { constructor( private route: ActivatedRoute, private router: Router, - private infraListStore: Store, + private store: Store, ) { } diff --git a/@overflow/target/store/index.ts b/@overflow/target/store/index.ts deleted file mode 100644 index 5984241..0000000 --- a/@overflow/target/store/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - createSelector, - createFeatureSelector, - ActionReducerMap, - } from '@ngrx/store'; - - import { StateSelector } from '@overflow/core/ngrx/store'; - - import { MODULE } from '../target.constant'; - - import * as TargetModifyStore from './modify'; - - export interface State { - modify: TargetModifyStore.State; - } - - export const REDUCERS = { - modify: TargetModifyStore.reducer, - }; - - export const EFFECTS = [ - TargetModifyStore.Effects, - ]; - - export const selectTargetState = createFeatureSelector(MODULE.name); - - export const ModifySelector = new StateSelector(createSelector( - selectTargetState, - (state: State) => state.modify - )); diff --git a/@overflow/target/store/modify/index.ts b/@overflow/target/store/modify/index.ts deleted file mode 100644 index 9f23ca0..0000000 --- a/@overflow/target/store/modify/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './modify.action'; -export * from './modify.effect'; -export * from './modify.reducer'; -export * from './modify.state'; diff --git a/@overflow/target/store/modify/modify.action.ts b/@overflow/target/store/modify/modify.action.ts deleted file mode 100644 index a93aee1..0000000 --- a/@overflow/target/store/modify/modify.action.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { RPCClientError } from '@loafer/ng-rpc'; -import { Target } from '@overflow/commons-typescript/model/target'; - -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/@overflow/target/store/modify/modify.effect.spec.ts b/@overflow/target/store/modify/modify.effect.spec.ts deleted file mode 100644 index b064f15..0000000 --- a/@overflow/target/store/modify/modify.effect.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { Effects } from './modify.effect'; - -describe('Target.Effects', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [Effects] - }); - }); - - it('should be created', inject([Effects], (effects: Effects) => { - expect(effects).toBeTruthy(); - })); -}); diff --git a/@overflow/target/store/modify/modify.effect.ts b/@overflow/target/store/modify/modify.effect.ts deleted file mode 100644 index bff3f13..0000000 --- a/@overflow/target/store/modify/modify.effect.ts +++ /dev/null @@ -1,44 +0,0 @@ -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 { TargetService } from '../../service/target.service'; - -import { - Modify, - ModifySuccess, - ModifyFailure, - ActionType, -} from './modify.action'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private targetService: TargetService, - private router: Router - ) { } - - @Effect() - 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/@overflow/target/store/modify/modify.reducer.ts b/@overflow/target/store/modify/modify.reducer.ts deleted file mode 100644 index ad9a369..0000000 --- a/@overflow/target/store/modify/modify.reducer.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { - Actions, - ActionType, -} from './modify.action'; - -import { - State, - initialState, -} from './modify.state'; - -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.ModifyFailure: { - return { - ...state, - error: action.payload, - pending: false, - target: null, - }; - } - - default: { - return state; - } - } -} diff --git a/@overflow/target/store/modify/modify.state.ts b/@overflow/target/store/modify/modify.state.ts deleted file mode 100644 index d9c5edd..0000000 --- a/@overflow/target/store/modify/modify.state.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { RPCClientError } from '@loafer/ng-rpc'; -import { Target } from '@overflow/commons-typescript/model/target'; - -export interface State { - error: RPCClientError | null; - pending: boolean; - target: Target | null; -} - -export const initialState: State = { - error: null, - pending: false, - target: null, -}; diff --git a/@overflow/target/target-store.module.ts b/@overflow/target/target-store.module.ts deleted file mode 100644 index 0e972ef..0000000 --- a/@overflow/target/target-store.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import { StoreModule } from '@ngrx/store'; -import { EffectsModule } from '@ngrx/effects'; - -import { - REDUCERS, - EFFECTS, -} from './store'; - -import { MODULE } from './target.constant'; - -@NgModule({ - imports: [ - StoreModule.forFeature(MODULE.name, REDUCERS), - EffectsModule.forFeature(EFFECTS), - ], -}) -export class TargetStoreModule { }