This commit is contained in:
insanity 2017-08-11 12:23:22 +09:00
parent f79d59e8cd
commit bd1748ab7d
13 changed files with 103 additions and 138 deletions

View File

@ -6,11 +6,13 @@ 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 readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe';
import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target'; import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target';
import SensorReadReducer from '@overflow/sensor/redux/reducer/read'; import SensorReadReducer from '@overflow/sensor/redux/reducer/read';
import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor'; import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor';
import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest';
// Container Configuration // Container Configuration
@ -52,6 +54,7 @@ const reduxConfig: ReduxConfig = {
SensorReadReducer, SensorReadReducer,
signUpReducer, signUpReducer,
SensorItemReadAllBySensorReducer, SensorItemReadAllBySensorReducer,
readAllTargetByProbeReducer,
], ],
sagaWatchers: [ sagaWatchers: [
AsyncRequest, AsyncRequest,

View File

@ -10,7 +10,7 @@ class TargetList extends React.Component<RouteComponentProps<object>, object> {
public render(): JSX.Element { public render(): JSX.Element {
return ( return (
<TargetListContainer/> <TargetListContainer params={this.props.match.params}/>
); );
} }
} }

View File

@ -28,3 +28,4 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatch
} }
export default connect(mapStateToProps, mapDispatchToProps)(ProbeDetailInfo); export default connect(mapStateToProps, mapDispatchToProps)(ProbeDetailInfo);

View File

@ -5,16 +5,22 @@ import {
DispatchProps as ProbeDetailDispatchProps, DispatchProps as ProbeDetailDispatchProps,
} from './components/ProbeHost'; } from './components/ProbeHost';
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 * as probeReadActions from '../redux/action/read';
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,
}; };
} }
export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): ProbeDetailDispatchProps {
return { return {
onRead: (id: string) => {
dispatch(asyncRequestActions.request('ProbeService', 'read', probeReadActions.REQUEST, id));
},
}; };
} }

View File

@ -12,15 +12,16 @@ import InfraHost from '@overflow/infra/api/model/InfraHost';
export interface StateProps { export interface StateProps {
id: string; id: string;
probe: Probe;
} }
export interface DispatchProps { export interface DispatchProps {
onRead?(id: string): void;
} }
export type Props = StateProps & DispatchProps; export type Props = StateProps & DispatchProps;
export interface State { export interface State {
host: InfraHost;
} }
@ -34,39 +35,7 @@ export class ProbeHost extends React.Component<Props, State> {
} }
public componentWillMount(): void { public componentWillMount(): void {
this.props.onRead(this.props.id);
// 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,
});
} }
@ -79,31 +48,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.state.host.ip}</Table.Cell> <Table.Cell>{this.props.probe.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>{this.state.host.mac}</Table.Cell> <Table.Cell>{this.props.probe.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.state.host.os.meta}</Table.Cell> <Table.Cell>{this.props.probe.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.state.host.os.vendor.name}</Table.Cell> <Table.Cell>{this.props.probe.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.state.host.os.vendor.infraType.name}</Table.Cell> <Table.Cell>{this.props.probe.host.os.vendor.infraType.name}</Table.Cell>
</Table.Row> </Table.Row>
</Table.Body> </Table.Body>
</Table> </Table>

View File

@ -3,20 +3,20 @@ import { ReducersMapObject } from 'redux';
import Probe from '@overflow/probe/api/model/Probe'; import Probe from '@overflow/probe/api/model/Probe';
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain'; 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 = { const reducer: ReducersMapObject = {
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]: [ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Probe>): (state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Probe>):
ReadAllProbeByDomainState => { ReadAllByDomainState => {
return { return {
...state, ...state,
probeList: <Probe[]>action.payload, probeList: <Probe[]>action.payload,
}; };
}, },
[ReadAllByDomainActionTypes.REQUEST_FAILURE]: [ReadAllByDomainActionTypes.REQUEST_FAILURE]:
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Error>): (state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Error>):
ReadAllProbeByDomainState => { ReadAllByDomainState => {
return state; return state;
}, },
}; };

View File

