From a630a4eb9909d7917b609150313509580843a1bd Mon Sep 17 00:00:00 2001 From: snoop Date: Mon, 21 Aug 2017 16:47:07 +0900 Subject: [PATCH] fixed infra model --- src/ts/@overflow/infra/api/model/InfraHost.ts | 5 +- .../@overflow/infra/api/model/InfraMachine.ts | 6 +- src/ts/@overflow/infra/api/model/InfraOS.ts | 6 +- .../infra/api/model/InfraOSApplication.ts | 5 +- .../infra/api/model/InfraOSDaemon.ts | 5 +- .../@overflow/infra/api/model/InfraOSPort.ts | 5 +- .../@overflow/infra/api/model/InfraService.ts | 5 +- src/ts/@overflow/target/react/TargetChild.tsx | 56 +++--- .../target/react/components/TargetChild.tsx | 170 +++++++++--------- .../target/react/components/TargetDetail.tsx | 2 +- 10 files changed, 136 insertions(+), 129 deletions(-) diff --git a/src/ts/@overflow/infra/api/model/InfraHost.ts b/src/ts/@overflow/infra/api/model/InfraHost.ts index f112202..aab7e9c 100644 --- a/src/ts/@overflow/infra/api/model/InfraHost.ts +++ b/src/ts/@overflow/infra/api/model/InfraHost.ts @@ -1,7 +1,8 @@ import InfraOS from './InfraOS'; +import Infra from './Infra'; -interface InfraHost { - id?: number; +interface InfraHost extends Infra { + // id?: number; os?: InfraOS; ip?: number; mac?: number; diff --git a/src/ts/@overflow/infra/api/model/InfraMachine.ts b/src/ts/@overflow/infra/api/model/InfraMachine.ts index c74330e..0baa64d 100644 --- a/src/ts/@overflow/infra/api/model/InfraMachine.ts +++ b/src/ts/@overflow/infra/api/model/InfraMachine.ts @@ -1,6 +1,8 @@ -interface InfraMachine { - id?: number; +import Infra from './Infra'; + +interface InfraMachine extends Infra { + // id?: number; meta?: string; createDate?: Date; } diff --git a/src/ts/@overflow/infra/api/model/InfraOS.ts b/src/ts/@overflow/infra/api/model/InfraOS.ts index 3c75e7e..b4d6b97 100644 --- a/src/ts/@overflow/infra/api/model/InfraOS.ts +++ b/src/ts/@overflow/infra/api/model/InfraOS.ts @@ -1,9 +1,9 @@ import InfraMachine from './InfraMachine'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; +import Infra from './Infra'; - -interface InfraOS { - id?: number; +interface InfraOS extends Infra { + // id?: number; machine?: InfraMachine; meta?: string; createDate?: Date; diff --git a/src/ts/@overflow/infra/api/model/InfraOSApplication.ts b/src/ts/@overflow/infra/api/model/InfraOSApplication.ts index 821acbf..681ff7d 100644 --- a/src/ts/@overflow/infra/api/model/InfraOSApplication.ts +++ b/src/ts/@overflow/infra/api/model/InfraOSApplication.ts @@ -1,8 +1,9 @@ import InfraOS from './InfraOS'; +import Infra from './Infra'; -interface InfraOSApplication { - id?: number; +interface InfraOSApplication extends Infra { + // id?: number; os?: InfraOS; name?: string; createDate?: Date; diff --git a/src/ts/@overflow/infra/api/model/InfraOSDaemon.ts b/src/ts/@overflow/infra/api/model/InfraOSDaemon.ts index f42962d..0e5321d 100644 --- a/src/ts/@overflow/infra/api/model/InfraOSDaemon.ts +++ b/src/ts/@overflow/infra/api/model/InfraOSDaemon.ts @@ -1,7 +1,8 @@ import InfraOS from './InfraOS'; +import Infra from './Infra'; -interface InfraOSDaemon { - id?: number; +interface InfraOSDaemon extends Infra { + // id?: number; os?: InfraOS; name?: string; createDate?: Date; diff --git a/src/ts/@overflow/infra/api/model/InfraOSPort.ts b/src/ts/@overflow/infra/api/model/InfraOSPort.ts index bd9ce5a..fc5888e 100644 --- a/src/ts/@overflow/infra/api/model/InfraOSPort.ts +++ b/src/ts/@overflow/infra/api/model/InfraOSPort.ts @@ -1,8 +1,9 @@ import InfraOS from './InfraOS'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; +import Infra from './Infra'; -interface InfraOSPort { - id?: number; +interface InfraOSPort extends Infra { + // id?: number; os?: InfraOS; createDate?: Date; port?: number; diff --git a/src/ts/@overflow/infra/api/model/InfraService.ts b/src/ts/@overflow/infra/api/model/InfraService.ts index 8ce91ab..112595f 100644 --- a/src/ts/@overflow/infra/api/model/InfraService.ts +++ b/src/ts/@overflow/infra/api/model/InfraService.ts @@ -1,8 +1,9 @@ import InfraHost from './InfraHost'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; +import Infra from './Infra'; -interface InfraService { - id?: number; +interface InfraService extends Infra { + // id?: number; host?: InfraHost; portType?: string; port?: number; diff --git a/src/ts/@overflow/target/react/TargetChild.tsx b/src/ts/@overflow/target/react/TargetChild.tsx index 2149b79..9d53e9a 100644 --- a/src/ts/@overflow/target/react/TargetChild.tsx +++ b/src/ts/@overflow/target/react/TargetChild.tsx @@ -19,39 +19,39 @@ import * as asyncRequestActions from '@overflow/commons/redux/action/asyncReques export function mapStateToProps(state: any, props: any): StateProps { 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, + // 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): DispatchProps { return { - 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)); - }, + // 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/components/TargetChild.tsx b/src/ts/@overflow/target/react/components/TargetChild.tsx index 7d9cff2..a2166aa 100644 --- a/src/ts/@overflow/target/react/components/TargetChild.tsx +++ b/src/ts/@overflow/target/react/components/TargetChild.tsx @@ -14,25 +14,25 @@ import InfraService from '@overflow/infra/api/model/InfraService'; import * as Utils from '@overflow/commons/util/Utils'; export interface StateProps { - infraId?: number; + // infraId?: number; infra: Infra; - machine?: InfraMachine; - host?: InfraHost; - os?: InfraOS; - osApplication?: InfraOSApplication; - osDaemon?: InfraOSDaemon; - osPort?: InfraOSPort; - service?: InfraService; + // 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; + // 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; @@ -47,10 +47,10 @@ export class TargetChild extends React.Component { super(props, context); this.state = { }; - if (this.props.infra !== undefined && this.props.infra.id === this.props.infraId) { - console.log('initninitnitni'); - this.getChild(this.props.infra); - } + // if (this.props.infra !== undefined && this.props.infra.id === this.props.infraId) { + // console.log('initninitnitni'); + // this.getChild(this.props.infra); + // } } // public componentWillMount(): void { @@ -63,59 +63,59 @@ export class TargetChild extends React.Component { // return true; // } - public componentWillReceiveProps(nextProps: Readonly, nextContext: Readonly): void { + // public componentWillReceiveProps(nextProps: Readonly, nextContext: Readonly): void { - // if(this.props.infra === undefined) { - // this.getChild(nextProps.infra); - // return; - // } + // // if(this.props.infra === undefined) { + // // this.getChild(nextProps.infra); + // // return; + // // } - if (nextProps.infra.id !== this.props.infra.id) { - this.getChild(nextProps.infra); - } - // console.log(nextProps); - // console.log(nextContext); - } + // if (nextProps.infra.id !== this.props.infra.id) { + // this.getChild(nextProps.infra); + // } + // // console.log(nextProps); + // // console.log(nextContext); + // } - public getChild(infra: Infra): void { - let infraType = infra.infraType.id; - let id = String(infra.childId); - console.log('getting infra child of ' + this.props.infra.id); - 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 getChild(infra: Infra): void { + // let infraType = infra.infraType.id; + // let id = String(infra.childId); + // console.log('getting infra child of ' + this.props.infra.id); + // 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) { @@ -129,38 +129,38 @@ export class TargetChild extends React.Component { } 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; - } + // 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 this.props.machine ? : null; + return ; } case 2: { - return this.props.host ? : null; + return ; } case 3: { - return this.props.os ? : null; + return ; } case 4: { - return ; + return ; } case 5: { - return ; + return ; } case 6: { - return ; + return ; } case 7: { - return this.props.service ? : null; + return ; } default: { break; diff --git a/src/ts/@overflow/target/react/components/TargetDetail.tsx b/src/ts/@overflow/target/react/components/TargetDetail.tsx index ef3f206..b8e2748 100644 --- a/src/ts/@overflow/target/react/components/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/components/TargetDetail.tsx @@ -65,7 +65,7 @@ export class TargetDetail extends React.Component {
- +