target list from domain

This commit is contained in:
snoop 2017-08-14 17:56:27 +09:00
parent 8556f5edbc
commit 6a38cd64ea
8 changed files with 84 additions and 12 deletions

View File

@ -10,6 +10,7 @@ import readProbeReducer from '@overflow/probe/redux/reducer/read';
import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain'; import readNoAuthProbeReducer from '@overflow/noauthprobe/redux/reducer/read_all_by_domain';
import readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe'; import readAllTargetByProbeReducer from '@overflow/target/redux/reducer/readAllByProbe';
import readAllTargetByDomainReducer from '@overflow/target/redux/reducer/read_all_by_domain';
import readTargetReducer from '@overflow/target/redux/reducer/read'; import readTargetReducer from '@overflow/target/redux/reducer/read';
import sensorReadAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target'; import sensorReadAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_target';
@ -66,6 +67,7 @@ const reduxConfig: ReduxConfig = {
signUpReducer, signUpReducer,
SensorItemReadAllBySensorReducer, SensorItemReadAllBySensorReducer,
readAllTargetByProbeReducer, readAllTargetByProbeReducer,
readAllTargetByDomainReducer,
readTargetReducer, readTargetReducer,
readNoAuthProbeReducer, readNoAuthProbeReducer,
readMachineReducer, readMachineReducer,

View File

@ -153,11 +153,11 @@ export class InfraDetail extends React.Component<Props, State> {
NewTableDatas = [{ NewTableDatas = [{
header: 'IP', header: 'IP',
contents: infraChild.ip, contents: Utils.int2ip(infraChild.ip),
}, },
{ {
header: 'MAC', header: 'MAC',
contents: infraChild.mac, contents: Utils.intToMac(infraChild.mac),
}, },
]; ];

View File

@ -6,6 +6,7 @@ import {
} from './components/TargetList'; } from './components/TargetList';
import Probe from '@overflow/probe/api/model/Probe'; import Probe from '@overflow/probe/api/model/Probe';
import Domain from '@overflow/domain/api/model/Domain';
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'; import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
@ -22,6 +23,9 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps {
onReadAllByProbe: (probe: Probe) => { onReadAllByProbe: (probe: Probe) => {
dispatch(asyncRequestActions.request('InfraService', 'readAllByProbe', targetListActions.REQUEST, JSON.stringify(probe))); dispatch(asyncRequestActions.request('InfraService', 'readAllByProbe', targetListActions.REQUEST, JSON.stringify(probe)));
}, },
onReadAllByDomain: (domain: Domain) => {
dispatch(asyncRequestActions.request('InfraService', 'readAllByDomain', targetListActions.REQUEST, JSON.stringify(domain)));
},
onTargetSelection: (id: string) => { onTargetSelection: (id: string) => {
dispatch(routerPush('/target/' + id)); dispatch(routerPush('/target/' + id));
}, },

View File

@ -3,17 +3,19 @@ import { Table, Button, Modal, Input, Header, Container, InputOnChangeData, Butt
import { TargetDetail } from './TargetDetail'; import { TargetDetail } from './TargetDetail';
import Infra from '@overflow/infra/api/model/Infra'; import Infra from '@overflow/infra/api/model/Infra';
import Probe from '@overflow/probe/api/model/Probe'; import Probe from '@overflow/probe/api/model/Probe';
import Domain from '@overflow/domain/api/model/Domain';
import { ListContainer } from '@overflow/commons/react/component/ListContainer'; 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; probeId?: string;
infraList: Infra[]; infraList?: Infra[];
} }
export interface DispatchProps { export interface DispatchProps {
onReadAllByProbe(probe: Probe): void; onReadAllByProbe?(probe: Probe): void;
onTargetSelection(id: string): void; onReadAllByDomain?(domain: Domain): void;
onTargetSelection?(id: string): void;
} }
export type Props = StateProps & DispatchProps; export type Props = StateProps & DispatchProps;
@ -34,10 +36,21 @@ export class TargetList extends React.Component<Props, State> {
} }
public componentWillMount(): void { public componentWillMount(): void {
let probe: Probe = {
id: Number(1), if (this.props.probeId === undefined) {
}; // FIXME: get domain
this.props.onReadAllByProbe(probe); let domain: Domain = {
id: 1,
};
this.props.onReadAllByDomain(domain);
} else {
let probe: Probe = {
id: Number(this.props.probeId),
};
this.props.onReadAllByProbe(probe);
}
} }
public handleSelect(selectedTarget: any): void { public handleSelect(selectedTarget: any): void {
@ -81,7 +94,7 @@ export class TargetList extends React.Component<Props, State> {
} }
public render(): JSX.Element { public render(): JSX.Element {
if(this.props.infraList === undefined) { if (this.props.infraList === undefined) {
return null; return null;
} }
let targetList = let targetList =
@ -103,7 +116,7 @@ export class TargetList extends React.Component<Props, State> {
{this.props.infraList.map((infra: Infra, index: number) => ( {this.props.infraList.map((infra: Infra, index: number) => (
<Table.Row key={index} onClick={this.handleSelect.bind(this, infra)}> <Table.Row key={index} onClick={this.handleSelect.bind(this, infra)}>
<Table.Cell textAlign={'center'}>{index + 1}</Table.Cell> <Table.Cell textAlign={'center'}>{index + 1}</Table.Cell>
<Table.Cell textAlign={'center'}>{infra.infraType.name}</Table.Cell> <Table.Cell textAlign={'center'}>{infra.infraType.name}</Table.Cell>
<Table.Cell textAlign={'center'}>{infra.target.displayName}</Table.Cell> <Table.Cell textAlign={'center'}>{infra.target.displayName}</Table.Cell>
<Table.Cell>TODO</Table.Cell> <Table.Cell>TODO</Table.Cell>
<Table.Cell>{infra.target.createDate}</Table.Cell> <Table.Cell>{infra.target.createDate}</Table.Cell>

View File

@ -0,0 +1,9 @@
// Action Type
export type REQUEST = '@overflow/target/read_all_by_domain/REQUEST';
export type REQUEST_SUCCESS = '@overflow/target/read_all_by_domain/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/target/read_all_by_domain/REQUEST/FAILURE';
export const REQUEST: REQUEST = '@overflow/target/read_all_by_domain/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/target/read_all_by_domain/REQUEST/SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/target/read_all_by_domain/REQUEST/FAILURE';

View File

@ -0,0 +1,7 @@
import Domain from '@overflow/domain/api/model/Domain';
interface ReadAllByDomainPayload {
probe: Domain;
}
export default ReadAllByDomainPayload;

View File

@ -0,0 +1,24 @@
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Infra from '@overflow/infra/api/model/Infra';
import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain';
import ReadAllByDomainState, { defaultState as ReadAllByDomainDefaultState } from '../state/ReadAllByDomain';
const reducer: ReducersMapObject = {
[ReadAllByDomainActionTypes.REQUEST_SUCCESS]:
(state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Infra>):
ReadAllByDomainState => {
return {
...state,
infraList: <Infra[]>action.payload,
};
},
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
(state: ReadAllByDomainState = ReadAllByDomainDefaultState, action: Action<Infra>):
ReadAllByDomainState => {
return state;
},
};
export default reducer;

View File

@ -0,0 +1,13 @@
import Infra from '@overflow/infra/api/model/Infra';
export interface State {
readonly infraList?: Infra[];
readonly error?: Error;
}
export const defaultState: State = {
infraList: undefined,
error: undefined,
};
export default State;