frontend/smart-hut/src/storeActions.js

121 lines
2.3 KiB
JavaScript
Raw Normal View History

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,
}),
triggerSave: (automation) => ({
type: "TRIGGER_SAVE",
automation,
}),
scenePrioritySave: (automation) => ({
type: "SCENE_PRIORITY_SAVE",
automation,
}),
automationSave: (automation) => ({
type: "AUTOMATION_SAVE",
automation,
}),
automationsUpdate: (automations) => ({
type: "AUTOMATION_UPDATE",
automations,
}),
stateSave: (sceneState) => ({
type: "STATE_SAVE",
sceneState,
}),
statesUpdate: (sceneId, sceneStates) => ({
2020-04-26 11:38:54 +00:00
type: "STATES_UPDATE",
sceneId,
sceneStates,
}),
2020-04-07 10:46:55 +00:00
devicesUpdate: (roomId, devices, partial = false) => ({
type: "DEVICES_UPDATE",
roomId,
devices,
partial,
}),
2020-04-26 11:38:54 +00:00
stateDelete: (stateId) => ({
2020-04-25 16:44:54 +00:00
type: "STATE_DELETE",
stateId,
}),
2020-04-26 11:38:54 +00:00
sceneApply: (sceneId) => ({
2020-04-26 09:09:49 +00:00
type: "SCENE_APPLY",
sceneId,
}),
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-28 09:39:38 +00:00
automationDelete: (id) => ({
type: "AUTOMATION_DELETE",
id,
}),
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,
}),
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;