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 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,
|
||||
|
|
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 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<any>): 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)));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Props, State> {
|
|||
}
|
||||
|
||||
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 (
|
||||
<Container fluid>
|
||||
<Table celled={false}>
|
||||
|
@ -50,31 +59,31 @@ export class ProbeHost extends React.Component<Props, State> {
|
|||
<Table.Cell collapsing>
|
||||
<Header size='small'>IP</Header>
|
||||
</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.Cell collapsing>
|
||||
<Header size='small'>MAC</Header>
|
||||
</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.Cell collapsing>
|
||||
<Header size='small'>OS meta</Header>
|
||||
</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.Cell collapsing>
|
||||
<Header size='small'>OS vendor name</Header>
|
||||
</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.Cell collapsing>
|
||||
<Header size='small'>OS vendor type</Header>
|
||||
</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.Body>
|
||||
</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