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) => ({
2020-05-12 13:18:33 +00:00
type: 'LOGIN_UPDATE',
2020-04-07 10:46:55 +00:00
login: {
loggedIn: true,
token,
},
}),
logout: () => ({
2020-05-12 13:18:33 +00:00
type: 'LOGOUT',
2020-04-07 10:46:55 +00:00
}),
userInfoUpdate: (userInfo) => ({
2020-05-12 13:18:33 +00:00
type: 'USER_INFO_UPDATE',
2020-04-07 10:46:55 +00:00
userInfo,
}),
roomSave: (room) => ({
2020-05-12 13:18:33 +00:00
type: 'ROOM_SAVE',
2020-04-07 10:46:55 +00:00
room,
}),
2020-04-18 14:26:12 +00:00
sceneSave: (scene) => ({
2020-05-12 13:18:33 +00:00
type: 'SCENE_SAVE',
2020-04-18 14:26:12 +00:00
scene,
}),
2020-04-10 15:25:52 +00:00
deviceSave: (device) => ({
2020-05-12 13:18:33 +00:00
type: 'DEVICE_SAVE',
2020-04-10 15:25:52 +00:00
device,
}),
2020-05-04 09:13:19 +00:00
hostDeviceSave: (hostId, device) => ({
2020-05-12 13:18:33 +00:00
type: 'HOST_DEVICE_SAVE',
2020-05-04 09:13:19 +00:00
hostId,
device,
}),
triggerSave: (automation) => ({
2020-05-12 13:18:33 +00:00
type: 'TRIGGER_SAVE',
automation,
}),
scenePrioritySave: (automation) => ({
2020-05-12 13:18:33 +00:00
type: 'SCENE_PRIORITY_SAVE',
automation,
}),
automationSave: (automation) => ({
2020-05-12 13:18:33 +00:00
type: 'AUTOMATION_SAVE',
automation,
}),
automationsUpdate: (automations) => ({
2020-05-12 13:18:33 +00:00
type: 'AUTOMATION_UPDATE',
automations,
}),
stateSave: (sceneState) => ({
2020-05-12 13:18:33 +00:00
type: 'STATE_SAVE',
sceneState,
}),
statesUpdate: (sceneId, sceneStates) => ({
2020-05-12 13:18:33 +00:00
type: 'STATES_UPDATE',
sceneId,
sceneStates,
}),
2020-04-07 10:46:55 +00:00
devicesUpdate: (roomId, devices, partial = false) => ({
2020-05-12 13:18:33 +00:00
type: 'DEVICES_UPDATE',
2020-04-07 10:46:55 +00:00
roomId,
devices,
partial,
}),
2020-05-08 12:55:26 +00:00
hostDevicesUpdate: (hostId, devices, partial = false) => ({
2020-05-12 13:18:33 +00:00
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-05-12 13:18:33 +00:00
type: 'STATE_DELETE',
2020-04-25 16:44:54 +00:00
stateId,
}),
2020-04-10 21:13:23 +00:00
deviceOperationUpdate: (devices) => ({
2020-05-12 13:18:33 +00:00
type: 'DEVICES_UPDATE',
2020-04-10 21:13:23 +00:00
devices,
partial: true,
}),
2020-04-10 15:25:52 +00:00
roomsUpdate: (rooms) => ({
2020-05-12 13:18:33 +00:00
type: 'ROOMS_UPDATE',
2020-04-10 15:25:52 +00:00
rooms,
}),
hostRoomsUpdate: (hostId, rooms) => ({
2020-05-12 13:18:33 +00:00
type: 'HOST_ROOMS_UPDATE',
hostId,
rooms,
}),
2020-04-07 10:46:55 +00:00
roomDelete: (roomId) => ({
2020-05-12 13:18:33 +00:00
type: 'ROOM_DELETE',
2020-04-07 10:46:55 +00:00
roomId,
}),
2020-04-28 09:39:38 +00:00
automationDelete: (id) => ({
2020-05-12 13:18:33 +00:00
type: 'AUTOMATION_DELETE',
2020-04-28 09:39:38 +00:00
id,
}),
2020-04-18 14:26:12 +00:00
sceneDelete: (sceneId) => ({
2020-05-12 13:18:33 +00:00
type: 'SCENE_DELETE',
2020-04-18 14:26:12 +00:00
sceneId,
}),
scenesUpdate: (scenes) => ({
2020-05-12 13:18:33 +00:00
type: 'SCENES_UPDATE',
2020-04-18 14:26:12 +00:00
scenes,
}),
2020-05-05 15:04:53 +00:00
hostScenesUpdate: (hostId, scenes) => ({
2020-05-12 13:18:33 +00:00
type: 'HOST_SCENES_UPDATE',
2020-05-05 15:04:53 +00:00
hostId,
scenes,
}),
2020-04-07 10:46:55 +00:00
deviceDelete: (deviceId) => ({
2020-05-12 13:18:33 +00:00
type: 'DEVICE_DELETE',
2020-04-07 10:46:55 +00:00
deviceId,
}),
2020-05-02 14:40:29 +00:00
hostsUpdate: (hosts) => ({
2020-05-12 13:18:33 +00:00
type: 'HG_UPDATE',
key: 'hosts',
2020-05-02 20:37:20 +00:00
value: hosts,
}),
guestsUpdate: (hosts) => ({
2020-05-12 13:18:33 +00:00
type: 'HG_UPDATE',
key: 'guests',
2020-05-02 20:37:20 +00:00
value: hosts,
2020-04-25 15:46:52 +00:00
}),
getHostDevices: (host) => ({
2020-05-12 13:18:33 +00:00
type: 'GET_HOST_DEVICES',
2020-05-02 14:40:29 +00:00
host,
2020-04-25 15:46:52 +00:00
}),
2020-05-02 20:37:20 +00:00
guestUpdate: (guests) => ({
2020-05-12 13:18:33 +00:00
type: 'HG_UPDATE',
key: 'guests',
2020-05-02 20:37:20 +00:00
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-12 13:18:33 +00:00
type: 'SET_ACTIVE',
key: 'activeRoom',
2020-05-02 20:37:20 +00:00
value: activeRoom,
2020-04-09 15:24:30 +00:00
}),
2020-04-14 12:58:03 +00:00
setActiveTab: (activeTab) => ({
2020-05-12 13:18:33 +00:00
type: 'SET_ACTIVE',
key: 'activeTab',
2020-05-02 20:37:20 +00:00
value: activeTab,
2020-04-14 12:58:03 +00:00
}),
setActiveScene: (activeScene = -1) => ({
2020-05-12 13:18:33 +00:00
type: 'SET_ACTIVE',
key: 'activeScene',
2020-05-02 20:37:20 +00:00
value: activeScene,
}),
setActiveHost: (activeHost = -1) => ({
2020-05-12 13:18:33 +00:00
type: 'SET_ACTIVE',
key: 'activeHost',
2020-05-02 20:37:20 +00:00
value: activeHost,
}),
2020-04-09 15:24:30 +00:00
};
2020-04-07 10:46:55 +00:00
export default actions;