frontend/smart-hut/src/storeActions.js
Claudio Maggioni 1de7b9992e Merge branch '70-5-users-can-create-basic-automations' into 'dev'
Resolve "5. Users can create basic automations"

Closes #70

See merge request sa4-2020/the-sanmarinoes/frontend!104
2020-04-28 12:07:58 +02:00

121 lines
2.3 KiB
JavaScript

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,
}),
sceneSave: (scene) => ({
type: "SCENE_SAVE",
scene,
}),
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) => ({
type: "STATES_UPDATE",
sceneId,
sceneStates,
}),
devicesUpdate: (roomId, devices, partial = false) => ({
type: "DEVICES_UPDATE",
roomId,
devices,
partial,
}),
stateDelete: (stateId) => ({
type: "STATE_DELETE",
stateId,
}),
sceneApply: (sceneId) => ({
type: "SCENE_APPLY",
sceneId,
}),
deviceOperationUpdate: (devices) => ({
type: "DEVICES_UPDATE",
devices,
partial: true,
}),
roomsUpdate: (rooms) => ({
type: "ROOMS_UPDATE",
rooms,
}),
roomDelete: (roomId) => ({
type: "ROOM_DELETE",
roomId,
}),
automationDelete: (id) => ({
type: "AUTOMATION_DELETE",
id,
}),
sceneDelete: (sceneId) => ({
type: "SCENE_DELETE",
sceneId,
}),
scenesUpdate: (scenes) => ({
type: "SCENES_UPDATE",
scenes,
}),
deviceDelete: (deviceId) => ({
type: "DEVICE_DELETE",
deviceId,
}),
};
export const appActions = {
// -1 for home view
setActiveRoom: (activeRoom = -1) => ({
type: "SET_ACTIVE_ROOM",
activeRoom,
}),
setActiveTab: (activeTab) => ({
type: "SET_ACTIVE_TAB",
activeTab,
}),
setActiveScene: (activeScene = -1) => ({
type: "SET_ACTIVE_SCENE",
activeScene,
}),
setActiveAutomations: (activeAutomation = -1) => ({
type: "SET_ACTIVE_AUTOMATION",
activeAutomation,
}),
};
export default actions;