2020-04-07 10:46:55 +00:00
|
|
|
const actions = {
|
|
|
|
loginSuccess: (token) => ({
|
|
|
|
type: "LOGIN_UPDATE",
|
|
|
|
login: {
|
|
|
|
loggedIn: true,
|
|
|
|
token,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
logout: () => ({
|
|
|
|
type: "LOGOUT",
|
|
|
|
}),
|
|
|
|
userInfoUpdate: (userInfo) => ({
|
|
|
|
type: "USER_INFO_UPDATE",
|
|
|
|
userInfo,
|
|
|
|
}),
|
|
|
|
roomSave: (room) => ({
|
|
|
|
type: "ROOM_SAVE",
|
|
|
|
room,
|
|
|
|
}),
|
2020-04-18 14:26:12 +00:00
|
|
|
sceneSave: (scene) => ({
|
|
|
|
type: "SCENE_SAVE",
|
|
|
|
scene,
|
|
|
|
}),
|
2020-04-10 15:25:52 +00:00
|
|
|
deviceSave: (device) => ({
|
|
|
|
type: "DEVICE_SAVE",
|
|
|
|
device,
|
|
|
|
}),
|
2020-04-21 12:58:36 +00:00
|
|
|
stateSave: (sceneState) => ({
|
|
|
|
type: "STATE_SAVE",
|
|
|
|
sceneState,
|
|
|
|
}),
|
|
|
|
statesUpdate: (sceneId, sceneStates) => ({
|
|
|
|
type: "STATE_UPDATE",
|
|
|
|
sceneId,
|
|
|
|
sceneStates,
|
|
|
|
}),
|
2020-04-07 10:46:55 +00:00
|
|
|
devicesUpdate: (roomId, devices, partial = false) => ({
|
|
|
|
type: "DEVICES_UPDATE",
|
|
|
|
roomId,
|
|
|
|
devices,
|
|
|
|
partial,
|
|
|
|
}),
|
2020-04-25 16:44:54 +00:00
|
|
|
stateDelete: (stateId)=>({
|
|
|
|
type: "STATE_DELETE",
|
|
|
|
stateId,
|
|
|
|
}),
|
2020-04-10 21:13:23 +00:00
|
|
|
deviceOperationUpdate: (devices) => ({
|
|
|
|
type: "DEVICES_UPDATE",
|
|
|
|
devices,
|
|
|
|
partial: true,
|
|
|
|
}),
|
2020-04-10 15:25:52 +00:00
|
|
|
roomsUpdate: (rooms) => ({
|
|
|
|
type: "ROOMS_UPDATE",
|
|
|
|
rooms,
|
|
|
|
}),
|
2020-04-07 10:46:55 +00:00
|
|
|
roomDelete: (roomId) => ({
|
|
|
|
type: "ROOM_DELETE",
|
|
|
|
roomId,
|
|
|
|
}),
|
2020-04-18 14:26:12 +00:00
|
|
|
sceneDelete: (sceneId) => ({
|
|
|
|
type: "SCENE_DELETE",
|
|
|
|
sceneId,
|
|
|
|
}),
|
|
|
|
scenesUpdate: (scenes) => ({
|
|
|
|
type: "SCENES_UPDATE",
|
|
|
|
scenes,
|
|
|
|
}),
|
2020-04-07 10:46:55 +00:00
|
|
|
deviceDelete: (deviceId) => ({
|
|
|
|
type: "DEVICE_DELETE",
|
|
|
|
deviceId,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
2020-04-09 15:24:30 +00:00
|
|
|
export const appActions = {
|
|
|
|
// -1 for home view
|
|
|
|
setActiveRoom: (activeRoom = -1) => ({
|
|
|
|
type: "SET_ACTIVE_ROOM",
|
|
|
|
activeRoom,
|
|
|
|
}),
|
2020-04-14 12:58:03 +00:00
|
|
|
setActiveTab: (activeTab) => ({
|
|
|
|
type: "SET_ACTIVE_TAB",
|
|
|
|
activeTab,
|
|
|
|
}),
|
2020-04-15 13:54:30 +00:00
|
|
|
setActiveScene: (activeScene = -1) => ({
|
|
|
|
type: "SET_ACTIVE_SCENE",
|
|
|
|
activeScene,
|
|
|
|
}),
|
|
|
|
setActiveAutomations: (activeAutomation = -1) => ({
|
|
|
|
type: "SET_ACTIVE_AUTOMATION",
|
|
|
|
activeAutomation,
|
|
|
|
}),
|
2020-04-09 15:24:30 +00:00
|
|
|
};
|
|
|
|
|
2020-04-07 10:46:55 +00:00
|
|
|
export default actions;
|