From 78da1859ce0fdac76b0fdda4289e0b7cd30f686f Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 27 Jul 2017 19:10:46 +0900 Subject: [PATCH] target fix --- .../@overflow/target/react/TargetDetail.tsx | 2 +- .../target/react/components/TargetDetail.tsx | 107 ++++----- .../react/components/TargetDetailInfra.tsx | 137 ++++++++++++ .../target/react/components/TargetList.tsx | 203 ++++++------------ 4 files changed, 242 insertions(+), 207 deletions(-) create mode 100644 src/ts/@overflow/target/react/components/TargetDetailInfra.tsx diff --git a/src/ts/@overflow/target/react/TargetDetail.tsx b/src/ts/@overflow/target/react/TargetDetail.tsx index a0ceb56..54d99b4 100644 --- a/src/ts/@overflow/target/react/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/TargetDetail.tsx @@ -9,7 +9,7 @@ import * as targetDetailActions from '../redux/action/read'; export function mapStateToProps(state: any): StateProps { return { - probe: state.probe, + // probe: state.probe, }; } diff --git a/src/ts/@overflow/target/react/components/TargetDetail.tsx b/src/ts/@overflow/target/react/components/TargetDetail.tsx index f4ddf24..0f6c65c 100644 --- a/src/ts/@overflow/target/react/components/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/components/TargetDetail.tsx @@ -1,28 +1,20 @@ import * as React from 'react'; import { Button, Table, Header, Container } from 'semantic-ui-react'; -import { SensorList } from '@overflow/sensor/react/components/SensorList'; import { DetailContainer } from '@overflow/commons/react/component/DetailContainer'; - -import Probe from '@overflow/probe/api/model/Probe'; +import { TargetDetailInfra } from './TargetDetailInfra'; import Target from '@overflow/target/api/model/Target'; export interface StateProps { - probe?: Probe; - target?: Target; } export interface DispatchProps { - onRead(id: string): void; } export type Props = StateProps & DispatchProps; export interface State { - selected: Probe; - targetTemp: any; - isDetail: boolean; - list: Probe[]; + target: any; // todo. fix to Target } @@ -31,41 +23,20 @@ export class TargetDetail extends React.Component { constructor(props: Props, context: State) { super(props, context); this.state = { - selected: null, - targetTemp: null, - isDetail: false, - list: null, + target: null, }; } public componentWillMount(): void { let data = { 'id': '1', - 'probe': { - 'id': '1', - 'status': { - 'id': '1', - 'name': 'INITIAL', - }, - 'description': 'snoop probe', - 'domain': { - 'id': '1', - 'name': 'overFlow`s domain', - }, - }, - 'infra': { - 'id': '1', - 'type': { - 'id': '1', - 'name': 'MACHINE', - }, - }, + 'createDate': '2017-01-01', + 'displayName': '192.168.1.105', + 'description': '', + 'sensorCount': 'todo.', }; - this.setState({targetTemp: data}); - } - public handleBack(): void { - console.log('handleBack'); + this.setState({ target: data }); } public handleRemoveTarget(): void { @@ -73,20 +44,13 @@ export class TargetDetail extends React.Component { } public render(): JSX.Element { - - if (this.props.probe === null) { - return null; - } - - const items = [ - { name: 'Info', child: }, - { name: 'Sensors', child: }, - ]; - return ( - - {/**/} + +
+ +
+
); } @@ -94,11 +58,11 @@ export class TargetDetail extends React.Component { export interface TargetBasicInfoProps { - target?: Target; + target?: any; // todo. fix to Target } export interface TargetBasicInfoState { - + infra: any; } export class TargetBasicInfo extends React.Component { @@ -106,12 +70,20 @@ export class TargetBasicInfo extends React.ComponentName - {this.props.target.probe.domain.name} - + {this.props.target.displayName} + -
Type
+
Description
- {this.props.target.infra.type.name} - + {this.props.target.description} +
-
Sensor count
+
Sensor Count
- 1 - + {this.props.target.sensorCount} +
@@ -152,12 +124,19 @@ export class TargetBasicInfo extends React.Component {this.props.target.createDate} - + + + +
Type
+
+ + {this.state.infra.type} + +
- ); } diff --git a/src/ts/@overflow/target/react/components/TargetDetailInfra.tsx b/src/ts/@overflow/target/react/components/TargetDetailInfra.tsx new file mode 100644 index 0000000..db71352 --- /dev/null +++ b/src/ts/@overflow/target/react/components/TargetDetailInfra.tsx @@ -0,0 +1,137 @@ +import * as React from 'react'; +import { Button, Table, Header, Container } from 'semantic-ui-react'; +import { SensorList } from '@overflow/sensor/react/components/SensorList'; +import { DetailContainer } from '@overflow/commons/react/component/DetailContainer'; + +import Target from '@overflow/target/api/model/Target'; + + +export interface StateProps { + target: any; +} + +export interface DispatchProps { +} + +export type Props = StateProps & DispatchProps; + +export interface State { + infra: any; // todo. fix to Infra + childInfra: any; // todo. fix to InfraTypes +} + + +export class TargetDetailInfra extends React.Component { + + constructor(props: Props, context: State) { + super(props, context); + this.state = { + infra: null, + childInfra: null, + }; + } + + public componentWillMount(): void { + // todo. getting infra and child infra + + let child = { // infraHost + 'id': '1', + 'os': { + 'id': '11', + 'machine': { + 'id': '111', + }, + 'meta': 'T ^ T', + 'vendor': { + 'name': 'Loafle', + }, + }, + 'ip': '192.168.1.105', + 'mac': 'ab:12:cd:34:ef:ef', + 'createDate': '2017-01-01', + }; + + this.setState({ + infra: infra, + childInfra: child, + }); + } + + public handleRemoveTarget(): void { + alert('remove'); + } + + public renderInfra(): JSX.Element { + let type = this.state.infra.type; + switch (type) { + case 'Host': { + return ; + } + case 'OS': { + break; + } + default: + break; + } + return null; + } + + + + public render(): JSX.Element { + return ( + + {this.renderInfra()} + + ); + } +} + + +export class InfraHostTable extends React.Component { + constructor(props: any, context: any) { + super(props, context); + this.state = { + }; + } + public render(): JSX.Element { + return ( + + + + +
os.vender.name?
+
+ + {this.props.data.os.vendor.name} + +
+ + +
os.meta?
+
+ + {this.props.data.os.meta} + +
+ + +
IP
+
+ + {this.props.data.ip} + +
+ + +
mac
+
+ + {this.props.data.mac} + +
+
+
+ ); + } +} diff --git a/src/ts/@overflow/target/react/components/TargetList.tsx b/src/ts/@overflow/target/react/components/TargetList.tsx index 076fb98..9c62742 100644 --- a/src/ts/@overflow/target/react/components/TargetList.tsx +++ b/src/ts/@overflow/target/react/components/TargetList.tsx @@ -4,7 +4,7 @@ import { TargetDetail } from './TargetDetail'; import Target from '@overflow/target/api/model/Target'; import Probe from '@overflow/probe/api/model/Probe'; import { ListContainer } from '@overflow/commons/react/component/ListContainer'; -import {Discovery} from '../../../discovery/react/components/Discovery'; +import { Discovery } from '../../../discovery/react/components/Discovery'; export interface StateProps { @@ -35,6 +35,43 @@ export class TargetList extends React.Component { }; } + public componentWillMount(): void { + this.data = [ + { + 'id': '1', + 'createDate': '2017-01-01', + 'displayName': 'Oracle', + 'description': '', + 'sensorCount': 'todo.', + }, + { + 'id': '2', + 'createDate': '2017-01-01', + 'displayName': 'MySQL', + 'description': '', + 'sensorCount': 'todo.', + }, + { + 'id': '3', + 'createDate': '2017-01-01', + 'displayName': '192.168.1.105', + 'description': '', + 'sensorCount': 'todo.', + }, + ]; + + this.setState({ list: this.data }); + } + + public handleSelect(selectedTarget: any): void { + + this.setState({ + selected: selectedTarget, + }); + + this.props.onTargetSelection(selectedTarget.id); + } + public handleAddTarget(event: React.MouseEvent, data: ButtonProps): void { this.setState({ @@ -72,16 +109,35 @@ export class TargetList extends React.Component { {/*search bar */} @@ -101,146 +157,9 @@ export class TargetList extends React.Component { private handleSelectedTarget = (target: Target): void => { console.log('handleSelectedTarget '); - this.setState({selected: target}); + this.setState({ selected: target }); this.props.onTargetSelection(String(target.id)); } } -export interface TargetTableProps { - onSelectTarget?:((target:Target) => void); -} - -export interface TargetTableState { - list: Array; - selected: Target; -} - -export class TargetTable extends React.Component { - private data: any; - - constructor(props: TargetTableProps, context: TargetTableState) { - super(props, context); - this.state = { - selected: null, - list: [], - }; - } - - public componentWillMount(): void { - this.data = [ - { - 'id': '1', - 'probe': { - 'id': '1', - 'status': { - 'id': '1', - 'name': 'INITIAL', - }, - 'description': 'snoop probe', - 'domain': { - 'id': '1', - 'name': 'overFlow`s domain', - }, - }, - 'infra': { - 'id': '1', - 'type': { - 'id': '1', - 'name': 'MACHINE', - }, - }, - }, - - { - 'id': '11', - 'probe': { - 'id': '1', - 'status': { - 'id': '1', - 'name': 'INITIAL', - }, - 'description': 'snoop probe', - 'domain': { - 'id': '1', - 'name': 'overFlow`s domain', - }, - }, - 'infra': { - 'id': '1', - 'type': { - 'id': '1', - 'name': 'MACHINE', - }, - }, - }, - - { - 'id': '21', - 'probe': { - 'id': '1', - 'status': { - 'id': '1', - 'name': 'INITIAL', - }, - 'description': 'snoop probe', - 'domain': { - 'id': '1', - 'name': 'overFlow`s domain', - }, - }, - 'infra': { - 'id': '3', - 'type': { - 'id': '2', - 'name': 'HOST', - }, - }, - }, - ]; - - this.setState({list:this.data}); - } - - public handleSelect(selectedTarget: Target): void { - - console.log(selectedTarget.id); - this.setState({ - selected: selectedTarget, - }); - - this.props.onSelectTarget(selectedTarget); - } - - public render(): JSX.Element { - return ( - - - - - No. - Type - Name - Version - - - - - {this.state.list.map((target: Target, index: number) => ( - - {index + 1} - {target.infra.type.name} - {target.probe.domain.name} - todo - - ))} - -
-
- ); - } - -} - - -