This commit is contained in:
insanity 2018-04-30 19:59:32 +09:00
parent fd51af6d67
commit bfb3f7a59c
13 changed files with 128 additions and 89 deletions

View File

@ -430,7 +430,7 @@ export class MapComponent implements OnInit, AfterContentInit {
if (nodeType === 'probe') { if (nodeType === 'probe') {
this.router.navigate(['probe', event.node.obj.id, 'info']); this.router.navigate(['probe', event.node.obj.id, 'info']);
} else if (nodeType === 'host' || nodeType === 'service') { } else if (nodeType === 'host' || nodeType === 'service') {
this.router.navigate(['sensors'], { queryParams: { target: event.node.obj.target.id } }); this.router.navigate(['target', event.node.obj.id, 'info']);
} else if (nodeType === 'sensor') { } else if (nodeType === 'sensor') {
this.router.navigate(['sensor', event.node.obj.id, 'info']); this.router.navigate(['sensor', event.node.obj.id, 'info']);
} }

View File

@ -1,13 +1,25 @@
<div *ngIf="infra"> <div *ngIf="infra">
<div *ngIf="infra.infraType.name == 'HOST'">
<button pButton type="button" label="Traceroute" (click)="onTraceroute()"></button>
</div>
<div class="ui-g"> <div class="ui-g">
<div class="ui-g-12"> <div class="ui-g-12">
<div class="ui-inputgroup">
<span class="md-inputfield">
<input #input type="text" pInputText value="{{infra.target.displayName}}" (keypress)="onDisplayNameChangeKeypress($event, input.value)">
<label></label>
</span>
<button pButton label="Save" type="button" (click)="onDisplayNameChange(input.value)"></button>
</div>
<p-panel [showHeader]="false"> <p-panel [showHeader]="false">
<div class="ui-key-value"> <div class="ui-key-value">
<span>Status</span> <span>Status</span>
<span class="ng-star-inserted"> <span class="ng-star-inserted">
<i class="fa ui-icon-stop ui-status-icon ui-status-success"></i>Up</span> <i class="fa ui-icon-stop ui-status-icon ui-status-success"></i>Up</span>
</div> </div>
<of-key-value [key]="'Alias'" [value]="infra.target.displayName" class="ui-key-value"></of-key-value>
<of-key-value [key]="'Description'" [value]="infra.target.description" class="ui-key-value"></of-key-value> <of-key-value [key]="'Description'" [value]="infra.target.description" class="ui-key-value"></of-key-value>
<of-key-value [key]="'Type'" [value]="infra.infraType.name" class="ui-key-value"></of-key-value> <of-key-value [key]="'Type'" [value]="infra.infraType.name" class="ui-key-value"></of-key-value>
<of-key-value [key]="'Created at'" [value]="infra.createDate | date: 'dd/MM/yyyy'" class="ui-key-value"></of-key-value> <of-key-value [key]="'Created at'" [value]="infra.createDate | date: 'dd/MM/yyyy'" class="ui-key-value"></of-key-value>

View File

@ -7,10 +7,11 @@ import { DetailSelector as InfraDetailSelector } from 'packages/infra/store';
import * as InfraDetailStore from 'packages/infra/store/detail'; import * as InfraDetailStore from 'packages/infra/store/detail';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { sensorListSelector } from 'packages/sensor/store'; import { sensorListSelector } from 'packages/sensor/store';
import * as SensorListStore from 'packages/sensor/store/list'; import * as SensorListStore from 'packages/sensor/store/list';
import { PageParams, Page } from 'app/commons/model'; import { PageParams, Page } from 'app/commons/model';
// import { target } from 'packages/target/store';
// import * as SensorListStore from 'packages/sensor/store/list';
@Component({ @Component({
@ -24,6 +25,8 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy {
sensorsSubscription$: Subscription; sensorsSubscription$: Subscription;
sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page'))); sensors$ = this.sensorListStore.pipe(select(sensorListSelector.select('page')));
targetSubscription$: Subscription;
infraId = null; infraId = null;
infra: Infra; infra: Infra;
sensors: Sensor[]; sensors: Sensor[];
@ -107,6 +110,47 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy {
onPaging(e) { onPaging(e) {
this.getSensors(e.page); this.getSensors(e.page);
} }
onRowSelect(event) {
this.router.navigate(['sensor', event.data.id, 'info']);
}
onTraceroute() {
alert('지원 예정');
}
onDisplayNameChange(value: string) {
console.log(value);
// if (value === this.probe.displayName) {
// return;
// }
// this.probe.displayName = value;
// this.modifyStore.dispatch(
// new ModifyStore.Modify(this.probe)
// );
// const modifySuccessSubscription$: Subscription = this.modifySuccess$.subscribe(
// (probe: Probe) => {
// if (probe) {
// this.msgs = [];
// this.msgs.push({ severity: 'success', summary: 'Succeed', detail: 'Probe name has changed.' });
// }
// if (modifySuccessSubscription$) {
// modifySuccessSubscription$.unsubscribe();
// }
// },
// (error: RPCClientError) => {
// console.log(error.response.message);
// }
// );
}
onDisplayNameChangeKeypress(event, value) {
if (event.key === 'Enter') {
this.onDisplayNameChange(value);
}
}
} }

View File

@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
import { RPCService } from '@loafer/ng-rpc/service'; import { RPCService } from '@loafer/ng-rpc/service';
import { Target } from '../model'; import { Target } from '../model';
import { Domain } from '../../domain/model';
@Injectable() @Injectable()
@ -18,21 +17,8 @@ export class TargetService {
} }
public readAllByDomain(domain: Domain): Observable<Target[]> { public modify(target: Target): Observable<Target> {
const body = { return this.rpcService.call('TargetService.modify', target);
domain: domain,
};
return this.rpcService.call('TargetService.readAllByDomain', domain);
} }
// public readAllByProbe(domain: Domain): Observable<Target[]> {
// const body = {
// domain: domain,
// };
// return this.rpcService.call('TargetService.readAllByDomain', domain);
// }
} }

View File

@ -8,23 +8,23 @@ import {
import { MODULE } from '../target.constant'; import { MODULE } from '../target.constant';
import * as TargetStore from './target'; import * as TargetModifyStore from './modify';
export interface State { export interface State {
readallbydomain: TargetStore.State; modify: TargetModifyStore.State;
} }
export const REDUCERS = { export const REDUCERS = {
readallbydomain: TargetStore.reducer, modify: TargetModifyStore.reducer,
}; };
export const EFFECTS = [ export const EFFECTS = [
TargetStore.Effects, TargetModifyStore.Effects,
]; ];
export const selectTargetState = createFeatureSelector<State>(MODULE.name); export const selectTargetState = createFeatureSelector<State>(MODULE.name);
export const ReadAllByDomainSelector = new StateSelector<TargetStore.State>(createSelector( export const ReadAllByDomainSelector = new StateSelector<TargetModifyStore.State>(createSelector(
selectTargetState, selectTargetState,
(state: State) => state.readallbydomain (state: State) => state.modify
)); ));

View File

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

View File

@ -0,0 +1,35 @@
import { Action } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Target } from '../../model';
export enum ActionType {
Modify = '[Target.modify] Modify',
ModifySuccess = '[Target.modify] ModifySuccess',
ModifyFailure = '[Target.modify] ModifyFailure',
}
export class Modify implements Action {
readonly type = ActionType.Modify;
constructor(public payload: Target) {}
}
export class ModifySuccess implements Action {
readonly type = ActionType.ModifySuccess;
constructor(public payload: Target) {}
}
export class ModifyFailure implements Action {
readonly type = ActionType.ModifyFailure;
constructor(public payload: RPCClientError) {}
}
export type Actions =
| Modify
| ModifySuccess
| ModifyFailure
;

View File

@ -1,6 +1,6 @@
import { TestBed, inject } from '@angular/core/testing'; import { TestBed, inject } from '@angular/core/testing';
import { Effects } from './target.effect'; import { Effects } from './modify.effect';
describe('Target.Effects', () => { describe('Target.Effects', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -17,11 +17,11 @@ import { Target } from '../../model';
import { TargetService } from '../../service/target.service'; import { TargetService } from '../../service/target.service';
import { import {
ReadAllByDomain, Modify,
ReadAllByDomainSuccess, ModifySuccess,
ReadAllByDomainFailure, ModifyFailure,
ActionType, ActionType,
} from './target.action'; } from './modify.action';
@Injectable() @Injectable()
export class Effects { export class Effects {
@ -33,14 +33,13 @@ export class Effects {
) { } ) { }
@Effect() @Effect()
readAllByMember$: Observable<Action> = this.actions$ modify$: Observable<Action> = this.actions$
.ofType(ActionType.ReadAllByDomain) .ofType(ActionType.Modify)
.map((action: ReadAllByDomain) => action.payload) .map((action: Modify) => action.payload)
.exhaustMap(domain => .exhaustMap(target =>
this.targetService this.targetService.modify(target)
.readAllByDomain(domain) .map(targets => new ModifySuccess(targets))
.map(targets => new ReadAllByDomainSuccess(targets)) .catch(error => of(new ModifyFailure(error)))
.catch(error => of(new ReadAllByDomainFailure(error)))
); );
} }

View File

@ -1,18 +1,18 @@
import { import {
Actions, Actions,
ActionType, ActionType,
} from './target.action'; } from './modify.action';
import { import {
State, State,
initialState, initialState,
} from './target.state'; } from './modify.state';
import { Target } from '../../model'; import { Target } from '../../model';
export function reducer(state = initialState, action: Actions): State { export function reducer(state = initialState, action: Actions): State {
switch (action.type) { switch (action.type) {
case ActionType.ReadAllByDomain: { case ActionType.Modify: {
return { return {
...state, ...state,
error: null, error: null,
@ -20,21 +20,21 @@ import {
}; };
} }
case ActionType.ReadAllByDomainSuccess: { case ActionType.ModifySuccess: {
return { return {
...state, ...state,
error: null, error: null,
pending: false, pending: false,
targets: action.payload target: action.payload
}; };
} }
case ActionType.ReadAllByDomainFailure: { case ActionType.ModifyFailure: {
return { return {
...state, ...state,
error: action.payload, error: action.payload,
pending: false, pending: false,
targets: null, target: null,
}; };
} }

View File

@ -1,15 +1,14 @@
import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Target } from '../../model'; import { Target } from '../../model';
export interface State { export interface State {
error: RPCClientError | null; error: RPCClientError | null;
pending: boolean; pending: boolean;
targets: Target[] | null; target: Target | null;
} }
export const initialState: State = { export const initialState: State = {
error: null, error: null,
pending: false, pending: false,
targets: null, target: null,
}; };

View File

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

View File

@ -1,36 +0,0 @@
import { Action } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Target } from '../../model';
import { Domain } from '../../../domain/model';
export enum ActionType {
ReadAllByDomain = '[Target.ReadAllByDomain] ReadAllByDomain',
ReadAllByDomainSuccess = '[Target.ReadAllByDomainSuccess] ReadAllByDomainSuccess',
ReadAllByDomainFailure = '[Target.ReadAllByDomainFailure] 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: Target[]) {}
}
export class ReadAllByDomainFailure implements Action {
readonly type = ActionType.ReadAllByDomainFailure;
constructor(public payload: RPCClientError) {}
}
export type Actions =
| ReadAllByDomain
| ReadAllByDomainSuccess
| ReadAllByDomainFailure
;