From a71820ef6bcadff56baf4ec9d05ed7e79910ccec Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 11 Apr 2018 17:28:33 -0400 Subject: [PATCH 1/4] Add sensor IAQ page --- src/components/SensorInstall/Gateway.js | 140 +++- src/components/SensorInstall/constants.js | 5 + .../BuildingArea/BuildingAreaTable.js | 10 +- src/containers/Sensors/SensorGraph.js | 2 +- src/containers/Sensors/SensorGraphIAQ.js | 679 ++++++++++++++++++ src/containers/Sensors/Sensors.js | 20 +- src/containers/Sensors/SensorsIAQ.js | 41 ++ src/routes.js | 2 + 8 files changed, 860 insertions(+), 39 deletions(-) create mode 100644 src/containers/Sensors/SensorGraphIAQ.js create mode 100644 src/containers/Sensors/SensorsIAQ.js diff --git a/src/components/SensorInstall/Gateway.js b/src/components/SensorInstall/Gateway.js index d4715b06..bab31a61 100644 --- a/src/components/SensorInstall/Gateway.js +++ b/src/components/SensorInstall/Gateway.js @@ -12,19 +12,15 @@ import 'box-ui-elements/dist/preview.css'; import { sensewareNodeURL } from '../../utils/restServices'; import SensewareNode from './Nodes/SensewareNode'; import SensorImageUpload from './SensorImageUpload'; -import { ENTITY_TYPES } from './constants'; +import { ENTITY_TYPES, SENSOR_TYPES } from './constants'; import documentsPropType from '../../containers/Documents/propTypes'; import ErrorAlert from '../../components/ErrorAlert'; import BoxLogin from '../../components/BoxLogin'; import userPropType from '../../containers/User/propTypes'; +import SpacePicker from '../../components/SpacePicker/SpacePicker'; import './styles.css'; class Gateway extends Component { - SENSOR_TYPES = { // eslint-disable-line - senseware: 1, - awair: 2, - other: 3, - } HEATING_SYSTEM_TYPES = { // eslint-disable-line hydronic: 1, steam: 2, @@ -62,6 +58,7 @@ class Gateway extends Component { gateway_id: this.props.form.gateway_id, installer_name: this.props.form.installer_name, placement_type: this.props.form.placement_type, + space_id: this.props.form.space_id, notes: this.props.form.notes, }, display_name: displayName, @@ -204,30 +201,36 @@ class Gateway extends Component { value = value.replace(/[^a-zA-Z0-9]+/g, '').toUpperCase(); break; case 'gateway_id': - value = value.replace(/\D/g, ''); + if (this.state.form.sensor_type === SENSOR_TYPES.senseware) { + value = value.replace(/\D/g, ''); + } break; default: break; } - this.setState({ - form: { - ...this.state.form, - [event.target.name]: value, - }, - display_name: displayName, - lastEdited: Date.now(), - // Only set the saved flag if the gateway is created - saved: !this.state.gatewayCreated || this.state.offlineCreated, - }); - if ( - this.state.gatewayCreated && - !this.state.offlineCreated && - !this.state.offlineSaving - ) { - // Save in a half a second, unless more input changes are made - clearTimeout(this.saveSoon); - this.saveSoon = setTimeout(this.handleSave, 500); - } + this.saveInputChange( + { ...this.state.form, [event.target.name]: value }, + displayName, + ); + } + } + + saveInputChange = (form, displayName) => { + this.setState({ + form, + display_name: displayName, + lastEdited: Date.now(), + // Only set the saved flag if the gateway is created + saved: !this.state.gatewayCreated || this.state.offlineCreated, + }); + if ( + this.state.gatewayCreated && + !this.state.offlineCreated && + !this.state.offlineSaving + ) { + // Save in a half a second, unless more input changes are made + clearTimeout(this.saveSoon); + this.saveSoon = setTimeout(this.handleSave, 500); } } @@ -379,6 +382,13 @@ class Gateway extends Component { this.setState({ uploadedImages }); } + updateSpaceId = (spaceId) => { + this.saveInputChange( + { ...this.state.form, space_id: spaceId }, + this.state.display_name, + ); + } + renderAddGatewayBtn = () => (