From d1cd93afe58f34728a4d9c3c8f4cd726836d1c2a Mon Sep 17 00:00:00 2001 From: britea Date: Fri, 8 May 2020 13:45:13 +0200 Subject: [PATCH 1/2] apply scene in host --- smart-hut/src/components/dashboard/HostsPanel.js | 9 ++++++++- smart-hut/src/remote.js | 5 ++++- smart-hut/src/store.js | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/smart-hut/src/components/dashboard/HostsPanel.js b/smart-hut/src/components/dashboard/HostsPanel.js index 5a6d380..0e8e13a 100644 --- a/smart-hut/src/components/dashboard/HostsPanel.js +++ b/smart-hut/src/components/dashboard/HostsPanel.js @@ -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 {
- +
diff --git a/smart-hut/src/remote.js b/smart-hut/src/remote.js index f0cfcea..5164ced 100644 --- a/smart-hut/src/remote.js +++ b/smart-hut/src/remote.js @@ -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))) diff --git a/smart-hut/src/store.js b/smart-hut/src/store.js index f256839..cbc8ba2 100644 --- a/smart-hut/src/store.js +++ b/smart-hut/src/store.js @@ -49,6 +49,7 @@ function reducer(previousState, action) { [scene.id]: { name: { $set: scene.name }, icon: { $set: scene.icon }, + guestAccessEnabled: { $set: scene.guestAccessEnabled }, }, }, }); From 4688995d12fe8799e427c87699d2f53ed70e0cea Mon Sep 17 00:00:00 2001 From: britea Date: Fri, 8 May 2020 14:55:26 +0200 Subject: [PATCH 2/2] fix apply scene --- smart-hut/src/components/dashboard/HostsPanel.js | 6 ++++-- smart-hut/src/components/dashboard/devices/Videocam.js | 3 ++- smart-hut/src/remote.js | 8 +++++++- smart-hut/src/storeActions.js | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/smart-hut/src/components/dashboard/HostsPanel.js b/smart-hut/src/components/dashboard/HostsPanel.js index 0e8e13a..50f2097 100644 --- a/smart-hut/src/components/dashboard/HostsPanel.js +++ b/smart-hut/src/components/dashboard/HostsPanel.js @@ -53,9 +53,11 @@ class HostsPanel extends Component { {scene.name} - +
- +
diff --git a/smart-hut/src/components/dashboard/devices/Videocam.js b/smart-hut/src/components/dashboard/devices/Videocam.js index 409d467..75dee30 100644 --- a/smart-hut/src/components/dashboard/devices/Videocam.js +++ b/smart-hut/src/components/dashboard/devices/Videocam.js @@ -70,11 +70,12 @@ class Videocam extends Component { /> - + this.setOnOff(val.checked)} /> diff --git a/smart-hut/src/remote.js b/smart-hut/src/remote.js index 5164ced..42a5841 100644 --- a/smart-hut/src/remote.js +++ b/smart-hut/src/remote.js @@ -557,7 +557,13 @@ export const RemoteService = { } return Endpoint.post(url) - .then((res) => dispatch(actions.deviceOperationUpdate(res.data))) + .then((res) => + dispatch( + hostId + ? actions.hostDevicesUpdate(hostId, res.data, true) + : actions.deviceOperationUpdate(res.data) + ) + ) .catch((err) => { console.warn("scene apply error", err); throw new RemoteError(["Network error"]); diff --git a/smart-hut/src/storeActions.js b/smart-hut/src/storeActions.js index 218f4b9..6a4e4e4 100644 --- a/smart-hut/src/storeActions.js +++ b/smart-hut/src/storeActions.js @@ -63,9 +63,10 @@ const actions = { devices, partial, }), - hostDevicesUpdate: (hostId, devices) => ({ + hostDevicesUpdate: (hostId, devices, partial = false) => ({ type: "HOST_DEVICES_UPDATE", hostId, + partial, devices, }), stateDelete: (stateId) => ({