diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 1f1f0f2..61d6a7b 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -6,6 +6,7 @@ import signUpReducer from '@overflow/member/redux/reducer/signUp'; import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain'; 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'; @@ -83,6 +84,7 @@ const reduxConfig: ReduxConfig = { MetaSensorItemTypeReadAllReducer, readOSReducer, readServiceReducer, + hostReadByProbeReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/probe/api/model/ProbeHost.ts b/src/ts/@overflow/probe/api/model/ProbeHost.ts new file mode 100644 index 0000000..c40a3b1 --- /dev/null +++ b/src/ts/@overflow/probe/api/model/ProbeHost.ts @@ -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; diff --git a/src/ts/@overflow/probe/react/ProbeHost.tsx b/src/ts/@overflow/probe/react/ProbeHost.tsx index 6434a1e..ae13c79 100644 --- a/src/ts/@overflow/probe/react/ProbeHost.tsx +++ b/src/ts/@overflow/probe/react/ProbeHost.tsx @@ -7,12 +7,14 @@ import { import { push as routerPush } from 'react-router-redux'; import Probe from '@overflow/probe/api/model/Probe'; 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'; export function mapStateToProps(state: any, props: any): ProbeDetailStateProps { return { id: props.params.id, probe: state.probe, + probeHost: state.probeHost, }; } @@ -21,6 +23,10 @@ export function mapDispatchToProps(dispatch: Dispatch): ProbeDetailDispatch onRead: (id: string) => { dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id)); }, + onHostReadByProbe: (probe: Probe) => { + dispatch(asyncRequestActions.request('ProbeHostService', 'readByProbe', + probeHostReadByProbeActions.REQUEST, JSON.stringify(probe))); + }, }; } diff --git a/src/ts/@overflow/probe/react/components/ProbeHost.tsx b/src/ts/@overflow/probe/react/components/ProbeHost.tsx index 7af23d7..95d51da 100644 --- a/src/ts/@overflow/probe/react/components/ProbeHost.tsx +++ b/src/ts/@overflow/probe/react/components/ProbeHost.tsx @@ -8,6 +8,7 @@ import { Container, } from 'semantic-ui-react'; 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 * as Utils from '@overflow/commons/util/Utils'; @@ -15,10 +16,12 @@ import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { id: string; probe: Probe; + probeHost: ProbeHostModel; } export interface DispatchProps { onRead?(id: string): void; + onHostReadByProbe?(probe: Probe): void; } export type Props = StateProps & DispatchProps; @@ -37,11 +40,17 @@ export class ProbeHost extends React.Component { } 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 { + + if(this.props.probeHost === undefined) { + return null; + } + return ( @@ -50,31 +59,31 @@ export class ProbeHost extends React.Component {
IP
- {this.props.probe.host ? Utils.int2ip(this.props.probe.host.ip) : ''} + {this.props.probeHost.host ? Utils.int2ip(this.props.probeHost.host.ip) : ''}
MAC
- {Utils.intToMac(this.props.probe.host.mac)} + {Utils.intToMac(this.props.probeHost.host.mac)}
OS meta
- {this.props.probe.host.os.meta} + {this.props.probeHost.host.os.meta}
OS vendor name
- {this.props.probe.host.os.vendor.name} + {this.props.probeHost.host.os.vendor.name}
OS vendor type
- {this.props.probe.host.os.vendor.infraType.name} + {this.props.probeHost.host.os.vendor.infraType.name}
diff --git a/src/ts/@overflow/probe/redux/action/host_read_by_probe.ts b/src/ts/@overflow/probe/redux/action/host_read_by_probe.ts new file mode 100644 index 0000000..0ff1616 --- /dev/null +++ b/src/ts/@overflow/probe/redux/action/host_read_by_probe.ts @@ -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'; diff --git a/src/ts/@overflow/probe/redux/payload/HostReadByProbePayload.ts b/src/ts/@overflow/probe/redux/payload/HostReadByProbePayload.ts new file mode 100644 index 0000000..fc2f7cb --- /dev/null +++ b/src/ts/@overflow/probe/redux/payload/HostReadByProbePayload.ts @@ -0,0 +1,7 @@ +import Probe from '../../api/model/Probe'; + +interface HostReadByProbePayload { + probe: Probe; +} + +export default HostReadByProbePayload; diff --git a/src/ts/@overflow/probe/redux/reducer/host_read_by_probe.ts b/src/ts/@overflow/probe/redux/reducer/host_read_by_probe.ts new file mode 100644 index 0000000..40d9a26 --- /dev/null +++ b/src/ts/@overflow/probe/redux/reducer/host_read_by_probe.ts @@ -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): + HostReadByProbeState => { + return { + ...state, + probeHost: action.payload, + }; + }, + [HostReadByProbeActionTypes.REQUEST_FAILURE]: + (state: HostReadByProbeState = hostReadByProbeDefaultState, action: Action): + HostReadByProbeState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/probe/redux/state/HostReadByProbe.ts b/src/ts/@overflow/probe/redux/state/HostReadByProbe.ts new file mode 100644 index 0000000..a692b5e --- /dev/null +++ b/src/ts/@overflow/probe/redux/state/HostReadByProbe.ts @@ -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;