@ -8,18 +8,19 @@ import {
import Probe from '@overflow/probe/api/model/Probe'; import Probe from '@overflow/probe/api/model/Probe';
import * as targetListActions from '../redux/action/read_all_by_probe'; import * as targetListActions from '../redux/action/read_all_by_probe';
import { push as routerPush } from 'react-router-redux'; import { push as routerPush } from 'react-router-redux';
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
export function mapStateToProps(state: any, props: any): StateProps {
export function mapStateToProps(state: any): StateProps {
return { return {
probeId: props.params.id,
targetList: state.targetList,
}; };
} }
export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps {
return { return {
onReadAllByProbe: (probe: Probe) => { onReadAllByProbe: (probe: Probe) => {
dispatch(targetListActions.request(probe)); dispatch(asyncRequestActions.request('InfraService', 'readAllByProbe', targetListActions.REQUEST, JSON.stringify(probe)));
}, },
onTargetSelection: (id: string) => { onTargetSelection: (id: string) => {
dispatch(routerPush('/target/' + id)); dispatch(routerPush('/target/' + id));

View File

@ -7,7 +7,8 @@ import { ListContainer } from '@overflow/commons/react/component/ListContainer';
import { Discovery } from '../../../discovery/react/components/Discovery'; import { Discovery } from '../../../discovery/react/components/Discovery';
export interface StateProps { export interface StateProps {
probeId: string;
targetList: Target[];
} }
export interface DispatchProps { export interface DispatchProps {
@ -20,47 +21,23 @@ export type Props = StateProps & DispatchProps;
export interface State { export interface State {
selected: Target; selected: Target;
openAddTarget: boolean; openAddTarget: boolean;
list: Target[];
} }
export class TargetList extends React.Component<Props, State> { export class TargetList extends React.Component<Props, State> {
private data: any;
constructor(props: Props, context: State) { constructor(props: Props, context: State) {
super(props, context); super(props, context);
this.state = { this.state = {
selected: null, selected: null,
openAddTarget: false, openAddTarget: false,
list: null,
}; };
} }
public componentWillMount(): void { public componentWillMount(): void {
this.data = [ const probe: Probe = {
{ id: 1,
'id': '1', };
'createDate': '2017-01-01', this.props.onReadAllByProbe(probe);
'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 });
} }
public handleSelect(selectedTarget: any): void { public handleSelect(selectedTarget: any): void {
@ -80,30 +57,33 @@ export class TargetList extends React.Component<Props, State> {
} }
public handleSearch(result: Target[]): void { public handleSearch(result: Target[]): void {
this.setState({ // this.setState({
list: result, // list: result,
}); // });
} }
public handleFilter(filterStr: string): void { public handleFilter(filterStr: string): void {
if (filterStr === null) { // if (filterStr === null) {
this.setState({ // this.setState({
list: this.data, // list: this.data,
}); // });
return; // return;
} // }
let founds = new Array(); // let founds = new Array();
for (let probe of this.data) { // for (let probe of this.data) {
if (probe.metaProbeStatus.name.indexOf(filterStr) !== -1) { // if (probe.metaProbeStatus.name.indexOf(filterStr) !== -1) {
founds.push(probe); // founds.push(probe);
} // }
} // }
this.setState({ // this.setState({
list: founds, // list: founds,
}); // });
} }
public render(): JSX.Element { public render(): JSX.Element {
if(this.props.targetList === undefined) {
return null;
}
let targetList = let targetList =
<Container fluid> <Container fluid>
{/*search bar */} {/*search bar */}
@ -113,6 +93,7 @@ export class TargetList extends React.Component<Props, State> {
<Table.Header> <Table.Header>
<Table.Row> <Table.Row>
<Table.HeaderCell textAlign={'center'}>No</Table.HeaderCell> <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'}>Name</Table.HeaderCell>
<Table.HeaderCell textAlign={'center'} collapsing>Sensor Count</Table.HeaderCell> <Table.HeaderCell textAlign={'center'} collapsing>Sensor Count</Table.HeaderCell>
<Table.HeaderCell textAlign={'center'}>Created at</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.Header>
<Table.Body> <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.Row key={index} onClick={this.handleSelect.bind(this, target)}>
<Table.Cell textAlign={'center'}>{index + 1}</Table.Cell> <Table.Cell textAlign={'center'}>{index + 1}</Table.Cell>
<Table.Cell textAlign={'center'}>{target.displayName}</Table.Cell> <Table.Cell textAlign={'center'}>{target.infraType.name}</Table.Cell>
<Table.Cell>{target.sensorCount}</Table.Cell> <Table.Cell textAlign={'center'}>{target.target.displayName}</Table.Cell>
<Table.Cell>TODO</Table.Cell>
<Table.Cell>{target.createDate}</Table.Cell> <Table.Cell>{target.createDate}</Table.Cell>
</Table.Row> </Table.Row>
))} ))}

View File

@ -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 // Action Type
export type REQUEST = '@overflow/target/read_all_by_probe/REQUEST'; 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_SUCCESS = '@overflow/target/read_all_by_probe/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/target/read_all_by_probe/REQUEST_FAILURE'; 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: 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_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_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,
};
};

View 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;

View 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;