Skip to content

Commit 9baafe7

Browse files
author
Lucas Rebscher
authored
Merge pull request #252 from MetaCell/feature/197_fix_network_plots
#197 Recreate network plots on CREATE_NETWORK action
2 parents 08aa7d2 + 9de4332 commit 9baafe7

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

webapp/constants.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const TOPBAR_CONSTANTS = {
6868
* ------------------------------------------------------------------------------ //
6969
* ------------------------------------------------------------------------------ //
7070
*/
71-
export const PLOT_WIDGETS = {
71+
export const NETWORK_PLOT_WIDGETS = {
7272
connectionPlot: {
7373
id: 'connectionPlot',
7474
name: 'Connections Plot',
@@ -101,6 +101,10 @@ export const PLOT_WIDGETS = {
101101
},
102102
pos: 2,
103103
},
104+
};
105+
106+
export const PLOT_WIDGETS = {
107+
...NETWORK_PLOT_WIDGETS,
104108
tracesPlot: {
105109
id: 'tracesPlot',
106110
name: 'Cell traces',

webapp/redux/middleware/plotMiddleware.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { addWidget, SET_WIDGETS, UPDATE_WIDGET } from '../actions/layout';
22
import Utils from '../../Utils';
3-
import { NETPYNE_COMMANDS, PLOT_WIDGETS, WidgetStatus } from 'root/constants';
3+
import { NETPYNE_COMMANDS, NETWORK_PLOT_WIDGETS, PLOT_WIDGETS, WidgetStatus } from 'root/constants';
44
import { processError } from './middleware';
5-
import { SIMULATE_NETWORK, CREATE_SIMULATE_NETWORK, SET_THEME } from '../actions/general';
5+
import {
6+
SIMULATE_NETWORK,
7+
CREATE_SIMULATE_NETWORK,
8+
SET_THEME,
9+
CREATE_NETWORK
10+
} from '../actions/general';
611

712
// A simple cache for plots coming from the backend.
813
// This is a temporary solution until we have a proper strategy to store the plot data in redux
@@ -55,6 +60,16 @@ export default store => next => action => {
5560
next(action);
5661
break;
5762
}
63+
case CREATE_NETWORK: {
64+
// Reset network plots
65+
for (let widget of Object.values(NETWORK_PLOT_WIDGETS)) {
66+
delete window.plotCache[widget.id];
67+
widget.initialized = false;
68+
next(addWidget(widget));
69+
}
70+
next(action);
71+
break;
72+
}
5873
case SIMULATE_NETWORK:
5974
case CREATE_SIMULATE_NETWORK: {
6075
window.plotCache = {};

0 commit comments

Comments
 (0)