diff --git a/package.json b/package.json index 7026de0..bf97a56 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "express-bearer-token": "2.1.0", "http-proxy-middleware": "0.17.4", "lodash": "4.17.4", - "material-ui": "^0.20.0", + "material-ui": "^0.20.1", "material-ui-datetimepicker": "^1.0.6", "react": "15.4.2", "react-dom": "15.4.2", @@ -61,4 +61,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/actions/index.js b/src/actions/index.js index 53bb8c4..d6743b3 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -886,3 +886,13 @@ export const recordsDelete = (deviceId, componentId) => { }) } } + +export const deviceTypesGet = (deviceOverview) => { + return agile.deviceManager.typeof(deviceOverview) + .then(deviceTypes => { + return deviceTypes + }) + .catch(err => { + return err + }); +} \ No newline at end of file diff --git a/src/components/RegisterDeviceManual.js b/src/components/RegisterDeviceManual.js new file mode 100644 index 0000000..75bfbb0 --- /dev/null +++ b/src/components/RegisterDeviceManual.js @@ -0,0 +1,253 @@ + +import React from 'react'; + +import TextField from 'material-ui/TextField'; +import Dialog from 'material-ui/Dialog'; +import { FlatButton } from 'material-ui'; +import SelectField from 'material-ui/SelectField'; +import MenuItem from 'material-ui/MenuItem'; + +import { connect } from 'react-redux'; + +import { Card } from 'material-ui/Card'; + +import { + devicesCreate, + deviceTypesFetch, + protocolsFetch, + deviceTypesGet +} from '../actions'; + +class RegisterDeviceManually extends React.Component { + constructor() { + super(); + + this.state = { + open: false, + deviceStatus: "AVAILABLE", + deviceProtocol: null, + deviceName: null, + deviceId: null, + deviceType: null, + deviceTypesMenuItem: [] + }; + this.handleDeviceValueChange = this.handleDeviceValueChange.bind(this); + this.submitManualDeviceForm = this.submitManualDeviceForm.bind(this); + this.handleChangeDeviceType = this.handleChangeDeviceType.bind(this); + this.handleChangeDeviceProtocol = this.handleChangeDeviceProtocol.bind(this); + this.renderDeviceTypeItems = this.renderDeviceTypeItems.bind(this); + } + + componentDidMount() { + this.props.protocolsFetch() + } + + handleDeviceValueChange(event) { + this.setState({ + [event.target.name]: event.target.value + }); + } + + handleChangeDeviceProtocol(event, index, value) { + this.setState({ + deviceProtocol: value + }) + this.renderDeviceTypesSelectList(false) + this.renderDeviceTypeItems(value) + } + + handleChangeDeviceType (event, index, value) { + this.setState({ + deviceType: value + }) + } + + renderDeviceTypeItems(value) { + let device = { + id: this.state.deviceId, + name: this.state.deviceName, + protocol: value, + status: this.state.deviceStatus + } + console.log(device) + deviceTypesGet(device) + .then(deviceTypes => { + console.log(deviceTypes) + + deviceTypes.map((type, i) => { + return this.state.deviceTypesMenuItem.push()} ) + }) + .catch(err => { + console.log(err) + }); + // this.renderDeviceTypes(device, this.props.deviceTypes[device.id]) + } + + renderDeviceTypesSelectList(disable) { + return( +