From 77801a61200562ed13a5acc919cb0dbe44f177bc Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 18 Aug 2017 13:56:10 +0900 Subject: [PATCH] infra child --- src/ts/@overflow/app/config/index.ts | 6 +- src/ts/@overflow/infra/react/InfraDetail.tsx | 53 ---- .../infra/react/components/InfraDetail.tsx | 246 ---------------- .../@overflow/infra/redux/action/host_read.ts | 8 + .../infra/redux/action/machine_read.ts | 8 + .../infra/redux/action/os_application_read.ts | 8 + .../infra/redux/action/os_daemon_read.ts | 8 + .../infra/redux/action/os_port_read.ts | 8 + .../@overflow/infra/redux/action/os_read.ts | 8 + .../infra/redux/action/service_read.ts | 8 + .../infra/redux/reducer/host_read.ts | 2 +- .../{infra_host_regist.ts => host_regist.ts} | 0 .../infra/redux/reducer/machine_read.ts | 2 +- ...ra_machine_regist.ts => machine_regist.ts} | 0 .../redux/reducer/os_application_read.ts | 24 ++ ...ion_regist.ts => os_application_regist.ts} | 0 .../infra/redux/reducer/os_daemon_read.ts | 24 ++ ...s_daemon_regist.ts => os_daemon_regist.ts} | 0 .../infra/redux/reducer/os_port_read.ts | 24 ++ ...ra_os_port_regist.ts => os_port_regist.ts} | 0 .../@overflow/infra/redux/reducer/os_read.ts | 24 ++ .../{infra_os_regist.ts => os_regist.ts} | 0 .../reducer/{infra_regist.ts => regist.ts} | 0 .../infra/redux/reducer/service_read.ts | 24 ++ ...ra_service_regist.ts => service_regist.ts} | 0 .../@overflow/target/react/TargetDetail.tsx | 36 +++ src/ts/@overflow/target/react/_ | 0 .../target/react/components/TargetDetail.tsx | 272 +++++++++++++++++- src/ts/@overflow/target/react/components/_ | 0 29 files changed, 489 insertions(+), 304 deletions(-) delete mode 100644 src/ts/@overflow/infra/react/InfraDetail.tsx delete mode 100644 src/ts/@overflow/infra/react/components/InfraDetail.tsx create mode 100644 src/ts/@overflow/infra/redux/action/host_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/machine_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/os_application_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/os_daemon_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/os_port_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/os_read.ts create mode 100644 src/ts/@overflow/infra/redux/action/service_read.ts rename src/ts/@overflow/infra/redux/reducer/{infra_host_regist.ts => host_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_machine_regist.ts => machine_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_os_application_regist.ts => os_application_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_os_daemon_regist.ts => os_daemon_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_os_port_regist.ts => os_port_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_os_regist.ts => os_regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_regist.ts => regist.ts} (100%) rename src/ts/@overflow/infra/redux/reducer/{infra_service_regist.ts => service_regist.ts} (100%) delete mode 100644 src/ts/@overflow/target/react/_ delete mode 100644 src/ts/@overflow/target/react/components/_ diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 8d00eb9..e566b70 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -20,6 +20,8 @@ import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/ite import readMachineReducer from '@overflow/infra/redux/reducer/machine_read'; import readHostReducer from '@overflow/infra/redux/reducer/host_read'; +import readOSReducer from '@overflow/infra/redux/reducer/os_read'; +import readServiceReducer from '@overflow/infra/redux/reducer/service_read'; import CrawlerReadAllByTargetReducer from '@overflow/meta/redux/reducer/crawler_read_all_by_target'; import CrawlerAuthInputsReducer from '@overflow/meta/redux/reducer/crawler_auth_inputs'; @@ -42,7 +44,7 @@ export interface RPCConfig { url: string; } const rpcConfig: RPCConfig = { - url: 'ws://127.0.0.1:18081/rpc', + url: 'ws://192.168.1.209:18081/rpc', }; // Redux Configuration @@ -79,6 +81,8 @@ const reduxConfig: ReduxConfig = { CrawlerAuthInputsReducer, MetaSensorItemReadAllReducer, MetaSensorItemTypeReadAllReducer, + readOSReducer, + readServiceReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/infra/react/InfraDetail.tsx b/src/ts/@overflow/infra/react/InfraDetail.tsx deleted file mode 100644 index 2a88bdb..0000000 --- a/src/ts/@overflow/infra/react/InfraDetail.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { connect, Dispatch } from 'react-redux'; -import { - InfraDetail, - StateProps as InfraDetailStateProps, - DispatchProps as InfraDetailDispatchProps, -} from './components/InfraDetail'; - -import MetaInfraType from '@overflow/meta/api/model/MetaInfraType'; -import * as ReadActions from '../redux/action/read'; -import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; - -export function mapStateToProps(state: any, props: any): InfraDetailStateProps { - return { - infra: props.infra, - machine: state.machine, - host: state.host, - os: state.os, - osApplication: state.osApplication, - osDaemon: state.osDaemon, - osPort: state.osPort, - service: state.service, - }; -} - -export function mapDispatchToProps(dispatch: Dispatch): InfraDetailDispatchProps { - return { - onReadInfraMachine: (id: string) => { - dispatch(asyncRequestActions.request('InfraMachineService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraHost: (id: string) => { - dispatch(asyncRequestActions.request('InfraHostService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraOS: (id: string) => { - dispatch(asyncRequestActions.request('InfraOSService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraOSApplication: (id: string) => { - dispatch(asyncRequestActions.request('InfraOSApplicationService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraOSDaemon: (id: string) => { - dispatch(asyncRequestActions.request('InfraOSDaemonService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraOSPort: (id: string) => { - dispatch(asyncRequestActions.request('InfraOSPortService', 'read', ReadActions.REQUEST, id)); - }, - onReadInfraService: (id: string) => { - dispatch(asyncRequestActions.request('InfraServiceService', 'read', ReadActions.REQUEST, id)); - }, - }; -} - - - -export default connect(mapStateToProps, mapDispatchToProps)(InfraDetail); diff --git a/src/ts/@overflow/infra/react/components/InfraDetail.tsx b/src/ts/@overflow/infra/react/components/InfraDetail.tsx deleted file mode 100644 index d9bbbce..0000000 --- a/src/ts/@overflow/infra/react/components/InfraDetail.tsx +++ /dev/null @@ -1,246 +0,0 @@ -import * as React from 'react'; -import { Button, Table, Header, Container } from 'semantic-ui-react'; -import { SensorList } from '@overflow/sensor/react/components/SensorList'; -import { DetailContainer } from '@overflow/commons/react/component/DetailContainer'; - -import Target from '@overflow/target/api/model/Target'; -import MetaInfraType from '@overflow/meta/api/model/MetaInfraType'; -import Infra from '@overflow/infra/api/model/Infra'; -import InfraHost from '@overflow/infra/api/model/InfraHost'; -import InfraMachine from '@overflow/infra/api/model/InfraMachine'; -import InfraOS from '@overflow/infra/api/model/InfraOS'; -import InfraOSApplication from '@overflow/infra/api/model/InfraOSApplication'; -import InfraOSDaemon from '@overflow/infra/api/model/InfraOSDaemon'; -import InfraOSPort from '@overflow/infra/api/model/InfraOSPort'; -import InfraService from '@overflow/infra/api/model/InfraService'; - -import * as Utils from '@overflow/commons/util/Utils'; - -export interface StateProps { - infra?: Infra; - // children of Infra - machine?: InfraMachine; - host?: InfraHost; - os?: InfraOS; - osApplication?: InfraOSApplication; - osDaemon?: InfraOSDaemon; - osPort?: InfraOSPort; - service?: InfraService; -} - -export interface DispatchProps { - onReadInfraMachine?(id: string): void; - onReadInfraHost?(id: string): void; - onReadInfraOS?(id: string): void; - onReadInfraOSApplication?(id: string): void; - onReadInfraOSDaemon?(id: string): void; - onReadInfraOSPort?(id: string): void; - onReadInfraService?(id: string): void; -} - - -export type Props = StateProps & DispatchProps; - -export interface State { -} - -export class InfraDetail extends React.Component { - - constructor(props: Props, context: State) { - super(props, context); - this.state = { - }; - } - - public componentWillMount(): void { - let infraType = this.props.infra.infraType.id; - let id = String(this.props.infra.childId); - switch (infraType) { - case 1: { - this.props.onReadInfraMachine(id); - break; - } - case 2: { - this.props.onReadInfraHost(id); - break; - } - case 3: { - this.props.onReadInfraOS(id); - break; - } - case 4: { - this.props.onReadInfraOSApplication(id); - break; - } - case 5: { - this.props.onReadInfraOSDaemon(id); - break; - } - case 6: { - this.props.onReadInfraOSPort(id); - break; - } - case 7: { - this.props.onReadInfraService(id); - break; - } - default: { - break; - } - } - } - - public handleRemoveTarget(): void { - alert('remove'); - } - - public render(): JSX.Element { - if (this.props.machine === undefined - && this.props.host === undefined - && this.props.os === undefined - && this.props.osApplication === undefined - && this.props.osDaemon === undefined - && this.props.osPort === undefined - && this.props.service === undefined - ) { - return null; - } - let infraType = this.props.infra.infraType.id; - let child = null; - switch (infraType) { - case 1: { - child = ; - break; - } - case 2: { - child = ; - break; - } - case 3: { - // this.props.onReadInfraOS(id); - break; - } - case 4: { - // this.props.onReadInfraOSApplication(id); - break; - } - case 5: { - // this.props.onReadInfraOSDaemon(id); - break; - } - case 6: { - // this.props.onReadInfraOSPort(id); - break; - } - case 7: { - // this.props.onReadInfraService(id); - break; - } - default: { - break; - } - } - - return ( - - {child} - - ); - } - - private ConvertTableDataForHost(infraChild: InfraHost): Array { - let NewTableDatas: Array; - - NewTableDatas = [{ - header: 'IP', - contents: Utils.int2ip(infraChild.ip), - }, - { - header: 'MAC', - contents: Utils.intToMac(infraChild.mac), - }, - ]; - - return NewTableDatas; - } - - private ConvertTableDataForMachine(infraChild: InfraMachine): Array { - - let NewTableDatas: Array; - - NewTableDatas = [{ - header: 'Meta', - contents: infraChild.meta, - }, - ]; - - return NewTableDatas; - } - - private ConvertTableDataForOS(infraChild: InfraOS): Array { - - let NewTableDatas: Array; - - NewTableDatas = [ - { - header: 'Meta', - contents: infraChild.meta, - }, - { - header: 'Vendor', - contents: infraChild.vendor.name, - }, - ]; - - return NewTableDatas; - } - - -} - -export interface TableData { - header: string; - contents: any; -} - -export interface InfraTableProps { - tableDatas: Array; -} - -export class InfraTable extends React.Component { - constructor(props: InfraTableProps, context: any) { - super(props, context); - this.state = { - }; - } - - public showInfra(): JSX.Element[] { - let elems: Array = new Array(); - let i = 0; - for (let data of this.props.tableDatas) { - elems.push( - - -
{data.header}
-
- - {data.contents} - -
, - ); - } - - return elems; - } - - public render(): JSX.Element { - return ( - - - {this.showInfra()} - -
- ); - } -} - diff --git a/src/ts/@overflow/infra/redux/action/host_read.ts b/src/ts/@overflow/infra/redux/action/host_read.ts new file mode 100644 index 0000000..b233fad --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/host_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/host_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/host_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/host_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/host_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/host_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/host_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/machine_read.ts b/src/ts/@overflow/infra/redux/action/machine_read.ts new file mode 100644 index 0000000..a34c7d9 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/machine_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/machine_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/machine_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/machine_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/machine_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/machine_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/machine_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/os_application_read.ts b/src/ts/@overflow/infra/redux/action/os_application_read.ts new file mode 100644 index 0000000..809ee73 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/os_application_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/application_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/application_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/application_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/application_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/application_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/application_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/os_daemon_read.ts b/src/ts/@overflow/infra/redux/action/os_daemon_read.ts new file mode 100644 index 0000000..3a40c10 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/os_daemon_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/daemon_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/daemon_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/daemon_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/daemon_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/daemon_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/daemon_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/os_port_read.ts b/src/ts/@overflow/infra/redux/action/os_port_read.ts new file mode 100644 index 0000000..2b57d56 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/os_port_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/port_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/port_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/port_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/port_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/port_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/port_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/os_read.ts b/src/ts/@overflow/infra/redux/action/os_read.ts new file mode 100644 index 0000000..71290b7 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/os_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/os_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/os_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/os_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/os_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/os_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/os_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/service_read.ts b/src/ts/@overflow/infra/redux/action/service_read.ts new file mode 100644 index 0000000..e654ec2 --- /dev/null +++ b/src/ts/@overflow/infra/redux/action/service_read.ts @@ -0,0 +1,8 @@ +// Action Type +export type REQUEST = '@overflow/infra/service_read/REQUEST'; +export type REQUEST_SUCCESS = '@overflow/infra/service_read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/service_read/REQUEST/FAILURE'; + +export const REQUEST: REQUEST = '@overflow/infra/service_read/REQUEST'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/service_read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/service_read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/reducer/host_read.ts b/src/ts/@overflow/infra/redux/reducer/host_read.ts index 08fd717..b229347 100644 --- a/src/ts/@overflow/infra/redux/reducer/host_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/host_read.ts @@ -2,7 +2,7 @@ import Action from '@overflow/commons/redux/Action'; import { ReducersMapObject } from 'redux'; import InfraHost from '@overflow/infra/api/model/InfraHost'; -import * as actionType from '../action/read'; +import * as actionType from '../action/host_read'; import ReadHostState, { defaultState as ReadHostDefaultState } from '../state/HostRead'; const reducer: ReducersMapObject = { diff --git a/src/ts/@overflow/infra/redux/reducer/infra_host_regist.ts b/src/ts/@overflow/infra/redux/reducer/host_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_host_regist.ts rename to src/ts/@overflow/infra/redux/reducer/host_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/machine_read.ts b/src/ts/@overflow/infra/redux/reducer/machine_read.ts index 5f51697..02a1605 100644 --- a/src/ts/@overflow/infra/redux/reducer/machine_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/machine_read.ts @@ -2,7 +2,7 @@ import Action from '@overflow/commons/redux/Action'; import { ReducersMapObject } from 'redux'; import InfraMachine from '@overflow/infra/api/model/InfraMachine'; -import * as actionType from '../action/read'; +import * as actionType from '../action/machine_read'; import ReadMachineState, { defaultState as ReadMachineDefaultState } from '../state/MachineRead'; const reducer: ReducersMapObject = { diff --git a/src/ts/@overflow/infra/redux/reducer/infra_machine_regist.ts b/src/ts/@overflow/infra/redux/reducer/machine_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_machine_regist.ts rename to src/ts/@overflow/infra/redux/reducer/machine_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/os_application_read.ts b/src/ts/@overflow/infra/redux/reducer/os_application_read.ts index e69de29..827e53a 100644 --- a/src/ts/@overflow/infra/redux/reducer/os_application_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/os_application_read.ts @@ -0,0 +1,24 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import InfraOSApplication from '@overflow/infra/api/model/InfraOSApplication'; + +import * as actionType from '../action/os_application_read'; +import ReadOSAppplicationState, { defaultState as ReadOSApplicationDefaultState } from '../state/OSApplicationRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadOSAppplicationState = ReadOSApplicationDefaultState, action: Action): + ReadOSAppplicationState => { + return { + ...state, + osApplication: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadOSAppplicationState = ReadOSApplicationDefaultState, action: Action): + ReadOSAppplicationState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/infra_os_application_regist.ts b/src/ts/@overflow/infra/redux/reducer/os_application_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_os_application_regist.ts rename to src/ts/@overflow/infra/redux/reducer/os_application_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/os_daemon_read.ts b/src/ts/@overflow/infra/redux/reducer/os_daemon_read.ts index e69de29..5ae0f89 100644 --- a/src/ts/@overflow/infra/redux/reducer/os_daemon_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/os_daemon_read.ts @@ -0,0 +1,24 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import InfraOSDaemon from '@overflow/infra/api/model/InfraOSDaemon'; + +import * as actionType from '../action/os_daemon_read'; +import ReadOSDaemonState, { defaultState as ReadOSDaemonDefaultState } from '../state/OSDaemonRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadOSDaemonState = ReadOSDaemonDefaultState, action: Action): + ReadOSDaemonState => { + return { + ...state, + osDaemon: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadOSDaemonState = ReadOSDaemonDefaultState, action: Action): + ReadOSDaemonState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/infra_os_daemon_regist.ts b/src/ts/@overflow/infra/redux/reducer/os_daemon_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_os_daemon_regist.ts rename to src/ts/@overflow/infra/redux/reducer/os_daemon_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/os_port_read.ts b/src/ts/@overflow/infra/redux/reducer/os_port_read.ts index e69de29..abcb9c9 100644 --- a/src/ts/@overflow/infra/redux/reducer/os_port_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/os_port_read.ts @@ -0,0 +1,24 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import InfraOSPort from '@overflow/infra/api/model/InfraOSPort'; + +import * as actionType from '../action/os_port_read'; +import ReadOSPortState, { defaultState as ReadOSPortDefaultState } from '../state/OSPortRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadOSPortState = ReadOSPortDefaultState, action: Action): + ReadOSPortState => { + return { + ...state, + osPort: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadOSPortState = ReadOSPortDefaultState, action: Action): + ReadOSPortState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/infra_os_port_regist.ts b/src/ts/@overflow/infra/redux/reducer/os_port_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_os_port_regist.ts rename to src/ts/@overflow/infra/redux/reducer/os_port_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/os_read.ts b/src/ts/@overflow/infra/redux/reducer/os_read.ts index e69de29..23516eb 100644 --- a/src/ts/@overflow/infra/redux/reducer/os_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/os_read.ts @@ -0,0 +1,24 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import InfraOS from '@overflow/infra/api/model/InfraOS'; + +import * as actionType from '../action/os_read'; +import ReadOSState, { defaultState as ReadOSDefaultState } from '../state/OSRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadOSState = ReadOSDefaultState, action: Action): + ReadOSState => { + return { + ...state, + os: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadOSState = ReadOSDefaultState, action: Action): + ReadOSState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/infra_os_regist.ts b/src/ts/@overflow/infra/redux/reducer/os_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_os_regist.ts rename to src/ts/@overflow/infra/redux/reducer/os_regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/infra_regist.ts b/src/ts/@overflow/infra/redux/reducer/regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_regist.ts rename to src/ts/@overflow/infra/redux/reducer/regist.ts diff --git a/src/ts/@overflow/infra/redux/reducer/service_read.ts b/src/ts/@overflow/infra/redux/reducer/service_read.ts index e69de29..4cdc373 100644 --- a/src/ts/@overflow/infra/redux/reducer/service_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/service_read.ts @@ -0,0 +1,24 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import InfraService from '@overflow/infra/api/model/InfraService'; + +import * as actionType from '../action/service_read'; +import ReadServiceState, { defaultState as ReadServiceDefaultState } from '../state/ServiceRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadServiceState = ReadServiceDefaultState, action: Action): + ReadServiceState => { + return { + ...state, + service: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadServiceState = ReadServiceDefaultState, action: Action): + ReadServiceState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/infra_service_regist.ts b/src/ts/@overflow/infra/redux/reducer/service_regist.ts similarity index 100% rename from src/ts/@overflow/infra/redux/reducer/infra_service_regist.ts rename to src/ts/@overflow/infra/redux/reducer/service_regist.ts diff --git a/src/ts/@overflow/target/react/TargetDetail.tsx b/src/ts/@overflow/target/react/TargetDetail.tsx index c8e3ea8..d1f1bef 100644 --- a/src/ts/@overflow/target/react/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/TargetDetail.tsx @@ -6,12 +6,27 @@ import { } from './components/TargetDetail'; import * as targetDetailActions from '../redux/action/read'; +import * as HostReadActions from '@overflow/infra/redux/action/host_read'; +import * as MachineReadActions from '@overflow/infra/redux/action/machine_read'; +import * as OSReadActions from '@overflow/infra/redux/action/os_read'; +import * as ServiceReadActions from '@overflow/infra/redux/action/service_read'; +import * as ApplicationReadActions from '@overflow/infra/redux/action/os_application_read'; +import * as DaemonReadActions from '@overflow/infra/redux/action/os_daemon_read'; +import * as PortReadActions from '@overflow/infra/redux/action/os_port_read'; + import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; export function mapStateToProps(state: any, props: any): StateProps { return { id: props.params.id, infra: state.infra, + machine: state.machine, + host: state.host, + os: state.os, + osApplication: state.osApplication, + osDaemon: state.osDaemon, + osPort: state.osPort, + service: state.service, }; } @@ -20,6 +35,27 @@ export function mapDispatchToProps(dispatch: Dispatch): DispatchProps { onRead: (id: string) => { dispatch(asyncRequestActions.request('InfraService', 'read', targetDetailActions.REQUEST, id)); }, + onReadInfraMachine: (id: string) => { + dispatch(asyncRequestActions.request('InfraMachineService', 'read', MachineReadActions.REQUEST, id)); + }, + onReadInfraHost: (id: string) => { + dispatch(asyncRequestActions.request('InfraHostService', 'read', HostReadActions.REQUEST, id)); + }, + onReadInfraOS: (id: string) => { + dispatch(asyncRequestActions.request('InfraOSService', 'read', OSReadActions.REQUEST, id)); + }, + onReadInfraOSApplication: (id: string) => { + dispatch(asyncRequestActions.request('InfraOSApplicationService', 'read', ApplicationReadActions.REQUEST, id)); + }, + onReadInfraOSDaemon: (id: string) => { + dispatch(asyncRequestActions.request('InfraOSDaemonService', 'read', DaemonReadActions.REQUEST, id)); + }, + onReadInfraOSPort: (id: string) => { + dispatch(asyncRequestActions.request('InfraOSPortService', 'read', PortReadActions.REQUEST, id)); + }, + onReadInfraService: (id: string) => { + dispatch(asyncRequestActions.request('InfraServiceService', 'read', ServiceReadActions.REQUEST, id)); + }, }; } diff --git a/src/ts/@overflow/target/react/_ b/src/ts/@overflow/target/react/_ deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/target/react/components/TargetDetail.tsx b/src/ts/@overflow/target/react/components/TargetDetail.tsx index ef2bfe9..5ebd51a 100644 --- a/src/ts/@overflow/target/react/components/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/components/TargetDetail.tsx @@ -2,18 +2,40 @@ import * as React from 'react'; import { Button, Table, Header, Container } from 'semantic-ui-react'; import { DetailContainer } from '@overflow/commons/react/component/DetailContainer'; import { TargetDetailInfra } from './TargetDetailInfra'; -import InfraDetailContainer from '@overflow/infra/react/InfraDetail'; import Infra from '@overflow/infra/api/model/Infra'; +import InfraHost from '@overflow/infra/api/model/InfraHost'; +import InfraMachine from '@overflow/infra/api/model/InfraMachine'; +import InfraOS from '@overflow/infra/api/model/InfraOS'; +import InfraOSApplication from '@overflow/infra/api/model/InfraOSApplication'; +import InfraOSDaemon from '@overflow/infra/api/model/InfraOSDaemon'; +import InfraOSPort from '@overflow/infra/api/model/InfraOSPort'; +import InfraService from '@overflow/infra/api/model/InfraService'; + import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { id: string; infra: Infra; + + machine?: InfraMachine; + host?: InfraHost; + os?: InfraOS; + osApplication?: InfraOSApplication; + osDaemon?: InfraOSDaemon; + osPort?: InfraOSPort; + service?: InfraService; } export interface DispatchProps { onRead(id: string): void; + onReadInfraMachine?(id: string): void; + onReadInfraHost?(id: string): void; + onReadInfraOS?(id: string): void; + onReadInfraOSApplication?(id: string): void; + onReadInfraOSDaemon?(id: string): void; + onReadInfraOSPort?(id: string): void; + onReadInfraService?(id: string): void; } export type Props = StateProps & DispatchProps; @@ -38,22 +60,268 @@ export class TargetDetail extends React.Component { alert('remove'); } + public shouldComponentUpdate(nextProps: any, nextContext: any): boolean { + if (this.props.infra === undefined) { + return false; + } + if (nextProps.infra.id !== this.props.infra.id) { + return true; + } + return false; + } + + public getChild(): void { + let infraType = this.props.infra.infraType.id; + let id = String(this.props.infra.childId); + switch (infraType) { + case 1: { + this.props.onReadInfraMachine(id); + break; + } + case 2: { + this.props.onReadInfraHost(id); + break; + } + case 3: { + this.props.onReadInfraOS(id); + break; + } + case 4: { + this.props.onReadInfraOSApplication(id); + break; + } + case 5: { + this.props.onReadInfraOSDaemon(id); + break; + } + case 6: { + this.props.onReadInfraOSPort(id); + break; + } + case 7: { + this.props.onReadInfraService(id); + break; + } + default: { + break; + } + } + + } + public render(): JSX.Element { if (this.props.infra === undefined) { return null; + } else { + this.getChild(); } return (
- + {this.renderInfraChild()}
); } + + public renderInfraChild(): JSX.Element { + if (this.props.machine === undefined + && this.props.host === undefined + && this.props.os === undefined + && this.props.osApplication === undefined + && this.props.osDaemon === undefined + && this.props.osPort === undefined + && this.props.service === undefined + ) { + return null; + } + let infraType = this.props.infra.infraType.id; + switch (infraType) { + case 1: { + return ; + } + case 2: { + return ; + } + case 3: { + return ; + } + case 4: { + return ; + } + case 5: { + return ; + } + case 6: { + return ; + } + case 7: { + return ; + } + default: { + break; + } + } + } + + private ConvertTableDataForHost(infraChild: InfraHost): Array { + let NewTableDatas: Array; + NewTableDatas = [{ + header: 'IP', + contents: Utils.int2ip(infraChild.ip), + }, + { + header: 'MAC', + contents: Utils.intToMac(infraChild.mac), + }, + ]; + return NewTableDatas; + } + + private ConvertTableDataForMachine(infraChild: InfraMachine): Array { + let NewTableDatas: Array; + + NewTableDatas = [{ + header: 'Meta', + contents: infraChild.meta, + }, + ]; + return NewTableDatas; + } + + private ConvertTableDataForOS(infraChild: InfraOS): Array { + let NewTableDatas: Array; + NewTableDatas = [ + { + header: 'Meta', + contents: infraChild.meta, + }, + { + header: 'Vendor', + contents: infraChild.vendor.name, + }, + ]; + return NewTableDatas; + } + + private ConvertTableDataForApplication(infraChild: InfraOSApplication): Array { + let NewTableDatas: Array; + NewTableDatas = [ + { + header: 'Name', + contents: infraChild.name, + }, + { + header: 'OS', + contents: infraChild.os.vendor.name, + }, + ]; + return NewTableDatas; + } + private ConvertTableDataForDaemon(infraChild: InfraOSDaemon): Array { + let NewTableDatas: Array; + NewTableDatas = [ + { + header: 'Name', + contents: infraChild.name, + }, + { + header: 'OS', + contents: infraChild.os.vendor.name, + }, + ]; + return NewTableDatas; + } + + private ConvertTableDataForPort(infraChild: InfraOSPort): Array { + let NewTableDatas: Array; + NewTableDatas = [ + { + header: 'Port', + contents: infraChild.port, + }, + { + header: 'Type', + contents: infraChild.portType, + }, + { + header: 'OS', + contents: infraChild.os.vendor.name, + }, + ]; + return NewTableDatas; + } + private ConvertTableDataForService(infraChild: InfraService): Array { + let NewTableDatas: Array; + NewTableDatas = [ + { + header: 'Host', + contents: infraChild.host.ip, + }, + { + header: 'Port', + contents: infraChild.port, + }, + { + header: 'Type', + contents: infraChild.portType, + }, + { + header: 'OS', + contents: infraChild.host.os.vendor.name, + }, + ]; + return NewTableDatas; + } } +export interface TableData { + header: string; + contents: any; +} + +export interface InfraTableProps { + tableDatas: Array; +} + +export class InfraTable extends React.Component { + constructor(props: InfraTableProps, context: any) { + super(props, context); + this.state = { + }; + } + + public showInfra(): JSX.Element[] { + let elems: Array = new Array(); + let i = 0; + for (let data of this.props.tableDatas) { + elems.push( + + +
{data.header}
+
+ + {data.contents} + +
, + ); + } + + return elems; + } + + public render(): JSX.Element { + return ( + + + {this.showInfra()} + +
+ ); + } +} export interface TargetBasicInfoProps { infra?: Infra; diff --git a/src/ts/@overflow/target/react/components/_ b/src/ts/@overflow/target/react/components/_ deleted file mode 100644 index e69de29..0000000