infra children

This commit is contained in:
insanity 2017-08-11 17:46:56 +09:00
parent 1de2073605
commit 8dd3cc62f9
22 changed files with 293 additions and 595 deletions

View File

@ -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,

View File

@ -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<any>): 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);

View File

@ -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<TableData>;
testInfra: Infra;
}
export class InfraDetail extends React.Component<Props, State> {
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<TableData>;
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 = <InfraTable tableDatas={this.ConvertTableDataForMachine(this.props.machine)} />;
break;
}
case 2: {
child = <InfraTable tableDatas={this.ConvertTableDataForHost(this.props.host)} />;
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 (
<Container fluid>
{/*<InfraTable tableDatas={this.ConvertInfra()} />*/}
<h3>test - InfraHost</h3>
<InfraTable tableDatas={this.ConvertTableDataForHost(InfraHostJson)} />
<h3>test - InfraHost</h3>
<InfraTable tableDatas={this.ConvertTableDataForMachine(InfraMachineJson)} />
<h3>test - InfraOS</h3>
<InfraTable tableDatas={this.ConvertTableDataForOS(InfraOSJson)} />
{child}
</Container>
);
}
private ConvertTableDataForHost(infraChild: InfraHost): Array<TableData> {
let NewTableDatas: Array<TableData>;
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<Props, State> {
let NewTableDatas: Array<TableData>;
NewTableDatas = [{
header: 'meta',
header: 'Meta',
contents: infraChild.meta,
},
];
@ -141,11 +184,11 @@ export class InfraDetail extends React.Component<Props, State> {
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<Props, State> {
export interface TableData {
header: string;
contents: string;
contents: any;
}
export interface InfraTableProps {
@ -172,12 +215,12 @@ export class InfraTable extends React.Component<InfraTableProps, any> {
};
}
public ViewInfra(): JSX.Element[] {
public showInfra(): JSX.Element[] {
let elems: Array<JSX.Element> = new Array();
let i = 0;
for (let data of this.props.tableDatas) {
elems.push(
<Table.Row>
<Table.Row key={i++}>
<Table.Cell collapsing>
<Header size='small'>{data.header}</Header>
</Table.Cell>
@ -195,142 +238,10 @@ export class InfraTable extends React.Component<InfraTableProps, any> {
return (
<Table celled={false}>
<Table.Body>
{this.ViewInfra()}
{this.showInfra()}
</Table.Body>
</Table>
);
}
}
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,
},
},
};

View File

@ -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<HostReadPayload>;
export type requestSuccess = (infraHost: InfraHost) => Action<InfraHost>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<HostReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraHost: InfraHost): Action<InfraHost> => {
return {
type: REQUEST_SUCCESS,
payload: infraHost,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<MachineReadPayload>;
export type requestSuccess = (infraMachine: InfraMachine) => Action<InfraMachine>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<MachineReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraMachine: InfraMachine): Action<InfraMachine> => {
return {
type: REQUEST_SUCCESS,
payload: infraMachine,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<OSApplicationReadPayload>;
export type requestSuccess = (infraOSApplication: InfraOSApplication) => Action<InfraOSApplication>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<OSApplicationReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraOSApplication: InfraOSApplication): Action<InfraOSApplication> => {
return {
type: REQUEST_SUCCESS,
payload: infraOSApplication,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<OSDaemonReadPayload>;
export type requestSuccess = (infraOSDaemon: InfraOSDaemon) => Action<InfraOSDaemon>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<OSDaemonReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraOSDaemon: InfraOSDaemon): Action<InfraOSDaemon> => {
return {
type: REQUEST_SUCCESS,
payload: infraOSDaemon,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<OSPortReadPayload>;
export type requestSuccess = (infraOSPort: InfraOSPort) => Action<InfraOSPort>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<OSPortReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraOSPort: InfraOSPort): Action<InfraOSPort> => {
return {
type: REQUEST_SUCCESS,
payload: infraOSPort,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<OSReadPayload>;
export type requestSuccess = (infraOS: InfraOS) => Action<InfraOS>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<OSReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraOS: InfraOS): Action<InfraOS> => {
return {
type: REQUEST_SUCCESS,
payload: infraOS,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<ReadPayload>;
export type requestSuccess = (infra: Infra) => Action<Infra>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<ReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infra: Infra): Action<Infra> => {
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';

View File

@ -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<ReadByChildPayload>;
export type requestSuccess = (infra: Infra) => Action<Infra>;
export type requestFailure = (error: Error) => Action;
export const request: request = (metaInfraType: MetaInfraType, id: number): Action<ReadByChildPayload> => {
return {
type: REQUEST,
payload: {
metaInfraType: metaInfraType,
id: id,
},
};
};
export const requestSuccess: requestSuccess = (infra: Infra): Action<Infra> => {
return {
type: REQUEST_SUCCESS,
payload: infra,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -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<ServiceReadPayload>;
export type requestSuccess = (infraService: InfraService) => Action<InfraService>;
export type requestFailure = (error: Error) => Action;
export const request: request = (id: number): Action<ServiceReadPayload> => {
return {
type: REQUEST,
payload: {
id:id,
},
};
};
export const requestSuccess: requestSuccess = (infraService: InfraService): Action<InfraService> => {
return {
type: REQUEST_SUCCESS,
payload: infraService,
};
};
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 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<InfraHost>):
ReadHostState => {
return {
...state,
host: <InfraHost>action.payload,
};
},
[actionType.REQUEST_FAILURE]:
(state: ReadHostState = ReadHostDefaultState, action: Action<Error>):
ReadHostState => {
return state;
},
};
export default reducer;

View File

@ -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<InfraMachine>):
ReadMachineState => {
return {
...state,
machine: <InfraMachine>action.payload,
};
},
[actionType.REQUEST_FAILURE]:
(state: ReadMachineState = ReadMachineDefaultState, action: Action<Error>):
ReadMachineState => {
return state;
},
};
export default reducer;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
interface MetaInfraType {
id?: number;
name: string;
createDate: Date;
name?: string;
createDate?: Date;
}
export enum MetaInfraType_ID {