Merge branch 'master' of https://git.loafle.net/overflow/overflow-webapp
This commit is contained in:
commit
a8e92b170d
|
@ -5,7 +5,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||||
|
|
||||||
import { AuthGuard } from './guard/auth.guard';
|
// import { AuthGuard } from './guard/auth.guard';
|
||||||
|
|
||||||
import { MemberStoreModule } from './member-store.module';
|
import { MemberStoreModule } from './member-store.module';
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.name}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.displayName}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="ip">
|
<ng-container matColumnDef="ip">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> IP </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> IP </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.ip}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.host.ip}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="os">
|
<ng-container matColumnDef="os">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> OS </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> OS </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.os}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.host.os.meta}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="cidr">
|
<ng-container matColumnDef="cidr">
|
||||||
|
@ -23,17 +23,17 @@
|
||||||
|
|
||||||
<ng-container matColumnDef="targetCnt">
|
<ng-container matColumnDef="targetCnt">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Targets </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Targets </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.targetCnt}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.targets.length}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="date">
|
<ng-container matColumnDef="date">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Date </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> Date </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.date}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.authorizeDate.toLocaleString()}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="authBy">
|
<ng-container matColumnDef="authBy">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> AuthBy </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> AuthBy </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let element"> {{element.authBy}} </mat-cell>
|
<mat-cell *matCellDef="let element"> {{element.authorizeMember.name}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns" ></mat-header-row>
|
<mat-header-row *matHeaderRowDef="displayedColumns" ></mat-header-row>
|
||||||
|
|
|
@ -2,17 +2,7 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
|
||||||
import { MatTableDataSource, MatSort } from '@angular/material';
|
import { MatTableDataSource, MatSort } from '@angular/material';
|
||||||
import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
|
import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { Probe } from '../../model';
|
||||||
export interface Probe {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
ip: string;
|
|
||||||
os: string;
|
|
||||||
cidr: string;
|
|
||||||
targetCnt: number;
|
|
||||||
date: string;
|
|
||||||
authBy: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -35,14 +25,24 @@ export class ListComponent implements OnInit, AfterContentInit {
|
||||||
const data: Probe[] = new Array();
|
const data: Probe[] = new Array();
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
const p: Probe = {
|
const p: Probe = {
|
||||||
id: String('id' + i),
|
id: i,
|
||||||
name: String('name' + i),
|
displayName: String('displayName' + i),
|
||||||
ip: String('ip' + i),
|
host: {
|
||||||
os: String('os' + i),
|
ip: i,
|
||||||
|
os: {
|
||||||
|
meta: 'blahblahblah'
|
||||||
|
},
|
||||||
|
},
|
||||||
cidr: String('cidr' + i),
|
cidr: String('cidr' + i),
|
||||||
targetCnt: i,
|
targets: [
|
||||||
date: String('date' + i),
|
{
|
||||||
authBy: String('insanity')
|
id: i,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
authorizeDate: new Date(),
|
||||||
|
authorizeMember: {
|
||||||
|
'name': String('insanity')
|
||||||
|
},
|
||||||
};
|
};
|
||||||
data.push(p);
|
data.push(p);
|
||||||
}
|
}
|
||||||
|
|
24
src/packages/probe/probe-store.module.ts
Normal file
24
src/packages/probe/probe-store.module.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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 { }
|
3
src/packages/probe/probe.constant.ts
Normal file
3
src/packages/probe/probe.constant.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export const MODULE = {
|
||||||
|
name: 'probe'
|
||||||
|
};
|
|
@ -4,12 +4,15 @@ import { MaterialModule } from 'app/commons/ui/material/material.module';
|
||||||
import { InfoTableModule } from 'app/commons/component/info-table/info-table.module';
|
import { InfoTableModule } from 'app/commons/component/info-table/info-table.module';
|
||||||
|
|
||||||
import { COMPONENTS } from './component';
|
import { COMPONENTS } from './component';
|
||||||
|
import { ProbeStoreModule } from './probe-store.module';
|
||||||
|
import { SERVICES } from './service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
InfoTableModule,
|
InfoTableModule,
|
||||||
|
ProbeStoreModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
COMPONENTS,
|
COMPONENTS,
|
||||||
|
@ -17,5 +20,8 @@ import { COMPONENTS } from './component';
|
||||||
exports: [
|
exports: [
|
||||||
COMPONENTS,
|
COMPONENTS,
|
||||||
],
|
],
|
||||||
|
providers: [
|
||||||
|
SERVICES,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class ProbeModule { }
|
export class ProbeModule { }
|
||||||
|
|
|
@ -5,6 +5,10 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { RPCService } from 'packages/commons/service/rpc.service';
|
import { RPCService } from 'packages/commons/service/rpc.service';
|
||||||
|
|
||||||
|
import { Domain } from 'packages/domain/model';
|
||||||
|
|
||||||
|
import { Probe } from '../model';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ProbeService {
|
export class ProbeService {
|
||||||
|
@ -15,4 +19,14 @@ export class ProbeService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readAllByDomain(domain: Domain): Observable<Probe[]> {
|
||||||
|
return this.rpcService.call<Probe[]>('ProbeService.readAllByDomain', domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public read(id: string): Observable<Probe> {
|
||||||
|
const param = {
|
||||||
|
id: id,
|
||||||
|
};
|
||||||
|
return this.rpcService.call<Probe>('ProbeService.read', param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
37
src/packages/probe/store/detail/detail.action.ts
Normal file
37
src/packages/probe/store/detail/detail.action.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { Action } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
|
||||||
|
export enum ActionType {
|
||||||
|
Read = '[probe.detail] Read',
|
||||||
|
ReadSuccess = '[probe.detail] ReadSuccess',
|
||||||
|
ReadFailure = '[probe.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: Probe) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReadFailure implements Action {
|
||||||
|
readonly type = ActionType.ReadFailure;
|
||||||
|
|
||||||
|
constructor(public payload: ErrorResponse) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type Actions =
|
||||||
|
| Read
|
||||||
|
| ReadSuccess
|
||||||
|
| ReadFailure
|
||||||
|
;
|
15
src/packages/probe/store/detail/detail.effect.spec.ts
Normal file
15
src/packages/probe/store/detail/detail.effect.spec.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
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();
|
||||||
|
}));
|
||||||
|
});
|
49
src/packages/probe/store/detail/detail.effect.ts
Normal file
49
src/packages/probe/store/detail/detail.effect.ts
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||||
|
import { Action } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { of } from 'rxjs/observable/of';
|
||||||
|
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/do';
|
||||||
|
import 'rxjs/add/operator/exhaustMap';
|
||||||
|
import 'rxjs/add/operator/switchMap';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
import 'rxjs/add/operator/take';
|
||||||
|
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
import { ProbeService } from '../../service/probe.service';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Read,
|
||||||
|
ReadFailure,
|
||||||
|
ReadSuccess,
|
||||||
|
ActionType
|
||||||
|
} from './detail.action';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class Effects {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actions$: Actions,
|
||||||
|
private probeService: ProbeService,
|
||||||
|
private router: Router
|
||||||
|
) { }
|
||||||
|
|
||||||
|
@Effect()
|
||||||
|
read$: Observable<Action> = this.actions$
|
||||||
|
.ofType(ActionType.Read)
|
||||||
|
.map((action: Read) => action.payload)
|
||||||
|
.switchMap(payload => this.probeService.read(payload.id))
|
||||||
|
.map(probe => {
|
||||||
|
return new ReadSuccess(probe);
|
||||||
|
})
|
||||||
|
.catch((error: ErrorResponse) => {
|
||||||
|
return of(new ReadFailure(error));
|
||||||
|
});
|
||||||
|
}
|
50
src/packages/probe/store/detail/detail.reducer.ts
Normal file
50
src/packages/probe/store/detail/detail.reducer.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Read,
|
||||||
|
ReadFailure,
|
||||||
|
ReadSuccess,
|
||||||
|
ActionType,
|
||||||
|
Actions,
|
||||||
|
} from './detail.action';
|
||||||
|
|
||||||
|
import {
|
||||||
|
State,
|
||||||
|
initialState,
|
||||||
|
} from './detail.state';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
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,
|
||||||
|
probe: action.payload,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case ActionType.ReadFailure: {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
error: action.payload,
|
||||||
|
isPending: false,
|
||||||
|
probe: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/packages/probe/store/detail/detail.state.ts
Normal file
19
src/packages/probe/store/detail/detail.state.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
error: ErrorResponse | null;
|
||||||
|
isPending: boolean;
|
||||||
|
probe: Probe | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialState: State = {
|
||||||
|
error: null,
|
||||||
|
isPending: false,
|
||||||
|
probe: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getProbe = (state: State) => state.probe;
|
||||||
|
export const getError = (state: State) => state.error;
|
||||||
|
export const isPending = (state: State) => state.isPending;
|
4
src/packages/probe/store/detail/index.ts
Normal file
4
src/packages/probe/store/detail/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './detail.action';
|
||||||
|
export * from './detail.effect';
|
||||||
|
export * from './detail.reducer';
|
||||||
|
export * from './detail.state';
|
17
src/packages/probe/store/index.ts
Normal file
17
src/packages/probe/store/index.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import * as ProbeListStore from './list';
|
||||||
|
import * as ProbeDetailStore from './detail';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
list: ProbeListStore.State;
|
||||||
|
detail: ProbeDetailStore.State;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const REDUCERS = {
|
||||||
|
list: ProbeListStore.reducer,
|
||||||
|
detail: ProbeDetailStore.reducer,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const EFFECTS = [
|
||||||
|
ProbeListStore.Effects,
|
||||||
|
ProbeDetailStore.Effects,
|
||||||
|
];
|
4
src/packages/probe/store/list/index.ts
Normal file
4
src/packages/probe/store/list/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './list.action';
|
||||||
|
export * from './list.effect';
|
||||||
|
export * from './list.reducer';
|
||||||
|
export * from './list.state';
|
38
src/packages/probe/store/list/list.action.ts
Normal file
38
src/packages/probe/store/list/list.action.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import { Action } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Domain } from 'packages/domain/model';
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
|
||||||
|
export enum ActionType {
|
||||||
|
ReadAllByDomain = '[probe.list] ReadAllByDomain',
|
||||||
|
ReadAllByDomainSuccess = '[probe.list] ReadAllByDomainSuccess',
|
||||||
|
ReadAllByDomainFailure = '[probe.list] ReadAllByDomainFailure',
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReadAllByDomain implements Action {
|
||||||
|
readonly type = ActionType.ReadAllByDomain;
|
||||||
|
|
||||||
|
constructor(public payload: Domain) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReadAllByDomainSuccess implements Action {
|
||||||
|
readonly type = ActionType.ReadAllByDomainSuccess;
|
||||||
|
|
||||||
|
constructor(public payload: Probe[]) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReadAllByDomainFailure implements Action {
|
||||||
|
readonly type = ActionType.ReadAllByDomainFailure;
|
||||||
|
|
||||||
|
constructor(public payload: ErrorResponse) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type Actions =
|
||||||
|
| ReadAllByDomain
|
||||||
|
| ReadAllByDomainSuccess
|
||||||
|
| ReadAllByDomainFailure
|
||||||
|
;
|
15
src/packages/probe/store/list/list.effect.spec.ts
Normal file
15
src/packages/probe/store/list/list.effect.spec.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { TestBed, inject } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Effects } from './list.effect';
|
||||||
|
|
||||||
|
describe('ProbeList.Effects', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [Effects]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([Effects], (effects: Effects) => {
|
||||||
|
expect(effects).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
51
src/packages/probe/store/list/list.effect.ts
Normal file
51
src/packages/probe/store/list/list.effect.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
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 { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Domain } from 'packages/domain/model';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
import { ProbeService } from '../../service/probe.service';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ReadAllByDomain,
|
||||||
|
ReadAllByDomainFailure,
|
||||||
|
ReadAllByDomainSuccess,
|
||||||
|
ActionType
|
||||||
|
} from './list.action';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class Effects {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actions$: Actions,
|
||||||
|
private probeService: ProbeService,
|
||||||
|
private router: Router
|
||||||
|
) { }
|
||||||
|
|
||||||
|
@Effect()
|
||||||
|
readAllByDomain$: Observable<Action> = this.actions$
|
||||||
|
.ofType(ActionType.ReadAllByDomain)
|
||||||
|
.map((action: ReadAllByDomain) => action.payload)
|
||||||
|
.switchMap(payload => this.probeService.readAllByDomain(payload))
|
||||||
|
.map(probes => {
|
||||||
|
return new ReadAllByDomainSuccess(probes);
|
||||||
|
})
|
||||||
|
.catch((error: ErrorResponse) => {
|
||||||
|
return of(new ReadAllByDomainFailure(error));
|
||||||
|
});
|
||||||
|
}
|
50
src/packages/probe/store/list/list.reducer.ts
Normal file
50
src/packages/probe/store/list/list.reducer.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ReadAllByDomain,
|
||||||
|
ReadAllByDomainFailure,
|
||||||
|
ReadAllByDomainSuccess,
|
||||||
|
ActionType,
|
||||||
|
Actions,
|
||||||
|
} from './list.action';
|
||||||
|
|
||||||
|
import {
|
||||||
|
State,
|
||||||
|
initialState,
|
||||||
|
} from './list.state';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
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,
|
||||||
|
probes: action.payload,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case ActionType.ReadAllByDomainFailure: {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
error: action.payload,
|
||||||
|
isPending: false,
|
||||||
|
probes: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/packages/probe/store/list/list.state.ts
Normal file
19
src/packages/probe/store/list/list.state.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { ErrorResponse } from 'packages/commons/service/error-response';
|
||||||
|
|
||||||
|
import { Probe } from '../../model';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
error: ErrorResponse | null;
|
||||||
|
isPending: boolean;
|
||||||
|
probes: Probe[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialState: State = {
|
||||||
|
error: null,
|
||||||
|
isPending: false,
|
||||||
|
probes: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getProbes = (state: State) => state.probes;
|
||||||
|
export const getError = (state: State) => state.error;
|
||||||
|
export const isPending = (state: State) => state.isPending;
|
|
@ -403,6 +403,12 @@ amqplib@^0.5.2:
|
||||||
readable-stream "1.x >=1.1.9"
|
readable-stream "1.x >=1.1.9"
|
||||||
safe-buffer "^5.0.1"
|
safe-buffer "^5.0.1"
|
||||||
|
|
||||||
|
angular-l10n@^4.1.5:
|
||||||
|
version "4.1.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/angular-l10n/-/angular-l10n-4.1.5.tgz#4b65cdb819be4daaaadc006ecf873d6ed1fd0fd4"
|
||||||
|
dependencies:
|
||||||
|
tslib "^1.7.1"
|
||||||
|
|
||||||
ansi-html@0.0.7:
|
ansi-html@0.0.7:
|
||||||
version "0.0.7"
|
version "0.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
|
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user