scene apply preparations
This commit is contained in:
parent
34f83c9cce
commit
07f4a8ee43
4 changed files with 27 additions and 0 deletions
|
@ -231,6 +231,7 @@ const mapStateToProps = (state, ownProps) => ({
|
|||
}
|
||||
},
|
||||
get type() {
|
||||
console.log("ALPACA",state,ownProps);
|
||||
if (state.active.activeTab === "Scenes") {
|
||||
if (state.sceneStates[ownProps.id]) {
|
||||
console.log(state.sceneStates[ownProps.id], ownProps.id);
|
||||
|
|
|
@ -413,6 +413,19 @@ export const RemoteService = {
|
|||
};
|
||||
},
|
||||
|
||||
sceneApply: (id)=>{
|
||||
return (dispatch)=>{
|
||||
let url=`/scene/${id}/apply`;
|
||||
|
||||
return Endpoint.post(url)
|
||||
.then((res)=> dispatch(actions.sceneApply(id)))
|
||||
.catch((err)=>{
|
||||
console.warn('scene apply error',err);
|
||||
throw new RemoteError(["Network error"]);
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates/Updates a device with the given data. If
|
||||
* data.id is truthy, then a update call is performed,
|
||||
|
|
|
@ -377,6 +377,15 @@ function reducer(previousState, action) {
|
|||
}
|
||||
|
||||
newState = update(previousState, change);
|
||||
break;
|
||||
|
||||
case "SCENE_APPLY":
|
||||
if (!(action.sceneId in previousState.scenes)) {
|
||||
console.warn(`Scene ${action.sceneId} does not exist`);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case "DEVICE_DELETE":
|
||||
if (!(action.deviceId in previousState.devices)) {
|
||||
|
|
|
@ -44,6 +44,10 @@ const actions = {
|
|||
type: "STATE_DELETE",
|
||||
stateId,
|
||||
}),
|
||||
sceneApply: (sceneId)=>({
|
||||
type: "SCENE_APPLY",
|
||||
sceneId,
|
||||
}),
|
||||
deviceOperationUpdate: (devices) => ({
|
||||
type: "DEVICES_UPDATE",
|
||||
devices,
|
||||
|
|
Loading…
Reference in a new issue