target
This commit is contained in:
parent
f79d59e8cd
commit
bd1748ab7d
|
@ -6,11 +6,13 @@ 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 readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe';
|
||||
|
||||
import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target';
|
||||
import SensorReadReducer from '@overflow/sensor/redux/reducer/read';
|
||||
import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor';
|
||||
|
||||
|
||||
import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest';
|
||||
|
||||
// Container Configuration
|
||||
|
@ -52,6 +54,7 @@ const reduxConfig: ReduxConfig = {
|
|||
SensorReadReducer,
|
||||
signUpReducer,
|
||||
SensorItemReadAllBySensorReducer,
|
||||
readAllTargetByProbeReducer,
|
||||
],
|
||||
sagaWatchers: [
|
||||
AsyncRequest,
|
||||
|
|
|
@ -10,7 +10,7 @@ class TargetList extends React.Component<RouteComponentProps<object>, object> {
|
|||
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<TargetListContainer/>
|
||||
<TargetListContainer params={this.props.match.params}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,3 +28,4 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatch
|
|||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ProbeDetailInfo);
|
||||
|
||||
|
|
|
@ -5,16 +5,22 @@ import {
|
|||
DispatchProps as ProbeDetailDispatchProps,
|
||||
} from './components/ProbeHost';
|
||||
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 asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||
|
||||
export function mapStateToProps(state: any, props: any): ProbeDetailStateProps {
|
||||
return {
|
||||
id: props.params.id,
|
||||
probe: state.probe,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatchProps {
|
||||
return {
|
||||
onRead: (id: string) => {
|
||||
dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,15 +12,16 @@ import InfraHost from '@overflow/infra/api/model/InfraHost';
|
|||
|
||||
export interface StateProps {
|
||||
id: string;
|
||||
probe: Probe;
|
||||
}
|
||||
|
||||
export interface DispatchProps {
|
||||
onRead?(id: string): void;
|
||||
}
|
||||
|
||||
export type Props = StateProps & DispatchProps;
|
||||
|
||||
export interface State {
|
||||
host: InfraHost;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,39 +35,7 @@ export class ProbeHost extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
public componentWillMount(): void {
|
||||
|
||||
// todo. getting probe by probeId
|
||||
let p: any = {
|
||||
'id': '11',
|
||||
'status': {
|
||||
'name': 'STARTED',
|
||||
},
|
||||
'domain': {
|
||||
'name': 'insanity\'s domain',
|
||||
},
|
||||
'host': {
|
||||
'id': 111,
|
||||
'os': {
|
||||
'machine': {
|
||||
'meta': 'machine meta',
|
||||
},
|
||||
'meta': 'os meta',
|
||||
'vendor': {
|
||||
'name': 'vendor name',
|
||||
'infraType': {
|
||||
'name': 'vendor type name',
|
||||
},
|
||||
},
|
||||
},
|
||||
'ip': 3232235881,
|
||||
'mac': 8796753988883,
|
||||
'createDate': null,
|
||||
},
|
||||
};
|
||||
|
||||
this.setState({
|
||||
host: p.host,
|
||||
});
|
||||
this.props.onRead(this.props.id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,31 +48,31 @@ export class ProbeHost extends React.Component<Props, State> {
|
|||
<Table.Cell collapsing>
|
||||
<Header size='small'>IP</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{this.state.host.ip}</Table.Cell>
|
||||
<Table.Cell>{this.props.probe.host.ip}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>MAC</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{this.state.host.mac}</Table.Cell>
|
||||
<Table.Cell>{this.props.probe.host.mac}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>OS meta</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{this.state.host.os.meta}</Table.Cell>
|
||||
<Table.Cell>{this.props.probe.host.os.meta}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>OS vendor name</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{this.state.host.os.vendor.name}</Table.Cell>
|
||||
<Table.Cell>{this.props.probe.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.state.host.os.vendor.infraType.name}</Table.Cell>
|
||||
<Table.Cell>{this.props.probe.host.os.vendor.infraType.name}</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
|
|
|
@ -3,20 +3,20 @@ import { ReducersMapObject } from 'redux';
|
|||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
|
||||
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain';
|
||||
import ReadAllProbeByDomainState, { defaultState as readAllProbeByDomainDefaultState } from '../state/ReadAllByDomain';
|
||||
import ReadAllByDomainState, { defaultState as ReadAllByDomainDefaultState } from '../state/ReadAllByDomain';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
|
||||
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Probe>):
|
||||
ReadAllProbeByDomainState => {
|
||||
(state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Probe>):
|
||||
ReadAllByDomainState => {
|
||||
return {
|
||||
...state,
|
||||
probeList: <Probe[]>action.payload,
|
||||
};
|
||||
},
|
||||
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
|
||||
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Error>):
|
||||
ReadAllProbeByDomainState => {
|
||||
(state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Error>):
|
||||
ReadAllByDomainState => {
|
||||
return state;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -8,18 +8,19 @@ import {
|
|||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
import * as targetListActions from '../redux/action/read_all_by_probe';
|
||||
import { push as routerPush } from 'react-router-redux';
|
||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||
|
||||
|
||||
export function mapStateToProps(state: any): StateProps {
|
||||
export function mapStateToProps(state: any, props: any): StateProps {
|
||||
return {
|
||||
|
||||
probeId: props.params.id,
|
||||
targetList: state.targetList,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps {
|
||||
return {
|
||||
onReadAllByProbe: (probe: Probe) => {
|
||||
dispatch(targetListActions.request(probe));
|
||||
dispatch(asyncRequestActions.request('InfraService', 'readAllByProbe', targetListActions.REQUEST, JSON.stringify(probe)));
|
||||
},
|
||||
onTargetSelection: (id: string) => {
|
||||
dispatch(routerPush('/target/' + id));
|
||||
|
|
|
@ -7,7 +7,8 @@ import { ListContainer } from '@overflow/commons/react/component/ListContainer';
|
|||
import { Discovery } from '../../../discovery/react/components/Discovery';
|
||||
|
||||
export interface StateProps {
|
||||
|
||||
probeId: string;
|
||||
targetList: Target[];
|
||||
}
|
||||
|
||||
export interface DispatchProps {
|
||||
|
@ -20,47 +21,23 @@ export type Props = StateProps & DispatchProps;
|
|||
export interface State {
|
||||
selected: Target;
|
||||
openAddTarget: boolean;
|
||||
list: Target[];
|
||||
}
|
||||
|
||||
export class TargetList extends React.Component<Props, State> {
|
||||
|
||||
private data: any;
|
||||
constructor(props: Props, context: State) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
selected: null,
|
||||
openAddTarget: false,
|
||||
list: null,
|
||||
};
|
||||
}
|
||||
|
||||
public componentWillMount(): void {
|
||||
this.data = [
|
||||
{
|
||||
'id': '1',
|
||||
'createDate': '2017-01-01',
|
||||
'displayName': 'Oracle',
|
||||
'description': '',
|
||||
'sensorCount': 'todo.',
|
||||
},
|
||||
{
|
||||
'id': '2',
|
||||
'createDate': '2017-01-01',
|
||||
'displayName': 'MySQL',
|
||||
'description': '',
|
||||
'sensorCount': 'todo.',
|
||||
},
|
||||
{
|
||||
'id': '3',
|
||||
'createDate': '2017-01-01',
|
||||
'displayName': '192.168.1.105',
|
||||
'description': '',
|
||||
'sensorCount': 'todo.',
|
||||
},
|
||||
];
|
||||
|
||||
this.setState({ list: this.data });
|
||||
const probe: Probe = {
|
||||
id: 1,
|
||||
};
|
||||
this.props.onReadAllByProbe(probe);
|
||||
}
|
||||
|
||||
public handleSelect(selectedTarget: any): void {
|
||||
|
@ -80,30 +57,33 @@ export class TargetList extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
public handleSearch(result: Target[]): void {
|
||||
this.setState({
|
||||
list: result,
|
||||
});
|
||||
// this.setState({
|
||||
// list: result,
|
||||
// });
|
||||
}
|
||||
|
||||
public handleFilter(filterStr: string): void {
|
||||
if (filterStr === null) {
|
||||
this.setState({
|
||||
list: this.data,
|
||||
});
|
||||
return;
|
||||
}
|
||||
let founds = new Array();
|
||||
for (let probe of this.data) {
|
||||
if (probe.metaProbeStatus.name.indexOf(filterStr) !== -1) {
|
||||
founds.push(probe);
|
||||
}
|
||||
}
|
||||
this.setState({
|
||||
list: founds,
|
||||
});
|
||||
// if (filterStr === null) {
|
||||
// this.setState({
|
||||
// list: this.data,
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// let founds = new Array();
|
||||
// for (let probe of this.data) {
|
||||
// if (probe.metaProbeStatus.name.indexOf(filterStr) !== -1) {
|
||||
// founds.push(probe);
|
||||
// }
|
||||
// }
|
||||
// this.setState({
|
||||
// list: founds,
|
||||
// });
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
if(this.props.targetList === undefined) {
|
||||
return null;
|
||||
}
|
||||
let targetList =
|
||||
<Container fluid>
|
||||
{/*search bar */}
|
||||
|
@ -113,6 +93,7 @@ export class TargetList extends React.Component<Props, State> {
|
|||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell textAlign={'center'}>No</Table.HeaderCell>
|
||||
<Table.HeaderCell textAlign={'center'}>Type</Table.HeaderCell>
|
||||
<Table.HeaderCell textAlign={'center'}>Name</Table.HeaderCell>
|
||||
<Table.HeaderCell textAlign={'center'} collapsing>Sensor Count</Table.HeaderCell>
|
||||
<Table.HeaderCell textAlign={'center'}>Created at</Table.HeaderCell>
|
||||
|
@ -120,11 +101,12 @@ export class TargetList extends React.Component<Props, State> {
|
|||
</Table.Header>
|
||||
|
||||
<Table.Body>
|
||||
{this.state.list.map((target: any, index: number) => (
|
||||
{this.props.targetList.map((target: any, index: number) => (
|
||||
<Table.Row key={index} onClick={this.handleSelect.bind(this, target)}>
|
||||
<Table.Cell textAlign={'center'}>{index + 1}</Table.Cell>
|
||||
<Table.Cell textAlign={'center'}>{target.displayName}</Table.Cell>
|
||||
<Table.Cell>{target.sensorCount}</Table.Cell>
|
||||
<Table.Cell textAlign={'center'}>{target.infraType.name}</Table.Cell>
|
||||
<Table.Cell textAlign={'center'}>{target.target.displayName}</Table.Cell>
|
||||
<Table.Cell>TODO</Table.Cell>
|
||||
<Table.Cell>{target.createDate}</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
|
|
|
@ -1,43 +1,9 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import Target from '../../api/model/Target';
|
||||
import Probe from '@overflow/probe/api/model/Probe';
|
||||
import ReadAllByProbePayload from '../payload/ReadAllByProbePayload';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/target/read_all_by_probe/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST_FAILURE';
|
||||
export type REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST/FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/target/read_all_by_probe/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST_FAILURE';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST/FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = (probe: Probe) => Action<ReadAllByProbePayload>;
|
||||
export type requestSuccess = (targets: Target[]) => Action<Target[]>;
|
||||
export type requestFailure = (error: Error) => Action;
|
||||
|
||||
|
||||
|
||||
export const request: request = (probe: Probe): Action<ReadAllByProbePayload> => {
|
||||
return {
|
||||
type: REQUEST,
|
||||
payload: {
|
||||
probe: probe,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const requestSuccess: requestSuccess = (targets: Target[]): Action<Target[]> => {
|
||||
return {
|
||||
type: REQUEST_SUCCESS,
|
||||
payload: targets,
|
||||
};
|
||||
};
|
||||
|
||||
export const requestFailure: requestFailure = (error: Error): Action => {
|
||||
return {
|
||||
type: REQUEST_FAILURE,
|
||||
error: error,
|
||||
};
|
||||
};
|
||||
|
|
24
src/ts/@overflow/target/redux/reducer/readAllByProbe.ts
Normal file
24
src/ts/@overflow/target/redux/reducer/readAllByProbe.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import { ReducersMapObject } from 'redux';
|
||||
import Target from '@overflow/target/api/model/Target';
|
||||
|
||||
import * as ReadAllByProbeActionTypes from '../action/read_all_by_probe';
|
||||
import ReadAllByProbeState, { defaultState as ReadAllByProbeDefaultState } from '../state/ReadAllByProbe';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[ReadAllByProbeActionTypes.REQUEST_SUCCESS]:
|
||||
(state: ReadAllByProbeState = ReadAllByProbeDefaultState, action: Action<Target>):
|
||||
ReadAllByProbeState => {
|
||||
return {
|
||||
...state,
|
||||
targetList: <Target[]>action.payload,
|
||||
};
|
||||
},
|
||||
[ReadAllByProbeActionTypes.REQUEST_FAILURE]:
|
||||
(state: ReadAllByProbeState = ReadAllByProbeDefaultState, action: Action<Error>):
|
||||
ReadAllByProbeState => {
|
||||
return state;
|
||||
},
|
||||
};
|
||||
|
||||
export default reducer;
|
13
src/ts/@overflow/target/redux/state/ReadAllByProbe.ts
Normal file
13
src/ts/@overflow/target/redux/state/ReadAllByProbe.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Target from '../../api/model/Target';
|
||||
|
||||
export interface State {
|
||||
readonly targetList?: Target[];
|
||||
readonly error?: Error;
|
||||
}
|
||||
|
||||
export const defaultState: State = {
|
||||
targetList: undefined,
|
||||
error: undefined,
|
||||
};
|
||||
|
||||
export default State;
|
Loading…
Reference in New Issue
Block a user