1- import * as React from 'react'
2-
3- import { NetPyNEInstantiated , HTMLViewer } from '..' ;
1+ import * as React from 'react' ;
42
53import {
4+ HTMLViewer ,
5+ NetPyNEInstantiated ,
66 NetPyNESynapses ,
77 NetPyNEConnectivityRules ,
88 NetPyNECellRules ,
@@ -11,19 +11,18 @@ import {
1111 NetPyNESimConfig ,
1212 NetPyNEPopulations ,
1313 NetPyNEPlots ,
14- NetPyNEPythonConsole
15- } from "../" ;
14+ NetPyNEPythonConsole ,
15+ } from '..' ;
1616
1717import { WidgetComponent } from './model' ;
1818
1919export default class WidgetFactory {
20-
2120 widgets = { } ;
2221
2322 // FIXME didn't found a way to make standard refs work here, so using a custom callback
2423 refs : { [ id : string ] : WidgetComponent } = { } ;
2524
26- constructor ( ) {
25+ constructor ( ) {
2726 this . widgets = { } ;
2827 }
2928
@@ -34,15 +33,15 @@ export default class WidgetFactory {
3433 *
3534 * @param { id, name, component, panelName, [instancePath], * } widgetConfig
3635 */
37- factory ( widgetConfig ) {
36+ factory ( widgetConfig ) {
3837 if ( ! this . widgets [ widgetConfig . id ] ) {
3938 this . widgets [ widgetConfig . id ] = this . newWidget ( widgetConfig ) ;
4039 }
4140
4241 return this . widgets [ widgetConfig . id ] ;
4342 }
4443
45- getComponents ( ) : { [ id : string ] : WidgetComponent } {
44+ getComponents ( ) : { [ id : string ] : WidgetComponent } {
4645 const confs : { [ id : string ] : WidgetComponent } = { } ;
4746 for ( const wid in this . refs ) {
4847 const component = this . refs [ wid ] ;
@@ -53,65 +52,77 @@ export default class WidgetFactory {
5352 return confs ;
5453 }
5554
56- getComponent ( widgetId : string ) {
55+ getComponent ( widgetId : string ) {
5756 return this . refs [ widgetId ] ;
5857 }
5958
60- updateWidget ( widgetConfig ) {
59+ updateWidget ( widgetConfig ) {
6160 this . widgets [ widgetConfig . id ] = this . newWidget ( widgetConfig ) ;
6261 return this . widgets [ widgetConfig . id ] ;
6362 }
6463
65- newWidget ( widgetConfig ) {
66- const component = widgetConfig . component ;
64+ newWidget ( widgetConfig ) {
65+ const { component } = widgetConfig ;
6766 switch ( component ) {
68- case " PythonConsole" : {
67+ case ' PythonConsole' : {
6968 return < NetPyNEPythonConsole /> ;
7069 }
71- case " D3Canvas" :
72- return < NetPyNEInstantiated />
73- case " Plot" : {
74- const data = window [ 'plotCache' ] [ widgetConfig . id ]
75- if ( widgetConfig . method . plotMethod . startsWith ( " iplot" ) ) {
70+ case ' D3Canvas' :
71+ return < NetPyNEInstantiated /> ;
72+ case ' Plot' : {
73+ const data = window [ 'plotCache' ] [ widgetConfig . id ] ;
74+ if ( widgetConfig . method . plotMethod . startsWith ( ' iplot' ) ) {
7675 return (
77- < div style = { { width : '100%' , height : '100%' , textAlign : "center" } } >
78- < iframe name = 'dipole' srcDoc = { data }
76+ < div style = { {
77+ width : '100%' ,
78+ height : '100%' ,
79+ textAlign : 'center' ,
80+ } }
81+ >
82+ < iframe
83+ name = "dipole"
84+ srcDoc = { data }
7985 // onLoad={() => this.centerIframe('dipole')}
80- style = { { border : 0 , width : '100%' , height : '100%' } } />
86+ style = { {
87+ border : 0 ,
88+ width : '100%' ,
89+ height : '100%' ,
90+ } }
91+ />
8192 </ div >
82- )
93+ ) ;
8394 }
8495 return (
8596 < HTMLViewer
8697 content = { data }
8798 id = { widgetConfig . id }
8899 />
89- )
100+ ) ;
90101 }
91102
92- case " popParams" : {
93- return < NetPyNEPopulations model = { "netParams.popParams" } />
103+ case ' popParams' : {
104+ return < NetPyNEPopulations model = "netParams.popParams" /> ;
94105 }
95- case " cellParams" : {
96- return < NetPyNECellRules model = { "netParams.cellParams" } />
106+ case ' cellParams' : {
107+ return < NetPyNECellRules model = "netParams.cellParams" /> ;
97108 }
98- case " synMechParams" : {
99- return < NetPyNESynapses model = { "netParams.synMechParams" } />
109+ case ' synMechParams' : {
110+ return < NetPyNESynapses model = "netParams.synMechParams" /> ;
100111 }
101- case " connParams" : {
102- return < NetPyNEConnectivityRules model = { "netParams.connParams" } />
112+ case ' connParams' : {
113+ return < NetPyNEConnectivityRules model = "netParams.connParams" /> ;
103114 }
104- case " stimSourceParams" : {
105- return < NetPyNEStimulationSources model = { "netParams.stimSourceParams" } />
115+ case ' stimSourceParams' : {
116+ return < NetPyNEStimulationSources model = "netParams.stimSourceParams" /> ;
106117 }
107- case " stimTargetParams" : {
108- return < NetPyNEStimulationTargets model = { "netParams.stimTargetParams" } />
118+ case ' stimTargetParams' : {
119+ return < NetPyNEStimulationTargets model = "netParams.stimTargetParams" /> ;
109120 }
110- case " simConfig" : {
111- return < NetPyNESimConfig model = { "simConfig" } />
121+ case ' simConfig' : {
122+ return < NetPyNESimConfig model = "simConfig" /> ;
112123 }
113- case " analysis" : {
114- return < NetPyNEPlots model = { "simConfig.analysis" } />
124+ case ' analysis' : {
125+ return < NetPyNEPlots model = "simConfig.analysis" /> ;
115126 }
116127 }
117128 }
0 commit comments