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() {
if (this.props.isActiveDefaultHost) {
return (
@ -48,7 +55,7 @@ class HostsPanel extends Component {
</Card.Header>
<Card.Content extras>
<div className="ui two buttons">
<Button>Apply</Button>
<Button onClick={this.applyHostScene(scene.id)}>Apply</Button>
</div>
</Card.Content>
</Card>

View File

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

View File

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