Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2018-05-28 19:46:50 +09:00
commit cdcd5b8f0b
37 changed files with 1997 additions and 2570 deletions

View File

@ -11,8 +11,8 @@ 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 } from '@overflow/commons-typescript/model/domain';
import { AuthSelector } from '@overflow/member/store';
import { Domain, DomainMember } from '@overflow/commons-typescript/model/domain';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
// import { sensorListSelector } from '@overflow/sensor/store';
@ -68,8 +68,8 @@ export class MapComponent implements OnInit, AfterContentInit {
ngAfterContentInit() {
this.listStore.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
this.listStore.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
// const pageParams: PageParams = {
// pageNo: '0',

View File

@ -2,11 +2,10 @@ import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { AfterContentInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core/src/metadata/lifecycle_hooks';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Domain } from '@overflow/commons-typescript/model/domain';
import { Domain, DomainMember } from '@overflow/commons-typescript/model/domain';
import * as NotificationEntityStore from '../../store/entity/notification';
import { NotificationEntitySelector } from '../../store/';
import { AuthSelector } from '../../../member/store';
import { Member } from '@overflow/commons-typescript/model/member';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
import { Page } from '@overflow/commons-typescript/model/commons/Page';
import { Notification } from '@overflow/commons-typescript/model/notification';
@ -38,37 +37,34 @@ export class NotificationBadgeContainerComponent implements OnInit, OnChanges {
}
getNotifications() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
const pageParams: PageParams = {
pageNo: 0,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member, pageParams }));
},
(error) => {
console.log(error);
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member: domainMember.member, pageParams }));
}
);
}
markAllasRead() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
const pageParams: PageParams = {
pageNo: 0,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending'
};
this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member, pageParams }));
},
(error) => {
console.log(error);
}
);
// this.store.select(AuthSelector.select('member')).subscribe(
// (member: Member) => {
// const pageParams: PageParams = {
// pageNo: 0,
// countPerPage: 10,
// sortCol: 'id',
// sortDirection: 'descending'
// };
// this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member, pageParams }));
// },
// (error) => {
// console.log(error);
// }
// );
}
onSelect(notification: Notification) {

View File

@ -2,15 +2,15 @@ import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { AfterContentInit, OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Domain } from '@overflow/commons-typescript/model/domain';
import * as NotificationEntityStore from '../../store/entity/notification';
import { NotificationEntitySelector } from '../../store/';
import { AuthSelector } from '../../../member/store';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { Member } from '@overflow/commons-typescript/model/member';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
import { Page } from '@overflow/commons-typescript/model/commons/Page';
import { Notification } from '@overflow/commons-typescript/model/notification';
import { ActivatedRoute } from '@angular/router';
import { DomainMember } from '@overflow/commons-typescript/model/domain';
@Component({
selector: 'of-notification-container',
@ -40,35 +40,29 @@ export class NotificationListContainerComponent implements OnInit {
}
getNotifications() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
const pageParams: PageParams = {
pageNo: this.pageNo,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member, pageParams }));
},
(error) => {
console.log(error);
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member: domainMember.member, pageParams }));
}
);
}
markAllasRead() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
const pageParams: PageParams = {
pageNo: this.pageNo,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending'
sortDirection: 'descending',
};
this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member, pageParams }));
},
(error) => {
console.log(error);
this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member: domainMember.member, pageParams }));
}
);
}

View File

@ -0,0 +1,2 @@
export * from './probe-selector.reducer';
export * from './probe-selector.state';

View File

@ -0,0 +1,31 @@
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;
}
}
}

View File

@ -0,0 +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 const probeSelectorContainerAdapter = createEntityAdapter<ProbeHost, RPCClientError>();
export interface State extends EntityState<ProbeHost, RPCClientError> {
pending: boolean;
}
export const initialState: State = probeSelectorContainerAdapter.getInitialState({
pending: false,
});
export function getSelectors<S>(selector: Selector<any, State>) {
return {
...probeSelectorContainerAdapter.getSelectors(selector),
selectPending: createSelector(selector, (state: State) => state.pending),
};
}

