From 8dd3cc62f9aa73d0fe00fc9079af2b451c22c8f7 Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 11 Aug 2017 17:46:56 +0900 Subject: [PATCH] infra children --- src/ts/@overflow/app/config/index.ts | 4 + src/ts/@overflow/infra/react/InfraDetail.tsx | 36 +- .../infra/react/components/InfraDetail.tsx | 315 +++++++----------- .../@overflow/infra/redux/action/host_read.ts | 43 --- .../infra/redux/action/machine_read.ts | 43 --- .../infra/redux/action/os_application_read.ts | 43 --- .../infra/redux/action/os_daemon_read.ts | 43 --- .../infra/redux/action/os_port_read.ts | 43 --- .../@overflow/infra/redux/action/os_read.ts | 43 --- src/ts/@overflow/infra/redux/action/read.ts | 43 +-- .../infra/redux/action/read_by_child.ts | 46 --- .../infra/redux/action/service_read.ts | 43 --- .../infra/redux/reducer/host_read.ts | 24 ++ .../infra/redux/reducer/machine_read.ts | 24 ++ .../@overflow/infra/redux/state/HostRead.ts | 13 + .../infra/redux/state/MachineRead.ts | 13 + .../infra/redux/state/OSApplicationRead.ts | 13 + .../infra/redux/state/OSDaemonRead.ts | 13 + .../@overflow/infra/redux/state/OSPortRead.ts | 13 + src/ts/@overflow/infra/redux/state/OSRead.ts | 13 + .../infra/redux/state/ServiceRead.ts | 13 + .../@overflow/meta/api/model/MetaInfraType.ts | 4 +- 22 files changed, 293 insertions(+), 595 deletions(-) delete mode 100644 src/ts/@overflow/infra/redux/action/host_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/machine_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/os_application_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/os_daemon_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/os_port_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/os_read.ts delete mode 100644 src/ts/@overflow/infra/redux/action/read_by_child.ts delete mode 100644 src/ts/@overflow/infra/redux/action/service_read.ts diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index c9b1154..52eb65a 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -16,6 +16,8 @@ import readAllByTargetReducer from '@overflow/sensor/redux/reducer/read_all_by_t import SensorReadReducer from '@overflow/sensor/redux/reducer/read'; import SensorItemReadAllBySensorReducer from '@overflow/sensor/redux/reducer/item_read_all_by_sensor'; +import readMachineReducer from '@overflow/infra/redux/reducer/machine_read'; +import readHostReducer from '@overflow/infra/redux/reducer/host_read'; import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; @@ -61,6 +63,8 @@ const reduxConfig: ReduxConfig = { readAllTargetByProbeReducer, readTargetReducer, readNoAuthProbeReducer, + readMachineReducer, + readHostReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/infra/react/InfraDetail.tsx b/src/ts/@overflow/infra/react/InfraDetail.tsx index 2b84da6..eca5de9 100644 --- a/src/ts/@overflow/infra/react/InfraDetail.tsx +++ b/src/ts/@overflow/infra/react/InfraDetail.tsx @@ -6,21 +6,47 @@ import { } from './components/InfraDetail'; import MetaInfraType from '@overflow/meta/api/model/MetaInfraType'; -import * as ReadByChildActions from '../redux/action/read_by_child'; +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 { - target: props.target, - 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 { - onGetChildInfra: (type: MetaInfraType, id: number) => { - dispatch(ReadByChildActions.request(type, id)); + 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 index 7297b64..2e7688f 100644 --- a/src/ts/@overflow/infra/react/components/InfraDetail.tsx +++ b/src/ts/@overflow/infra/react/components/InfraDetail.tsx @@ -9,113 +9,156 @@ 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 { - childInfra: any; // todo. fix to InfraTypes - tableDatas: Array; - testInfra: Infra; } - export class InfraDetail extends React.Component { constructor(props: Props, context: State) { super(props, context); this.state = { - childInfra: null, - tableDatas: null, - testInfra: InfraJson, }; } public componentWillMount(): void { - this.getInfraChild(); - } - - public getInfraChild = () => { - let childObject = InfraHostJson; - - this.setState({ - childInfra: childObject, - }); + let infraType = this.props.infra.infraType.id; + let id = String(this.props.infra.childId); + console.log('**** componentWillMount', infraType); + 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 ConvertInfra = () => { - // let type = this.props.infra.type.name; - let NewTableDatas: Array; - let type = this.state.testInfra.infraType.name; - switch (type) { - case 'MACHINE': - NewTableDatas = this.ConvertTableDataForMachine(this.state.childInfra); - break; - case 'HOST': - NewTableDatas = this.ConvertTableDataForHost(this.state.childInfra); - break; - case 'OS': { - break; - } - case 'OS_APPLICATION': { - break; - } - case 'OS_DAEMON': { - break; - } - case 'OS_PORT': { - break; - } - case 'OS_SERVICE': { - break; - } - default: - break; - - } - return NewTableDatas; - - } - - - 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 ( - {/**/} -

