Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e9bb57b893
|
@ -2,6 +2,7 @@
|
|||
<div class="ui-g-6 ui-nopad">
|
||||
<h1>Info</h1>
|
||||
</div>
|
||||
<!-- <p-messages [(value)]="msgs"></p-messages> -->
|
||||
<div class="ui-g-6 nopad" dir="rtl" style="padding-top: 15px">
|
||||
<button class="ui-button-width-fit" *ngIf="!editMode" pButton type="button" label="Edit" (click)="editMode = true"></button>
|
||||
<button class="ui-button-width-fit" *ngIf="editMode" pButton type="button" label="Save" (click)="onEditSave()"></button>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
|
||||
import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
import { MessageService } from 'primeng/components/common/messageservice';
|
||||
|
||||
@Component({
|
||||
selector: 'of-probe-detail',
|
||||
templateUrl: './detail.component.html',
|
||||
// providers: [ConfirmationService, MessageService]
|
||||
providers: [MessageService]
|
||||
})
|
||||
export class ProbeDetailComponent {
|
||||
|
||||
|
@ -15,10 +15,22 @@ export class ProbeDetailComponent {
|
|||
|
||||
editMode = false;
|
||||
|
||||
constructor() {
|
||||
constructor(private messageService: MessageService) {
|
||||
}
|
||||
|
||||
onEditSave() {
|
||||
const displayNameValidation = this.checkValidDisplayName();
|
||||
if (displayNameValidation) {
|
||||
alert(displayNameValidation);
|
||||
return;
|
||||
}
|
||||
|
||||
const descriptionValidation = this.checkValidDescription();
|
||||
if (descriptionValidation) {
|
||||
alert(descriptionValidation);
|
||||
return;
|
||||
}
|
||||
|
||||
this.modify.emit(this.probeHost);
|
||||
this.editMode = false;
|
||||
}
|
||||
|
@ -26,5 +38,29 @@ export class ProbeDetailComponent {
|
|||
onDiscoveryClick() {
|
||||
this.discovery.emit(this.probeHost.id);
|
||||
}
|
||||
|
||||
checkValidDisplayName(): string {
|
||||
const displayName = this.probeHost.probe.displayName;
|
||||
if (displayName.length <= 2 || displayName.length > 20) {
|
||||
return 'displayname length : 3 ~ 20';
|
||||
}
|
||||
const regex = /[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi;
|
||||
if (displayName.match(regex)) {
|
||||
return 'Cannot use special characters.';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
checkValidDescription(): string {
|
||||
const description = this.probeHost.probe.description;
|
||||
if (description.length > 50) {
|
||||
return 'description length : 0 ~ 50';
|
||||
}
|
||||
const regex = /[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi;
|
||||
if (description.match(regex)) {
|
||||
return 'Cannot use special characters.';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { Store, select } from '@ngrx/store';
|
|||
import * as ProbeStore from '../store/entity/probe';
|
||||
import { ProbeSelector } from '../store';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
@Component({
|
||||
selector: 'of-probe-detail-container',
|
||||
|
@ -15,6 +16,7 @@ export class ProbeDetailContainerComponent implements OnInit {
|
|||
@Input() probeHostID;
|
||||
@Output() discovery = new EventEmitter<number>();
|
||||
probeHosts$: Observable<ProbeHost[]>;
|
||||
error$: Observable<RPCClientError>;
|
||||
|
||||
constructor(
|
||||
private store: Store<ProbeStore.State>,
|
||||
|
|
2
@overflow/probe/store/container/probe-list/index.ts
Normal file
2
@overflow/probe/store/container/probe-list/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
export * from './probe-list.reducer';
|
||||
export * from './probe-list.state';
|
|
@ -0,0 +1,36 @@
|
|||
import { ActionType, Actions } from '../../entity/probe';
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './probe-list.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.ReadAllByDomainID: {
|
||||
return {
|
||||
...state,
|
||||
pending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllByDomainIDSuccess: {
|
||||
return {
|
||||
...state,
|
||||
pending: false,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllByDomainIDFailure: {
|
||||
return {
|
||||
...state,
|
||||
pending: true,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface State {
|
||||
pending: boolean;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
pending: false,
|
||||
};
|
|
@ -65,6 +65,21 @@ export function reducer(state = initialState, action: Actions): State {
|
|||
};
|
||||
}
|
||||
|
||||
case ActionType.ModifySuccess: {
|
||||
return {
|
||||
...state,
|
||||
probeHosts: state.probeHosts.map(
|
||||
(probeHost, i) => probeHost.probe.id === action.payload.id ?
|
||||
{
|
||||
...probeHost,
|
||||
probe : action.payload
|
||||
} : probeHost
|
||||
),
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
case ActionType.ModifyFailure: {
|
||||
return {
|
||||
...state,
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
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: RPCClientError) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| Read
|
||||
| ReadSuccess
|
||||
| ReadFailure
|
||||
;
|
|
@ -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();
|
||||
}));
|
||||
});
|
|
@ -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 { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
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: RPCClientError) => {
|
||||
return of(new ReadFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import {
|
||||
Read,
|
||||
ReadFailure,
|
||||
ReadSuccess,
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './detail.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './detail.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.Read: {
|
||||
return {
|
||||
...state,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity';
|
||||
|
||||
export interface State extends EntityState<Probe> {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
probe: Probe | null;
|
||||
}
|
||||
export const adapter: EntityAdapter<Probe> = createEntityAdapter<Probe>();
|
||||
export const initialState: State = adapter.getInitialState({
|
||||
error: null,
|
||||
isPending: false,
|
||||
probe: null,
|
||||
});
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
export * from './detail.action';
|
||||
export * from './detail.effect';
|
||||
export * from './detail.reducer';
|
||||
export * from './detail.state';
|
|
@ -1,4 +0,0 @@
|
|||
export * from './list.action';
|
||||
export * from './list.effect';
|
||||
export * from './list.reducer';
|
||||
export * from './list.state';
|
|
@ -1,38 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
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: RPCClientError) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| ReadAllByDomain
|
||||
| ReadAllByDomainSuccess
|
||||
| ReadAllByDomainFailure
|
||||
;
|
|
@ -1,15 +0,0 @@
|
|||
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();
|
||||
}));
|
||||
});
|
|
@ -1,51 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs/observable/of';
|
||||
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/exhaustMap';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { 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: RPCClientError) => {
|
||||
return of(new ReadAllByDomainFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
import {
|
||||
ReadAllByDomain,
|
||||
ReadAllByDomainFailure,
|
||||
ReadAllByDomainSuccess,
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './list.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './list.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export interface State {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
probes: Probe[] | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
isPending: false,
|
||||
probes: null,
|
||||
};
|
|
@ -1,4 +0,0 @@
|
|||
export * from './modify.action';
|
||||
export * from './modify.effect';
|
||||
export * from './modify.reducer';
|
||||
export * from './modify.state';
|
|
@ -1,45 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export enum ActionType {
|
||||
Modify = '[probe.modify] Modify',
|
||||
ModifyDisplayName = '[probe.modify] ModifyDisplayName',
|
||||
ModifySuccess = '[probe.modify] ModifySuccess',
|
||||
ModifyFailure = '[probe.modify] ModifyFailure',
|
||||
}
|
||||
|
||||
export class Modify implements Action {
|
||||
readonly type = ActionType.Modify;
|
||||
|
||||
constructor(public payload: Probe) {}
|
||||
}
|
||||
|
||||
export class ModifySuccess implements Action {
|
||||
readonly type = ActionType.ModifySuccess;
|
||||
|
||||
constructor(public payload: Probe) {}
|
||||
}
|
||||
|
||||
export class ModifyFailure implements Action {
|
||||
readonly type = ActionType.ModifyFailure;
|
||||
|
||||
constructor(public payload: RPCClientError) {}
|
||||
}
|
||||
|
||||
export class ModifyDisplayName implements Action {
|
||||
readonly type = ActionType.ModifyDisplayName;
|
||||
|
||||
constructor(public payload: {id: string, displayName: string}) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| Modify
|
||||
| ModifySuccess
|
||||
| ModifyFailure
|
||||
| ModifyDisplayName
|
||||
;
|
|
@ -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();
|
||||
}));
|
||||
});
|
|
@ -1,62 +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 { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { ProbeService } from '../../service/probe.service';
|
||||
|
||||
import {
|
||||
Modify,
|
||||
ModifyDisplayName,
|
||||
ModifySuccess,
|
||||
ModifyFailure,
|
||||
ActionType
|
||||
} from './modify.action';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private probeService: ProbeService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
modify$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.Modify)
|
||||
.map((action: Modify) => action.payload)
|
||||
.switchMap(payload => this.probeService.modify(payload))
|
||||
.map(probe => {
|
||||
return new ModifySuccess(probe);
|
||||
})
|
||||
.catch((error: RPCClientError) => {
|
||||
return of(new ModifyFailure(error));
|
||||
});
|
||||
|
||||
@Effect()
|
||||
modifyDisplayName$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.ModifyDisplayName)
|
||||
.map((action: ModifyDisplayName) => action.payload)
|
||||
.switchMap(payload => this.probeService.modifyDisplayName(payload.id, payload.displayName))
|
||||
.map(probe => {
|
||||
return new ModifySuccess(probe);
|
||||
})
|
||||
.catch((error: RPCClientError) => {
|
||||
return of(new ModifyFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
import {
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './modify.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './modify.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.Modify: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ModifySuccess: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: false,
|
||||
modifiedProbe: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ModifyFailure: {
|
||||
return {
|
||||
...state,
|
||||
error: action.payload,
|
||||
isPending: false,
|
||||
modifiedProbe: null,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ModifyDisplayName: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: true,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity';
|
||||
|
||||
export interface State extends EntityState<Probe> {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
modifiedProbe: Probe | null;
|
||||
}
|
||||
export const adapter: EntityAdapter<Probe> = createEntityAdapter<Probe>();
|
||||
export const initialState: State = adapter.getInitialState({
|
||||
error: null,
|
||||
isPending: false,
|
||||
modifiedProbe: null,
|
||||
});
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
export * from './list.action';
|
||||
export * from './list.effect';
|
||||
export * from './list.reducer';
|
||||
export * from './list.state';
|
|
@ -1,38 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
||||
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export enum ActionType {
|
||||
ReadAllByDomain = '[probeHost.list] ReadAllByDomain',
|
||||
ReadAllByDomainSuccess = '[probeHost.list] ReadAllByDomainSuccess',
|
||||
ReadAllByDomainFailure = '[probeHost.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: ProbeHost[]) {}
|
||||
}
|
||||
|
||||
export class ReadAllByDomainFailure implements Action {
|
||||
readonly type = ActionType.ReadAllByDomainFailure;
|
||||
|
||||
constructor(public payload: RPCClientError) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| ReadAllByDomain
|
||||
| ReadAllByDomainSuccess
|
||||
| ReadAllByDomainFailure
|
||||
;
|
|
@ -1,15 +0,0 @@
|
|||
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();
|
||||
}));
|
||||
});
|
|
@ -1,51 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs/observable/of';
|
||||
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/exhaustMap';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
import {
|
||||
ReadAllByDomain,
|
||||
ReadAllByDomainFailure,
|
||||
ReadAllByDomainSuccess,
|
||||
ActionType
|
||||
} from './list.action';
|
||||
import { ProbeHostService } from '../../service/probe-host.service';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private probeHostService: ProbeHostService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
readAllByDomain$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.ReadAllByDomain)
|
||||
.map((action: ReadAllByDomain) => action.payload)
|
||||
.switchMap(payload => this.probeHostService.readAllByDomain(payload))
|
||||
.map(probeHosts => {
|
||||
return new ReadAllByDomainSuccess(probeHosts);
|
||||
})
|
||||
.catch((error: RPCClientError) => {
|
||||
return of(new ReadAllByDomainFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
import {
|
||||
ReadAllByDomain,
|
||||
ReadAllByDomainFailure,
|
||||
ReadAllByDomainSuccess,
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './list.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './list.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
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,
|
||||
probeHosts: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllByDomainFailure: {
|
||||
return {
|
||||
...state,
|
||||
error: action.payload,
|
||||
isPending: false,
|
||||
probeHosts: null,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export interface State {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
probeHosts: ProbeHost[] | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
isPending: false,
|
||||
probeHosts: null,
|
||||
};
|
|
@ -1,4 +0,0 @@
|
|||
export * from './probe-host.action';
|
||||
export * from './probe-host.effect';
|
||||
export * from './probe-host.reducer';
|
||||
export * from './probe-host.state';
|
|
@ -1,37 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export enum ActionType {
|
||||
ReadByProbe = '[probeHost.detail] Read',
|
||||
ReadByProbeSuccess = '[probeHost.detail] ReadSuccess',
|
||||
ReadByProbeFailure = '[probeHost.detail] ReadFailure',
|
||||
}
|
||||
|
||||
export class ReadByProbe implements Action {
|
||||
readonly type = ActionType.ReadByProbe;
|
||||
|
||||
constructor(public payload: Probe) {}
|
||||
}
|
||||
|
||||
export class ReadByProbeSuccess implements Action {
|
||||
readonly type = ActionType.ReadByProbeSuccess;
|
||||
|
||||
constructor(public payload: ProbeHost) {}
|
||||
}
|
||||
|
||||
export class ReadByProbeFailure implements Action {
|
||||
readonly type = ActionType.ReadByProbeFailure;
|
||||
|
||||
constructor(public payload: RPCClientError) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| ReadByProbe
|
||||
| ReadByProbeSuccess
|
||||
| ReadByProbeFailure
|
||||
;
|
|
@ -1,15 +0,0 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { Effects } from './probe-host.effect';
|
||||
|
||||
describe('ProbeDetail.Effects', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [Effects]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([Effects], (effects: Effects) => {
|
||||
expect(effects).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -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 { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { ProbeHostService } from '../../service/probe-host.service';
|
||||
|
||||
import {
|
||||
ReadByProbe,
|
||||
ReadByProbeSuccess,
|
||||
ReadByProbeFailure,
|
||||
ActionType
|
||||
} from './probe-host.action';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private probeHostService: ProbeHostService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
read$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.ReadByProbe)
|
||||
.map((action: ReadByProbe) => action.payload)
|
||||
.switchMap(payload => this.probeHostService.readByProbe(payload))
|
||||
.map(probe => {
|
||||
return new ReadByProbeSuccess(probe);
|
||||
})
|
||||
.catch((error: RPCClientError) => {
|
||||
return of(new ReadByProbeFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import {
|
||||
ReadByProbe,
|
||||
ReadByProbeFailure,
|
||||
ReadByProbeSuccess,
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './probe-host.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './probe-host.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.ReadByProbe: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadByProbeSuccess: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: false,
|
||||
probeHost: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadByProbeFailure: {
|
||||
return {
|
||||
...state,
|
||||
error: action.payload,
|
||||
isPending: false,
|
||||
probeHost: null,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export interface State {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
probeHost: ProbeHost | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
isPending: false,
|
||||
probeHost: null,
|
||||
};
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
export * from './remove.action';
|
||||
export * from './remove.effect';
|
||||
export * from './remove.reducer';
|
||||
export * from './remove.state';
|
|
@ -1,37 +0,0 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export enum ActionType {
|
||||
Remove = '[probe.remove] Remove',
|
||||
RemoveSuccess = '[probe.detail] RemoveSuccess',
|
||||
RemoveFailure = '[probe.detail] RemoveFailure',
|
||||
}
|
||||
|
||||
export class Remove implements Action {
|
||||
readonly type = ActionType.Remove;
|
||||
|
||||
constructor(public payload: {id: string}) {}
|
||||
}
|
||||
|
||||
export class RemoveSuccess implements Action {
|
||||
readonly type = ActionType.RemoveSuccess;
|
||||
|
||||
constructor(public payload: boolean) {}
|
||||
}
|
||||
|
||||
export class RemoveFailure implements Action {
|
||||
readonly type = ActionType.RemoveFailure;
|
||||
|
||||
constructor(public payload: RPCClientError) {}
|
||||
}
|
||||
|
||||
|
||||
export type Actions =
|
||||
| Remove
|
||||
| RemoveSuccess
|
||||
| RemoveFailure
|
||||
;
|
|
@ -1,15 +0,0 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { Effects } from './remove.effect';
|
||||
|
||||
describe('ProbeDetail.Effects', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [Effects]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([Effects], (effects: Effects) => {
|
||||
expect(effects).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -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 { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { ProbeService } from '../../service/probe.service';
|
||||
|
||||
import {
|
||||
Remove,
|
||||
RemoveSuccess,
|
||||
RemoveFailure,
|
||||
ActionType
|
||||
} from './remove.action';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private probeService: ProbeService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
remove$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.Remove)
|
||||
.map((action: Remove) => action.payload)
|
||||
.switchMap(payload => this.probeService.remove(payload.id))
|
||||
.map(result => {
|
||||
return new RemoveSuccess(result);
|
||||
})
|
||||
.catch((error: RPCClientError) => {
|
||||
return of(new RemoveFailure(error));
|
||||
});
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import {
|
||||
Remove,
|
||||
RemoveFailure,
|
||||
RemoveSuccess,
|
||||
ActionType,
|
||||
Actions,
|
||||
} from './remove.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './remove.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.Remove: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.RemoveSuccess: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
isPending: false,
|
||||
succeed: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.RemoveFailure: {
|
||||
return {
|
||||
...state,
|
||||
error: action.payload,
|
||||
isPending: false,
|
||||
succeed: false,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export interface State {
|
||||
error: RPCClientError | null;
|
||||
isPending: boolean;
|
||||
succeed: boolean | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
isPending: false,
|
||||
succeed: null,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user