fixed infra model

This commit is contained in:
snoop 2017-08-21 16:47:07 +09:00
parent 860f50b64b
commit a630a4eb99
10 changed files with 136 additions and 129 deletions

View File

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

View File

@ -1,6 +1,8 @@
interface InfraMachine {
id?: number;
import Infra from './Infra';
interface InfraMachine extends Infra {
// id?: number;
meta?: string;
createDate?: Date;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<Props, State> {
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<Props, State> {
// return true;
// }
public componentWillReceiveProps(nextProps: Readonly<Props>, nextContext: Readonly<State>): void {
// public componentWillReceiveProps(nextProps: Readonly<Props>, nextContext: Readonly<State>): 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<Props, State> {
}
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 ? <InfraTable tableDatas={this.ConvertTableDataForMachine(this.props.machine)} /> : null;
return <InfraTable tableDatas={this.ConvertTableDataForMachine(this.props.infra)} />;
}
case 2: {
return this.props.host ? <InfraTable tableDatas={this.ConvertTableDataForHost(this.props.host)} /> : null;
return <InfraTable tableDatas={this.ConvertTableDataForHost(this.props.infra)} />;
}
case 3: {
return this.props.os ? <InfraTable tableDatas={this.ConvertTableDataForOS(this.props.os)} /> : null;
return <InfraTable tableDatas={this.ConvertTableDataForOS(this.props.infra)} />;
}
case 4: {
return <InfraTable tableDatas={this.ConvertTableDataForApplication(this.props.osApplication)} />;
return <InfraTable tableDatas={this.ConvertTableDataForApplication(this.props.infra)} />;
}
case 5: {
return <InfraTable tableDatas={this.ConvertTableDataForDaemon(this.props.osDaemon)} />;
return <InfraTable tableDatas={this.ConvertTableDataForDaemon(this.props.infra)} />;
}
case 6: {
return <InfraTable tableDatas={this.ConvertTableDataForPort(this.props.osPort)} />;
return <InfraTable tableDatas={this.ConvertTableDataForPort(this.props.infra)} />;
}
case 7: {
return this.props.service ? <InfraTable tableDatas={this.ConvertTableDataForService(this.props.service)} /> : null;
return <InfraTable tableDatas={this.ConvertTableDataForService(this.props.infra)} />;
}
default: {
break;

View File

@ -65,7 +65,7 @@ export class TargetDetail extends React.Component<Props, State> {
<Container fluid>
<TargetBasicInfo infra={this.props.infra} />
<br />
<TargetChildContainer infra={this.props.infra} infraId={Number(this.props.id)}/>
<TargetChildContainer infra={this.props.infra}/>
<br />
<Button primary floated={'right'} negative onClick={this.handleRemoveTarget}>Remove</Button>
</Container>