diff --git a/smart-hut/package-lock.json b/smart-hut/package-lock.json index 11b699e..b2d2c82 100644 --- a/smart-hut/package-lock.json +++ b/smart-hut/package-lock.json @@ -10483,6 +10483,12 @@ "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" }, + "prettier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.1.tgz", + "integrity": "sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA==", + "dev": true + }, "pretty-bytes": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz", @@ -10897,6 +10903,14 @@ } } }, + "react-device-detect": { + "version": "1.11.14", + "resolved": "https://registry.npmjs.org/react-device-detect/-/react-device-detect-1.11.14.tgz", + "integrity": "sha512-WSjch241xI+rXHVtJaSYxNUT2WAykzfJgMI2Hg9xjNNTlIZdJu/fmWf4iedNH7qzFq+JaJ6fDJu3mrKFLerKBw==", + "requires": { + "ua-parser-js": "^0.7.20" + } + }, "react-dom": { "version": "16.12.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.12.0.tgz", diff --git a/smart-hut/public/img/humidityIcon.svg b/smart-hut/public/img/humidityIcon.svg new file mode 100644 index 0000000..aacac30 --- /dev/null +++ b/smart-hut/public/img/humidityIcon.svg @@ -0,0 +1,12 @@ + + diff --git a/smart-hut/public/img/lightSensorIcon.svg b/smart-hut/public/img/lightSensorIcon.svg new file mode 100644 index 0000000..f2836c2 --- /dev/null +++ b/smart-hut/public/img/lightSensorIcon.svg @@ -0,0 +1,58 @@ + + diff --git a/smart-hut/public/img/motionSensorIcon.svg b/smart-hut/public/img/motionSensorIcon.svg new file mode 100644 index 0000000..ff89667 --- /dev/null +++ b/smart-hut/public/img/motionSensorIcon.svg @@ -0,0 +1,62 @@ + + diff --git a/smart-hut/public/img/temperatureIcon.svg b/smart-hut/public/img/temperatureIcon.svg new file mode 100644 index 0000000..414c428 --- /dev/null +++ b/smart-hut/public/img/temperatureIcon.svg @@ -0,0 +1,18 @@ + + diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index 7ef0ad1..1ba9bb8 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -9,14 +9,13 @@ */ import React, { Component } from "react"; -import { iconStyle, StyledDiv, ThumbText } from "./styleComponents"; +import { iconStyle, StyledDiv, BottomPanel, ThumbText } from "./styleComponents"; import Settings from "./DeviceSettings"; import { Image } from "semantic-ui-react"; import { CircularInput, CircularProgress, CircularThumb, - CircularTrack, } from "react-circular-input"; import { LightDimmerContainer, @@ -27,7 +26,9 @@ import { CircularThumbStyle, knobIcon } from "./LightStyle"; -import { call } from "../../../client_server"; +import { call } from '../../../client_server'; + + export default class Light extends Component { constructor(props) { @@ -37,33 +38,17 @@ export default class Light extends Component { intensity: props.device.intensity, }; this.iconOn = "/img/lightOn.svg"; - this.iconOff = "/img/lightOff.svg"; - - this.stateCallback = (e) => { - const update = {}; - if (e.kind === "dimmableLight") { - update.intensity = e.intensity; - } else { - update.turnedOn = e.on; - } - - this.setState(Object.assign(this.state, update)); - }; - - call.socketSubscribe(this.props.device.id, this.stateCallback); - } - - componentWillUnmount() { - call.socketUnsubscribe(this.props.device.id, this.stateCallback); + this.iconOff = "/img/lightOff.svg" } onClickDevice = () => { this.props.device.on = !this.state.turnedOn; - call.deviceUpdate(this.props.device, "regularLight").then((res) => { - if (res.status === 200) { - this.setState((prevState) => ({ turnedOn: !prevState.turnedOn })); - } - }); + call.deviceUpdate(this.props.device, 'regularLight') + .then(res => { + if (res.status === 200) { + this.setState((prevState) => ({ turnedOn: !prevState.turnedOn })); + } + }) }; @@ -90,6 +75,7 @@ export default class Light extends Component { }; + render() { const intensityLightView = (