apply scene in host

This commit is contained in:
britea 2020-05-08 13:45:13 +02:00
parent c1898ffa6c
commit d1cd93afe5
3 changed files with 13 additions and 2 deletions

View file

@ -16,6 +16,13 @@ class HostsPanel extends Component {
} }
} }
applyHostScene(id) {
this.props
.sceneApply(id, this.props.activeHost)
.then(() => console.log("SCCUESS"))
.catch((err) => console.error("sceneApply update error", err));
}
render() { render() {
if (this.props.isActiveDefaultHost) { if (this.props.isActiveDefaultHost) {
return ( return (
@ -48,7 +55,7 @@ class HostsPanel extends Component {
</Card.Header> </Card.Header>
<Card.Content extras> <Card.Content extras>
<div className="ui two buttons"> <div className="ui two buttons">
<Button>Apply</Button> <Button onClick={this.applyHostScene(scene.id)}>Apply</Button>
</div> </div>
</Card.Content> </Card.Content>
</Card> </Card>

View file

@ -549,9 +549,12 @@ export const RemoteService = {
}; };
}, },
sceneApply: (id) => { sceneApply: (id, hostId = null) => {
return (dispatch) => { return (dispatch) => {
let url = `/scene/${id}/apply`; let url = `/scene/${id}/apply`;
if (hostId) {
url = url + "?hostId=" + hostId;
}
return Endpoint.post(url) return Endpoint.post(url)
.then((res) => dispatch(actions.deviceOperationUpdate(res.data))) .then((res) => dispatch(actions.deviceOperationUpdate(res.data)))

View file

@ -49,6 +49,7 @@ function reducer(previousState, action) {
[scene.id]: { [scene.id]: {
name: { $set: scene.name }, name: { $set: scene.name },
icon: { $set: scene.icon }, icon: { $set: scene.icon },
guestAccessEnabled: { $set: scene.guestAccessEnabled },
}, },
}, },
}); });