View File

@ -11,15 +11,18 @@ 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_detail_container: ProbeDetailContainerStore.reducer,
probe_selector_container: ProbeSelectorContainerStore.reducer
};
export const EFFECTS = [
@ -37,3 +40,8 @@ export const ProbeDetailContainerSelector = ProbeDetailContainerStore.getSelecto
selectState,
(state: State) => state.probe_detail_container
));
export const ProbeSelectorContainerSelector = ProbeSelectorContainerStore.getSelectors(createSelector(
selectState,
(state: State) => state.probe_selector_container
));

View File

@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ConfirmationService } from 'primeng/primeng';
import { Store, select } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc';
import * as DetailStore from '../../store/detail';
// import { sensorSelector } from '../../store';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import { Subscription } from 'rxjs/Subscription';

View File

@ -4,11 +4,11 @@ import { Store, select } from '@ngrx/store';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import * as SensorEntityStore from '../store/entity/sensor';
import { SensorEntitySelector, SensorPageSelector } from '../store';
import { AuthSelector } from '../../member/store';
import { Domain } from '@overflow/commons-typescript/model/domain';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
import { Page } from '@overflow/commons-typescript/model/commons/Page';
import { Target } from '@overflow/commons-typescript/model/target';
import { DomainMember } from '@overflow/commons-typescript/model/domain';
@Component({
selector: 'of-sensor-list-container',
@ -19,26 +19,27 @@ export class SensorListContainerComponent implements OnInit {
page$: Observable<Page<Sensor>>;
@Output() select = new EventEmitter<Sensor>();
@Output() addSensor = new EventEmitter();
pageNo: number;
constructor(private store: Store<SensorEntityStore.State>) {
this.page$ = store.pipe(select(SensorPageSelector));
constructor(private store: Store<any>) {
}
ngOnInit() {
this.store.select(AuthSelector.select('domain')).subscribe(
(domain: Domain) => {
this.page$ = this.store.pipe(select(SensorPageSelector));
this.getSensors();
}
getSensors() {
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
const pageParams: PageParams = {
pageNo: 0,
pageNo: this.pageNo,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new SensorEntityStore.ReadAllByDomainID({domainID : domain.id, pageParams}));
},
(error) => {
console.log(error);
this.store.dispatch(new SensorEntityStore.ReadAllByDomainID({ domainID: domainMember.domain.id, pageParams }));
}
);
}
}

View File

@ -11,7 +11,7 @@ import { SensorEntitySelector } from '../store';
})
export class SensorSettingContainerComponent {
constructor(private store: Store<SensorEntityStore.State>) {
constructor(private store: Store<any>) {
}
}

View File

@ -0,0 +1,2 @@
export * from './sensor-list.reducer';
export * from './sensor-list.state';

View File

@ -1,13 +1,11 @@
import {
ActionType,
Actions,
} from './sensor.action';
import { ActionType, Actions } from '../../entity/sensor';
import {
State,
initialState,
sensorAdapter,
} from './sensor.state';
sensorListContainerAdapter,
} from './sensor-list.state';
import { Probe } from '@overflow/commons-typescript/model/probe';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
@ -19,11 +17,11 @@ export function reducer(state = initialState, action: Actions): State {
}
case ActionType.ReadAllByDomainIDSuccess: {
return sensorAdapter.setAll(action.payload.content, {...state, page: action.payload});
return sensorListContainerAdapter.setAll(action.payload.content, {...state, page: action.payload});
}
case ActionType.ReadAllByDomainIDFailure: {
return sensorAdapter.setError(action.payload, state);
return sensorListContainerAdapter.setError(action.payload, state);
}
case ActionType.Read: {
@ -34,11 +32,11 @@ export function reducer(state = initialState, action: Actions): State {
}
case ActionType.ReadSuccess: {
return sensorAdapter.setOne(action.payload, {...state, page: null});
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null});
}
case ActionType.ReadFailure: {
return sensorAdapter.setError(action.payload, state);
return sensorListContainerAdapter.setError(action.payload, state);
}
case ActionType.Modify: {
@ -49,15 +47,11 @@ export function reducer(state = initialState, action: Actions): State {
}
case ActionType.ModifySuccess: {
return sensorAdapter.upsertOne(action.payload, state);
return sensorListContainerAdapter.upsertOne(action.payload, state);
}
case ActionType.ModifyFailure: {
return sensorAdapter.setError(action.payload, state);
}
default: {
return state;
return sensorListContainerAdapter.setError(action.payload, state);
}
}
}