test - InfraHost

- -

test - InfraHost

- -

test - InfraOS

- + {child}
); } - private ConvertTableDataForHost(infraChild: InfraHost): Array { let NewTableDatas: Array; NewTableDatas = [{ header: 'IP', - contents: Utils.int2ip(infraChild.ip), + contents: infraChild.ip, }, { header: 'MAC', - contents: Utils.intToMac(infraChild.mac), + contents: infraChild.mac, }, ]; @@ -127,7 +170,7 @@ export class InfraDetail extends React.Component { let NewTableDatas: Array; NewTableDatas = [{ - header: 'meta', + header: 'Meta', contents: infraChild.meta, }, ]; @@ -141,11 +184,11 @@ export class InfraDetail extends React.Component { NewTableDatas = [ { - header: 'meta', + header: 'Meta', contents: infraChild.meta, }, { - header: 'vendor', + header: 'Vendor', contents: infraChild.vendor.name, }, ]; @@ -158,7 +201,7 @@ export class InfraDetail extends React.Component { export interface TableData { header: string; - contents: string; + contents: any; } export interface InfraTableProps { @@ -172,12 +215,12 @@ export class InfraTable extends React.Component { }; } - public ViewInfra(): JSX.Element[] { + public showInfra(): JSX.Element[] { let elems: Array = new Array(); - + let i = 0; for (let data of this.props.tableDatas) { elems.push( - +
{data.header}
@@ -195,142 +238,10 @@ export class InfraTable extends React.Component { return ( - {this.ViewInfra()} + {this.showInfra()}
); } } - -const InfraJson: any = { - 'id': 3, - 'infraType': { - 'id': 2, - 'name': 'HOST', - 'createDate': 1498379502894, - }, - 'childId': 1, - 'createDate': 1501207730841, - 'probe': { - 'id': 1, - 'status': { - 'id': 1, - 'name': 'INITIAL', - }, - 'description': 'snoop probe', - 'createDate': 1501153288513, - 'domain': { - 'id': 1, - 'name': 'overFlow\'s domain', - 'createDate': 1498443944866, - }, - 'probeKey': '899fdd145bcc11e7b611080027658d13', - 'encryptionKey': '8c51fa9c5bcc11e7980a080027658d13', - 'targetCount': 0, - 'sensorCount': 0, - 'displayName': 'test probe', - 'cidr': '192.168.1.0/24', - 'authorizeDate': 1501153288513, - 'authorizeMember': { - 'id': 1, - 'email': 'overflow@loafle.com', - 'pw': 'qwer5795', - 'name': 'overFlow', - 'phone': '000-000-0000', - 'companyName': 'loafle', - 'createDate': 1498442847625, - 'status': { - 'id': 2, - 'name': 'NORMAL', - }, - }, - 'host': { - 'id': 1, - 'os': { - 'id': 1, - 'machine': { - 'id': 1, - 'meta': '', - 'createDate': 1501152866677, - }, - 'meta': '', - 'createDate': 1501152947326, - 'vendor': { - 'id': 26, - 'name': 'Windows', - 'createDate': 1501136812985, - 'infraType': { - 'id': 3, - 'name': 'OS', - 'createDate': 1498379502906, - }, - }, - }, - 'ip': 3232235980, - 'mac': 8796753988883, - 'createDate': 1501153030607, - }, - }, - 'target': { - 'id': 1, - 'createDate': 1501154289555, - 'displayName': 'ghost target', - 'description': 'i am target', - }, -}; - - -const InfraHostJson: any = { - 'id': 1, - 'os': { - 'id': 1, - 'machine': { - 'id': 1, - 'meta': '', - 'createDate': 1501152866677, - }, - 'meta': '', - 'createDate': 1501152947326, - 'vendor': { - 'id': 26, - 'name': 'Windows', - 'createDate': 1501136812985, - 'infraType': { - 'id': 3, - 'name': 'OS', - 'createDate': 1498379502906, - }, - }, - }, - 'ip': 3232235980, - 'mac': 8796753988883, - 'createDate': 1501153030607, -}; - -const InfraMachineJson: any = { - 'id': 1, - 'meta': '', - 'createDate': 1501152866677, -}; - -const InfraOSJson: any = { - 'id': 1, - 'machine': { - 'id': 1, - 'meta': '', - 'createDate': 1501152866677, - }, - 'meta': '', - 'createDate': 1501152947326, - 'vendor': { - 'id': 26, - 'name': 'Windows', - 'createDate': 1501136812985, - 'infraType': { - 'id': 3, - 'name': 'OS', - 'createDate': 1498379502906, - }, - }, -}; diff --git a/src/ts/@overflow/infra/redux/action/host_read.ts b/src/ts/@overflow/infra/redux/action/host_read.ts deleted file mode 100644 index bfef34b..0000000 --- a/src/ts/@overflow/infra/redux/action/host_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraHost from '../..//api/model/InfraHost'; - -import HostReadPayload from '../payload/HostReadPayload'; - -// 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'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraHost: InfraHost) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraHost: InfraHost): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraHost, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/machine_read.ts b/src/ts/@overflow/infra/redux/action/machine_read.ts deleted file mode 100644 index afa91b5..0000000 --- a/src/ts/@overflow/infra/redux/action/machine_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraMachine from '../..//api/model/InfraMachine'; - -import MachineReadPayload from '../payload/MachineReadPayload'; - -// 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'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraMachine: InfraMachine) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraMachine: InfraMachine): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraMachine, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/os_application_read.ts b/src/ts/@overflow/infra/redux/action/os_application_read.ts deleted file mode 100644 index 371abd9..0000000 --- a/src/ts/@overflow/infra/redux/action/os_application_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraOSApplication from '../..//api/model/InfraOSApplication'; - -import OSApplicationReadPayload from '../payload/OSApplicationReadPayload'; - -// Action Type -export type REQUEST = '@overflow/infra/os_application_read/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/infra/os_application_read/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/infra/os_application_read/REQUEST_FAILURE'; - -export const REQUEST: REQUEST = '@overflow/infra/os_application_read/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/os_application_read/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/os_application_read/REQUEST_FAILURE'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraOSApplication: InfraOSApplication) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraOSApplication: InfraOSApplication): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraOSApplication, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/os_daemon_read.ts b/src/ts/@overflow/infra/redux/action/os_daemon_read.ts deleted file mode 100644 index e64369c..0000000 --- a/src/ts/@overflow/infra/redux/action/os_daemon_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraOSDaemon from '../..//api/model/InfraOSDaemon'; - -import OSDaemonReadPayload from '../payload/OSDaemonReadPayload'; - -// Action Type -export type REQUEST = '@overflow/infra/os_daemon_read/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/infra/os_daemon_read/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/infra/os_daemon_read/REQUEST_FAILURE'; - -export const REQUEST: REQUEST = '@overflow/infra/os_daemon_read/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/os_daemon_read/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/os_daemon_read/REQUEST_FAILURE'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraOSDaemon: InfraOSDaemon) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraOSDaemon: InfraOSDaemon): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraOSDaemon, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/os_port_read.ts b/src/ts/@overflow/infra/redux/action/os_port_read.ts deleted file mode 100644 index 76dea06..0000000 --- a/src/ts/@overflow/infra/redux/action/os_port_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraOSPort from '../..//api/model/InfraOSPort'; - -import OSPortReadPayload from '../payload/OSPortReadPayload'; - -// Action Type -export type REQUEST = '@overflow/infra/os_port_read/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/infra/os_port_read/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/infra/os_port_read/REQUEST_FAILURE'; - -export const REQUEST: REQUEST = '@overflow/infra/os_port_read/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/os_port_read/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/os_port_read/REQUEST_FAILURE'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraOSPort: InfraOSPort) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraOSPort: InfraOSPort): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraOSPort, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/os_read.ts b/src/ts/@overflow/infra/redux/action/os_read.ts deleted file mode 100644 index 131a033..0000000 --- a/src/ts/@overflow/infra/redux/action/os_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraOS from '../..//api/model/InfraOS'; - -import OSReadPayload from '../payload/OSReadPayload'; - -// 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'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraOS: InfraOS) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraOS: InfraOS): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraOS, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/read.ts b/src/ts/@overflow/infra/redux/action/read.ts index d0a0c5e..2d24f1b 100644 --- a/src/ts/@overflow/infra/redux/action/read.ts +++ b/src/ts/@overflow/infra/redux/action/read.ts @@ -1,43 +1,8 @@ -import Action from '@overflow/commons/redux/Action'; -import Infra from '../..//api/model/Infra'; - -import ReadPayload from '../payload/ReadPayload'; - // Action Type export type REQUEST = '@overflow/infra/read/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/infra/read/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/infra/read/REQUEST_FAILURE'; +export type REQUEST_SUCCESS = '@overflow/infra/read/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/infra/read/REQUEST/FAILURE'; export const REQUEST: REQUEST = '@overflow/infra/read/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/read/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/read/REQUEST_FAILURE'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infra: Infra) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infra: Infra): Action => { - return { - type: REQUEST_SUCCESS, - payload: infra, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/read/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/read/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/infra/redux/action/read_by_child.ts b/src/ts/@overflow/infra/redux/action/read_by_child.ts deleted file mode 100644 index 1422e35..0000000 --- a/src/ts/@overflow/infra/redux/action/read_by_child.ts +++ /dev/null @@ -1,46 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import Infra from '../..//api/model/Infra'; - -import ReadByChildPayload from '../payload/ReadByChildPayload'; - -import MetaInfraType from '@overflow/meta/api/model/MetaInfraType'; - -// Action Type -export type REQUEST = '@overflow/infra/read_by_child/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/infra/read_by_child/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/infra/read_by_child/REQUEST_FAILURE'; - -export const REQUEST: REQUEST = '@overflow/infra/read_by_child/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/infra/read_by_child/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/infra/read_by_child/REQUEST_FAILURE'; - -// Action Creater -export type request = (metaInfraType: MetaInfraType, id: number) => Action; -export type requestSuccess = (infra: Infra) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (metaInfraType: MetaInfraType, id: number): Action => { - return { - type: REQUEST, - payload: { - metaInfraType: metaInfraType, - id: id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infra: Infra): Action => { - return { - type: REQUEST_SUCCESS, - payload: infra, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/action/service_read.ts b/src/ts/@overflow/infra/redux/action/service_read.ts deleted file mode 100644 index c547617..0000000 --- a/src/ts/@overflow/infra/redux/action/service_read.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import InfraService from '../..//api/model/InfraService'; - -import ServiceReadPayload from '../payload/ServiceReadPayload'; - -// 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'; - -// Action Creater -export type request = (id: number) => Action; -export type requestSuccess = (infraService: InfraService) => Action; -export type requestFailure = (error: Error) => Action; - - - -export const request: request = (id: number): Action => { - return { - type: REQUEST, - payload: { - id:id, - }, - }; -}; - -export const requestSuccess: requestSuccess = (infraService: InfraService): Action => { - return { - type: REQUEST_SUCCESS, - payload: infraService, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/infra/redux/reducer/host_read.ts b/src/ts/@overflow/infra/redux/reducer/host_read.ts index e69de29..08fd717 100644 --- a/src/ts/@overflow/infra/redux/reducer/host_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/host_read.ts @@ -0,0 +1,24 @@ +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 ReadHostState, { defaultState as ReadHostDefaultState } from '../state/HostRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadHostState = ReadHostDefaultState, action: Action): + ReadHostState => { + return { + ...state, + host: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadHostState = ReadHostDefaultState, action: Action): + ReadHostState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/reducer/machine_read.ts b/src/ts/@overflow/infra/redux/reducer/machine_read.ts index e69de29..5f51697 100644 --- a/src/ts/@overflow/infra/redux/reducer/machine_read.ts +++ b/src/ts/@overflow/infra/redux/reducer/machine_read.ts @@ -0,0 +1,24 @@ +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 ReadMachineState, { defaultState as ReadMachineDefaultState } from '../state/MachineRead'; + +const reducer: ReducersMapObject = { + [actionType.REQUEST_SUCCESS]: + (state: ReadMachineState = ReadMachineDefaultState, action: Action): + ReadMachineState => { + return { + ...state, + machine: action.payload, + }; + }, + [actionType.REQUEST_FAILURE]: + (state: ReadMachineState = ReadMachineDefaultState, action: Action): + ReadMachineState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/infra/redux/state/HostRead.ts b/src/ts/@overflow/infra/redux/state/HostRead.ts index e69de29..ce699e2 100644 --- a/src/ts/@overflow/infra/redux/state/HostRead.ts +++ b/src/ts/@overflow/infra/redux/state/HostRead.ts @@ -0,0 +1,13 @@ +import InfraHost from '@overflow/infra/api/model/InfraHost'; + +export interface State { + readonly host?: InfraHost; + readonly error?: Error; +} + +export const defaultState: State = { + host: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/MachineRead.ts b/src/ts/@overflow/infra/redux/state/MachineRead.ts index e69de29..980af98 100644 --- a/src/ts/@overflow/infra/redux/state/MachineRead.ts +++ b/src/ts/@overflow/infra/redux/state/MachineRead.ts @@ -0,0 +1,13 @@ +import InfraMachine from '@overflow/infra/api/model/InfraMachine'; + +export interface State { + readonly machine?: InfraMachine; + readonly error?: Error; +} + +export const defaultState: State = { + machine: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/OSApplicationRead.ts b/src/ts/@overflow/infra/redux/state/OSApplicationRead.ts index e69de29..577346d 100644 --- a/src/ts/@overflow/infra/redux/state/OSApplicationRead.ts +++ b/src/ts/@overflow/infra/redux/state/OSApplicationRead.ts @@ -0,0 +1,13 @@ +import InfraOSApplication from '@overflow/infra/api/model/InfraOSApplication'; + +export interface State { + readonly osApplication?: InfraOSApplication; + readonly error?: Error; +} + +export const defaultState: State = { + osApplication: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/OSDaemonRead.ts b/src/ts/@overflow/infra/redux/state/OSDaemonRead.ts index e69de29..e8eab86 100644 --- a/src/ts/@overflow/infra/redux/state/OSDaemonRead.ts +++ b/src/ts/@overflow/infra/redux/state/OSDaemonRead.ts @@ -0,0 +1,13 @@ +import InfraOSDaemon from '@overflow/infra/api/model/InfraOSDaemon'; + +export interface State { + readonly osDaemon?: InfraOSDaemon; + readonly error?: Error; +} + +export const defaultState: State = { + osDaemon: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/OSPortRead.ts b/src/ts/@overflow/infra/redux/state/OSPortRead.ts index e69de29..1c2f6d0 100644 --- a/src/ts/@overflow/infra/redux/state/OSPortRead.ts +++ b/src/ts/@overflow/infra/redux/state/OSPortRead.ts @@ -0,0 +1,13 @@ +import InfraOSPort from '@overflow/infra/api/model/InfraOSPort'; + +export interface State { + readonly osPort?: InfraOSPort; + readonly error?: Error; +} + +export const defaultState: State = { + osPort: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/OSRead.ts b/src/ts/@overflow/infra/redux/state/OSRead.ts index e69de29..8c1d9ec 100644 --- a/src/ts/@overflow/infra/redux/state/OSRead.ts +++ b/src/ts/@overflow/infra/redux/state/OSRead.ts @@ -0,0 +1,13 @@ +import InfraOS from '@overflow/infra/api/model/InfraOS'; + +export interface State { + readonly os?: InfraOS; + readonly error?: Error; +} + +export const defaultState: State = { + os: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/infra/redux/state/ServiceRead.ts b/src/ts/@overflow/infra/redux/state/ServiceRead.ts index e69de29..703b13c 100644 --- a/src/ts/@overflow/infra/redux/state/ServiceRead.ts +++ b/src/ts/@overflow/infra/redux/state/ServiceRead.ts @@ -0,0 +1,13 @@ +import InfraService from '@overflow/infra/api/model/InfraService'; + +export interface State { + readonly service?: InfraService; + readonly error?: Error; +} + +export const defaultState: State = { + service: undefined, + error: undefined, +}; + +export default State; diff --git a/src/ts/@overflow/meta/api/model/MetaInfraType.ts b/src/ts/@overflow/meta/api/model/MetaInfraType.ts index 09acfc8..66631c9 100644 --- a/src/ts/@overflow/meta/api/model/MetaInfraType.ts +++ b/src/ts/@overflow/meta/api/model/MetaInfraType.ts @@ -1,8 +1,8 @@ interface MetaInfraType { id?: number; - name: string; - createDate: Date; + name?: string; + createDate?: Date; } export enum MetaInfraType_ID {