added probe host
This commit is contained in:
parent
a630a4eb99
commit
40eaf2c0f3
|
@ -6,6 +6,7 @@ import signUpReducer from '@overflow/member/redux/reducer/signUp';
|
||||||
|
|
||||||
import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain';
|
import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain';
|
||||||
import readProbeReducer from '@overflow/probe/redux/reducer/read';
|
import readProbeReducer from '@overflow/probe/redux/reducer/read';
|
||||||
|
import hostReadByProbeReducer from '@overflow/probe/redux/reducer/host_read_by_probe';
|
||||||
|
|
||||||
import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain';
|
import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain';
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ const reduxConfig: ReduxConfig = {
|
||||||
MetaSensorItemTypeReadAllReducer,
|
MetaSensorItemTypeReadAllReducer,
|
||||||
readOSReducer,
|
readOSReducer,
|
||||||
readServiceReducer,
|
readServiceReducer,
|
||||||
|
hostReadByProbeReducer,
|
||||||
],
|
],
|
||||||
sagaWatchers: [
|
sagaWatchers: [
|
||||||
AsyncRequest,
|
AsyncRequest,
|
||||||
|
|
13
src/ts/@overflow/probe/api/model/ProbeHost.ts
Normal file
13
src/ts/@overflow/probe/api/model/ProbeHost.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
import Probe from './Probe';
|
||||||
|
import InfraHost from '@overflow/infra/api/model/InfraHost';
|
||||||
|
|
||||||
|
|
||||||
|
interface ProbeHost {
|
||||||
|
id?: number;
|
||||||
|
probe?: Probe;
|
||||||
|
host?: InfraHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default ProbeHost;
|
|
@ -7,12 +7,14 @@ import {
|
||||||
import { push as routerPush } from 'react-router-redux';
|
import { push as routerPush } from 'react-router-redux';
|
||||||
import Probe from '@overflow/probe/api/model/Probe';
|
import Probe from '@overflow/probe/api/model/Probe';
|
||||||
import * as probeReadActions from '../redux/action/read';
|
import * as probeReadActions from '../redux/action/read';
|
||||||
|
import * as probeHostReadByProbeActions from '../redux/action/host_read_by_probe';
|
||||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||||
|
|
||||||
export function mapStateToProps(state: any, props: any): ProbeDetailStateProps {
|
export function mapStateToProps(state: any, props: any): ProbeDetailStateProps {
|
||||||
return {
|
return {
|
||||||
id: props.params.id,
|
id: props.params.id,
|
||||||
probe: state.probe,
|
probe: state.probe,
|
||||||
|
probeHost: state.probeHost,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +23,10 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatch
|
||||||
onRead: (id: string) => {
|
onRead: (id: string) => {
|
||||||
dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id));
|
dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id));
|
||||||
},
|
},
|
||||||
|
onHostReadByProbe: (probe: Probe) => {
|
||||||
|
dispatch(asyncRequestActions.request('ProbeHostService', 'readByProbe',
|
||||||
|
probeHostReadByProbeActions.REQUEST, JSON.stringify(probe)));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
Container,
|
Container,
|
||||||
} from 'semantic-ui-react';
|
} from 'semantic-ui-react';
|
||||||
import Probe from '@overflow/probe/api/model/Probe';
|
import Probe from '@overflow/probe/api/model/Probe';
|
||||||
|
import ProbeHostModel from '@overflow/probe/api/model/ProbeHost';
|
||||||
import InfraHost from '@overflow/infra/api/model/InfraHost';
|
import InfraHost from '@overflow/infra/api/model/InfraHost';
|
||||||
|
|
||||||
import * as Utils from '@overflow/commons/util/Utils';
|
import * as Utils from '@overflow/commons/util/Utils';
|
||||||
|
@ -15,10 +16,12 @@ import * as Utils from '@overflow/commons/util/Utils';
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
id: string;
|
id: string;
|
||||||
probe: Probe;
|
probe: Probe;
|
||||||
|
probeHost: ProbeHostModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DispatchProps {
|
export interface DispatchProps {
|
||||||
onRead?(id: string): void;
|
onRead?(id: string): void;
|
||||||
|
onHostReadByProbe?(probe: Probe): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
|
@ -37,11 +40,17 @@ export class ProbeHost extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillMount(): void {
|
public componentWillMount(): void {
|
||||||
this.props.onRead(this.props.id);
|
// this.props.onRead(this.props.id);
|
||||||
|
this.props.onHostReadByProbe({id: Number(this.props.id)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
|
|
||||||
|
if(this.props.probeHost === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container fluid>
|
<Container fluid>
|
||||||
<Table celled={false}>
|
<Table celled={false}>
|
||||||
|
@ -50,31 +59,31 @@ export class ProbeHost extends React.Component<Props, State> {
|
||||||
<Table.Cell collapsing>
|
<Table.Cell collapsing>
|
||||||
<Header size='small'>IP</Header>
|
<Header size='small'>IP</Header>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{this.props.probe.host ? Utils.int2ip(this.props.probe.host.ip) : ''}</Table.Cell>
|
<Table.Cell>{this.props.probeHost.host ? Utils.int2ip(this.props.probeHost.host.ip) : ''}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell collapsing>
|
||||||
<Header size='small'>MAC</Header>
|
<Header size='small'>MAC</Header>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{Utils.intToMac(this.props.probe.host.mac)}</Table.Cell>
|
<Table.Cell>{Utils.intToMac(this.props.probeHost.host.mac)}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell collapsing>
|
||||||
<Header size='small'>OS meta</Header>
|
<Header size='small'>OS meta</Header>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{this.props.probe.host.os.meta}</Table.Cell>
|
<Table.Cell>{this.props.probeHost.host.os.meta}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell collapsing>
|
||||||
<Header size='small'>OS vendor name</Header>
|
<Header size='small'>OS vendor name</Header>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{this.props.probe.host.os.vendor.name}</Table.Cell>
|
<Table.Cell>{this.props.probeHost.host.os.vendor.name}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell collapsing>
|
<Table.Cell collapsing>
|
||||||
<Header size='small'>OS vendor type</Header>
|
<Header size='small'>OS vendor type</Header>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>{this.props.probe.host.os.vendor.infraType.name}</Table.Cell>
|
<Table.Cell>{this.props.probeHost.host.os.vendor.infraType.name}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Body>
|
</Table.Body>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
// Action Type
|
||||||
|
export type REQUEST = '@overflow/probe/host_read_by_probe/REQUEST';
|
||||||
|
export type REQUEST_SUCCESS = '@overflow/probe/host_read_by_probe/REQUEST/SUCCESS';
|
||||||
|
export type REQUEST_FAILURE = '@overflow/probe/host_read_by_probe/REQUEST/FAILURE';
|
||||||
|
|
||||||
|
export const REQUEST: REQUEST = '@overflow/probe/host_read_by_probe/REQUEST';
|
||||||
|
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/probe/host_read_by_probe/REQUEST/SUCCESS';
|
||||||
|
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/probe/host_read_by_probe/REQUEST/FAILURE';
|
|
@ -0,0 +1,7 @@
|
||||||
|
import Probe from '../../api/model/Probe';
|
||||||
|
|
||||||
|
interface HostReadByProbePayload {
|
||||||
|
probe: Probe;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HostReadByProbePayload;
|
25
src/ts/@overflow/probe/redux/reducer/host_read_by_probe.ts
Normal file
25
src/ts/@overflow/probe/redux/reducer/host_read_by_probe.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import Action from '@overflow/commons/redux/Action';
|
||||||
|
import { ReducersMapObject } from 'redux';
|
||||||
|
import Probe from '@overflow/probe/api/model/Probe';
|
||||||
|
import ProbeHost from '@overflow/probe/api/model/ProbeHost';
|
||||||
|
|
||||||
|
import * as HostReadByProbeActionTypes from '../action/host_read_by_probe';
|
||||||
|
import HostReadByProbeState, { defaultState as hostReadByProbeDefaultState } from '../state/HostReadByProbe';
|
||||||
|
|
||||||
|
const reducer: ReducersMapObject = {
|
||||||
|
[HostReadByProbeActionTypes.REQUEST_SUCCESS]:
|
||||||
|
(state: HostReadByProbeState = hostReadByProbeDefaultState, action: Action<ProbeHost>):
|
||||||
|
HostReadByProbeState => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
probeHost: <ProbeHost>action.payload,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[HostReadByProbeActionTypes.REQUEST_FAILURE]:
|
||||||
|
(state: HostReadByProbeState = hostReadByProbeDefaultState, action: Action<Error>):
|
||||||
|
HostReadByProbeState => {
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
14
src/ts/@overflow/probe/redux/state/HostReadByProbe.ts
Normal file
14
src/ts/@overflow/probe/redux/state/HostReadByProbe.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import ProbeHost from '../../api/model/ProbeHost';
|
||||||
|
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
readonly probeHost?: ProbeHost;
|
||||||
|
readonly error?: Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultState: State = {
|
||||||
|
probeHost: undefined,
|
||||||
|
error: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default State;
|
Loading…
Reference in New Issue
Block a user