View File

@ -1,24 +1,23 @@
import { RPCClientError } from '@loafer/ng-rpc';
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
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';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export const sensorAdapter = createEntityAdapter<Sensor, RPCClientError>();
export const sensorListContainerAdapter = createEntityAdapter<Sensor, RPCClientError>();
export interface State extends EntityState<Sensor, RPCClientError> {
page: Page<Sensor>;
pending: boolean;
}
export const initialState: State = {
ids : [],
entities : null,
export const initialState: State = sensorListContainerAdapter.getInitialState({
page: null,
error: null,
};
pending: false,
});
export function getSelectors<S>(selector: Selector<any, State>) {
return sensorAdapter.getSelectors(selector);
export function getSelectors(selector: Selector<any, State>) {
return {
...sensorListContainerAdapter.getSelectors(selector),
selectPending: createSelector(selector, (state: State) => state.pending),
};
}

View File

@ -1,37 +0,0 @@
import { Action } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export enum ActionType {
Read = '[sensor.detail] Read',
ReadSuccess = '[sensor.detail] ReadSuccess',
ReadFailure = '[sensor.detail] 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: Sensor) {}
}
export class ReadFailure implements Action {
readonly type = ActionType.ReadFailure;
constructor(public payload: RPCClientError) {}
}
export type Actions =
| Read
| ReadSuccess
| ReadFailure
;

View File

@ -1,15 +0,0 @@
import { TestBed, inject } from '@angular/core/testing';
import { Effects } from './detail.effect';
describe('ProbeDetail.Effects', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [Effects]
});
});
it('should be created', inject([Effects], (effects: Effects) => {
expect(effects).toBeTruthy();
}));
});

View File

@ -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/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 { SensorService } from '../../service/sensor.service';
import {
Read,
ReadFailure,
ReadSuccess,
ActionType
} from './detail.action';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private sensorService: SensorService,
private router: Router
) { }
@Effect()
read$: Observable<Action> = this.actions$
.ofType(ActionType.Read)
.map((action: Read) => action.payload)
.switchMap(payload => this.sensorService.read(payload.id))
.map(sensor => {
return new ReadSuccess(sensor);
})
.catch((error: RPCClientError) => {
return of(new ReadFailure(error));
});
}

View File

@ -1,49 +0,0 @@
import {
Read,
ReadFailure,
ReadSuccess,
ActionType,
Actions,
} from './detail.action';
import {
State,
initialState,
} from './detail.state';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
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,
sensor: action.payload,
};
}
case ActionType.ReadFailure: {
return {
...state,
error: action.payload,
isPending: false,
sensor: null,
};
}
default: {
return state;
}
}
}

View File

@ -1,14 +0,0 @@
import { RPCClientError } from '@loafer/ng-rpc';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export interface State {
error: RPCClientError | null;
isPending: boolean;
sensor: Sensor | null;
}
export const initialState: State = {
error: null,
isPending: false,
sensor: null,
};

View File

@ -1,4 +0,0 @@
export * from './detail.action';
export * from './detail.effect';
export * from './detail.reducer';
export * from './detail.state';

View File

@ -1,4 +1,2 @@
export * from './sensor.action';
export * from './sensor.effect';
export * from './sensor.reducer';
export * from './sensor.state';

View File

