Merge branch 'dev' of https://lab.si.usi.ch/sa4-2020/the-sanmarinoes/frontend into dev
This commit is contained in:
commit
be8c049e47
6 changed files with 31 additions and 2 deletions
|
@ -8,6 +8,7 @@ import {
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
|
import SelectIcons from "./SelectIcons";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { RemoteService } from "../remote";
|
import { RemoteService } from "../remote";
|
||||||
import { appActions } from "../storeActions";
|
import { appActions } from "../storeActions";
|
||||||
|
@ -20,12 +21,14 @@ class SceneModal extends Component {
|
||||||
this.addSceneModal = this.addSceneModal.bind(this);
|
this.addSceneModal = this.addSceneModal.bind(this);
|
||||||
this.modifySceneModal = this.modifySceneModal.bind(this);
|
this.modifySceneModal = this.modifySceneModal.bind(this);
|
||||||
this.deleteScene = this.deleteScene.bind(this);
|
this.deleteScene = this.deleteScene.bind(this);
|
||||||
|
this.updateIcon = this.updateIcon.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get initialState() {
|
get initialState() {
|
||||||
return {
|
return {
|
||||||
name: this.type === "new" ? "New Scene" : this.props.scene.name,
|
name: this.type === "new" ? "New Scene" : this.props.scene.name,
|
||||||
openModal: false,
|
openModal: false,
|
||||||
|
selectedIcon: "home",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +43,7 @@ class SceneModal extends Component {
|
||||||
addSceneModal = (e) => {
|
addSceneModal = (e) => {
|
||||||
let data = {
|
let data = {
|
||||||
name: this.state.name,
|
name: this.state.name,
|
||||||
|
icon: this.state.selectedIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.props
|
this.props
|
||||||
|
@ -54,6 +58,7 @@ class SceneModal extends Component {
|
||||||
modifySceneModal = (e) => {
|
modifySceneModal = (e) => {
|
||||||
let data = {
|
let data = {
|
||||||
name: this.state.name,
|
name: this.state.name,
|
||||||
|
icon: this.state.selectedIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.props
|
this.props
|
||||||
|
@ -86,7 +91,16 @@ class SceneModal extends Component {
|
||||||
this.setState({ openModal: true });
|
this.setState({ openModal: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateIcon(e) {
|
||||||
|
this.setState({ selectedIcon: e });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const spaceDiv = {
|
||||||
|
background: "#f4f4f4",
|
||||||
|
padding: "10px 10px",
|
||||||
|
margin: "10px 0px",
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{!this.props.nicolaStop ? (
|
{!this.props.nicolaStop ? (
|
||||||
|
@ -149,6 +163,15 @@ class SceneModal extends Component {
|
||||||
value={this.state.name}
|
value={this.state.name}
|
||||||
/>
|
/>
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
|
<div style={spaceDiv}>
|
||||||
|
<p>Select an icon:</p>
|
||||||
|
<SelectIcons
|
||||||
|
updateIcon={this.updateIcon}
|
||||||
|
currentIcon={
|
||||||
|
this.type === "new" ? "home" : this.props.scene.icon
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
{this.type === "modify" ? (
|
{this.type === "modify" ? (
|
||||||
|
|
|
@ -108,6 +108,7 @@ class NewDevice extends Component {
|
||||||
knobDimmer: "New knob dimmer",
|
knobDimmer: "New knob dimmer",
|
||||||
securityCamera: "New security camera",
|
securityCamera: "New security camera",
|
||||||
thermostat: "New thermostat",
|
thermostat: "New thermostat",
|
||||||
|
curtains: "New curtains",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.state.deviceName === "") {
|
if (this.state.deviceName === "") {
|
||||||
|
|
|
@ -454,6 +454,7 @@ export const RemoteService = {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
data = {
|
data = {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
|
icon: data.icon,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (sceneId
|
return (sceneId
|
||||||
|
|
|
@ -49,6 +49,7 @@ function reducer(previousState, action) {
|
||||||
scenes: {
|
scenes: {
|
||||||
[scene.id]: {
|
[scene.id]: {
|
||||||
name: { $set: scene.name },
|
name: { $set: scene.name },
|
||||||
|
icon: { $set: scene.icon },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Navbar extends Component {
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
<Icon name={e.icon} size="small" />
|
<Icon name={e.icon} size="small" />
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column width={8}>{e.name}</Grid.Column>
|
<Grid.Column width={11}>{e.name}</Grid.Column>
|
||||||
<Grid.Column floated="right">
|
<Grid.Column floated="right">
|
||||||
{this.state.editMode ? (
|
{this.state.editMode ? (
|
||||||
<RoomModal id={e.id} />
|
<RoomModal id={e.id} />
|
||||||
|
|
|
@ -100,7 +100,10 @@ class ScenesNavbar extends Component {
|
||||||
>
|
>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Row>
|
<Grid.Row>
|
||||||
<Grid.Column width={12}>{e.name}</Grid.Column>
|
<Grid.Column>
|
||||||
|
<Icon name={e.icon} size="small" />
|
||||||
|
</Grid.Column>
|
||||||
|
<Grid.Column width={11}>{e.name}</Grid.Column>
|
||||||
<Grid.Column floated="right">
|
<Grid.Column floated="right">
|
||||||
{this.state.editMode ? (
|
{this.state.editMode ? (
|
||||||
<SceneModal id={e.id} />
|
<SceneModal id={e.id} />
|
||||||
|
|
Loading…
Reference in a new issue