From 14a4acb784b73a579fc0b225a532456c7b246427 Mon Sep 17 00:00:00 2001 From: insanity Date: Mon, 28 May 2018 18:58:13 +0900 Subject: [PATCH 1/3] arrange --- .../discovery/discovery.component.html | 8 +-- .../discovery/discovery.component.ts | 11 ++-- .../probe-selector.component.html | 9 --- .../probe-selector.component.ts | 59 ----------------- @overflow/discovery/component/index.ts | 2 - .../discovery-container.component.html | 3 +- .../discovery-container.component.ts | 42 ++---------- @overflow/discovery/discovery.module.ts | 4 +- @overflow/member/container/index.ts | 2 +- @overflow/probe/component/index.ts | 2 + .../selector/selector.component.html | 1 + .../component/selector/selector.component.ts | 29 +++++++++ @overflow/probe/container/index.ts | 2 + .../probe-detail-container.component.ts | 12 ++-- .../probe-list-container.component.ts | 22 +++---- .../probe-selector-container.component.html | 1 + .../probe-selector-container.component.ts | 39 +++++++++++ @overflow/probe/probe.module.ts | 2 - .../probe-detail/probe-detail.reducer.ts | 11 +--- .../probe-detail/probe-detail.state.ts | 10 ++- .../probe-list/probe-list.reducer.ts | 11 +--- .../container/probe-list/probe-list.state.ts | 12 +++- @overflow/probe/store/entity/probe/index.ts | 2 - .../probe/store/entity/probe/probe.reducer.ts | 65 ------------------- .../probe/store/entity/probe/probe.state.ts | 14 ---- @overflow/probe/store/index.ts | 7 -- .../component/detail/detail.component.html | 5 +- .../sensor/component/list/list.component.html | 2 +- .../sensor/component/list/list.component.ts | 1 + .../sensor-list-container.component.html | 2 +- .../discovery/discovery-page.component.html | 2 +- .../discovery/discovery-page.component.ts | 5 +- .../noauth-probe-page-routing.module.ts | 1 - .../sensors/sensor/sensor-page.component.html | 12 ++-- .../sensors/sensor/sensor-page.component.ts | 16 ++++- 35 files changed, 159 insertions(+), 269 deletions(-) delete mode 100644 @overflow/discovery/component/discovery/probe-selector/probe-selector.component.html delete mode 100644 @overflow/discovery/component/discovery/probe-selector/probe-selector.component.ts create mode 100644 @overflow/probe/component/selector/selector.component.html create mode 100644 @overflow/probe/component/selector/selector.component.ts create mode 100644 @overflow/probe/container/probe-selector-container.component.html create mode 100644 @overflow/probe/container/probe-selector-container.component.ts delete mode 100644 @overflow/probe/store/entity/probe/probe.reducer.ts delete mode 100644 @overflow/probe/store/entity/probe/probe.state.ts diff --git a/@overflow/discovery/component/discovery/discovery.component.html b/@overflow/discovery/component/discovery/discovery.component.html index db6e5b7..732f9b1 100644 --- a/@overflow/discovery/component/discovery/discovery.component.html +++ b/@overflow/discovery/component/discovery/discovery.component.html @@ -2,14 +2,14 @@ +
- + probeHost.id === this.probeHostID); + // } } ngAfterContentInit() { @@ -43,7 +46,7 @@ export class DiscoveryComponent implements OnInit, AfterContentInit { onSelectedProbe(probe) { console.log(probe); - this.selectedProbe = probe; + // this.selectedProbe = probe; } onProbeSelect(probe) { diff --git a/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.html b/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.html deleted file mode 100644 index 3385880..0000000 --- a/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - -
diff --git a/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.ts b/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.ts deleted file mode 100644 index f8cafcd..0000000 --- a/@overflow/discovery/component/discovery/probe-selector/probe-selector.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - Component, OnInit, Input, AfterContentInit, Output, - EventEmitter, OnDestroy, ViewChild -} from '@angular/core'; - -import { Subscription } from 'rxjs/Subscription'; -import {Probe, ProbeHost} from '@overflow/commons-typescript/model/probe'; - -@Component({ - selector: 'of-probe-selector', - templateUrl: './probe-selector.component.html', -}) -export class ProbeSelectorComponent implements OnInit, AfterContentInit, OnDestroy { - - @Input() preProbe: ProbeHost; - probes: Probe[]; - selected: Probe; - - @Output() probeSelected = new EventEmitter(); - - constructor( - ) { - } - - ngOnInit() { - - } - - ngAfterContentInit() { - this.getProbes(); - } - - ngOnDestroy() { - this.selected = null; - this.probes = null; - } - - getProbes() { - - } - - onProbeSelect(event) { - this.selected = event.value; - this.probeSelected.emit(this.selected); - } - - registerOnChange(fn: any): void { - } - - registerOnTouched(fn: any): void { - } - - setDisabledState(isDisabled: boolean): void { - } - - writeValue(obj: any): void { - } - -} diff --git a/@overflow/discovery/component/index.ts b/@overflow/discovery/component/index.ts index 0d18f7e..e5843c9 100644 --- a/@overflow/discovery/component/index.ts +++ b/@overflow/discovery/component/index.ts @@ -1,4 +1,3 @@ -import { ProbeSelectorComponent } from './discovery/probe-selector/probe-selector.component'; import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component'; import { DiscoveryComponent } from './discovery/discovery.component'; import { SearchConfigComponent } from './discovery/search-config/search-config.component'; @@ -8,7 +7,6 @@ import { IpInputComponent } from './discovery/search-config/ip-input.component'; export const COMPONENTS = [ ServiceSelectorComponent, - ProbeSelectorComponent, DiscoveryComponent, SearchConfigComponent, SearchFilterComponent, diff --git a/@overflow/discovery/container/discovery/discovery-container.component.html b/@overflow/discovery/container/discovery/discovery-container.component.html index 363056a..664dac4 100644 --- a/@overflow/discovery/container/discovery/discovery-container.component.html +++ b/@overflow/discovery/container/discovery/discovery-container.component.html @@ -1 +1,2 @@ - + + diff --git a/@overflow/discovery/container/discovery/discovery-container.component.ts b/@overflow/discovery/container/discovery/discovery-container.component.ts index a513aad..a270bd9 100644 --- a/@overflow/discovery/container/discovery/discovery-container.component.ts +++ b/@overflow/discovery/container/discovery/discovery-container.component.ts @@ -1,53 +1,19 @@ import { - AfterContentInit, Component, Input, - OnInit + Component, + Input, } from '@angular/core'; -import { select, Store} from '@ngrx/store'; -import { ActivatedRoute } from '@angular/router'; -import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; - -import { AuthSelector } from '@overflow/member/store'; -import { Domain } from '@overflow/commons-typescript/model/domain'; -import * as ProbeEntityStore from '@overflow/probe/store/entity/probe'; -import {Observable} from 'rxjs'; -import { ProbeEntitySelector } from '@overflow/probe/store'; @Component({ selector: 'of-discovery-container', templateUrl: './discovery-container.component.html', }) -export class DiscoveryContainerComponent implements OnInit, AfterContentInit { +export class DiscoveryContainerComponent { - // probe select ? - // get probe list for server - // discovery start - // discovery stop - // get service list - @Input() hostID; - - probeHosts$: Observable; - selectProbes?: Probe[]; + @Input() probeHostID; constructor( - private activatedRoute: ActivatedRoute, - private store: Store ) { - this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll)); - } - ngOnInit() { - this.store.select(AuthSelector.select('domain')).subscribe( - (domain: Domain) => { - this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domain.id)); - }, - (error) => { - console.log(error); - } - ); - } - - ngAfterContentInit() { - } } diff --git a/@overflow/discovery/discovery.module.ts b/@overflow/discovery/discovery.module.ts index 7bbff37..3063c2e 100644 --- a/@overflow/discovery/discovery.module.ts +++ b/@overflow/discovery/discovery.module.ts @@ -11,6 +11,7 @@ import { SERVICES } from './service'; import { PrimeNGModules } from '@overflow/commons/prime-ng/prime-ng.module'; import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module'; import { CONTAINER_COMPONENTS } from './container'; +import { ProbeModule } from '../probe/probe.module'; @NgModule({ imports: [ @@ -21,7 +22,8 @@ import { CONTAINER_COMPONENTS } from './container'; DiscoveryStoreModule, DiscoveryRPCModule, DiscoveryLoggerModule, - KeyValueModule + KeyValueModule, + ProbeModule ], declarations: [ COMPONENTS, diff --git a/@overflow/member/container/index.ts b/@overflow/member/container/index.ts index 87723ae..b932c14 100644 --- a/@overflow/member/container/index.ts +++ b/@overflow/member/container/index.ts @@ -3,5 +3,5 @@ import { MemberSignupContainerComponent } from './member-signup-container.compon export const CONTAINERS = [ MemberSigninContainerComponent, - MemberSignupContainerComponent, + // MemberSignupContainerComponent, ]; diff --git a/@overflow/probe/component/index.ts b/@overflow/probe/component/index.ts index ffd7e65..aa2b63a 100644 --- a/@overflow/probe/component/index.ts +++ b/@overflow/probe/component/index.ts @@ -1,9 +1,11 @@ import { ProbeDetailComponent } from './detail/detail.component'; import { ProbeListComponent } from './list/list.component'; import { ProbeDownloadComponent } from './download/download.component'; +import { ProbeSelectorComponent } from './selector/selector.component'; export const COMPONENTS = [ ProbeListComponent, ProbeDetailComponent, ProbeDownloadComponent, + ProbeSelectorComponent, ]; diff --git a/@overflow/probe/component/selector/selector.component.html b/@overflow/probe/component/selector/selector.component.html new file mode 100644 index 0000000..f0ad369 --- /dev/null +++ b/@overflow/probe/component/selector/selector.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/@overflow/probe/component/selector/selector.component.ts b/@overflow/probe/component/selector/selector.component.ts new file mode 100644 index 0000000..c20b64e --- /dev/null +++ b/@overflow/probe/component/selector/selector.component.ts @@ -0,0 +1,29 @@ +import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; + +@Component({ + selector: 'of-probe-selector', + templateUrl: './selector.component.html', +}) +export class ProbeSelectorComponent implements OnChanges { + + @Output() select = new EventEmitter(); + @Input() probeHosts: ProbeHost[]; + @Input() probeHostID: number; + + options: Probe[]; + + constructor() { + } + + ngOnChanges(changes: SimpleChanges): void { + this.options = []; + for (const ph of this.probeHosts) { + this.options.push(ph.probe); + } + } + + onProbeSelect(event) { + this.select.emit(event.data); + } +} diff --git a/@overflow/probe/container/index.ts b/@overflow/probe/container/index.ts index dfe25b1..bbe719c 100644 --- a/@overflow/probe/container/index.ts +++ b/@overflow/probe/container/index.ts @@ -1,7 +1,9 @@ import { ProbeListContainerComponent } from '../container/probe-list-container.component'; import { ProbeDetailContainerComponent } from '../container/probe-detail-container.component'; +import { ProbeSelectorContainerComponent } from './probe-selector-container.component'; export const CONTAINER_COMPONENTS = [ ProbeListContainerComponent, ProbeDetailContainerComponent, + ProbeSelectorContainerComponent ]; diff --git a/@overflow/probe/container/probe-detail-container.component.ts b/@overflow/probe/container/probe-detail-container.component.ts index b9f32db..843fa58 100644 --- a/@overflow/probe/container/probe-detail-container.component.ts +++ b/@overflow/probe/container/probe-detail-container.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; import { Observable } from 'rxjs'; -import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { ProbeHost } from '@overflow/commons-typescript/model/probe'; import { Store, select } from '@ngrx/store'; import * as ProbeStore from '../store/entity/probe'; -import { ProbeEntitySelector, ProbeDetailContainerSelector } from '../store'; +import { ProbeDetailContainerSelector } from '../store'; import { ActivatedRoute } from '@angular/router'; @Component({ @@ -19,15 +19,15 @@ export class ProbeDetailContainerComponent implements OnInit, OnChanges { error$: Observable; constructor( - private store: Store, + private store: Store, private route: ActivatedRoute, ) { - this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending)); - this.error$ = this.store.pipe(select(ProbeEntitySelector.selectError)); } ngOnInit() { - this.probeHost$ = this.store.pipe(select(ProbeEntitySelector.selectOne(this.probeHostID))); + this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending)); + this.error$ = this.store.pipe(select(ProbeDetailContainerSelector.selectError)); + this.probeHost$ = this.store.pipe(select(ProbeDetailContainerSelector.selectOne(this.probeHostID))); } ngOnChanges(changes: SimpleChanges): void { diff --git a/@overflow/probe/container/probe-list-container.component.ts b/@overflow/probe/container/probe-list-container.component.ts index f090460..f06c72c 100644 --- a/@overflow/probe/container/probe-list-container.component.ts +++ b/@overflow/probe/container/probe-list-container.component.ts @@ -3,9 +3,9 @@ import { ProbeHost } from '@overflow/commons-typescript/model/probe'; import { Observable } from 'rxjs'; import { Store, select } from '@ngrx/store'; import * as ProbeEntityStore from '../store/entity/probe'; -import { ProbeEntitySelector, ProbeListContainerSelector } from '../store'; -import { AuthSelector } from '@overflow/member/store'; -import { Domain } from '@overflow/commons-typescript/model/domain'; +import { ProbeListContainerSelector } from '../store'; +import { AuthContainerSelector } from '../../shared/auth/store'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; @Component({ selector: 'of-probe-list-container', @@ -15,22 +15,20 @@ export class ProbeListContainerComponent implements OnInit { probeHosts$: Observable; pending$: Observable; + error$: Observable; @Output() select = new EventEmitter(); constructor( - private store: Store, + private store: Store, ) { - this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll)); - this.pending$ = store.pipe(select(ProbeListContainerSelector.selectPending)); } ngOnInit() { - this.store.select(AuthSelector.select('domain')).subscribe( - (domain: Domain) => { - this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domain.id)); - }, - (error) => { - console.log(error); + this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll)); + this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending)); + this.store.select(AuthContainerSelector.selectDomainMember).subscribe( + (domainMember: DomainMember) => { + this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id)); } ); } diff --git a/@overflow/probe/container/probe-selector-container.component.html b/@overflow/probe/container/probe-selector-container.component.html new file mode 100644 index 0000000..8f51e22 --- /dev/null +++ b/@overflow/probe/container/probe-selector-container.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/@overflow/probe/container/probe-selector-container.component.ts b/@overflow/probe/container/probe-selector-container.component.ts new file mode 100644 index 0000000..7403a1e --- /dev/null +++ b/@overflow/probe/container/probe-selector-container.component.ts @@ -0,0 +1,39 @@ +import { Component, EventEmitter, Output, OnInit, Input } from '@angular/core'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { Observable } from 'rxjs'; +import { Store, select } from '@ngrx/store'; +import * as ProbeEntityStore from '@overflow/probe/store/entity/probe'; +import { ProbeListContainerSelector } from '@overflow/probe/store'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; + +@Component({ + selector: 'of-probe-selector-container', + templateUrl: './probe-selector-container.component.html', +}) +export class ProbeSelectorContainerComponent implements OnInit { + + probeHosts$: Observable; + @Output() select = new EventEmitter(); + @Input() probeHostID: number; + + constructor( + private store: Store, + ) { + } + + ngOnInit() { + this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll)); + this.store.select(AuthContainerSelector.selectDomainMember).subscribe( + (domainMember: DomainMember) => { + this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id)); + } + ); + } + + onSelect(probeHost: ProbeHost) { + alert(probeHost.probe.displayName); + // this.select.emit(probeHost); + } + +} diff --git a/@overflow/probe/probe.module.ts b/@overflow/probe/probe.module.ts index e554b08..333e0c2 100644 --- a/@overflow/probe/probe.module.ts +++ b/@overflow/probe/probe.module.ts @@ -7,7 +7,6 @@ import { ProbeStoreModule } from './probe-store.module'; import { SERVICES } from './service'; import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module'; import { FormsModule } from '@angular/forms'; -import { DiscoveryModule } from '@overflow/discovery/discovery.module'; import { MetaCrawlerModule } from '@overflow/meta/crawler/crawler.module'; import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module'; @@ -17,7 +16,6 @@ import { KeyValueModule } from '@overflow/commons/component/key-value/key-value. PrimeNGModules, ProbeStoreModule, FormsModule, - DiscoveryModule, KeyValueModule, MetaCrawlerModule ], diff --git a/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts b/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts index 43c19c4..18e4519 100644 --- a/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts +++ b/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts @@ -2,6 +2,7 @@ import { ActionType, Actions } from '../../entity/probe'; import { State, initialState, + probeListContainerAdapter } from './probe-detail.state'; import { Probe } from '@overflow/commons-typescript/model/probe'; @@ -16,17 +17,11 @@ export function reducer(state = initialState, action: Actions): State { } case ActionType.ReadSuccess: { - return { - ...state, - pending: false, - }; + return probeListContainerAdapter.setOne(action.payload, {...state, pending: false}); } case ActionType.ReadFailure: { - return { - ...state, - pending: true, - }; + return probeListContainerAdapter.setError(action.payload, {...state, pending: false}); } default: { diff --git a/@overflow/probe/store/container/probe-detail/probe-detail.state.ts b/@overflow/probe/store/container/probe-detail/probe-detail.state.ts index 236ecca..5f8896a 100644 --- a/@overflow/probe/store/container/probe-detail/probe-detail.state.ts +++ b/@overflow/probe/store/container/probe-detail/probe-detail.state.ts @@ -1,15 +1,19 @@ +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 interface State { +export const probeListContainerAdapter = createEntityAdapter(); +export interface State extends EntityState { pending: boolean; } -export const initialState: State = { +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/probe-list.reducer.ts b/@overflow/probe/store/container/probe-list/probe-list.reducer.ts index fb86962..ced893e 100644 --- a/@overflow/probe/store/container/probe-list/probe-list.reducer.ts +++ b/@overflow/probe/store/container/probe-list/probe-list.reducer.ts @@ -2,6 +2,7 @@ import { ActionType, Actions } from '../../entity/probe'; import { State, initialState, + probeListContainerAdapter } from './probe-list.state'; import { Probe } from '@overflow/commons-typescript/model/probe'; @@ -16,17 +17,11 @@ export function reducer(state = initialState, action: Actions): State { } case ActionType.ReadAllByDomainIDSuccess: { - return { - ...state, - pending: false, - }; + return probeListContainerAdapter.setAll(action.payload, {...state, pending: false}); } case ActionType.ReadAllByDomainIDFailure: { - return { - ...state, - pending: true, - }; + return probeListContainerAdapter.setError(action.payload, {...state, pending: false}); } default: { diff --git a/@overflow/probe/store/container/probe-list/probe-list.state.ts b/@overflow/probe/store/container/probe-list/probe-list.state.ts index 236ecca..d3de23c 100644 --- a/@overflow/probe/store/container/probe-list/probe-list.state.ts +++ b/@overflow/probe/store/container/probe-list/probe-list.state.ts @@ -1,15 +1,21 @@ +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 interface State { +export const probeListContainerAdapter = createEntityAdapter(); +export interface State extends EntityState { pending: boolean; } -export const initialState: State = { +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/entity/probe/index.ts b/@overflow/probe/store/entity/probe/index.ts index d8f12e5..6d98072 100644 --- a/@overflow/probe/store/entity/probe/index.ts +++ b/@overflow/probe/store/entity/probe/index.ts @@ -1,4 +1,2 @@ export * from './probe.action'; export * from './probe.effect'; -export * from './probe.reducer'; -export * from './probe.state'; diff --git a/@overflow/probe/store/entity/probe/probe.reducer.ts b/@overflow/probe/store/entity/probe/probe.reducer.ts deleted file mode 100644 index 4ebe85a..0000000 --- a/@overflow/probe/store/entity/probe/probe.reducer.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { - ActionType, - Actions, -} from './probe.action'; - -import { - State, - initialState, - probeAdapter, -} from './probe.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, - error: null, - }; - } - - case ActionType.ReadAllByDomainIDSuccess: { - return probeAdapter.setAll(action.payload, state); - } - - case ActionType.ReadAllByDomainIDFailure: { - return probeAdapter.setError(action.payload, state); - } - - case ActionType.Read: { - return { - ...state, - error: null, - }; - } - - case ActionType.ReadSuccess: { - return probeAdapter.setOne(action.payload, state); - } - - case ActionType.ReadFailure: { - return probeAdapter.setError(action.payload, state); - } - - case ActionType.Modify: { - return { - ...state, - error: null, - }; - } - - case ActionType.ModifySuccess: { - return probeAdapter.upsertOne(action.payload, state); - } - - case ActionType.ModifyFailure: { - return probeAdapter.setError(action.payload, state); - } - - default: { - return state; - } - } -} diff --git a/@overflow/probe/store/entity/probe/probe.state.ts b/@overflow/probe/store/entity/probe/probe.state.ts deleted file mode 100644 index 1a65bb5..0000000 --- a/@overflow/probe/store/entity/probe/probe.state.ts +++ /dev/null @@ -1,14 +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 probeAdapter = createEntityAdapter(); -export interface State extends EntityState { -} -export const initialState: State = probeAdapter.getInitialState(); - -export function getSelectors(selector: Selector) { - return probeAdapter.getSelectors(selector); -} - diff --git a/@overflow/probe/store/index.ts b/@overflow/probe/store/index.ts index 3f4480e..6a8f41d 100644 --- a/@overflow/probe/store/index.ts +++ b/@overflow/probe/store/index.ts @@ -13,13 +13,11 @@ import * as ProbeListContainerStore from './container/probe-list'; import * as ProbeDetailContainerStore from './container/probe-detail'; export interface State { - probe: ProbeEntityStore.State; probe_list_container: ProbeListContainerStore.State; probe_detail_container: ProbeDetailContainerStore.State; } export const REDUCERS = { - probe: ProbeEntityStore.reducer, probe_list_container: ProbeListContainerStore.reducer, probe_detail_container: ProbeDetailContainerStore.reducer }; @@ -30,11 +28,6 @@ export const EFFECTS = [ export const selectState = createFeatureSelector(MODULE.name); -export const ProbeEntitySelector = ProbeEntityStore.getSelectors(createSelector( - selectState, - (state: State) => state.probe -)); - export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector( selectState, (state: State) => state.probe_list_container diff --git a/@overflow/sensor/component/detail/detail.component.html b/@overflow/sensor/component/detail/detail.component.html index 6dbe420..ee7197b 100644 --- a/@overflow/sensor/component/detail/detail.component.html +++ b/@overflow/sensor/component/detail/detail.component.html @@ -1,4 +1,5 @@ -
+SENSOR_DETAIL_COMPONENT + diff --git a/@overflow/sensor/component/list/list.component.html b/@overflow/sensor/component/list/list.component.html index 18f6f16..b7d1009 100644 --- a/@overflow/sensor/component/list/list.component.html +++ b/@overflow/sensor/component/list/list.component.html @@ -77,7 +77,7 @@
diff --git a/@overflow/sensor/component/list/list.component.ts b/@overflow/sensor/component/list/list.component.ts index 6509d91..b0ae8ad 100644 --- a/@overflow/sensor/component/list/list.component.ts +++ b/@overflow/sensor/component/list/list.component.ts @@ -11,6 +11,7 @@ export class SensorListComponent implements OnChanges { @Input() page: Page; @Output() addSensor = new EventEmitter(); + @Output() select = new EventEmitter(); totalLength: number; targetSensors: Object; diff --git a/@overflow/sensor/container/sensor-list-container.component.html b/@overflow/sensor/container/sensor-list-container.component.html index 1f9f7ad..58b4952 100644 --- a/@overflow/sensor/container/sensor-list-container.component.html +++ b/@overflow/sensor/container/sensor-list-container.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/pages/discovery/discovery-page.component.html b/src/app/pages/discovery/discovery-page.component.html index 07af687..f7fa9b0 100644 --- a/src/app/pages/discovery/discovery-page.component.html +++ b/src/app/pages/discovery/discovery-page.component.html @@ -3,7 +3,7 @@
- +
diff --git a/src/app/pages/discovery/discovery-page.component.ts b/src/app/pages/discovery/discovery-page.component.ts index c13da36..338306e 100644 --- a/src/app/pages/discovery/discovery-page.component.ts +++ b/src/app/pages/discovery/discovery-page.component.ts @@ -7,7 +7,7 @@ import { ActivatedRoute } from '@angular/router'; }) export class DiscoveryPageComponent implements OnInit { - hostId: number; + probeHostID: number; constructor( private route: ActivatedRoute @@ -15,8 +15,7 @@ export class DiscoveryPageComponent implements OnInit { ngOnInit() { this.route.params.subscribe((params: any) => { - this.hostId = params['probeHostID']; - // console.log('probeHostID : ' + probeHostID); + this.probeHostID = params['probeHostID']; }); } } diff --git a/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts b/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts index c8225f6..5babd78 100644 --- a/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts +++ b/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { NoAuthProbePageComponent } from './noauth-probe-page.component'; import { ProbeListComponent } from '@overflow/probe/component/list/list.component'; -import { NoAuthProbeListComponent } from '@overflow/noauth-probe/component/list/list.component'; import { ProbeDownloadComponent } from '@overflow/probe/component/download/download.component'; const routes: Routes = [ diff --git a/src/app/pages/sensors/sensor/sensor-page.component.html b/src/app/pages/sensors/sensor/sensor-page.component.html index e84003f..9dbaeb4 100644 --- a/src/app/pages/sensors/sensor/sensor-page.component.html +++ b/src/app/pages/sensors/sensor/sensor-page.component.html @@ -1,8 +1,4 @@ -
- - -
- - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/src/app/pages/sensors/sensor/sensor-page.component.ts b/src/app/pages/sensors/sensor/sensor-page.component.ts index 75a6f73..4cd4deb 100644 --- a/src/app/pages/sensors/sensor/sensor-page.component.ts +++ b/src/app/pages/sensors/sensor/sensor-page.component.ts @@ -4,13 +4,19 @@ import { Sensor } from '@overflow/commons-typescript/model/sensor'; import { BreadcrumbService } from '@app/commons/service/breadcrumb.service'; import { Target } from '@overflow/commons-typescript/model/target'; +enum CONTAINER_TYPES { + List = 1, + Detail, + Setting, +} + @Component({ selector: 'of-pages-sensor', templateUrl: './sensor-page.component.html', }) export class SensorPageComponent { - isDetail: boolean; + containerType: CONTAINER_TYPES; sensorID: string; constructor( @@ -31,7 +37,11 @@ export class SensorPageComponent { this.breadcrumbService.setItems([ { label: 'Sensor', routerLink: ['/sensor/list'], } ]); - this.isDetail = false; + if (this.router.url === '/sensor/list') { + this.containerType = CONTAINER_TYPES.List; + } else { + this.containerType = CONTAINER_TYPES.Setting; + } } onDetailContainer(sensorID: string) { @@ -40,7 +50,7 @@ export class SensorPageComponent { { label: 'Sensor', routerLink: ['/sensor/list'] }, { label: this.sensorID } ]); - this.isDetail = true; + this.containerType = CONTAINER_TYPES.Detail; } onSensorSelect(sensor: Sensor) { From 2b323cd382a461e560be602455810030d872581b Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 28 May 2018 19:09:38 +0900 Subject: [PATCH 2/3] ing --- src/app/commons/guard/auth.guard.ts | 49 +++++++------ .../commons/store/container/signin/index.ts | 2 + .../store/container/signin/signin.action.ts | 15 ++++ .../signin/signin.effect.spec.ts} | 4 +- .../store/container/signin/signin.effect.ts | 72 +++++++++++++++++++ src/app/commons/store/index.ts | 4 +- src/app/commons/store/signin-init/index.ts | 1 - .../store/signin-init/signin-init.effect.ts | 68 ------------------ 8 files changed, 120 insertions(+), 95 deletions(-) create mode 100644 src/app/commons/store/container/signin/index.ts create mode 100644 src/app/commons/store/container/signin/signin.action.ts rename src/app/commons/store/{signin-init/signin-init.effect.spec.ts => container/signin/signin.effect.spec.ts} (75%) create mode 100644 src/app/commons/store/container/signin/signin.effect.ts delete mode 100644 src/app/commons/store/signin-init/index.ts delete mode 100644 src/app/commons/store/signin-init/signin-init.effect.ts diff --git a/src/app/commons/guard/auth.guard.ts b/src/app/commons/guard/auth.guard.ts index efe44a7..e8f1372 100644 --- a/src/app/commons/guard/auth.guard.ts +++ b/src/app/commons/guard/auth.guard.ts @@ -6,55 +6,60 @@ import { RouterStateSnapshot, Router, } from '@angular/router'; -import { Store } from '@ngrx/store'; - -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/take'; -import 'rxjs/add/operator/map'; +import { Store, select } from '@ngrx/store'; +import { Observable } from 'rxjs'; +import { map, take } from 'rxjs/operators'; import { CookieService } from 'ngx-cookie-service'; -import * as AuthStore from '@overflow/member/store/auth'; -import { AuthSelector } from '@overflow/member/store'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; +import * as MemberEntityStore from '@overflow/member/store/entity/member'; +import * as SigninContaifnerStore from '../store/container/signin'; @Injectable() export class AuthGuard implements CanActivate, CanActivateChild { constructor( - private store: Store, + private store: Store, private router: Router, private cookieService: CookieService, ) { } canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { - return this.store - .select(AuthSelector.select('signined')) - .map(signined => { + return this.store.pipe( + select(AuthContainerSelector.selectSignined), + map(signined => { if (!signined) { if (this.cookieService.check('authToken')) { - this.store.dispatch(new AuthStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url})); + this.store.dispatch(new MemberEntityStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url})); } else { - // this.store.dispatch(new AuthStore.SigninRedirect(state.url)); - this.router.navigateByUrl(state.url); + this.store.dispatch(new SigninContaifnerStore.SigninRedirect({returnURL: state.url})); } return false; } return true; - }) - .take(1); + }), + take(1) + ); } canActivateChild(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { - return this.store - .select(AuthSelector.select('signined')) - .map(signined => { + return this.store.pipe( + select(AuthContainerSelector.selectSignined), + map(signined => { if (!signined) { - this.store.dispatch(new AuthStore.SigninRedirect(state.url)); + if (this.cookieService.check('authToken')) { + this.store.dispatch(new MemberEntityStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url})); + } else { + this.store.dispatch(new SigninContaifnerStore.SigninRedirect({returnURL: state.url})); + } return false; } return true; - }) - .take(1); + }), + take(1) + ); } + } diff --git a/src/app/commons/store/container/signin/index.ts b/src/app/commons/store/container/signin/index.ts new file mode 100644 index 0000000..3a90828 --- /dev/null +++ b/src/app/commons/store/container/signin/index.ts @@ -0,0 +1,2 @@ +export * from './signin.action'; +export * from './signin.effect'; diff --git a/src/app/commons/store/container/signin/signin.action.ts b/src/app/commons/store/container/signin/signin.action.ts new file mode 100644 index 0000000..77226a5 --- /dev/null +++ b/src/app/commons/store/container/signin/signin.action.ts @@ -0,0 +1,15 @@ +import { Action } from '@ngrx/store'; + +export enum ActionType { + SigninRedirect = '[app.signin] SigninRedirect', +} + +export class SigninRedirect implements Action { + readonly type = ActionType.SigninRedirect; + + constructor(public payload: {returnURL: string}) {} +} + +export type Actions = + | SigninRedirect +; diff --git a/src/app/commons/store/signin-init/signin-init.effect.spec.ts b/src/app/commons/store/container/signin/signin.effect.spec.ts similarity index 75% rename from src/app/commons/store/signin-init/signin-init.effect.spec.ts rename to src/app/commons/store/container/signin/signin.effect.spec.ts index 6214021..2736e83 100644 --- a/src/app/commons/store/signin-init/signin-init.effect.spec.ts +++ b/src/app/commons/store/container/signin/signin.effect.spec.ts @@ -1,8 +1,8 @@ import { TestBed, inject } from '@angular/core/testing'; -import { Effects } from './signin-init.effect'; +import { Effects } from './signin.effect'; -describe('SigninInit.Effects', () => { +describe('signin-container.Effects', () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [Effects] diff --git a/src/app/commons/store/container/signin/signin.effect.ts b/src/app/commons/store/container/signin/signin.effect.ts new file mode 100644 index 0000000..d8b92ad --- /dev/null +++ b/src/app/commons/store/container/signin/signin.effect.ts @@ -0,0 +1,72 @@ +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +import { Effect, Actions, ofType } from '@ngrx/effects'; + +import { map, tap } from 'rxjs/operators'; + +import { CookieService } from 'ngx-cookie-service'; +import { RPCService } from '@loafer/ng-rpc'; + +import { + SigninSuccess, + SigninCookieSuccess, + ActionType as AuthActionType, +} from '@overflow/shared/auth/store/container/auth'; + +import { + SigninRedirect, + ActionType, +} from './signin.action'; + +import { DomainMember } from '@overflow/commons-typescript/model/domain'; + + +@Injectable() +export class Effects { + + constructor( + private actions$: Actions, + private rpcService: RPCService, + private cookieService: CookieService, + private router: Router + ) { } + + @Effect({ dispatch: false }) + signinSuccess$ = this.actions$.pipe( + ofType(AuthActionType.SigninSuccess), + map((action: SigninSuccess) => action.payload), + tap((info: {authToken: string, domainMember: DomainMember, returnURL: string}) => { + const expires = new Date(); + expires.setDate(expires.getDate() + 1); + this.cookieService.set('authToken', info.authToken, expires, '/'); + const queryString = `authToken=${info.authToken}`; + this.rpcService.connect(queryString); + + this.router.navigateByUrl(info.returnURL); + }) + ); + + @Effect({ dispatch: false }) + signinCookieSuccess$ = this.actions$.pipe( + ofType(AuthActionType.SigninCookieSuccess), + map((action: SigninCookieSuccess) => action.payload), + tap((info: {domainMember: DomainMember, returnURL: string}) => { + const authToken = this.cookieService.get('authToken'); + const queryString = `authToken=${authToken}`; + this.rpcService.connect(queryString); + + this.router.navigateByUrl(info.returnURL); + }) + ); + + @Effect({ dispatch: false }) + signinRedirect$ = this.actions$.pipe( + ofType(ActionType.SigninRedirect), + map((action: SigninRedirect) => action.payload), + tap((info: {returnURL: string}) => { + this.router.navigate(['/auth/signin'], {queryParams: {returnURL: info.returnURL}}); + }) + ); + +} diff --git a/src/app/commons/store/index.ts b/src/app/commons/store/index.ts index 64ea21e..67a90b3 100644 --- a/src/app/commons/store/index.ts +++ b/src/app/commons/store/index.ts @@ -1,6 +1,6 @@ import { ActionReducerMap } from '@ngrx/store'; -import * as SigninInitStore from './signin-init'; +import * as SigninContainerStore from './container/signin'; export interface State { } @@ -9,5 +9,5 @@ export const REDUCERS: ActionReducerMap = { }; export const EFFECTS = [ - SigninInitStore.Effects, + SigninContainerStore.Effects, ]; diff --git a/src/app/commons/store/signin-init/index.ts b/src/app/commons/store/signin-init/index.ts deleted file mode 100644 index 3ac331f..0000000 --- a/src/app/commons/store/signin-init/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './signin-init.effect'; diff --git a/src/app/commons/store/signin-init/signin-init.effect.ts b/src/app/commons/store/signin-init/signin-init.effect.ts deleted file mode 100644 index 368c51d..0000000 --- a/src/app/commons/store/signin-init/signin-init.effect.ts +++ /dev/null @@ -1,68 +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 { CookieService } from 'ngx-cookie-service'; - -import { RPCService } from '@loafer/ng-rpc'; - -import { - SigninSuccess, - SigninCookieSuccess, - ActionType, -} from '@overflow/member/store/auth'; - -@Injectable() -export class Effects { - - constructor( - private actions$: Actions, - private rpcService: RPCService, - private cookieService: CookieService, - ) { } - - @Effect({ dispatch: false }) - signinSuccess$ = this.actions$ - .ofType(ActionType.SigninSuccess) - .map((action: SigninSuccess) => action.payload) - .do( - (result) => { - const authToken = result.authToken; - // console.log(`authToken: ${authToken}`); - - const expires = new Date(); - expires.setDate(expires.getDate() + 1); - this.cookieService.set('authToken', authToken, expires, '/'); - - const queryString = `authToken=${authToken}`; - - this.rpcService.connect(queryString); - } - ); - - @Effect({ dispatch: false }) - signinCookieSuccess$ = this.actions$ - .ofType(ActionType.SigninCookieSuccess) - .map((action: SigninCookieSuccess) => action.payload) - .do( - (result) => { - const authToken = this.cookieService.get('authToken'); - // console.log(`authToken: ${authToken}`); - const queryString = `authToken=${authToken}`; - - this.rpcService.connect(queryString); - } - ); -} From e1300b568928ba7e06a50612d17821dad410e432 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 28 May 2018 19:10:59 +0900 Subject: [PATCH 3/3] ing --- .../signin/{signin.action.ts => app-signin.action.ts} | 0 .../{signin.effect.spec.ts => app-signin.effect.spec.ts} | 4 ++-- .../signin/{signin.effect.ts => app-signin.effect.ts} | 2 +- src/app/commons/store/container/signin/index.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/app/commons/store/container/signin/{signin.action.ts => app-signin.action.ts} (100%) rename src/app/commons/store/container/signin/{signin.effect.spec.ts => app-signin.effect.spec.ts} (73%) rename src/app/commons/store/container/signin/{signin.effect.ts => app-signin.effect.ts} (98%) diff --git a/src/app/commons/store/container/signin/signin.action.ts b/src/app/commons/store/container/signin/app-signin.action.ts similarity index 100% rename from src/app/commons/store/container/signin/signin.action.ts rename to src/app/commons/store/container/signin/app-signin.action.ts diff --git a/src/app/commons/store/container/signin/signin.effect.spec.ts b/src/app/commons/store/container/signin/app-signin.effect.spec.ts similarity index 73% rename from src/app/commons/store/container/signin/signin.effect.spec.ts rename to src/app/commons/store/container/signin/app-signin.effect.spec.ts index 2736e83..30b413f 100644 --- a/src/app/commons/store/container/signin/signin.effect.spec.ts +++ b/src/app/commons/store/container/signin/app-signin.effect.spec.ts @@ -1,8 +1,8 @@ import { TestBed, inject } from '@angular/core/testing'; -import { Effects } from './signin.effect'; +import { Effects } from './app-signin.effect'; -describe('signin-container.Effects', () => { +describe('app-signin-container.Effects', () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [Effects] diff --git a/src/app/commons/store/container/signin/signin.effect.ts b/src/app/commons/store/container/signin/app-signin.effect.ts similarity index 98% rename from src/app/commons/store/container/signin/signin.effect.ts rename to src/app/commons/store/container/signin/app-signin.effect.ts index d8b92ad..c83dbe5 100644 --- a/src/app/commons/store/container/signin/signin.effect.ts +++ b/src/app/commons/store/container/signin/app-signin.effect.ts @@ -17,7 +17,7 @@ import { import { SigninRedirect, ActionType, -} from './signin.action'; +} from './app-signin.action'; import { DomainMember } from '@overflow/commons-typescript/model/domain'; diff --git a/src/app/commons/store/container/signin/index.ts b/src/app/commons/store/container/signin/index.ts index 3a90828..a2747c0 100644 --- a/src/app/commons/store/container/signin/index.ts +++ b/src/app/commons/store/container/signin/index.ts @@ -1,2 +1,2 @@ -export * from './signin.action'; -export * from './signin.effect'; +export * from './app-signin.action'; +export * from './app-signin.effect';