frontend/smart-hut/src/storeActions.js

161 lines
3.1 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,
}),
2020-05-04 09:13:19 +00:00
hostDeviceSave: (hostId, device) => ({
type: "HOST_DEVICE_SAVE",
hostId,
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-05-08 12:55:26 +00:00
hostDevicesUpdate: (hostId, devices, partial = false) => ({
type: "HOST_DEVICES_UPDATE",
hostId,
2020-05-08 12:55:26 +00:00
partial,
devices,
}),
2020-04-26 11:38:54 +00:00
stateDelete: (stateId) => ({
2020-04-25 16:44:54 +00:00
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,
}),
hostRoomsUpdate: (hostId, rooms) => ({
type: "HOST_ROOMS_UPDATE",
hostId,
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-05-05 15:04:53 +00:00
hostScenesUpdate: (hostId, scenes) => ({
type: "HOST_SCENES_UPDATE",
hostId,
scenes,
}),
2020-04-07 10:46:55 +00:00
deviceDelete: (deviceId) => ({
type: "DEVICE_DELETE",
deviceId,
}),
2020-05-02 14:40:29 +00:00
hostsUpdate: (hosts) => ({
2020-05-02 20:37:20 +00:00
type: "HG_UPDATE",
key: "hosts",
value: hosts,
}),
guestsUpdate: (hosts) => ({
type: "HG_UPDATE",
key: "guests",
value: hosts,
2020-04-25 15:46:52 +00:00
}),
getHostDevices: (host) => ({
2020-05-02 14:40:29 +00:00
type: "GET_HOST_DEVICES",
host,
2020-04-25 15:46:52 +00:00
}),
2020-05-02 20:37:20 +00:00
guestUpdate: (guests) => ({
type: "HG_UPDATE",
key: "guests",
value: guests,
2020-04-25 15:46:52 +00:00
}),
2020-04-07 10:46:55 +00:00
};
2020-04-09 15:24:30 +00:00
export const appActions = {
// -1 for home view
setActiveRoom: (activeRoom = -1) => ({
2020-05-02 20:37:20 +00:00
type: "SET_ACTIVE",
key: "activeRoom",
value: activeRoom,
2020-04-09 15:24:30 +00:00
}),
2020-04-14 12:58:03 +00:00
setActiveTab: (activeTab) => ({
2020-05-02 20:37:20 +00:00
type: "SET_ACTIVE",
key: "activeTab",
value: activeTab,
2020-04-14 12:58:03 +00:00
}),
setActiveScene: (activeScene = -1) => ({
2020-05-02 20:37:20 +00:00
type: "SET_ACTIVE",
key: "activeScene",
value: activeScene,
}),
setActiveHost: (activeHost = -1) => ({
type: "SET_ACTIVE",
key: "activeHost",
value: activeHost,
}),
2020-04-09 15:24:30 +00:00
};
2020-04-07 10:46:55 +00:00
export default actions;