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 InfraOS from './InfraOS';
import Infra from './Infra';
interface InfraHost { interface InfraHost extends Infra {
id?: number; // id?: number;
os?: InfraOS; os?: InfraOS;
ip?: number; ip?: number;
mac?: number; mac?: number;

View File

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

View File

@ -1,9 +1,9 @@
import InfraMachine from './InfraMachine'; import InfraMachine from './InfraMachine';
import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor';
import Infra from './Infra';
interface InfraOS extends Infra {
interface InfraOS { // id?: number;
id?: number;
machine?: InfraMachine; machine?: InfraMachine;
meta?: string; meta?: string;
createDate?: Date; createDate?: Date;

View File

@ -1,8 +1,9 @@
import InfraOS from './InfraOS'; import InfraOS from './InfraOS';
import Infra from './Infra';
interface InfraOSApplication { interface InfraOSApplication extends Infra {
id?: number; // id?: number;
os?: InfraOS; os?: InfraOS;
name?: string; name?: string;
createDate?: Date; createDate?: Date;

View File

@ -1,7 +1,8 @@
import InfraOS from './InfraOS'; import InfraOS from './InfraOS';
import Infra from './Infra';
interface InfraOSDaemon { interface InfraOSDaemon extends Infra {
id?: number; // id?: number;
os?: InfraOS; os?: InfraOS;
name?: string; name?: string;
createDate?: Date; createDate?: Date;

View File

@ -1,8 +1,9 @@
import InfraOS from './InfraOS'; import InfraOS from './InfraOS';
import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor';
import Infra from './Infra';
interface InfraOSPort { interface InfraOSPort extends Infra {
id?: number; // id?: number;
os?: InfraOS; os?: InfraOS;
createDate?: Date; createDate?: Date;
port?: number; port?: number;

View File

@ -1,8 +1,9 @@
import InfraHost from './InfraHost'; import InfraHost from './InfraHost';
import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor'; import MetaInfraVendor from '@overflow/meta/api/model/MetaInfraVendor';
import Infra from './Infra';
interface InfraService { interface InfraService extends Infra {
id?: number; // id?: number;
host?: InfraHost; host?: InfraHost;
portType?: string; portType?: string;
port?: number; 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 { export function mapStateToProps(state: any, props: any): StateProps {
return { return {
infra: props.infra, infra: props.infra,
machine: state.machine, // machine: state.machine,
host: state.host, // host: state.host,
os: state.os, // os: state.os,
osApplication: state.osApplication, // osApplication: state.osApplication,
osDaemon: state.osDaemon, // osDaemon: state.osDaemon,
osPort: state.osPort, // osPort: state.osPort,
service: state.service, // service: state.service,
}; };
} }
export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps {
return { return {
onReadInfraMachine: (id: string) => { // onReadInfraMachine: (id: string) => {
dispatch(asyncRequestActions.request('InfraMachineService', 'read', MachineReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraMachineService', 'read', MachineReadActions.REQUEST, id));
}, // },
onReadInfraHost: (id: string) => { // onReadInfraHost: (id: string) => {
dispatch(asyncRequestActions.request('InfraHostService', 'read', HostReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraHostService', 'read', HostReadActions.REQUEST, id));
}, // },
onReadInfraOS: (id: string) => { // onReadInfraOS: (id: string) => {
dispatch(asyncRequestActions.request('InfraOSService', 'read', OSReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraOSService', 'read', OSReadActions.REQUEST, id));
}, // },
onReadInfraOSApplication: (id: string) => { // onReadInfraOSApplication: (id: string) => {
dispatch(asyncRequestActions.request('InfraOSApplicationService', 'read', ApplicationReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraOSApplicationService', 'read', ApplicationReadActions.REQUEST, id));
}, // },
onReadInfraOSDaemon: (id: string) => { // onReadInfraOSDaemon: (id: string) => {
dispatch(asyncRequestActions.request('InfraOSDaemonService', 'read', DaemonReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraOSDaemonService', 'read', DaemonReadActions.REQUEST, id));
}, // },
onReadInfraOSPort: (id: string) => { // onReadInfraOSPort: (id: string) => {
dispatch(asyncRequestActions.request('InfraOSPortService', 'read', PortReadActions.REQUEST, id)); // dispatch(asyncRequestActions.request('InfraOSPortService', 'read', PortReadActions.REQUEST, id));
}, // },
onReadInfraService: (id: string) => { // onReadInfraService: (id: string) => {
dispatch(asyncRequestActions.request('InfraServiceService', 'read', ServiceReadActions.REQUEST, id)); // 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'; import * as Utils from '@overflow/commons/util/Utils';
export interface StateProps { export interface StateProps {
infraId?: number; // infraId?: number;
infra: Infra; infra: Infra;
machine?: InfraMachine; // machine?: InfraMachine;
host?: InfraHost; // host?: InfraHost;
os?: InfraOS; // os?: InfraOS;
osApplication?: InfraOSApplication; // osApplication?: InfraOSApplication;
osDaemon?: InfraOSDaemon; // osDaemon?: InfraOSDaemon;
osPort?: InfraOSPort; // osPort?: InfraOSPort;
service?: InfraService; // service?: InfraService;
} }
export interface DispatchProps { export interface DispatchProps {
onReadInfraMachine?(id: string): void; // onReadInfraMachine?(id: string): void;
onReadInfraHost?(id: string): void; // onReadInfraHost?(id: string): void;
onReadInfraOS?(id: string): void; // onReadInfraOS?(id: string): void;
onReadInfraOSApplication?(id: string): void; // onReadInfraOSApplication?(id: string): void;
onReadInfraOSDaemon?(id: string): void; // onReadInfraOSDaemon?(id: string): void;
onReadInfraOSPort?(id: string): void; // onReadInfraOSPort?(id: string): void;
onReadInfraService?(id: string): void; // onReadInfraService?(id: string): void;
} }
export type Props = StateProps & DispatchProps; export type Props = StateProps & DispatchProps;
@ -47,10 +47,10 @@ export class TargetChild extends React.Component<Props, State> {
super(props, context); super(props, context);
this.state = { this.state = {
}; };
if (this.props.infra !== undefined && this.props.infra.id === this.props.infraId) { // if (this.props.infra !== undefined && this.props.infra.id === this.props.infraId) {
console.log('initninitnitni'); // console.log('initninitnitni');
this.getChild(this.props.infra); // this.getChild(this.props.infra);
} // }
} }
// public componentWillMount(): void { // public componentWillMount(): void {
@ -63,59 +63,59 @@ export class TargetChild extends React.Component<Props, State> {
// return true; // 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) { // // if(this.props.infra === undefined) {
// this.getChild(nextProps.infra); // // this.getChild(nextProps.infra);
// return; // // return;
// } // // }
if (nextProps.infra.id !== this.props.infra.id) { // if (nextProps.infra.id !== this.props.infra.id) {
this.getChild(nextProps.infra); // this.getChild(nextProps.infra);
} // }
// console.log(nextProps); // // console.log(nextProps);
// console.log(nextContext); // // console.log(nextContext);
} // }
public getChild(infra: Infra): void { // public getChild(infra: Infra): void {
let infraType = infra.infraType.id; // let infraType = infra.infraType.id;
let id = String(infra.childId); // let id = String(infra.childId);
console.log('getting infra child of ' + this.props.infra.id); // console.log('getting infra child of ' + this.props.infra.id);
switch (infraType) { // switch (infraType) {
case 1: { // case 1: {
this.props.onReadInfraMachine(id); // this.props.onReadInfraMachine(id);
break; // break;
} // }
case 2: { // case 2: {
this.props.onReadInfraHost(id); // this.props.onReadInfraHost(id);
break; // break;
} // }
case 3: { // case 3: {
this.props.onReadInfraOS(id); // this.props.onReadInfraOS(id);
break; // break;
} // }
case 4: { // case 4: {
this.props.onReadInfraOSApplication(id); // this.props.onReadInfraOSApplication(id);
break; // break;
} // }
case 5: { // case 5: {
this.props.onReadInfraOSDaemon(id); // this.props.onReadInfraOSDaemon(id);
break; // break;
} // }
case 6: { // case 6: {
this.props.onReadInfraOSPort(id); // this.props.onReadInfraOSPort(id);
break; // break;
} // }
case 7: { // case 7: {
this.props.onReadInfraService(id); // this.props.onReadInfraService(id);
break; // break;
} // }
default: { // default: {
break; // break;
} // }
} // }
} // }
public render(): JSX.Element { public render(): JSX.Element {
if (this.props.infra === undefined) { if (this.props.infra === undefined) {
@ -129,38 +129,38 @@ export class TargetChild extends React.Component<Props, State> {
} }
public renderInfraChild(): JSX.Element { public renderInfraChild(): JSX.Element {
if (this.props.machine === undefined // if (this.props.machine === undefined
&& this.props.host === undefined // && this.props.host === undefined
&& this.props.os === undefined // && this.props.os === undefined
&& this.props.osApplication === undefined // && this.props.osApplication === undefined
&& this.props.osDaemon === undefined // && this.props.osDaemon === undefined
&& this.props.osPort === undefined // && this.props.osPort === undefined
&& this.props.service === undefined // && this.props.service === undefined
) { // ) {
return null; // return null;
} // }
let infraType = this.props.infra.infraType.id; let infraType = this.props.infra.infraType.id;
switch (infraType) { switch (infraType) {
case 1: { case 1: {
return this.props.machine ? <InfraTable tableDatas={this.ConvertTableDataForMachine(this.props.machine)} /> : null; return <InfraTable tableDatas={this.ConvertTableDataForMachine(this.props.infra)} />;
} }
case 2: { case 2: {
return this.props.host ? <InfraTable tableDatas={this.ConvertTableDataForHost(this.props.host)} /> : null; return <InfraTable tableDatas={this.ConvertTableDataForHost(this.props.infra)} />;
} }
case 3: { case 3: {
return this.props.os ? <InfraTable tableDatas={this.ConvertTableDataForOS(this.props.os)} /> : null; return <InfraTable tableDatas={this.ConvertTableDataForOS(this.props.infra)} />;
} }
case 4: { case 4: {
return <InfraTable tableDatas={this.ConvertTableDataForApplication(this.props.osApplication)} />; return <InfraTable tableDatas={this.ConvertTableDataForApplication(this.props.infra)} />;
} }
case 5: { case 5: {
return <InfraTable tableDatas={this.ConvertTableDataForDaemon(this.props.osDaemon)} />; return <InfraTable tableDatas={this.ConvertTableDataForDaemon(this.props.infra)} />;
} }
case 6: { case 6: {
return <InfraTable tableDatas={this.ConvertTableDataForPort(this.props.osPort)} />; return <InfraTable tableDatas={this.ConvertTableDataForPort(this.props.infra)} />;
} }
case 7: { case 7: {
return this.props.service ? <InfraTable tableDatas={this.ConvertTableDataForService(this.props.service)} /> : null; return <InfraTable tableDatas={this.ConvertTableDataForService(this.props.infra)} />;
} }
default: { default: {
break; break;

View File

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