@ -1,21 +1,19 @@
import {
createSelector,
createFeatureSelector,
ActionReducerMap,
} from '@ngrx/store';
import { StateSelector } from '@overflow/core/ngrx/store';
import { MODULE } from '../sensor.constant';
import * as SensorEntityStore from './entity/sensor';
import * as SensorListContainerStore from './container/sensor-list';
export interface State {
sensor: SensorEntityStore.State;
sensor_list: SensorListContainerStore.State;
}
export const REDUCERS = {
sensor: SensorEntityStore.reducer,
sensor: SensorListContainerStore.reducer,
};
export const EFFECTS = [
@ -24,14 +22,12 @@ export const EFFECTS = [
export const selectState = createFeatureSelector<State>(MODULE.name);
export const SensorEntitySelector = SensorEntityStore.getSelectors(createSelector(
export const SensorEntitySelector = SensorListContainerStore.getSelectors(createSelector(
selectState,
(state: State) => state.sensor
(state: State) => state.sensor_list
));
export const SensorPageSelector = createSelector(
selectState,
(state: State) => state.sensor.page
(state: State) => state.sensor_list.page
);

View File

@ -1,4 +0,0 @@
export * from './list.action';
export * from './list.effect';
export * from './list.reducer';
export * from './list.state';

View File

@ -1,86 +0,0 @@
import { Action } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc';
import { Domain } from '@overflow/commons-typescript/model/domain';
// import { PageParams, Page } from 'app/commons/model';
import { Target } from '@overflow/commons-typescript/model/target';
export enum ActionType {
ReadAllByDomain = '[Sensor.ReadAllByDomain] ReadAllByDomain',
ReadAllByDomainSuccess = '[Sensor.ReadAllByDomainSuccess] ReadAllByDomainSuccess',
ReadAllByDomainFailure = '[Sensor.ReadAllByDomainFailure] ReadAllByDomainFailure',
ReadAllByInfra = '[Sensor.ReadAllByInfra] ReadAllByInfra',
ReadAllByInfraSuccess = '[Sensor.ReadAllByInfraSuccess] ReadAllByInfraSuccess',
ReadAllByInfraFailure = '[Sensor.ReadAllByInfraFailure] ReadAllByInfraFailure',
ReadAllByTarget = '[Sensor.ReadAllByTarget] ReadAllByTarget',
ReadAllByTargetSuccess = '[Sensor.ReadAllByTargetSuccess] ReadAllByTargetSuccess',
ReadAllByTargetFailure = '[Sensor.ReadAllByTargetFailure] ReadAllByTargetFailure',
}
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 ReadAllByInfra implements Action {
readonly type = ActionType.ReadAllByInfra;
// constructor(public payload: { id: string, pageParams: PageParams}) {}
}
export class ReadAllByInfraSuccess implements Action {
readonly type = ActionType.ReadAllByInfraSuccess;
// constructor(public payload: Page) {}
}
export class ReadAllByInfraFailure implements Action {
readonly type = ActionType.ReadAllByInfraFailure;
constructor(public payload: RPCClientError) {}
}
//
export class ReadAllByTarget implements Action {
readonly type = ActionType.ReadAllByTarget;
// constructor(public payload: { target: Target, pageParams: PageParams}) {}
}
export class ReadAllByTargetSuccess implements Action {
readonly type = ActionType.ReadAllByTargetSuccess;
// constructor(public payload: Page) {}
}
export class ReadAllByTargetFailure implements Action {
readonly type = ActionType.ReadAllByTargetFailure;
constructor(public payload: RPCClientError) {}
}
export type Actions =
| ReadAllByDomain
| ReadAllByDomainSuccess
| ReadAllByDomainFailure
| ReadAllByInfra
| ReadAllByInfraSuccess
| ReadAllByInfraFailure
| ReadAllByTarget
| ReadAllByTargetSuccess
| ReadAllByTargetFailure
;

View File

@ -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/map';
import 'rxjs/add/operator/take';
import { RPCClientError } from '@loafer/ng-rpc';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import { SensorService } from '../../service/sensor.service';
import {
ReadAllByDomain,
ReadAllByDomainSuccess,
ReadAllByDomainFailure,
ReadAllByInfra,
ReadAllByInfraSuccess,
ReadAllByInfraFailure,
ReadAllByTarget,
ReadAllByTargetSuccess,
ReadAllByTargetFailure,
ActionType,
} from './list.action';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private service: SensorService,
private router: Router
) { }
// @Effect()
// readAllByDomain$: Observable<Action> = this.actions$
// .ofType(ActionType.ReadAllByDomain)
// .map((action: ReadAllByDomain) => action.payload)
// .switchMap(payload => this.service.readAllByDomain(payload.domain, payload.pageParams))
// .map(list => {
// return new ReadAllByDomainSuccess(list);
// })
// .catch((error: RPCClientError) => {
// return of(new ReadAllByDomainFailure(error));
// });
// @Effect()
// readAllByInfra$: Observable<Action> = this.actions$
// .ofType(ActionType.ReadAllByInfra)
// .map((action: ReadAllByInfra) => action.payload)
// .switchMap(payload => this.service.readAllByInfra(payload.id, payload.pageParams))
// .map(list => {
// return new ReadAllByInfraSuccess(list);
// })
// .catch((error: RPCClientError) => {
// return of(new ReadAllByInfraFailure(error));
// });
// @Effect()
// readAllByTarget$: Observable<Action> = this.actions$
// .ofType(ActionType.ReadAllByTarget)
// .map((action: ReadAllByTarget) => action.payload)
// .switchMap(payload => this.service.readAllByTarget(payload.target, payload.pageParams))
// .map(list => {
// return new ReadAllByTargetSuccess(list);
// })
// .catch((error: RPCClientError) => {
// return of(new ReadAllByTargetFailure(error));
// });
}

View File

@ -1,96 +0,0 @@
import {
Actions,
ActionType,
} from './list.action';
import {
State,
initialState,
} from './list.state';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.ReadAllByDomain: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.ReadAllByDomainSuccess: {
return {
...state,
error: null,
pending: false,
// page: action.payload
};
}
case ActionType.ReadAllByDomainFailure: {
return {
...state,
error: action.payload,
pending: false,
// page: null,
};
}
case ActionType.ReadAllByInfra: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.ReadAllByInfraSuccess: {
return {
...state,
error: null,
pending: false,
// page: action.payload
};
}
case ActionType.ReadAllByInfraFailure: {
return {
...state,
error: action.payload,
pending: false,
// page: null,
};
}
case ActionType.ReadAllByTarget: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.ReadAllByTargetSuccess: {
return {
...state,
error: null,
pending: false,
// page: action.payload
};
}
case ActionType.ReadAllByTargetFailure: {
return {
...state,
error: action.payload,
pending: false,
// page: null,
};
}
default: {
return state;
}
}
}

