From c5dbf0139473b7914f3e49d2af8a84033ea92169 Mon Sep 17 00:00:00 2001 From: Fil Cesana Date: Tue, 17 Mar 2020 15:06:40 +0100 Subject: [PATCH 01/10] changed text in homepage, add icons, instruction page still work in progress, changed logo headController --- smart-hut/public/smart-home_index.png | Bin 0 -> 19294 bytes smart-hut/public/title6.png | Bin 0 -> 3537 bytes smart-hut/src/App.js | 4 + smart-hut/src/components/HeaderController.js | 2 +- smart-hut/src/views/Home.js | 15 +- smart-hut/src/views/Instruction.js | 21 ++ smart-hut/yarn.lock | 220 ++++++++++++++++++- 7 files changed, 244 insertions(+), 18 deletions(-) create mode 100644 smart-hut/public/smart-home_index.png create mode 100644 smart-hut/public/title6.png create mode 100644 smart-hut/src/views/Instruction.js diff --git a/smart-hut/public/smart-home_index.png b/smart-hut/public/smart-home_index.png new file mode 100644 index 0000000000000000000000000000000000000000..3b678bc937d690411b9b370e29746b15f26f7866 GIT binary patch literal 19294 zcmeHv`(MlL|M(KcO-3O)B81c=IFo9aOv@kMAGwdH-_1^}4R>d468c)3u;~PiYJNBlZsr1`|4d z?C@zAY!Udsi(pFyz<)+D^%F3d&er3H51hq(AB@9(INK06bn~^&+9N3^CQ`->xLZPBEKC#2S@v2wFo?;#4tT{y{Z zcxSGig*HJkK>efW%7GugSPNt7(1liYuC^3~`}2qA6$`JX>jwtg6Fnppds^?TH}@V{ z%Nk2h7_5_3ow%wkjT!EE9?+!zAt@sxk@dpgp&hr3W4J{_ox4l?=FlLDbl&|QNO%cq1ElYhd+Z~3Ymoscb9DGxcv2= zeMY+=5;NRaCWq@o_j{{c7&bLl%jA6bmyAQN?EAq~7y_Svj=W|TQ>2^qG%j3amjMW= zEAtKvntCmcWN|f5a02*S(AW}lp&#s;4$JmpEUKf(HPEm|I)3@RJa_W!4*x?MxK(X< z?xA){s`Q|y_ONeZfGsNZG0KGFKbaw8-i;EFLSo!H_8sB$Esd8SSA;%wpdi4RWy!q8+R6c}Xda$V0{`Dl-WgObYI9dAMT}*I{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HeaderController.js index 355d08a..e5d8d08 100644 --- a/smart-hut/src/components/HeaderController.js +++ b/smart-hut/src/components/HeaderController.js @@ -20,7 +20,7 @@ const ImageExampleWrapped = () => ( ) const ImageExampleWrapped3 = () => ( - + ) const HeaderExampleIconProp = () => ( diff --git a/smart-hut/src/views/Home.js b/smart-hut/src/views/Home.js index 4937938..3566a33 100644 --- a/smart-hut/src/views/Home.js +++ b/smart-hut/src/views/Home.js @@ -197,11 +197,11 @@ const Home = () => ( In a few steps your home will be fully connected with SmartHut.

- We Make Bananas That Can Dance + Choose between a wide range of devices

- Yes that's right, you thought it was the stuff of dreams, but even bananas can be - bioengineered. + SmartHut is a leading worldwide company in technology innovation. + Explore our website to find the best devices for each room of your home!

@@ -219,12 +219,13 @@ const Home = () => (
- Breaking The Grid, Grabs Your Attention + Have you ever dreamt about a smart home?

- Instead of focusing on content creation and hard work, we have learned how to master the - art of doing nothing by providing massive amounts of whitespace and generic content that - can seem massive, monolithic and worth your attention. + Let us carrying you into the future. With SmartHut, being at home + will be a refreshing experience. With just a few clicks, you will be + able the set the illumination of your entire place. + Follow the intelligent light, follow SmartHut.

- - - - - - - - - - - - - - - - ) - } + render() { + return ( +
+ + + + + + + + + + + + + + + + + + +
+ ) + } } export default class DevicePanel extends Component { - constructor(props) { - super(props); - this.state = { - shownRoom: "All" - } + constructor(props) { + super(props); + this.state = { + shownRoom: "All" } + } - render() { - return ( - - ) - } + render() { + return ( + + ) + } } diff --git a/smart-hut/src/components/dashboard/devices/DigitalSensor.js b/smart-hut/src/components/dashboard/devices/DigitalSensor.js new file mode 100644 index 0000000..a39e6b3 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/DigitalSensor.js @@ -0,0 +1,58 @@ +/** + * Users can add sensors in their rooms. + * Sensors typically measure physical quantities in a room. + * You must support temperature sensors, humidity sensors, light sensors (which measure luminosity1). + * Sensors have an internal state that cannot be changed by the user. + * For this story, make the sensors return a constant value with some small random error. + */ + +import React, {Component} from "react"; +import {CircularInput, CircularProgress, CircularTrack} from "react-circular-input"; +import {errorStyle, sensorText, style, valueStyle} from "./SensorStyle"; +import {StyledDiv} from "./styleComponents"; +import Settings from "./DeviceSettings"; +import {Image} from "semantic-ui-react"; +import {imageStyle, nameStyle} from "./DigitalSensorStyle"; + +export default class DigitalSensor extends Component { + constructor(props) { + super(props); + this.state = { + value: false, // This value is a boolean, was this type of sensor returns presence/absence + }; + + this.iconOn = "/img/sensorOn.svg"; + this.iconOff = "/img/sensorOff.svg" + } + + setName = () => { + if(this.props.device.name.length > 15){ + return this.props.device.name.slice(0,12) + "..." + } + return this.props.device.name; + }; + + getIcon = () => { + if(this.state.value){ + return this.iconOn; + } + return this.iconOff; + }; + + componentDidMount() { + } + + + render() { + return ( + + this.props.onChangeData(id, newSettings)}/> + +
{this.props.device.name}
+
+ ) + } +} diff --git a/smart-hut/src/components/dashboard/devices/DigitalSensorStyle.js b/smart-hut/src/components/dashboard/devices/DigitalSensorStyle.js new file mode 100644 index 0000000..f0fdf12 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/DigitalSensorStyle.js @@ -0,0 +1,17 @@ +export const imageStyle = { + width: "3.5rem", + height: "auto", + position: "absolute", + top: "20%", + left: "50%", + transform: "translateX(-50%)", + filter: "drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25))" +}; + +export const nameStyle = { + color : "black", + position: "absolute", + top: "40%", + left: "50%", + transform: "translateX(-50%)" +}; diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index 69a7df8..9817af9 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -7,11 +7,11 @@ */ import React, {Component} from "react"; -import {iconStyle, StyledDiv, nameStyle} from "./styleComponents"; +import {iconStyle, StyledDiv} from "./styleComponents"; import Settings from "./DeviceSettings"; import {Image} from "semantic-ui-react"; import {CircularInput, CircularProgress, CircularThumb, CircularTrack} from "react-circular-input"; -import {valueStyle, intensityLightStyle, style} from "./LightStyle"; +import {valueStyle, intensityLightStyle, style, nameStyle} from "./LightStyle"; export default class Light extends Component { constructor(props) { diff --git a/smart-hut/src/components/dashboard/devices/LightStyle.js b/smart-hut/src/components/dashboard/devices/LightStyle.js index 046abee..528a2c1 100644 --- a/smart-hut/src/components/dashboard/devices/LightStyle.js +++ b/smart-hut/src/components/dashboard/devices/LightStyle.js @@ -8,7 +8,15 @@ export const valueStyle = { export const intensityLightStyle = { fill: "#3e99ff", - fontSize: "1.5rem", + fontSize: "1.2rem", fontFamily: "Lato", textShadow: "1px 1px 0.5px rgba(0, 0, 0, .2)", }; + +export const nameStyle = { + fontSize : "1.2rem", + position: "absolute", + top: "50%", + left: "50%", + transform: "translateX(-50%)" +}; diff --git a/smart-hut/src/components/dashboard/devices/Sensor.js b/smart-hut/src/components/dashboard/devices/Sensor.js index 5aaa7e5..2b80d19 100644 --- a/smart-hut/src/components/dashboard/devices/Sensor.js +++ b/smart-hut/src/components/dashboard/devices/Sensor.js @@ -10,7 +10,7 @@ import React, {Component} from "react"; import {CircularInput, CircularProgress, CircularTrack} from "react-circular-input"; import {errorStyle, sensorText, style, valueStyle} from "./SensorStyle"; -export default class Light extends Component { +export default class Sensor extends Component { constructor(props) { super(props); this.state = { diff --git a/smart-hut/src/components/dashboard/devices/SmartPlug.js b/smart-hut/src/components/dashboard/devices/SmartPlug.js index cd175c1..b5bde7f 100644 --- a/smart-hut/src/components/dashboard/devices/SmartPlug.js +++ b/smart-hut/src/components/dashboard/devices/SmartPlug.js @@ -7,12 +7,11 @@ (kWh) . The user can reset this value. **/ - import React, {Component} from 'react'; -import {iconStyle, nameStyle, StyledDiv} from "./styleComponents"; +import {StyledDiv} from "./styleComponents"; import Settings from "./DeviceSettings"; import {Image} from "semantic-ui-react"; -import {energyConsumedStyle, imageStyle} from "./SmartPlugStyle"; +import {energyConsumedStyle, imageStyle, nameStyle} from "./SmartPlugStyle"; export default class SmartPlug extends Component { constructor(props){ diff --git a/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js b/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js index 4ee42fd..ea74700 100644 --- a/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js +++ b/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js @@ -1,6 +1,7 @@ import {iconStyle} from "./styleComponents"; export const energyConsumedStyle = { + color : "black", fontSize : "1.3rem", position: "absolute", top: "30%", @@ -17,3 +18,11 @@ export const imageStyle = { transform: "translateX(-50%)", filter: "drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25))" }; + +export const nameStyle = { + color : "black", + position: "absolute", + top: "50%", + left: "50%", + transform: "translateX(-50%)" +}; diff --git a/smart-hut/src/components/dashboard/devices/Switch.js b/smart-hut/src/components/dashboard/devices/Switch.js new file mode 100644 index 0000000..4cc0021 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/Switch.js @@ -0,0 +1,56 @@ +/** + * Users can add on-off switches. A on-off switch can turn on (or off) lights. + * If a light has an intensity level, when it gets switched back on, it gets the last available + * intensity level that was set by the user (or 100% if no such level exists). + * The user can change the state of a switch through the SmartHut interface. + */ + +import React, {Component} from 'react'; +import {StyledDiv} from "./styleComponents"; +import Settings from "./DeviceSettings"; +import {Image} from "semantic-ui-react"; +import {imageStyle, nameStyle} from "./SwitchStyle"; + +export default class Switch extends Component { + constructor(props){ + super(props); + this.state = { + turnedOn: false, + pointingLights : [] + }; + this.iconOn = "/img/switchOn.svg"; + this.iconOff = "/img/switchOff.svg"; + } + + onClickDevice = () => { + this.setState((prevState) => ({turnedOn: !prevState.turnedOn})); + }; + + getIcon = () => { + if(this.state.turnedOn){ + return this.iconOn; + } + return this.iconOff; + }; + + resetEnergyConsumedValue = () => { + // In the settings form there must be an option to restore this value + // along with the rename feature. + } + + componentDidMount() { + } + + render(){ + return ( + {} : this.onClickDevice} style={{textAlign: "center"}}> + this.props.onChangeData(id, newSettings)}/> + +
{this.props.device.name}
+
+ ) + } +} diff --git a/smart-hut/src/components/dashboard/devices/SwitchStyle.js b/smart-hut/src/components/dashboard/devices/SwitchStyle.js new file mode 100644 index 0000000..98e75c2 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/SwitchStyle.js @@ -0,0 +1,17 @@ +export const imageStyle = { + width: "4.5rem", + height: "auto", + position: "absolute", + top: "15%", + left: "50%", + transform: "translateX(-50%)", + filter: "drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25))" +}; + +export const nameStyle = { + color : "black", + position: "absolute", + top: "45%", + left: "50%", + transform: "translateX(-50%)" +}; diff --git a/smart-hut/src/components/dashboard/devices/styleComponents.js b/smart-hut/src/components/dashboard/devices/styleComponents.js index 01c4083..6d3e289 100644 --- a/smart-hut/src/components/dashboard/devices/styleComponents.js +++ b/smart-hut/src/components/dashboard/devices/styleComponents.js @@ -16,9 +16,9 @@ export const editButtonStyle = { export const panelStyle = { position : "relative", backgroundColor: "#fafafa", - height: "100%", + height: "100vh", width: "auto", - padding: "3rem", + padding: "0rem 3rem", }; export const editModeStyle = { diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js index 30f36e0..c0d7411 100644 --- a/smart-hut/src/views/Dashboard.js +++ b/smart-hut/src/views/Dashboard.js @@ -56,21 +56,22 @@ export default class Dashboard extends Component{ handleItemClick(el) { //da fare richiesta get della room e settare activeItem } - + render () { return( + // TODO poner esto otra vez igual que antes.
- - - - - + {/**/} + {/* */} + {/* */} + {/* */} + {/**/} - + From 99f1e169273e02a32f0b1ecf5cd14bf59a191dbf Mon Sep 17 00:00:00 2001 From: christiancp Date: Tue, 17 Mar 2020 23:24:40 +0100 Subject: [PATCH 03/10] Everything related to the settings is done --- smart-hut/src/App.js | 3 +- .../src/components/dashboard/DevicePanel.js | 38 +++-- .../components/dashboard/devices/Device.js | 48 ------- .../dashboard/devices/DeviceSettings.js | 93 ++++-------- .../dashboard/devices/DigitalSensor.js | 2 +- .../src/components/dashboard/devices/Light.js | 136 +++++++++--------- .../dashboard/devices/LightStyle.js | 5 +- .../components/dashboard/devices/NewDevice.js | 2 +- .../components/dashboard/devices/Sensor.js | 80 ++++++----- .../dashboard/devices/SettingsModal.js | 68 +++++++++ .../components/dashboard/devices/SmartPlug.js | 14 +- .../components/dashboard/devices/Switch.js | 2 +- .../components/dashboard/devices/Switcher.js | 0 .../dashboard/devices/styleComponents.js | 4 +- smart-hut/src/views/Dashboard.js | 11 +- 15 files changed, 253 insertions(+), 253 deletions(-) delete mode 100644 smart-hut/src/components/dashboard/devices/Device.js create mode 100644 smart-hut/src/components/dashboard/devices/SettingsModal.js delete mode 100644 smart-hut/src/components/dashboard/devices/Switcher.js diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 5eb7263..232f63e 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -98,8 +98,7 @@ class App extends Component { - //TODO Change this back the exclamation - {!this.state.loggedIn ? : } + {this.state.loggedIn ? : } diff --git a/smart-hut/src/components/dashboard/DevicePanel.js b/smart-hut/src/components/dashboard/DevicePanel.js index b4b403d..4dfa259 100644 --- a/smart-hut/src/components/dashboard/DevicePanel.js +++ b/smart-hut/src/components/dashboard/DevicePanel.js @@ -2,7 +2,6 @@ import React, {Component} from 'react'; import { Grid, } from "semantic-ui-react"; -import Device from "./devices/Device"; import NewDevice from "./devices/NewDevice"; import {LightDevice, SmartPlugDevice} from "./devices/TypesOfDevices"; import {editButtonStyle, panelStyle} from "./devices/styleComponents"; @@ -12,6 +11,7 @@ import SmartPlug from "./devices/SmartPlug"; import Sensor from "./devices/Sensor"; import DigitalSensor from "./devices/DigitalSensor"; import Switch from "./devices/Switch"; +import SettingsModal from "./devices/SettingsModal"; const devices = [ @@ -44,7 +44,7 @@ const devices = [ { "id": 5, "name": "Smart Plug", - "type": "smartplug", + "type": "smart-plug", ...SmartPlugDevice }, { @@ -64,12 +64,18 @@ class Panel extends Component { constructor(props) { super(props); this.state = { - editMode: false, devices: devices, + + editMode: false, + openSettingsModal: false, + settingsDeviceId: null, }; } - editModeController = (e) => this.setState((prevState) => ({editMode: !prevState.editMode})); + editModeController = (e) => { + this.setState((prevState) => ({editMode: !prevState.editMode})); + console.log("CAMBIADO", this.state.editMode) + }; changeDeviceData = (deviceId, newSettings) => { console.log(newSettings.name, " <-- new name --> ", deviceId); @@ -95,23 +101,35 @@ class Panel extends Component { this.forceUpdate(); }; + openModal = (settingsDeviceId) => { + this.setState(prevState => ({ + openSettingsModal: !prevState.openSettingsModal, + settingsDeviceId: settingsDeviceId + })); + }; render() { + const edit = { + mode: this.state.editMode, + openModal: this.openModal, + }; return (
+ {this.state.openSettingsModal ? + d.id === this.state.settingsDeviceId)[0]}/> : ""} - + + + + - + - - - - + diff --git a/smart-hut/src/components/dashboard/devices/Device.js b/smart-hut/src/components/dashboard/devices/Device.js deleted file mode 100644 index d1fb1f0..0000000 --- a/smart-hut/src/components/dashboard/devices/Device.js +++ /dev/null @@ -1,48 +0,0 @@ -import React, {Component} from 'react'; -import {Image} from "semantic-ui-react"; -import {iconStyle, nameStyle, StyledDiv} from "./styleComponents"; -import Settings from './DeviceSettings'; - - -export default class Device extends Component { - constructor(props) { - super(props); - this.state = { - turnOnOff: "off", - icon: this.props.device.img - } - } - - onClickDevice = () => { - if (!this.props.edit) { - if (this.props.device.type === "light") { - if (this.state.turnOnOff === "on") { - this.setState({ - turnOnOff: "off", - icon: this.props.device.img - }); - } else { - this.setState({ - turnOnOff: "on", - icon: this.props.device.imgClick - }); - } - } - } - }; - render() { - return ( - { - } : this.onClickDevice} style={{textAlign: "center"}}> - this.props.onChangeData(id, newSettings)}/> - -
{this.props.device.name}
-
- ) - } -} - - diff --git a/smart-hut/src/components/dashboard/devices/DeviceSettings.js b/smart-hut/src/components/dashboard/devices/DeviceSettings.js index 7fe9884..c8e2fce 100644 --- a/smart-hut/src/components/dashboard/devices/DeviceSettings.js +++ b/smart-hut/src/components/dashboard/devices/DeviceSettings.js @@ -1,73 +1,34 @@ import React, {Component} from "react"; -import {Button, Form} from "semantic-ui-react"; -import {editModeIconStyle, editModeStyle, formStyle} from "./styleComponents"; - -class SettingsForm extends Component { - constructor(props) { - super(props); - this.state = {} - }; - - onChangeHandler = (event) => { - let nam = event.target.name; - let val = event.target.value; - this.setState({[nam]: val}); - }; - - saveChanges = () => { - let newName = this.state["new-name"]; - this.props.onChangeData(this.props.id, {"name": newName}); - }; - - render() { - return ( -
- - - - - -
- ) - } -} +import {editModeIconStyle, editModeStyle} from "./styleComponents"; export default class Settings extends Component { - constructor(props) { - super(props); - this.state = { - displayForm: false, - } - }; + constructor(props) { + super(props); + this.state = { + displayForm: true, + } + }; - displayForm = () => { - this.setState((prevState) => ({displayForm: !prevState.displayForm})); - }; + displayForm = () => { + this.setState((prevState) => ({displayForm: !prevState.displayForm})); + }; - render() { - const view = ( -
- {this.state.displayForm ? ( - ) : ("")} -
- - {!this.state.displayForm ? ( - ) - : -

×

- } -
-
-
- ); - return ( - - {this.props.edit ? view : ("")} - - ) - }; + render() { + const view = ( +
this.props.edit.openModal(this.props.deviceId)}> + + + +
+ ); + return ( + + {this.props.edit.mode ? view : ("")} + + ) + }; } diff --git a/smart-hut/src/components/dashboard/devices/DigitalSensor.js b/smart-hut/src/components/dashboard/devices/DigitalSensor.js index a39e6b3..cbc026c 100644 --- a/smart-hut/src/components/dashboard/devices/DigitalSensor.js +++ b/smart-hut/src/components/dashboard/devices/DigitalSensor.js @@ -45,7 +45,7 @@ export default class DigitalSensor extends Component { render() { return ( - + { - this.setState((prevState) => ({turnedOn: !prevState.turnedOn})); + constructor(props) { + super(props); + this.state = { + turnedOn: false, + hasIntensity: false }; + this.iconOn = "/img/lightOn.svg"; + this.iconOff = "/img/lightOff.svg" + } - setIntensity = (newValue) => { - this.setState({intensityLevel : newValue}); - }; + onClickDevice = () => { + this.setState((prevState) => ({turnedOn: !prevState.turnedOn})); + }; - getIcon = () => { - if(this.state.turnedOn){ - return this.iconOn; - } - return this.iconOff; - }; - - componentDidMount() { - if(this.props.device.hasOwnProperty("hasIntensity") && this.props.device.hasOwnProperty("intensityLevel")) { - this.setState({ - hasIntensity: this.props.device.hasIntensity, - intensityLevel: this.props.device.intensityLevel - }); - } - // Get the state and update it + setIntensity = (newValue) => { + this.setState({intensityLevel: newValue}); + }; + getIcon = () => { + if (this.state.turnedOn) { + return this.iconOn; } + return this.iconOff; + }; - - render() { - const intensityLightView = ( - - - - - - - {Math.round(this.state.intensityLevel*100)}% - - - {this.props.device.name} - - - ); - - const normalLightView = ( - { - } : this.onClickDevice} style={{textAlign: "center"}}> - this.props.onChangeData(id, newSettings)}/> - -
{this.props.device.name}
-
- ); - - return ( - - {this.state.hasIntensity ? (intensityLightView) : (normalLightView)} - - ) + componentDidMount() { + if (this.props.device.hasOwnProperty("hasIntensity") && this.props.device.hasOwnProperty("intensityLevel")) { + this.setState({ + hasIntensity: this.props.device.hasIntensity, + intensityLevel: this.props.device.intensityLevel + }); } + // Get the state and update it + + } + + + render() { + const intensityLightView = ( + + + + + + + {Math.round(this.state.intensityLevel * 100)}% + + + {this.props.device.name} + + + ); + + const normalLightView = ( +
{ + } : this.onClickDevice}> + +
{this.props.device.name}
+
+ ); + + return ( + + this.props.onChangeData(id, newSettings)}/> + {this.state.hasIntensity ? (intensityLightView) : (normalLightView)} + + ) + } } diff --git a/smart-hut/src/components/dashboard/devices/LightStyle.js b/smart-hut/src/components/dashboard/devices/LightStyle.js index 528a2c1..a6e672d 100644 --- a/smart-hut/src/components/dashboard/devices/LightStyle.js +++ b/smart-hut/src/components/dashboard/devices/LightStyle.js @@ -14,9 +14,10 @@ export const intensityLightStyle = { }; export const nameStyle = { - fontSize : "1.2rem", + fontSize : "1rem", position: "absolute", top: "50%", left: "50%", - transform: "translateX(-50%)" + transform: "translateX(-50%)", + color : "black" }; diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index ddf4e4d..1fc4428 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -97,7 +97,7 @@ export default class NewDevice extends Component { render() { return ( - + {this.state.openForm ? ( diff --git a/smart-hut/src/components/dashboard/devices/Sensor.js b/smart-hut/src/components/dashboard/devices/Sensor.js index 2b80d19..23cbc51 100644 --- a/smart-hut/src/components/dashboard/devices/Sensor.js +++ b/smart-hut/src/components/dashboard/devices/Sensor.js @@ -9,48 +9,56 @@ import React, {Component} from "react"; import {CircularInput, CircularProgress, CircularTrack} from "react-circular-input"; import {errorStyle, sensorText, style, valueStyle} from "./SensorStyle"; +import Settings from "./DeviceSettings"; +import {StyledDiv} from "./styleComponents"; export default class Sensor extends Component { - constructor(props) { - super(props); - this.state = { - turnedOn: false, - value: 20, - error : 2.4 - }; - this.units = "ºC" - } - - setName = () => { - if(this.props.device.name.length > 15){ - return this.props.device.name.slice(0,12) + "..." - } - return this.props.device.name; + constructor(props) { + super(props); + this.state = { + turnedOn: false, + value: 20, + error: 2.4 }; + this.units = "ºC" + } - componentDidMount() { + setName = () => { + if (this.props.device.name.length > 15) { + return this.props.device.name.slice(0, 12) + "..." } + return this.props.device.name; + }; + + componentDidMount() { + } - render() { - return ( - - - + render() { + return ( + + this.props.onChangeData(id, newSettings)}/> - - {Math.round(this.state.value)}{this.units} - - - ±{this.state.error} - - - {this.setName()} - - - ) - } + + + + + {Math.round(this.state.value)}{this.units} + + + ±{this.state.error} + + + {this.setName()} + + + + ) + } } diff --git a/smart-hut/src/components/dashboard/devices/SettingsModal.js b/smart-hut/src/components/dashboard/devices/SettingsModal.js new file mode 100644 index 0000000..abcb357 --- /dev/null +++ b/smart-hut/src/components/dashboard/devices/SettingsModal.js @@ -0,0 +1,68 @@ +import React, {Component, useState} from 'react'; +import {Button, Checkbox, Form, Modal} from "semantic-ui-react"; + +const SettingsForm = (props) => { + + const handleInputChange = e => { + const {name, value} = e.target; + setValues({...values, [name]: value}) + }; + + const handleCheckboxChange = (e,d) => { + const {name, checked} = d; + setValues({...values, [name]: checked}) + }; + + const [values, setValues] = useState({name: ''}); + + return ( +
+ + + + + {props.type === "smart-plug" ? ( + + + + ) : ""} + +
+ ) +} + +export default class SettingsModal extends Component { + + constructor(props) { + super(props); + this.state = { + open: true, + }; + } + + handleClose = () => { + this.setState({open: false}); + }; + + saveSettings = (device) => { + // TODO Here there should be all the connections to save the data in the backend + console.log("SAVED: ", device); + + this.props.openModal(); + }; + + render() { + const SettingsModal = () => ( + + Settings of {this.props.device.name} + + + + + ); + return ( + + ) + } + +} diff --git a/smart-hut/src/components/dashboard/devices/SmartPlug.js b/smart-hut/src/components/dashboard/devices/SmartPlug.js index b5bde7f..0c07ba4 100644 --- a/smart-hut/src/components/dashboard/devices/SmartPlug.js +++ b/smart-hut/src/components/dashboard/devices/SmartPlug.js @@ -1,11 +1,8 @@ /** - A smart plug is a plug that has a boolean internal state, i.e., that can be turned on or off, either with the SmartHut interface or by a switch. - The smart plug also stores the total energy consumed while the plug is active, in terms of kilowatt-hours - 2 - (kWh) . The user can reset this value. - + The smart plug also stores the total energy consumed while the plug is active, in terms of kilowatt-hours 2(kWh) . + The user can reset this value. **/ import React, {Component} from 'react'; import {StyledDiv} from "./styleComponents"; @@ -35,17 +32,12 @@ export default class SmartPlug extends Component { return this.iconOff; }; - resetEnergyConsumedValue = () => { - // In the settings form there must be an option to restore this value - // along with the rename feature. - } - componentDidMount() { } render(){ return ( - {} : this.onClickDevice} style={{textAlign: "center"}}> + {} : this.onClickDevice}> {} : this.onClickDevice} style={{textAlign: "center"}}> + {} : this.onClickDevice}> - {/**/} - {/* */} - {/* */} - {/* */} - {/**/} + + + + + From edf1706986e479f3ab3b27b05009072bca4b19e3 Mon Sep 17 00:00:00 2001 From: christiancp Date: Wed, 18 Mar 2020 14:18:37 +0100 Subject: [PATCH 04/10] Add device feature finished --- smart-hut/public/img/dimmer.svg | 1 + smart-hut/public/img/humidity-sensor.svg | 1 + smart-hut/public/img/intensity-light.svg | 1 + smart-hut/public/img/light-sensor.svg | 1 + smart-hut/public/img/temperature-sensor.svg | 14 + smart-hut/src/App.js | 3 +- .../src/components/dashboard/DevicePanel.js | 3 +- .../components/dashboard/devices/NewDevice.js | 288 ++++++++++++------ smart-hut/src/views/Dashboard.js | 6 +- 9 files changed, 227 insertions(+), 91 deletions(-) create mode 100644 smart-hut/public/img/dimmer.svg create mode 100644 smart-hut/public/img/humidity-sensor.svg create mode 100644 smart-hut/public/img/intensity-light.svg create mode 100644 smart-hut/public/img/light-sensor.svg create mode 100644 smart-hut/public/img/temperature-sensor.svg diff --git a/smart-hut/public/img/dimmer.svg b/smart-hut/public/img/dimmer.svg new file mode 100644 index 0000000..587066c --- /dev/null +++ b/smart-hut/public/img/dimmer.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/smart-hut/public/img/humidity-sensor.svg b/smart-hut/public/img/humidity-sensor.svg new file mode 100644 index 0000000..3f2aee8 --- /dev/null +++ b/smart-hut/public/img/humidity-sensor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/smart-hut/public/img/intensity-light.svg b/smart-hut/public/img/intensity-light.svg new file mode 100644 index 0000000..8a726f9 --- /dev/null +++ b/smart-hut/public/img/intensity-light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/smart-hut/public/img/light-sensor.svg b/smart-hut/public/img/light-sensor.svg new file mode 100644 index 0000000..7c01850 --- /dev/null +++ b/smart-hut/public/img/light-sensor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/smart-hut/public/img/temperature-sensor.svg b/smart-hut/public/img/temperature-sensor.svg new file mode 100644 index 0000000..678696b --- /dev/null +++ b/smart-hut/public/img/temperature-sensor.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 232f63e..5cc0cd3 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -98,7 +98,8 @@ class App extends Component { - {this.state.loggedIn ? : } + {/* ToDO change this back */} + {!this.state.loggedIn ? : } diff --git a/smart-hut/src/components/dashboard/DevicePanel.js b/smart-hut/src/components/dashboard/DevicePanel.js index 4dfa259..0276963 100644 --- a/smart-hut/src/components/dashboard/DevicePanel.js +++ b/smart-hut/src/components/dashboard/DevicePanel.js @@ -74,7 +74,6 @@ class Panel extends Component { editModeController = (e) => { this.setState((prevState) => ({editMode: !prevState.editMode})); - console.log("CAMBIADO", this.state.editMode) }; changeDeviceData = (deviceId, newSettings) => { @@ -132,7 +131,7 @@ class Panel extends Component { - +
diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index 1fc4428..122ee96 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -1,8 +1,6 @@ import React, {Component} from 'react'; import styled from 'styled-components'; -import {Button, Dropdown, Form, Image} from "semantic-ui-react"; -import {addDeviceFormStyle} from "./styleComponents"; -import {deviceList} from "./TypesOfDevices"; +import {Button, Dropdown, Form, Icon, Image, Input, Modal} from "semantic-ui-react"; const StyledDiv = styled.div` background-color : #ff4050; @@ -19,90 +17,208 @@ const StyledDiv = styled.div` } `; -class NewDeviceForm extends Component { - constructor(props) { - super(props); - } - - formSelector = (option) => { - switch (option) { - case "Light": - return ; - case "Sensor": - return "This is a sensor form"; - default: - return "This is a default text" - } - }; - - render() { - let options = []; - deviceList.forEach((e, i) => { - options.push({key: i, text: e, value: e}) - }); - - return ( -
- - - - - - -
- ); - } -} - - -class LightForm extends Component { - constructor(props) { - super(props); - this.state = {} - } - - render() { - let options = [ - { - key: 1, - value: "common", - text: "Normal Light" - }, - { - key: 1, - value: "intensity", - text: "Supports intensity level" - } - ] - return ( - - - - - ); - }; -}; - export default class NewDevice extends Component { - constructor(props) { - super(props); - this.state = { - openForm: false - } - } - - onClickDevice = (event) => { - this.setState((prevState) => ({openForm: !prevState.openForm})); + constructor(props) { + super(props); + this.state = { + step: 1, + openModal : false }; + this.baseState = this.state + } - render() { - return ( - - - {this.state.openForm ? ( - - ) : ""} - - ) - } + handleOpen = () => {this.setState({openModal : true})}; + handleClose = () => {this.setState({openModal : false})}; + + + resetState = () => { + this.setState(this.baseState); + this.handleClose(); + }; + + nextStep = () => { + this.setState((prevState) => ({step: prevState.step + 1})); + }; + previousStep = () => { + this.setState((prevState) => ({step: prevState.step - 1})); + }; + + setTypeOfDevice = (e, d) => { + this.setState({typeOfDevice: d.value}); + }; + + setDeviceName = (e, d) => { + this.setState({deviceName: d.value}); + }; + + setTypeOfSensor = (e, d) => { + this.setState({typeOfSensor: d.value}); + }; + + setLightsDimmerSwitch = (e, d) => { + this.setState({lightsAttached : d.value}); + }; + + createDevice = () => { + // Connect to the backend and create device here. + this.resetState(); + }; + + + render() { + const deviceOptions = [ + { + key: 'light', + text: 'Normal Light', + value: 'light', + image: {avatar: true, src: '/img/lightOn.svg'}, + }, + { + key: 'intensity-light', + text: 'Intensity Light', + value: 'intensity-light', + image: {avatar: true, src: '/img/intensity-light.svg'}, + }, + { + key: 'smart-plug', + text: 'Smart Plug', + value: 'smart-plug', + image: {avatar: true, src: '/img/smart-plug.svg'}, + }, + { + key: 'sensor', + text: 'Sensor', + value: 'sensor', + image: {avatar: true, src: '/img/sensorOn.svg'}, + }, + { + key: 'switch', + text: 'Switch', + value: 'switch', + image: {avatar: true, src: '/img/switchOn.svg'}, + }, + { + key: 'dimmer', + text: 'Dimmer', + value: 'dimmer', + image: {avatar: true, src: '/img/dimmer.svg'}, + }, + ]; + const sensorOptions = [ + { + key: "temperature", + text: "Temperature Sensor", + value: "temperature", + image: {avatar: true, src: '/img/temperature-sensor.svg'}, + }, + { + key: "humidity", + text: "Humidity Sensor", + value: "humidity", + image: {avatar: true, src: '/img/humidity-sensor.svg'}, + }, + { + key: "light", + text: "Light Sensor", + value: "light", + image: {avatar: true, src: '/img/light-sensor.svg'}, + }, + { + key: "motion", + text: "Motion Sensor", + value: "motion", + image: {avatar: true, src: '/img/sensorOn.svg'}, + } + ]; + const availableLights = []; + this.props.devices.forEach(d => { + availableLights.push( + { + key: d.id, + text: d.name, + value: d.id, + } + ) + }); + const step1 = ( + + ); + const step2 = (typeOfDevice) => { + const deviceName = (
+ + + + +
); + const sensorForm = ( + + + ); + const switchDimmerOptions = ( + + + ); + return ( +
+ {deviceName} + {this.state.typeOfDevice === "sensor" ? (sensorForm) : ""} + {this.state.typeOfDevice === "switch" || this.state.typeOfDevice === "dimmer" ? + (switchDimmerOptions) : "" + } +
+ ) + }; + const steps = [step1, step2()]; + return ( + + + } centered={true}> + Add a New Device + + {steps[this.state.step -1]} + + + {this.state.step > 1 ? ( + + ) : ""} + {this.state.step < steps.length ? ( + + ) : ""} + {this.state.step === steps.length ? ( + + ) : ""} + + + ) + } } diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js index 1078924..75222fc 100644 --- a/smart-hut/src/views/Dashboard.js +++ b/smart-hut/src/views/Dashboard.js @@ -61,10 +61,12 @@ export default class Dashboard extends Component{ return(
- + + + {/*TODO change this back - + */} From 70e5dc8017b27b1f9746fbec528c68fdab288f6e Mon Sep 17 00:00:00 2001 From: christiancp Date: Wed, 18 Mar 2020 14:19:47 +0100 Subject: [PATCH 05/10] change button color --- smart-hut/src/components/dashboard/devices/SettingsModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart-hut/src/components/dashboard/devices/SettingsModal.js b/smart-hut/src/components/dashboard/devices/SettingsModal.js index abcb357..ac5f982 100644 --- a/smart-hut/src/components/dashboard/devices/SettingsModal.js +++ b/smart-hut/src/components/dashboard/devices/SettingsModal.js @@ -26,7 +26,7 @@ const SettingsForm = (props) => { ) : ""} - + ) } From cd12d5f69f1c51230bb0a1028001409f37eb9938 Mon Sep 17 00:00:00 2001 From: christiancp Date: Wed, 18 Mar 2020 15:12:12 +0100 Subject: [PATCH 06/10] minor error fixed --- smart-hut/src/views/Dashboard.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js index 75222fc..10be5e6 100644 --- a/smart-hut/src/views/Dashboard.js +++ b/smart-hut/src/views/Dashboard.js @@ -63,10 +63,9 @@ export default class Dashboard extends Component{ - {/*TODO change this back - */} + From d7399abdea1ecfb3a8073d7edef4f9ec4bb71f17 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 18 Mar 2020 15:49:33 +0100 Subject: [PATCH 07/10] Removed TODO --- smart-hut/src/App.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index efde975..0054987 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -98,8 +98,7 @@ class App extends Component { - {/* ToDO change this back */} - {!this.state.loggedIn ? : } + {this.state.loggedIn ? : } From 1757c8e2d724b329e2a6fd64e938deef444743b4 Mon Sep 17 00:00:00 2001 From: Fil Cesana Date: Wed, 18 Mar 2020 16:35:42 +0100 Subject: [PATCH 08/10] Instructions pages done, I will wait until the app is more or less completed before writing the actual instructions, for many thing may change along the way. --- smart-hut/src/views/Instruction.js | 97 +++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/smart-hut/src/views/Instruction.js b/smart-hut/src/views/Instruction.js index a5bee71..6a58d4a 100644 --- a/smart-hut/src/views/Instruction.js +++ b/smart-hut/src/views/Instruction.js @@ -14,8 +14,103 @@ import { Grid } from "semantic-ui-react"; +const ContainerExampleAlignment = () => ( +
+ + +
Instructions Page
+ + + +
+ + First Step + +

+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo + ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et + magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, + ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa + quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, + arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. + Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras + dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend + tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, + enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. + Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean + imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper + ultricies nisi. +

+ +
+ + Second Step + +

+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo + ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et + magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, + ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa + quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, + arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. + Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras + dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend + tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, + enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. + Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean + imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper + ultricies nisi. +

+ +
+ + Third Step + +

+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo + ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et + magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, + ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa + quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, + arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. + Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras + dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend + tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, + enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. + Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean + imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper + ultricies nisi. +

+ +
+ +Last Step + +

+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo + ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et + magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, + ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa + quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, + arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. + Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras + dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend + tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, + enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. + Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean + imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper + ultricies nisi. +

+ +
+
+) + + export default class Insturction extends Component{ render() { - return; + return( + + ) } } \ No newline at end of file From e786288fa8610cc880cc060eb9e44bf14fe65d84 Mon Sep 17 00:00:00 2001 From: britea Date: Thu, 19 Mar 2020 11:52:13 +0100 Subject: [PATCH 09/10] fix all warnings and cleaned code --- smart-hut/src/App.js | 13 +- smart-hut/src/client_server.js | 84 +----------- smart-hut/src/components/HeaderController.js | 10 +- smart-hut/src/components/HomeNavbar.js | 1 - smart-hut/src/components/SelectIcons.js | 3 +- .../src/components/dashboard/DevicePanel.js | 121 ++++++++++-------- .../dashboard/devices/DeviceTypeController.js | 10 +- .../components/dashboard/devices/NewDevice.js | 13 +- .../dashboard/devices/SmartPlugStyle.js | 1 - smart-hut/src/components/modalform.js | 28 ++-- smart-hut/src/views/ConfirmForgotPassword.js | 7 - smart-hut/src/views/ConfirmRegistration.js | 7 - smart-hut/src/views/Dashboard.js | 91 +++++++++---- smart-hut/src/views/Forgot-pass-reset.js | 8 +- smart-hut/src/views/Home.js | 2 - smart-hut/src/views/Navbar.js | 12 +- smart-hut/src/views/NavbarTest.js | 12 -- smart-hut/src/views/TestHeaderController.js | 11 +- 18 files changed, 192 insertions(+), 242 deletions(-) delete mode 100644 smart-hut/src/views/NavbarTest.js diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 0054987..1126e85 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -44,18 +44,22 @@ class App extends Component { } componentDidMount() { - if (this.props.location) { - const values = queryString.parse(this.props.location.search); + if (window.location) { + const values = queryString.parse(window.location.search); + console.log(values); this.setState({ query : values }); + } else { + this.setState({ + query : "ciao" + }); } } auth(data) { return call.login(data.params) .then(res => { - console.log(res); if (res.data && res.status === 200) { localStorage.setItem("token", res.data.jwttoken); this.setState( @@ -80,7 +84,6 @@ class App extends Component { }; logout() { - console.log("logout") this.setState({ loggedIn : false, }); @@ -109,7 +112,7 @@ class App extends Component { - + diff --git a/smart-hut/src/client_server.js b/smart-hut/src/client_server.js index 3821dcb..8477ad4 100644 --- a/smart-hut/src/client_server.js +++ b/smart-hut/src/client_server.js @@ -17,132 +17,56 @@ const tkn = localStorage.getItem("token"); export var call = { login: function(data, headers) { return axios.post(config +'auth/login', data) - .then(res => { - return res; - }).catch(err => { - return {status : "Errore"}; - }); }, register: function(data, headers) { return axios.post(config + 'register', data) - .then(res => { - return res; - }).catch(err => { - //console.error(err); - return {status : "Errore"}; - }); }, initResetPassword: function(data, headers) { return axios.post(config + 'register/init-reset-password', data) - .then(res => { - return res; - }).catch(err => { - return {status : "Errore"}; - }); }, resetPassword: function(data, headers) { return axios.put(config + 'register/reset-password', data) - .then(res => { - return res; - }).catch(err => { - return {status : "Errore"}; - }); }, getAllRooms: function(token) { if (!token){ token = tkn; } return axios.get(config + 'room', { headers: { Authorization : "Bearer " + token } }) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, getAllDevices: function(token) { if (!token){ token = tkn; } - return axios.get(config + 'device', { headers: { Authorization : "Bearer " + token } }) - .then(res => { - return res; - }).catch(err => { - return err; - }); + return axios.get(config + 'device', { headers: { Authorization : "Bearer " + token } }); }, getAllDevicesByRoom: function(id, token) { if (!token){ token = tkn; } - return axios.get(config + 'room/' + id + '/devices' , { headers: { Authorization : "Bearer " + token } }) - .then(res => { - return res; - }).catch(err => { - return err; - }); + return axios.get(config + 'room/' + id + '/devices' , { headers: { Authorization : "Bearer " + token } }); }, createRoom: function(data, headers) { return axios.post(config + 'room', data, { headers: { Authorization : "Bearer " + tkn } }) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, updateRoom: function(data, headers) { return axios.put(config + 'room/'+data.id) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, deleteRoom: function(data, headers) { - return axios.delete(config + 'room/'+data.id) - .then(res => { - return res; - }).catch(err => { - return err; - }); + return axios.delete(config + 'room/'+data.id, { headers: { Authorization : "Bearer " + tkn } }); }, devicePost: function(data, headers) { - return axios.post(config + data.device, data.params) - .then(res => { - return res; - }).catch(err => { - return err; - }); + return axios.post(config + data.device, data.params, { headers: { Authorization : "Bearer " + tkn } }) }, deviceUpdate: function(data, headers) { return axios.put(config + data.device, data.params) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, deviceDelete: function(data, headers) { return axios.delete(config + data.device + '/' + data.id, data.params) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, deviceGetById: function(data, headers) { return axios.get(config + data.device + '/' + data.id) - .then(res => { - return res; - }).catch(err => { - return err; - }); }, deviceGetAll: function(data, headers) { return axios.get(config + data.device) - .then(res => { - return res; - }).catch(err => { - return err; - }); } }; diff --git a/smart-hut/src/components/HeaderController.js b/smart-hut/src/components/HeaderController.js index 5bf9c9f..afb59ef 100644 --- a/smart-hut/src/components/HeaderController.js +++ b/smart-hut/src/components/HeaderController.js @@ -1,6 +1,5 @@ -import React, { Component } from "react"; -import { render } from "react-dom"; -import { Button, Menu, Header, Dropdown, Icon, Grid, Divider} from 'semantic-ui-react' +import React from "react"; +import { Dropdown, Icon, Grid, Divider} from 'semantic-ui-react' import { Segment, Image } from 'semantic-ui-react' const ImageExampleWrapped = () => ( @@ -23,10 +22,6 @@ const ImageExampleWrapped3 = () => ( ) -const HeaderExampleIconProp = () => ( -
-) - const GridExampleInverted = (props) => ( @@ -67,7 +62,6 @@ const GridExampleInverted = (props) => ( export default class MyHeader extends React.Component { render() { - console.log(this.props) return (
diff --git a/smart-hut/src/components/HomeNavbar.js b/smart-hut/src/components/HomeNavbar.js index 5bcafb5..651e1a0 100644 --- a/smart-hut/src/components/HomeNavbar.js +++ b/smart-hut/src/components/HomeNavbar.js @@ -1,6 +1,5 @@ import _ from "lodash"; import React, { Component } from "react"; -import { render } from "react-dom"; import { Container, Icon, diff --git a/smart-hut/src/components/SelectIcons.js b/smart-hut/src/components/SelectIcons.js index e9d23f6..f1a7994 100644 --- a/smart-hut/src/components/SelectIcons.js +++ b/smart-hut/src/components/SelectIcons.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Button, Header, Image, Modal, Checkbox, Form, Grid, Input, Icon } from 'semantic-ui-react' +import { Button, Grid } from 'semantic-ui-react' export default class SelectIcons extends Component { @@ -29,7 +29,6 @@ export default class SelectIcons extends Component { ['trophy', 'wrench', 'image', 'book', 'university', 'medkit'], ['paw', 'tree', 'utensils', 'male', 'female', 'life ring outline']]; - var colums = 0; return ( { diff --git a/smart-hut/src/components/dashboard/DevicePanel.js b/smart-hut/src/components/dashboard/DevicePanel.js index cb32a63..a5b4eeb 100644 --- a/smart-hut/src/components/dashboard/DevicePanel.js +++ b/smart-hut/src/components/dashboard/DevicePanel.js @@ -1,6 +1,6 @@ import React, {Component} from 'react'; import { - Grid, + Grid, } from "semantic-ui-react"; import {editButtonStyle, panelStyle} from "./devices/styleComponents"; import {checkMaxLength, DEVICE_NAME_MAX_LENGTH} from "./devices/constants"; @@ -9,67 +9,76 @@ import NewDevice from "./devices/NewDevice"; export default class DevicePanel extends Component { - constructor(props) { - super(props); - this.state = { - editMode : false, - devices : this.props.devices, - }; - } + constructor(props) { + super(props); + this.state = { + editMode : false, + }; + + this.addDevice = this.addDevice.bind(this); + } - editModeController = (e) => this.setState((prevState) => ({ editMode: !prevState.editMode })); + editModeController = (e) => this.setState((prevState) => ({ editMode: !prevState.editMode })); - changeDeviceData = (deviceId, newSettings) => { + changeDeviceData = (deviceId, newSettings) => { - console.log(newSettings.name, " <-- new name --> ", deviceId ); - this.state.devices.map(device => { - if(device.id === deviceId){ - for(let prop in newSettings){ - if(device.hasOwnProperty(prop)){ - if(prop==="name"){ - if(checkMaxLength(newSettings[prop])){ - device[prop] = newSettings[prop]; - } - else{ - alert("Name must be less than " + DEVICE_NAME_MAX_LENGTH + " characters."); - } - }else{ - device[prop] = newSettings[prop]; + console.log(newSettings.name, " <-- new name --> ", deviceId ); + this.props.devices.map(device => { + if(device.id === deviceId){ + for(let prop in newSettings){ + if(device.hasOwnProperty(prop)){ + if(prop==="name"){ + if(checkMaxLength(newSettings[prop])){ + device[prop] = newSettings[prop]; + } + else{ + alert("Name must be less than " + DEVICE_NAME_MAX_LENGTH + " characters."); + } + }else{ + device[prop] = newSettings[prop]; + } + + } + } } + return null; + }); + this.forceUpdate(); + }; - } - } - } - return null; - }); - this.forceUpdate(); - }; + addDevice(data) { + const ds = this.props.addDevice(data); + this.setState({ + devices: ds + }); + } - render() { - return ( -
- - 0 ? this.state.devices.length : 1} divided="vertically"> - { - this.state.devices ? - this.state.devices.map((e, i) => { - return ( - - - - ) - }) - : - null - } - - - - -
- ) - } + render() { + const ds = this.state.devices ? this.state.devices : this.props.devices; + return ( +
+ + 0 ? ds.length : 1} divided="vertically"> + { + ds ? + ds.map((e, i) => { + return ( + + + + ) + }) + : + null + } + + + + +
+ ) + } -} +} diff --git a/smart-hut/src/components/dashboard/devices/DeviceTypeController.js b/smart-hut/src/components/dashboard/devices/DeviceTypeController.js index 2b1cc08..bb8de4d 100644 --- a/smart-hut/src/components/dashboard/devices/DeviceTypeController.js +++ b/smart-hut/src/components/dashboard/devices/DeviceTypeController.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React from 'react'; import Light from "./Light"; import SmartPlug from "./SmartPlug"; import Sensor from "./Sensor"; @@ -9,8 +9,8 @@ import Switcher from "./Switch"; const DeviceType = (props) => { switch(props.type) { - case "light": - return + case "regular-light": + return () case "sensor": return case "dimmer": @@ -19,6 +19,10 @@ const DeviceType = (props) => { return case "switch": return + case "light": + return + default: + return "" } } diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index 122ee96..77aca2e 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -25,6 +25,7 @@ export default class NewDevice extends Component { openModal : false }; this.baseState = this.state + this.createDevice = this.createDevice.bind(this); } handleOpen = () => {this.setState({openModal : true})}; @@ -59,8 +60,16 @@ export default class NewDevice extends Component { this.setState({lightsAttached : d.value}); }; - createDevice = () => { + createDevice() { // Connect to the backend and create device here. + const data = { + params: { + "name": this.state.deviceName, + }, + device: this.state.typeOfDevice + + } + this.props.addDevice(data); this.resetState(); }; @@ -70,7 +79,7 @@ export default class NewDevice extends Component { { key: 'light', text: 'Normal Light', - value: 'light', + value: 'regularLight', image: {avatar: true, src: '/img/lightOn.svg'}, }, { diff --git a/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js b/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js index ea74700..26b4b9e 100644 --- a/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js +++ b/smart-hut/src/components/dashboard/devices/SmartPlugStyle.js @@ -1,4 +1,3 @@ -import {iconStyle} from "./styleComponents"; export const energyConsumedStyle = { color : "black", diff --git a/smart-hut/src/components/modalform.js b/smart-hut/src/components/modalform.js index 79ca7da..682bd12 100644 --- a/smart-hut/src/components/modalform.js +++ b/smart-hut/src/components/modalform.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Button, Header, Image, Modal, Checkbox, Form, Grid, Input, Icon } from 'semantic-ui-react' +import { Button, Header, Modal, Form, Input, Icon } from 'semantic-ui-react' import SelectIcons from "./SelectIcons"; export default class ModalWindow extends Component { @@ -39,10 +39,7 @@ export default class ModalWindow extends Component { } deleteRoom = (e) => { - let data = { - "id" : this.state.id - } - this.props.deleteRoom(data); + this.props.deleteRoom(); this.closeModal(); } @@ -77,40 +74,39 @@ export default class ModalWindow extends Component { return (
- {this.props.type == "new" ? + {this.props.type === "new" ? : - + null } -
{this.props.type == "new" ? "Add new room" : "Modify room" }
+
{this.props.type === "new" ? "Add new room" : "Modify room" }

Insert the name of the room:

+ value={this.props.type === "new" ? null : this.props.idRoom.name }/>

Insert an image of the room:

+ value={this.props.type === "new" ? null : this.props.idRoom.images }/>

Select an icon:

- {this.props.type == "new" ? "home" : this.props.idRoom.icon } - +
- {this.props.type == "modify" ? + {this.props.type === "modify" ? - diff --git a/smart-hut/src/views/ConfirmForgotPassword.js b/smart-hut/src/views/ConfirmForgotPassword.js index e364f0d..7de5e16 100644 --- a/smart-hut/src/views/ConfirmForgotPassword.js +++ b/smart-hut/src/views/ConfirmForgotPassword.js @@ -1,14 +1,7 @@ import React, { Component } from "react"; -import { render } from "react-dom"; import HomeNavbar from "./../components/HomeNavbar"; import { - Container, - Icon, Image, - Menu, - Sidebar, - Responsive, - Header, Divider, Message, Grid diff --git a/smart-hut/src/views/ConfirmRegistration.js b/smart-hut/src/views/ConfirmRegistration.js index 9bec496..b1c5652 100644 --- a/smart-hut/src/views/ConfirmRegistration.js +++ b/smart-hut/src/views/ConfirmRegistration.js @@ -1,14 +1,7 @@ import React, { Component } from "react"; -import { render } from "react-dom"; import HomeNavbar from "./../components/HomeNavbar"; import { - Container, - Icon, Image, - Menu, - Sidebar, - Responsive, - Header, Divider, Message, Grid diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js index e9d4253..957c204 100644 --- a/smart-hut/src/views/Dashboard.js +++ b/smart-hut/src/views/Dashboard.js @@ -25,62 +25,101 @@ export default class Dashboard extends Component{ }; this.addRoom = this.addRoom.bind(this); + this.deleteRoom = this.deleteRoom.bind(this); + this.addDevice = this.addDevice.bind(this); this.handleItemClick = this.handleItemClick.bind(this); } componentDidMount() { call.getAllRooms(this.props.tkn) .then(res => { - this.setState({ - rooms: res.data - }); + if (res.status === 200){ + this.setState({ + rooms: res.data + }); + } }).catch(err => { - console.log(err); - }); + console.log(err); + }); call.getAllDevices(this.props.tkn) .then(res => { - this.setState({ - devices: res.data - }); + if (res.status === 200) { + this.setState({ + devices: res.data + }); + } }).catch(err => { - console.log(err); - }); + console.log(err); + }); } addRoom(data) { call.createRoom(data) .then(res => { - console.log(res); if (res.status === 200 && res.data) { this.setState(state => ({ rooms: state.rooms.concat([res.data]) })); } }).catch(err => { - console.log(err); - }); + console.log(err); + }); }; - deleteRoom(id) { - call.deleteRoom(id) + deleteRoom() { + let data = { + id : this.state.activeItem + } + call.deleteRoom(data) .then(res => { //remove room in state.rooms }).catch(err => { - console.log(err); - }); + console.log(err); + }); } handleItemClick(id) { // el -> obj of name and id //da fare richiesta get della room e settare activeItem - call.getAllDevicesByRoom(id, this.props.tkn) - .then(res => { - this.setState({ - devices: res.data - }); - }).catch(err => { - console.log(err); + this.setState({ + activeItem: id }); + if ( id === -1) { + call.getAllDevices(this.props.tkn) + .then(res => { + if ( res.status === 200) { + this.setState({ + devices: res.data + }); + } + }).catch(err => { + console.log(err); + }); + } else { + call.getAllDevicesByRoom(id, this.props.tkn) + .then(res => { + if (res.status === 200) { + this.setState({ + devices: res.data + }); + } + }).catch(err => { + console.log(err); + }); + } + } + + addDevice(data) { + data.params["roomId"] = this.state.activeItem; + call.devicePost(data, this.props.tkn) + .then(res => { + this.setState(state => ({ + devices: state.devices.concat([res.data]) + })); + }).catch(err => { + + }); + return this.state.devices; } render () { @@ -94,11 +133,11 @@ export default class Dashboard extends Component{ - + - + diff --git a/smart-hut/src/views/Forgot-pass-reset.js b/smart-hut/src/views/Forgot-pass-reset.js index 170bf1d..0989b91 100644 --- a/smart-hut/src/views/Forgot-pass-reset.js +++ b/smart-hut/src/views/Forgot-pass-reset.js @@ -1,6 +1,7 @@ import React, {Component} from 'react'; import {Button, Form, Grid, Header, Image, Icon, Message} from 'semantic-ui-react'; import { call } from '../client_server'; +import { Redirect } from "react-router-dom"; export default class ChangePass extends Component { @@ -13,6 +14,7 @@ export default class ChangePass extends Component { message: "", } } + this.handleChangePassword = this.handleChangePassword.bind(this); } onChangeHandler = (event) => { @@ -32,14 +34,16 @@ export default class ChangePass extends Component { handleChangePassword = (e) => { const params = { - "confirmationToken" : this.props.query.confirmationToken , + "confirmationToken" : this.props.query.token , "password" : this.state.password } call.resetPassword(params) .then(res => { - if (res.status === "Errore") { + if (res.status !== 200){ this.setState({ error: { state: true, message: "Errore"}}); + } else { + return } // else set a message that an email has been sent }).catch(err => { diff --git a/smart-hut/src/views/Home.js b/smart-hut/src/views/Home.js index 4937938..2cb4cff 100644 --- a/smart-hut/src/views/Home.js +++ b/smart-hut/src/views/Home.js @@ -4,7 +4,6 @@ import HomeNavbar from './../components/HomeNavbar'; import { Button, Container, - Divider, Grid, Header, Icon, @@ -70,7 +69,6 @@ class DesktopContainer extends Component { render() { const { children } = this.props - const { fixed } = this.state return ( diff --git a/smart-hut/src/views/Navbar.js b/smart-hut/src/views/Navbar.js index 121d4b7..de3f183 100644 --- a/smart-hut/src/views/Navbar.js +++ b/smart-hut/src/views/Navbar.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Menu, Grid, Icon, Button, Header, Image, Modal, Responsive, Segment } from "semantic-ui-react"; +import { Menu, Grid, Icon, Responsive, Segment } from "semantic-ui-react"; import {editButtonStyle} from "../components/dashboard/devices/styleComponents"; import ModalWindow from "../components/modalform"; @@ -19,7 +19,14 @@ class Navbar extends Component { handleClick = (e, {id}) => { console.log(id); + let obj = undefined; + this.props.rooms.forEach((e) => { + if (e.id === id) { + obj = e; + } + }); this.setState({ activeItem: id, + activeRoom: obj }); this.props.handleItemClick(id) } @@ -38,6 +45,7 @@ class Navbar extends Component { - //dropdown menu +
diff --git a/smart-hut/src/views/NavbarTest.js b/smart-hut/src/views/NavbarTest.js deleted file mode 100644 index c108c20..0000000 --- a/smart-hut/src/views/NavbarTest.js +++ /dev/null @@ -1,12 +0,0 @@ -import React, {Component} from 'react'; -import {Button } from 'semantic-ui-react'; - - -export default class NavbarTest extends Component { - - render() { - return ( -

Ciao

- ) - } -} \ No newline at end of file diff --git a/smart-hut/src/views/TestHeaderController.js b/smart-hut/src/views/TestHeaderController.js index 6293908..b0afedb 100644 --- a/smart-hut/src/views/TestHeaderController.js +++ b/smart-hut/src/views/TestHeaderController.js @@ -1,15 +1,6 @@ import _ from "lodash"; -import React, { Component } from "react"; +import React from "react"; import HeaderController from "./../components/HeaderController"; -import { render } from "react-dom"; -import { - Container, - Icon, - Image, - Menu, - Sidebar, - Responsive -} from "semantic-ui-react"; export default class TestHeaderController extends React.Component { render () { From 8b3200f639d5151ebf6324a2dac7985ff279a072 Mon Sep 17 00:00:00 2001 From: britea Date: Fri, 20 Mar 2020 18:42:38 +0100 Subject: [PATCH 10/10] initial setup for device with backend --- smart-hut/src/App.js | 1 + smart-hut/src/client_server.js | 20 +++- .../src/components/dashboard/DevicePanel.js | 104 ++++++++++++++++-- .../dashboard/devices/DeviceTypeController.js | 3 +- .../src/components/dashboard/devices/Light.js | 16 ++- .../components/dashboard/devices/NewDevice.js | 27 +++-- .../dashboard/devices/SettingsModal.js | 26 ++++- .../components/dashboard/devices/Switch.js | 6 +- smart-hut/src/views/Dashboard.js | 6 +- 9 files changed, 172 insertions(+), 37 deletions(-) diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 1126e85..d9ceba3 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -62,6 +62,7 @@ class App extends Component { .then(res => { if (res.data && res.status === 200) { localStorage.setItem("token", res.data.jwttoken); + call.setToken(res.data.jwttoken); this.setState( { user: data.params.user, diff --git a/smart-hut/src/client_server.js b/smart-hut/src/client_server.js index 8477ad4..6df5b30 100644 --- a/smart-hut/src/client_server.js +++ b/smart-hut/src/client_server.js @@ -1,7 +1,7 @@ import axios from 'axios'; let config = 'http://localhost:8080/'; -const tkn = localStorage.getItem("token"); +var tkn = localStorage.getItem("token"); // requests data devices /* @@ -12,9 +12,23 @@ const tkn = localStorage.getItem("token"); id: se serve } + + device routes: + - buttonDimmer + - dimmableLight + - knobDimmer + - motionSensor + - regularLight + - sensor + - smartPlug + - switch + */ export var call = { + setToken: function(token) { + tkn = token; + }, login: function(data, headers) { return axios.post(config +'auth/login', data) }, @@ -58,10 +72,10 @@ export var call = { return axios.post(config + data.device, data.params, { headers: { Authorization : "Bearer " + tkn } }) }, deviceUpdate: function(data, headers) { - return axios.put(config + data.device, data.params) + return axios.put(config + 'device', data, { headers: { Authorization : "Bearer " + tkn } }) }, deviceDelete: function(data, headers) { - return axios.delete(config + data.device + '/' + data.id, data.params) + return axios.delete(config + data.device + '/' + data.id, {}, { headers: { Authorization : "Bearer " + tkn } }) }, deviceGetById: function(data, headers) { return axios.get(config + data.device + '/' + data.id) diff --git a/smart-hut/src/components/dashboard/DevicePanel.js b/smart-hut/src/components/dashboard/DevicePanel.js index a5b4eeb..52466d6 100644 --- a/smart-hut/src/components/dashboard/DevicePanel.js +++ b/smart-hut/src/components/dashboard/DevicePanel.js @@ -6,6 +6,8 @@ import {editButtonStyle, panelStyle} from "./devices/styleComponents"; import {checkMaxLength, DEVICE_NAME_MAX_LENGTH} from "./devices/constants"; import DeviceType from './devices/DeviceTypeController'; import NewDevice from "./devices/NewDevice"; +import SettingsModal from "./devices/SettingsModal"; +import { call } from '../../client_server'; export default class DevicePanel extends Component { @@ -20,6 +22,13 @@ export default class DevicePanel extends Component { editModeController = (e) => this.setState((prevState) => ({ editMode: !prevState.editMode })); + openModal = (settingsDeviceId) => { + this.setState(prevState => ({ + openSettingsModal: !prevState.openSettingsModal, + settingsDeviceId: settingsDeviceId + })) + } + changeDeviceData = (deviceId, newSettings) => { console.log(newSettings.name, " <-- new name --> ", deviceId ); @@ -46,35 +55,116 @@ export default class DevicePanel extends Component { this.forceUpdate(); }; - addDevice(data) { - const ds = this.props.addDevice(data); + getDevices() { + if (this.props.activeItem === -1) { + call.getAllDevices() + .then(res => { + if ( res.status === 200) { + this.setState({ + devices: res.data + }); + } + }).catch(err => { + console.log(err); + }); + } else { + call.getAllDevicesByRoom(this.state.settingsDeviceId) + .then(res => { + if (res.status === 200) { + this.setState({ + devices: res.data + }); + } + }).catch(err => { + + }); + } + } + + async addDevice(data) { + const ds = await this.props.addDevice(data); this.setState({ devices: ds }); + this.forceUpdate(); + } + + updateDevice = (data) => { + const roomId = this.props.devices.filter(d => d.id === this.state.settingsDeviceId)[0].roomId; + console.log(roomId) + data["id"] = this.state.settingsDeviceId; + data["roomId"] = roomId; + call.deviceUpdate(data) + .then(res => { + if (res.status === 200) { + this.getDevices(); + } + }).catch(err => { + + }) + } + + removeDevice = () => { + const item = this.props.devices.filter(d => d.id === this.state.settingsDeviceId)[0]; + console.log(item) + const data = { + device: item.kind, + id: this.state.settingsDeviceId + }; + + call.deviceDelete(data) + .then(res => { + console.log(res) + if (res.status === 200) { + this.getDevices(); + } + }).catch(err => { + + }); } + + + + render() { + const edit = { + mode: this.state.editMode, + openModal: this.openModal, + }; const ds = this.state.devices ? this.state.devices : this.props.devices; return (
- 0 ? ds.length : 1} divided="vertically"> + + {this.state.openSettingsModal ? + d.id === this.state.settingsDeviceId)[0]}/> : "" + } { ds ? ds.map((e, i) => { + return ( - + ) }) : null } - - - + { + this.props.activeItem !== -1 ? + + + + : + null + }
) diff --git a/smart-hut/src/components/dashboard/devices/DeviceTypeController.js b/smart-hut/src/components/dashboard/devices/DeviceTypeController.js index bb8de4d..9049fd6 100644 --- a/smart-hut/src/components/dashboard/devices/DeviceTypeController.js +++ b/smart-hut/src/components/dashboard/devices/DeviceTypeController.js @@ -6,7 +6,6 @@ import DefaultDimmer from "./Dimmer"; import Switcher from "./Switch"; - const DeviceType = (props) => { switch(props.type) { case "regular-light": @@ -20,7 +19,7 @@ const DeviceType = (props) => { case "switch": return case "light": - return + return () default: return "" } diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index 53ac67a..c307da6 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -18,7 +18,6 @@ export default class Light extends Component { super(props); this.state = { turnedOn: false, - hasIntensity: false }; this.iconOn = "/img/lightOn.svg"; this.iconOff = "/img/lightOff.svg" @@ -29,7 +28,7 @@ export default class Light extends Component { }; setIntensity = (newValue) => { - this.setState({intensityLevel: newValue}); + this.setState({intensity: newValue}); }; getIcon = () => { @@ -40,10 +39,9 @@ export default class Light extends Component { }; componentDidMount() { - if (this.props.device.hasOwnProperty("hasIntensity") && this.props.device.hasOwnProperty("intensityLevel")) { + if (this.props.device.hasOwnProperty("intensity")) { this.setState({ - hasIntensity: this.props.device.hasIntensity, - intensityLevel: this.props.device.intensityLevel + intensity: this.props.device.intensity }); } // Get the state and update it @@ -54,7 +52,7 @@ export default class Light extends Component { render() { const intensityLightView = ( @@ -63,7 +61,7 @@ export default class Light extends Component { - {Math.round(this.state.intensityLevel * 100)}% + {Math.round(this.state.intensity * 100)}% {this.props.device.name} @@ -78,14 +76,14 @@ export default class Light extends Component {
{this.props.device.name}
); - + return ( this.props.onChangeData(id, newSettings)}/> - {this.state.hasIntensity ? (intensityLightView) : (normalLightView)} + {this.state.intensity ? (intensityLightView) : (normalLightView)} ) } diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index 77aca2e..e3ddf2a 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -45,7 +45,12 @@ export default class NewDevice extends Component { }; setTypeOfDevice = (e, d) => { - this.setState({typeOfDevice: d.value}); + if (d.value === "dimmableLight"){ + this.setState({typeOfDevice: d.value, + intensity: 0,}); + } else { + this.setState({typeOfDevice: d.value,}); + } }; setDeviceName = (e, d) => { @@ -69,6 +74,14 @@ export default class NewDevice extends Component { device: this.state.typeOfDevice } + + switch(this.state.typeOfDevice) { + case "dimmableLight": + data.params["intensity"] = 1; + break; + default: + break; + } this.props.addDevice(data); this.resetState(); }; @@ -85,13 +98,13 @@ export default class NewDevice extends Component { { key: 'intensity-light', text: 'Intensity Light', - value: 'intensity-light', + value: 'dimmableLight', image: {avatar: true, src: '/img/intensity-light.svg'}, }, { key: 'smart-plug', text: 'Smart Plug', - value: 'smart-plug', + value: 'smartPlug', image: {avatar: true, src: '/img/smart-plug.svg'}, }, { @@ -117,25 +130,25 @@ export default class NewDevice extends Component { { key: "temperature", text: "Temperature Sensor", - value: "temperature", + value: "TEMPERATURE", image: {avatar: true, src: '/img/temperature-sensor.svg'}, }, { key: "humidity", text: "Humidity Sensor", - value: "humidity", + value: "HUMIDITY", image: {avatar: true, src: '/img/humidity-sensor.svg'}, }, { key: "light", text: "Light Sensor", - value: "light", + value: "LIGHT", image: {avatar: true, src: '/img/light-sensor.svg'}, }, { key: "motion", text: "Motion Sensor", - value: "motion", + value: "motionSensor", image: {avatar: true, src: '/img/sensorOn.svg'}, } ]; diff --git a/smart-hut/src/components/dashboard/devices/SettingsModal.js b/smart-hut/src/components/dashboard/devices/SettingsModal.js index ac5f982..3166cc2 100644 --- a/smart-hut/src/components/dashboard/devices/SettingsModal.js +++ b/smart-hut/src/components/dashboard/devices/SettingsModal.js @@ -1,5 +1,19 @@ import React, {Component, useState} from 'react'; -import {Button, Checkbox, Form, Modal} from "semantic-ui-react"; +import {Button, Checkbox, Form, Icon, Header, Modal} from "semantic-ui-react"; + +const DeleteModal = (props) => ( + Remove} closeIcon> +
+ + + + + +) const SettingsForm = (props) => { @@ -21,11 +35,15 @@ const SettingsForm = (props) => { + {props.type === "smart-plug" ? ( ) : ""} + + props.removeDevice(values)} /> + ) @@ -47,16 +65,20 @@ export default class SettingsModal extends Component { saveSettings = (device) => { // TODO Here there should be all the connections to save the data in the backend console.log("SAVED: ", device); + if (device.name.length > 0) { + this.props.updateDevice(device); + } this.props.openModal(); }; + render() { const SettingsModal = () => ( Settings of {this.props.device.name} - + ); diff --git a/smart-hut/src/components/dashboard/devices/Switch.js b/smart-hut/src/components/dashboard/devices/Switch.js index 20a0cee..20080b3 100644 --- a/smart-hut/src/components/dashboard/devices/Switch.js +++ b/smart-hut/src/components/dashboard/devices/Switch.js @@ -33,12 +33,8 @@ export default class Switch extends Component { return this.iconOff; }; - resetEnergyConsumedValue = () => { - // In the settings form there must be an option to restore this value - // along with the rename feature. - } - componentDidMount() { + } render(){ diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js index 957c204..f84c813 100644 --- a/smart-hut/src/views/Dashboard.js +++ b/smart-hut/src/views/Dashboard.js @@ -99,6 +99,7 @@ export default class Dashboard extends Component{ call.getAllDevicesByRoom(id, this.props.tkn) .then(res => { if (res.status === 200) { + console.log(res.data); this.setState({ devices: res.data }); @@ -116,12 +117,13 @@ export default class Dashboard extends Component{ this.setState(state => ({ devices: state.devices.concat([res.data]) })); + return this.state.devices; }).catch(err => { }); - return this.state.devices; } + render () { return(
@@ -137,7 +139,7 @@ export default class Dashboard extends Component{ - +