diff --git a/src/ts/Routes.tsx b/src/ts/Routes.tsx index 37651a3..6bb706a 100644 --- a/src/ts/Routes.tsx +++ b/src/ts/Routes.tsx @@ -17,6 +17,7 @@ import { MemberRegistResult } from './containers/member/RegistResult'; import { ProveDownload } from './containers/prove/Download'; import { TargetList } from './containers/target/TargetList'; +import { TargetDetail } from './containers/target/TargetDetail'; import { DiscoveryResult } from './containers/discovery/DiscoveryResult'; export class Routes extends React.Component { @@ -38,6 +39,7 @@ export class Routes extends React.Component {
  • Agents
  • AgentDetail
  • TargetList
  • +
  • TargetDetail
  • DiscoveryResult
  • @@ -56,6 +58,7 @@ export class Routes extends React.Component { + diff --git a/src/ts/containers/prove/Download.tsx b/src/ts/containers/prove/Download.tsx index 4cbe93c..7a63e46 100644 --- a/src/ts/containers/prove/Download.tsx +++ b/src/ts/containers/prove/Download.tsx @@ -21,11 +21,11 @@ const styles = { height: 700, padding: 20, }, -} +}; export class ProveDownload extends React.Component { constructor(props: any, context: any) { - super(props, context) + super(props, context); this.state = { selectedOSidx: 0, selectedOSName: "Windows", diff --git a/src/ts/containers/sensor/SensorList.tsx b/src/ts/containers/sensor/SensorList.tsx deleted file mode 100644 index 9117e5b..0000000 --- a/src/ts/containers/sensor/SensorList.tsx +++ /dev/null @@ -1,136 +0,0 @@ -// import * as React from 'react'; -// import { List, ListItem, makeSelectable } from 'material-ui/List'; -// import Subheader from 'material-ui/Subheader'; -// import Paper from 'material-ui/Paper'; -// import { OFRest } from '../../components/Rest'; -// import * as Utils from '../../components/Utils'; -// import RaisedButton from 'material-ui/RaisedButton'; -// import { -// Table, -// TableBody, -// TableHeader, -// TableHeaderColumn, -// TableFooter, -// TableRow, -// TableRowColumn, -// } from 'material-ui/Table'; -// import { SensorConfigPopup } from '../../containers/config/SensorConfigPopup'; - -// export class SensorList extends React.Component { -// constructor(props: any, context: any) { -// super(props, context); -// this.state = { -// }; -// } - -// componentWillMount() { -// this.getSensorList(); -// } - -// getSensorList() { -// // let obj: any; -// // obj = { -// // "id": "0", -// // "member": { -// // "id": "1" -// // } -// // }; - -// // let os: OFRest = new OFRest("Target", "List", obj); -// // var that: any = this; -// // os.Call().then(function (res) { -// // return res.json(); -// // }).then(function (json) { -// // let targetList = JSON.parse(json.resultStr); -// // that.setState({ -// // targets: targetList, -// // }); -// // }).catch(function (err) { -// // console.log(err); -// // }); -// } - - -// handleRowSelection = (selectedRows: any) => { -// this.setState({ -// selected: selectedRows, -// }); -// } - -// // handleNext = () => { -// // if (this.state.selected.length === 0) { -// // alert('Select a target to monitor'); -// // } else { -// // this.setState({ -// // startConfig: true, -// // }); -// // } -// // } - -// isSelected = (index: any) => { -// if (this.state.selected.indexOf(index) === -1) { -// return false; -// } else { -// return true; -// } -// } -// handleConfigCancel = () => { -// this.setState({ -// startConfig: false, -// }); -// } -// showSensorConfigPopup = () => { -// if (this.state.startConfig) { -// return ; -// } -// return null; -// } - -// render() { -// return ( -//
    -// {this.showSensorConfigPopup()} -// -// -// -// Host -// Port -// Type -// Kind -// Name -// Version -// -// -// -// displayRowCheckbox={true} -// > -// {this.state.targets.map((row: any, index: number) => ( -// -// {Utils.int2ip(row.ip)} -// {row.port} -// {row.targetType} -// {row.kinds} -// {row.vendorName} -// {row.version} -// -// ))}; - -// -//
    - -// - -//
    -// ); -// } -// } diff --git a/src/ts/containers/sensor/Sensors.tsx b/src/ts/containers/sensor/Sensors.tsx new file mode 100644 index 0000000..c73bccb --- /dev/null +++ b/src/ts/containers/sensor/Sensors.tsx @@ -0,0 +1,107 @@ +import * as React from 'react'; +import { List, ListItem, makeSelectable } from 'material-ui/List'; +import { OFRest } from '../../components/Rest'; +import Paper from 'material-ui/Paper'; +import Avatar from 'material-ui/Avatar'; +import EditorInsertChart from 'material-ui/svg-icons/editor/insert-chart'; +import { blue500, yellow600 } from 'material-ui/styles/colors'; + + +export class Sensors extends React.Component { + sensorMap = {}; + constructor(props: any, context: any) { + super(props, context); + this.state = { + sensors: [], + test: {}, + }; + } + + componentWillMount() { + this.getSensorList(); + } + + + getSensorList() { + let obj: any; + obj = { + "id": "1", + }; + + let os: OFRest = new OFRest("Sensor", "List", obj); + var that: any = this; + os.Call().then(function (res) { + return res.json(); + }).then(function (json) { + let list = JSON.parse(json.resultStr); + that.setState({ + sensors: list, + }); + for (var i = 0; i < list.length; i++) { + that.getSensorItems(list[i]); + } + }).catch(function (err) { + console.log(err); + }); + } + + + isSelected = (index: any) => { + if (this.state.selected.indexOf(index) === -1) { + return false; + } else { + return true; + } + } + + + getSensorItems(sensor: any) { + var nested = Array(); + let os: OFRest = new OFRest("SensorItemMapping", "List", sensor); + var that: any = this; + os.Call().then(function (res) { + return res.json(); + }).then(function (json) { + var list = JSON.parse(json.resultStr); + that.sensorMap[sensor.id] = list; + that.setState({ + test: that.sensorMap, + }); + }).catch(function (err) { + console.log(err); + }); + } + + getItems = (sensor:any) => { + let arr = Array(); + let list = this.state.test[sensor.id]; + if(list === undefined || list.length === 0 || list === null) { + return arr; + } + for(var i=0;i); + } + + return arr; + } + + render() { + return ( + + Sensors + + {this.state.sensors.map((sensor: any, index: number) => ( + } backgroundColor={yellow600} />} + primaryText={'By ' + sensor.crawler.name} + secondaryText={'Created at ' + sensor.createDate} + initiallyOpen={true} + nestedItems={this.getItems(sensor)} + /> + ))} + + + ); + } +} diff --git a/src/ts/containers/target/TargetDetail.tsx b/src/ts/containers/target/TargetDetail.tsx new file mode 100644 index 0000000..ba69a0e --- /dev/null +++ b/src/ts/containers/target/TargetDetail.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; +import { OFRest } from '../../components/Rest'; +import Dialog from 'material-ui/Dialog'; +import FlatButton from 'material-ui/FlatButton'; +import RaisedButton from 'material-ui/RaisedButton'; +import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card'; +import * as Utils from '../../components/Utils'; +import DropDownMenu from 'material-ui/DropDownMenu'; +import MenuItem from 'material-ui/MenuItem'; +import AppBar from 'material-ui/AppBar'; +import Checkbox from 'material-ui/Checkbox'; +import TextField from 'material-ui/TextField'; +import { RadioButton, RadioButtonGroup } from 'material-ui/RadioButton'; +import Paper from 'material-ui/Paper'; +import { + Table, + TableBody, + TableHeader, + TableHeaderColumn, + TableRow, + TableRowColumn, +} from 'material-ui/Table'; +import { Sensors } from '../../containers/sensor/Sensors'; + + + +export class TargetDetail extends React.Component { + constructor(props: any, context: any) { + super(props, context); + this.state = { + }; + } + + + render() { + + return ( + + ); + } +} \ No newline at end of file diff --git a/src/ts/containers/target/TargetList.tsx b/src/ts/containers/target/TargetList.tsx index 17278cb..4411c23 100644 --- a/src/ts/containers/target/TargetList.tsx +++ b/src/ts/containers/target/TargetList.tsx @@ -60,6 +60,7 @@ export class TargetList extends React.Component { }); } + handleNext = () => { if (this.state.selected.length === 0) { alert('Select a target to monitor'); @@ -69,7 +70,13 @@ export class TargetList extends React.Component { }); } } - + handleDetail = () => { + if (this.state.selected.length === 0) { + alert('Select a target to monitor'); + } else { + this.props.history.push('/target/targetDetail'); + } + } isSelected = (index: any) => { if (this.state.selected.indexOf(index) === -1) { @@ -132,8 +139,8 @@ export class TargetList extends React.Component { - - + + ); }