View File

@ -1,15 +0,0 @@
import { RPCClientError } from '@loafer/ng-rpc';
// import { Page } from 'app/commons/model';
export interface State {
error: RPCClientError | null;
pending: boolean;
// page: Page | null;
}
export const initialState: State = {
error: null,
pending: false,
// page: null,
};

View File

@ -1,4 +0,0 @@
export * from './regist.action';
export * from './regist.effect';
export * from './regist.reducer';
export * from './regist.state';

View File

@ -1,38 +0,0 @@
import { Action } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc';
import { Domain } from '@overflow/commons-typescript/model/domain';
// import { PageParams, Page } from 'app/commons/model';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import { SensorItem } from '@overflow/commons-typescript/model/sensor-item';
export enum ActionType {
Regist = '[Sensor.Regist] Regist',
RegistSuccess = '[Sensor.RegistSuccess] RegistSuccess',
RegistFailure = '[Sensor.RegistFailure] RegistFailure',
}
export class Regist implements Action {
readonly type = ActionType.Regist;
constructor(public payload: { sensor: Sensor, sensorItems: SensorItem[]}) {}
}
export class RegistSuccess implements Action {
readonly type = ActionType.RegistSuccess;
constructor(public payload: Sensor) {}
}
export class RegistFailure implements Action {
readonly type = ActionType.RegistFailure;
constructor(public payload: RPCClientError) {}
}
export type Actions =
| Regist
| RegistSuccess
| RegistFailure
;

