From 506fe663e2e3b9ffe9764f5c06b04524c4793534 Mon Sep 17 00:00:00 2001 From: ditoaugusta Date: Wed, 25 Mar 2020 00:24:33 +0700 Subject: delete module subfolder. edit relative path. --- modern/jsconfig.json | 4 ++-- modern/src/DeviceList.js | 3 ++- modern/src/SocketController.js | 2 +- modern/src/index.js | 2 +- modern/src/store/devices.js | 20 ++++++++++++++++++++ modern/src/store/index.js | 15 ++++++++++++--- modern/src/store/modules/devices.js | 20 -------------------- modern/src/store/modules/index.js | 12 ------------ modern/src/store/modules/positions.js | 16 ---------------- modern/src/store/positions.js | 16 ++++++++++++++++ 10 files changed, 54 insertions(+), 56 deletions(-) create mode 100644 modern/src/store/devices.js delete mode 100644 modern/src/store/modules/devices.js delete mode 100644 modern/src/store/modules/index.js delete mode 100644 modern/src/store/modules/positions.js create mode 100644 modern/src/store/positions.js diff --git a/modern/jsconfig.json b/modern/jsconfig.json index ec9aa3f7..a66ba283 100644 --- a/modern/jsconfig.json +++ b/modern/jsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": "src" + "baseUrl": "./" }, - "include": ["src"] + "include": ["src/**/*"] } \ No newline at end of file diff --git a/modern/src/DeviceList.js b/modern/src/DeviceList.js index 88428007..edc6475b 100644 --- a/modern/src/DeviceList.js +++ b/modern/src/DeviceList.js @@ -10,7 +10,8 @@ import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction'; import IconButton from '@material-ui/core/IconButton'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import Divider from '@material-ui/core/Divider'; -import { devicesActions } from 'store/modules'; + +import { devicesActions } from 'src/store'; const mapStateToProps = state => ({ devices: Object.values(state.devices.items) diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js index 10db17a4..03f6e4cc 100644 --- a/modern/src/SocketController.js +++ b/modern/src/SocketController.js @@ -1,6 +1,6 @@ import { Component } from 'react'; import { connect } from 'react-redux'; -import { positionsActions, devicesActions } from 'store/modules'; +import { positionsActions, devicesActions } from 'src/store'; const displayNotifications = events => { if ("Notification" in window) { diff --git a/modern/src/index.js b/modern/src/index.js index f501a083..0c5361fa 100644 --- a/modern/src/index.js +++ b/modern/src/index.js @@ -6,7 +6,7 @@ import { Provider } from 'react-redux'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; -import store from './store'; +import store from 'src/store'; ReactDOM.render(( diff --git a/modern/src/store/devices.js b/modern/src/store/devices.js new file mode 100644 index 00000000..0d96e98d --- /dev/null +++ b/modern/src/store/devices.js @@ -0,0 +1,20 @@ +import { createSlice } from '@reduxjs/toolkit'; + +const { reducer, actions } = createSlice({ + name: 'devices', + initialState: { + items: {}, + selectedId: null + }, + reducers: { + update(state, action) { + action.payload.forEach(item => state.items[item['id']] = item); + }, + select(state, action) { + state.selectedId = action.payload.id; + } + } +}); + +export { actions as devicesActions }; +export { reducer as devicesReducer }; diff --git a/modern/src/store/index.js b/modern/src/store/index.js index c981c136..86de31a9 100644 --- a/modern/src/store/index.js +++ b/modern/src/store/index.js @@ -1,5 +1,14 @@ -import { configureStore } from '@reduxjs/toolkit'; +import { combineReducers, configureStore } from '@reduxjs/toolkit'; -import { rootReducer } from './modules'; +import { devicesReducer as devices } from './devices'; +import { positionsReducer as positions } from './positions'; -export default configureStore({ reducer: rootReducer }); +const reducer = combineReducers({ + devices, + positions, +}); + +export { devicesActions } from './devices'; +export { positionsActions } from './positions'; + +export default configureStore({ reducer }); diff --git a/modern/src/store/modules/devices.js b/modern/src/store/modules/devices.js deleted file mode 100644 index 0d96e98d..00000000 --- a/modern/src/store/modules/devices.js +++ /dev/null @@ -1,20 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const { reducer, actions } = createSlice({ - name: 'devices', - initialState: { - items: {}, - selectedId: null - }, - reducers: { - update(state, action) { - action.payload.forEach(item => state.items[item['id']] = item); - }, - select(state, action) { - state.selectedId = action.payload.id; - } - } -}); - -export { actions as devicesActions }; -export { reducer as devicesReducer }; diff --git a/modern/src/store/modules/index.js b/modern/src/store/modules/index.js deleted file mode 100644 index e2037c72..00000000 --- a/modern/src/store/modules/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { combineReducers } from '@reduxjs/toolkit'; - -import { devicesReducer as devices } from './devices'; -import { positionsReducer as positions } from './positions'; - -export const rootReducer = combineReducers({ - devices, - positions, -}); - -export { devicesActions } from './devices'; -export { positionsActions } from './positions'; diff --git a/modern/src/store/modules/positions.js b/modern/src/store/modules/positions.js deleted file mode 100644 index 1df468cd..00000000 --- a/modern/src/store/modules/positions.js +++ /dev/null @@ -1,16 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; - -const { reducer, actions } = createSlice({ - name: 'positions', - initialState: { - items: {}, - }, - reducers: { - update(state, action) { - action.payload.forEach(item => state.items[item['deviceId']] = item); - }, - } -}); - -export { actions as positionsActions }; -export { reducer as positionsReducer }; diff --git a/modern/src/store/positions.js b/modern/src/store/positions.js new file mode 100644 index 00000000..1df468cd --- /dev/null +++ b/modern/src/store/positions.js @@ -0,0 +1,16 @@ +import { createSlice } from '@reduxjs/toolkit'; + +const { reducer, actions } = createSlice({ + name: 'positions', + initialState: { + items: {}, + }, + reducers: { + update(state, action) { + action.payload.forEach(item => state.items[item['deviceId']] = item); + }, + } +}); + +export { actions as positionsActions }; +export { reducer as positionsReducer }; -- cgit v1.2.3