Skip to content

Commit

Permalink
#40 redux implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelpiano committed Nov 21, 2022
1 parent a18cc29 commit 67dbe6a
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"react": "^17.0.2",
"react-app-rewired": "^2.2.1",
"react-dom": "^17.0.2",
"react-redux": "^8.0.5",
"react-rnd": "^10.3.7",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"resize-observer-polyfill": "^1.5.1",
"stream-browserify": "^3.0.0",
"typescript": "^4.6.4",
Expand Down
10 changes: 7 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import './App.css';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import theme from './theme';
import { Provider } from 'react-redux';
import Layout from './components/common/Layout';
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';

// import Loader from './components/common/Loader';

function App() {
return (
<ThemeProvider theme={theme}>
<CssBaseline />
<Layout />
<Provider store={}>
<Layout />
</Provider>
{/* <Loader /> */}
</ThemeProvider>
);
Expand Down
5 changes: 5 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ export enum PNLClasses {
COMPOSITION = 'composition',
MECHANISM = 'mechanism',
PROJECTION = 'projection'
}

export enum GUIStates {
EDIT = 'gui_edit',
VIEW = 'gui_view'
}
54 changes: 54 additions & 0 deletions src/redux/actions/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export const OPEN_FILE = 'open_file';
export const LOAD_MODEL = 'load_model';
export const SAVE_MODEL = 'save_model';
export const UPDATE_MODEL = 'update_model';
export const SIMULATE_MODEL = 'simulate_model';
export const CHANGE_VIEW = 'change_view';
export const SELECT = 'select';
export const OPEN_COMPOSITION = 'open_composition';
export const CLOSE_COMPOSITION = 'close_composition';

export const openFile = filePath => ({
type: OPEN_FILE,
data: filePath
});

export const loadModel = modelData => ({
type: LOAD_MODEL,
data: modelData
});

export const saveModel = filePath => ({
type: SAVE_MODEL,
data: filePath
});

export const updateModel = newModel => ({
type: UPDATE_MODEL,
data: newModel
});

export const simulateModel = model => ({
type: SIMULATE_MODEL,
data: model
});

export const changeView = newView => ({
type: CHANGE_VIEW,
data: newView
});

export const select = node => ({
type: SELECT,
data: node
});

export const openComposition = compositionId => ({
type: OPEN_COMPOSITION,
data: compositionId
});

export const closeComposition = () => ({
type: OPEN_FILE,
data: undefined
});
Empty file.
11 changes: 11 additions & 0 deletions src/redux/reducers/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { GUIStates } from "../../constants"

export const GENERAL_DEFAULT_STATE = {
error: undefined,
selected: undefined,
original_model: undefined,
model: undefined,
gui_state: GUIStates.EDIT,
composition_opened: undefined
}

34 changes: 34 additions & 0 deletions src/redux/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const GENERAL_DEFAULT_STATE = {
error: undefined,
idsMap: {},
idsList: [],
idsLoaded: 0,
idsToLoad: 0,
stepsToLoad: 1,
stepsLoaded: 0,
loading: false,
instanceOnFocus : {},
ui : {
canvas : {
instanceSelection : {},
instanceDeleted : {},
instanceVisibilityChanged : false
},
graph : {
graphQueryIndex : -1,
visible : true,
sync : false
},
termInfo : { termInfoVisible : false },
layers : { listViewerInfoVisible : true },
circuitBrowser : {
circuitQuerySelected : [{ id : "", label : "" } , { id : "", label : "" }],
visible : true
},
layout: {
"ThreeDViewer": true,
"StackViewer": true,
"TermInfo": true
}
}
}

0 comments on commit 67dbe6a

Please sign in to comment.