diff --git a/smart-hut/src/components/RoomModal.js b/smart-hut/src/components/RoomModal.js
index eabdb89..36496b2 100644
--- a/smart-hut/src/components/RoomModal.js
+++ b/smart-hut/src/components/RoomModal.js
@@ -49,7 +49,16 @@ class RoomModal extends Component {
}
setInitialState() {
- this.setState(this.initialState);
+ for (let key in this.initialState) {
+ if (this.initialState.hasOwnProperty(key)) {
+ //console.log(key + " -> " + this.initialState[key]);
+ this.setState({
+ key: this.initialState[key],
+ });
+ }
+ }
+ console.log(this.initialState);
+ //this.setState(state);
}
get type() {
diff --git a/smart-hut/src/components/SceneModal.js b/smart-hut/src/components/SceneModal.js
index af97d89..cff8630 100644
--- a/smart-hut/src/components/SceneModal.js
+++ b/smart-hut/src/components/SceneModal.js
@@ -1,5 +1,14 @@
import React, { Component } from "react";
-import { Button, Header, Modal, Icon, Responsive } from "semantic-ui-react";
+import {
+ Button,
+ Header,
+ Modal,
+ Icon,
+ Responsive,
+ Form,
+ Input,
+ Dropdown,
+} from "semantic-ui-react";
import { connect } from "react-redux";
import { RemoteService } from "../remote";
import { appActions } from "../storeActions";
@@ -10,6 +19,7 @@ class SceneModal extends Component {
super(props);
this.state = this.initialState;
this.setInitialState();
+ this.getDevices();
this.addSceneModal = this.addSceneModal.bind(this);
this.modifySceneModal = this.modifySceneModal.bind(this);
@@ -18,7 +28,9 @@ class SceneModal extends Component {
get initialState() {
return {
- //INITIAL STATE HERE
+ name: this.type === "new" ? "New Scene" : this.props.room.name,
+ sceneDevices: this.type === "new" ? [{}] : [this.props.scene.devices],
+ openModal: false,
};
}
@@ -30,6 +42,12 @@ class SceneModal extends Component {
return !this.props.id ? "new" : "modify";
}
+ getDevices() {
+ this.props
+ .fetchDevices()
+ .catch((err) => console.error(`error fetching devices:`, err));
+ }
+
addSceneModal = (e) => {
/*let data = {
// DATA HERE
@@ -81,7 +99,21 @@ class SceneModal extends Component {
this.setState({ openModal: true });
};
+ setSceneDevice(e, d) {
+ this.setState({ sceneDevices: d.value });
+ }
+
render() {
+ const availableDevices = [];
+ this.props.devices.forEach((e) => {
+ if (!this.state.sceneDevices.includes(e)) {
+ availableDevices.push({
+ key: e.id,
+ text: e.name,
+ id: e.id,
+ });
+ }
+ });
return (
{!this.props.nicolaStop ? (
@@ -132,9 +164,30 @@ class SceneModal extends Component {
{this.type === "new" ? "Add new scene" : "Modify scene"}
- {
- //TODO FORM TO ADD OR MODIFY SCENE
- }
+
+
+
+
+
+
+
+
{this.type === "modify" ? (