View File

@ -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 { Sensor } from '@overflow/commons-typescript/model/sensor';
import { SensorService } from '../../service/sensor.service';
import {
Regist,
RegistSuccess,
RegistFailure,
ActionType,
} from './regist.action';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private service: SensorService,
private router: Router
) { }
@Effect()
regist$: Observable<Action> = this.actions$
.ofType(ActionType.Regist)
.map((action: Regist) => action.payload)
.switchMap(payload => this.service.registSensorConfig(payload.sensor, payload.sensorItems))
.map(list => {
return new RegistSuccess(list);
})
.catch((error: RPCClientError) => {
return of(new RegistFailure(error));
});
}

View File

@ -1,45 +0,0 @@
import {
Actions,
ActionType,
} from './regist.action';
import {
State,
initialState,
} from './regist.state';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Regist: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.RegistSuccess: {
return {
...state,
error: null,
pending: false,
sensor: action.payload
};
}
case ActionType.RegistFailure: {
return {
...state,
error: action.payload,
pending: false,
sensor: null,
};
}
default: {
return state;
}
}
}

View File

@ -1,16 +0,0 @@
import { RPCClientError } from '@loafer/ng-rpc';
// import { Page } from 'app/commons/model';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export interface State {
error: RPCClientError | null;
pending: boolean;
sensor: Sensor | null;
}
export const initialState: State = {
error: null,
pending: false,
sensor: null,
};

View File

@ -1,4 +0,0 @@
export * from './regist.action';
export * from './regist.effect';
export * from './regist.reducer';
export * from './regist.state';

3636
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ import { AuthGuard } from './commons/guard/auth.guard';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MemberModule } from '@overflow/member/member.module';
import { AuthModule } from '@overflow/shared/auth/auth.module';
@NgModule({
imports: [
@ -28,7 +28,7 @@ import { MemberModule } from '@overflow/member/member.module';
AppRPCModule,
AppRESTModule,
AppLoggerModule,
MemberModule,
AuthModule,
],
declarations: [
AppComponent,

View File

@ -1,7 +1,7 @@
<div class="profile" [ngClass]="{'profile-expanded':active}">
<div class="profile" [ngClass]="{'profile-expanded':active}" *ngIf="member">
<a href="#" (click)="onClick($event)">
<img class="profile-image" src="assets/layout/images/avatar.png" />
<span class="profile-name">{{member.name}}</span>
<span class="profile-name">{{name}}</span>
<i class="material-icons">keyboard_arrow_down</i>
</a>
</div>

View File

@ -1,12 +1,14 @@
import { Component, OnInit } from '@angular/core';
import {trigger, state, transition, style, animate } from '@angular/animations';
import {AppComponent} from '../../../../app.component';
import { trigger, state, transition, style, animate } from '@angular/animations';
import { ActivatedRoute, Router } from '@angular/router';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Member } from '@overflow/commons-typescript/model/member';
import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { AppComponent } from '../../../../app.component';
import { PagesComponent } from '../../../../pages/pages.component';
import {ActivatedRoute, Router} from '@angular/router';
import * as AuthStore from '@overflow/member/store/auth';
import {select, Store} from '@ngrx/store';
import {AuthSelector} from '@overflow/member/store';
import {Member} from '@overflow/commons-typescript/model/member';
@Component({
selector: 'of-inline-profile',
@ -25,32 +27,19 @@ import {Member} from '@overflow/commons-typescript/model/member';
]
})
export class AppInlineProfileComponent implements OnInit {
active: boolean;
member: Member;
// this.store.select(AuthSelector.select('member');
member$: Observable<Member>;
constructor(
public app: PagesComponent,
private activatedRoute: ActivatedRoute,
private router: Router,
private store: Store<AuthStore.State>,
private store: Store<any>,
) {
}
ngOnInit() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
this.member = member;
},
(error) => {
console.log(error);
}
);
this.member$ = this.store.select(AuthContainerSelector.selectDomainMember);
}
onClick(event) {
this.active = !this.active;
setTimeout(() => {