From b9393befb6f8d629365b1026d4a333f255cf6c08 Mon Sep 17 00:00:00 2001 From: Filippo Ledda Date: Mon, 17 Feb 2020 15:22:02 +0100 Subject: [PATCH] #102 port to geppetto-client 2.1.0 --- .gitignore | 5 + .travis.yml | 2 +- ComponentsInitialization.js | 108 ++--- NetPyNE.js | 269 +++++------ Utils.js | 334 ++++++------- WEB-INF/web.xml | 81 ++++ .../definition/cellRules/NetPyNECellRule.js | 50 +- .../definition/cellRules/NetPyNECellRules.js | 367 +++++++------- .../cellRules/sections/NetPyNESection.js | 52 +- .../sections/NetPyNESectionThumbnail.js | 63 ++- .../sections/mechanisms/NetPyNEMechanism.js | 36 +- .../mechanisms/NetPyNEMechanismThumbnail.js | 35 +- .../mechanisms/NetPyNENewMechanism.js | 52 +- .../configuration/NetPyNESimConfig.js | 126 +++-- .../connectivity/NetPyNEConnectivityRule.js | 60 ++- .../connectivity/NetPyNEConnectivityRules.js | 90 ++-- components/definition/plots/NetPyNEInclude.js | 282 ++++++----- components/definition/plots/NetPyNENewPlot.js | 32 +- .../definition/plots/NetPyNEPlotThumbnail.js | 14 +- components/definition/plots/NetPyNEPlots.js | 104 ++-- components/definition/plots/TimeRange.js | 16 +- .../definition/plots/plotTypes/Plot2Dnet.js | 21 +- .../definition/plots/plotTypes/PlotConn.js | 47 +- .../definition/plots/plotTypes/PlotGranger.js | 15 +- .../definition/plots/plotTypes/PlotLFP.js | 20 +- .../definition/plots/plotTypes/PlotRaster.js | 30 +- .../definition/plots/plotTypes/PlotRatePSD.js | 19 +- .../definition/plots/plotTypes/PlotShape.js | 27 +- .../plots/plotTypes/PlotSpikeHist.js | 19 +- .../plots/plotTypes/PlotSpikeStats.js | 17 +- .../definition/plots/plotTypes/PlotTraces.js | 23 +- .../definition/populations/Dimensions.js | 157 +++--- .../populations/NetPyNEPopulation.js | 91 ++-- .../populations/NetPyNEPopulations.js | 87 ++-- .../NetPyNEStimulationSource.js | 84 ++-- .../NetPyNEStimulationSources.js | 120 ++--- .../NetPyNEStimulationTarget.js | 144 +++--- .../NetPyNEStimulationTargets.js | 123 ++--- .../StimulationConditions.js | 33 +- .../definition/synapses/NetPyNESynapse.js | 93 ++-- .../definition/synapses/NetPyNESynapses.js | 118 ++--- components/general/AdapterComponent.js | 95 ++-- components/general/DeleteDialogBox.js | 78 +-- components/general/FileBrowser.js | 167 ++++--- components/general/List.js | 452 +++++++++--------- components/general/NetPyNEAddNew.js | 19 +- components/general/NetPyNECoordsRange.js | 128 +++-- components/general/NetPyNEField.js | 261 +++++----- components/general/NetPyNEHome.js | 4 +- components/general/NetPyNEThumbnail.js | 86 ++-- components/general/Slider.js | 66 ++- .../instantiation/NetPyNEInstantiated.js | 432 +++++++++-------- components/settings/NetPyNETabs.js | 101 ++-- components/settings/NetPyNEToolBar.js | 100 ++-- components/settings/actions/ActionDialog.js | 39 +- .../settings/actions/ImportCellParams.js | 68 ++- .../settings/actions/ImportExportHLS.js | 311 ++++++------ components/settings/actions/LoadFile.js | 92 ++-- components/settings/actions/NewModel.js | 36 +- components/settings/actions/SaveFile.js | 98 ++-- components/transition/Transition.js | 246 +++++----- css/colors.less | 2 +- tests/appbarTest.js | 356 +++++++------- tests/cellParamsTest.js | 290 ++++++----- tests/connParamsTest.js | 48 +- tests/netpyne-tests.js | 418 ++++++++-------- tests/popParamsTest.js | 72 +-- tests/rangeComponentTest.js | 52 +- tests/simConfigTest.js | 106 ++-- tests/simulationTest.js | 126 ++--- tests/stimSourceParamsTest.js | 54 ++- tests/stimTargetParamsTest.js | 48 +- tests/synMechParamsTest.js | 46 +- tests/toolbox.js | 384 ++++++++------- 74 files changed, 4170 insertions(+), 4177 deletions(-) create mode 100644 WEB-INF/web.xml diff --git a/.gitignore b/.gitignore index 5509140f..68700b55 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ *.DS_Store +.DS_Store +node_modules +build +geppetto-client +.idea/ diff --git a/.travis.yml b/.travis.yml index 319378b9..c6ec209f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,4 @@ script: - docker build -t="geppetto-neuron_pip" https://github.com/MetaCell/NEURON-UI.git#interface:Dockerfile_pip/ - echo "Current time :$(date +"%T")" - docker build -t="geppetto-neuron" https://github.com/MetaCell/NEURON-UI.git#interface:Dockerfile/ - - echo "Current time :$(date +"%T")" \ No newline at end of file + - echo "Current time :$(date +"%T")" diff --git a/ComponentsInitialization.js b/ComponentsInitialization.js index d1063032..79df8993 100644 --- a/ComponentsInitialization.js +++ b/ComponentsInitialization.js @@ -1,65 +1,65 @@ define(function (require) { - return function (GEPPETTO) { - var ReactDOM = require('react-dom'); - var React = require('react'); - var getMuiTheme = require('material-ui/styles/getMuiTheme').default; - var MuiThemeProvider = require('material-ui/styles/MuiThemeProvider').default; - var NetPyNE = require('./NetPyNE').default; - var injectTapEventPlugin = require('react-tap-event-plugin'); + return function (GEPPETTO) { + var ReactDOM = require('react-dom'); + var React = require('react'); + var getMuiTheme = require('material-ui/styles/getMuiTheme').default; + var MuiThemeProvider = require('material-ui/styles/MuiThemeProvider').default; + var NetPyNE = require('./NetPyNE').default; + var injectTapEventPlugin = require('react-tap-event-plugin'); - var Utils = require('./Utils').default; - var Console = require('../../js/components/interface/console/Console'); - var TabbedDrawer = require('../../js/components/interface/drawer/TabbedDrawer'); - var PythonConsole = require('../../js/components/interface/pythonConsole/PythonConsole'); + var Utils = require('./Utils').default; + var Console = require('../../js/components/interface/console/Console'); + var TabbedDrawer = require('../../js/components/interface/drawer/TabbedDrawer'); + var PythonConsole = require('../../js/components/interface/pythonConsole/PythonConsole'); - require('./css/netpyne.less'); - require('./css/material.less'); - require('./css/traceback.less'); + require('./css/netpyne.less'); + require('./css/material.less'); + require('./css/traceback.less'); - injectTapEventPlugin(); + injectTapEventPlugin(); - const customTheme = { - palette: { - primary1Color: '#543a73', - primary2Color: '#eb557a', - primary3Color: '#ebd07a' - } - }; + const customTheme = { + palette: { + primary1Color: '#543a73', + primary2Color: '#eb557a', + primary3Color: '#ebd07a' + } + }; - const theme = getMuiTheme(customTheme); + const theme = getMuiTheme(customTheme); - function App(data = {}) { - return ( -
- - - + function App (data = {}) { + return ( +
+ + + - -
- ); - } - ReactDOM.render(, document.querySelector('#mainContainer')); + +
+ ); + } + ReactDOM.render(, document.querySelector('#mainContainer')); - GEPPETTO.G.setIdleTimeOut(-1); - GEPPETTO.G.debug(false); //Change this to true to see messages on the Geppetto console while loading - GEPPETTO.Resources.COLORS.DEFAULT = "#6f54aa"; - GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, "Initialising NetPyNE"); + GEPPETTO.G.setIdleTimeOut(-1); + GEPPETTO.G.debug(false); // Change this to true to see messages on the Geppetto console while loading + GEPPETTO.Resources.COLORS.DEFAULT = "#6f54aa"; + GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, "Initialising NetPyNE"); - GEPPETTO.on('jupyter_geppetto_extension_ready', (data) => { - Utils.execPythonMessage('from netpyne_ui.netpyne_geppetto import netpyne_geppetto'); - Utils.evalPythonMessage('netpyne_geppetto.getData',[]).then((response) => { - var data = Utils.convertToJSON(response) - ReactDOM.render(, document.querySelector('#mainContainer')); - GEPPETTO.trigger("spinner:hide"); - }) - }); - }; + GEPPETTO.on('jupyter_geppetto_extension_ready', data => { + Utils.execPythonMessage('from netpyne_ui.netpyne_geppetto import netpyne_geppetto'); + Utils.evalPythonMessage('netpyne_geppetto.getData',[]).then(response => { + var data = Utils.convertToJSON(response) + ReactDOM.render(, document.querySelector('#mainContainer')); + GEPPETTO.trigger("spinner:hide"); + }) + }); + }; }); diff --git a/NetPyNE.js b/NetPyNE.js index fc50c98b..e1b99ad7 100644 --- a/NetPyNE.js +++ b/NetPyNE.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Toolbar, ToolbarGroup } from 'material-ui/Toolbar'; +import { Toolbar, ToolbarGroup } from 'material-ui/Toolbar'; import Transition from './components/transition/Transition'; import NetPyNEPopulations from './components/definition/populations/NetPyNEPopulations'; import NetPyNECellRules from './components/definition/cellRules/NetPyNECellRules'; @@ -24,7 +24,7 @@ var PythonControlledNetPyNEPlots = PythonControlledCapability.createPythonContro export default class NetPyNE extends React.Component { - constructor(props) { + constructor (props) { super(props); this.widgets = {}; this.state = { @@ -40,154 +40,147 @@ export default class NetPyNE extends React.Component { this.handleDeactivateInstanceUpdate = this.handleDeactivateInstanceUpdate.bind(this); this.handleDeactivateSimulationUpdate = this.handleDeactivateSimulationUpdate.bind(this); this.handleTabChangedByToolBar = this.handleTabChangedByToolBar.bind(this) - } - - componentWillReceiveProps(nextProps) { + } + + componentWillReceiveProps (nextProps) { if (this.props.data != nextProps.data) { console.log("Initialising NetPyNE Tabs") window.metadata = nextProps.data.metadata; window.currentFolder = nextProps.data.currentFolder; window.isDocker = nextProps.data.isDocker; - + this.setState({ model: nextProps.data }) } - }; - - hideWidgetsFor = (value) => { - if (value != "define") { - var page = this.refs[value]; - if (page) { - var widgets = page.getOpenedWidgets(); - if (this.widgets[value]) { - widgets = widgets.concat(this.widgets[value]); - } - for (var w in widgets) { - if(!widgets[w].destroyed){ - widgets[w].hide(); - } - else{ - delete widgets[w]; - } - } - this.widgets[value] = widgets; - } - } - } + } - restoreWidgetsFor = (value, rename=false) => { - if (value != "define") { - if (this.widgets[value]) { - let widgets = this.widgets[value] - for (var w in widgets) { - if (rename && !widgets[w].getName().endsWith('(OLD)')) widgets[w].setName(widgets[w].getName()+' (OLD)') - widgets[w].show(); - } - } - } - } + hideWidgetsFor = value => { + if (value != "define") { + var page = this.refs[value]; + if (page) { + var widgets = page.getOpenedWidgets(); + if (this.widgets[value]) { + widgets = widgets.concat(this.widgets[value]); + } + for (var w in widgets) { + if (!widgets[w].destroyed){ + widgets[w].hide(); + } else { + delete widgets[w]; + } + } + this.widgets[value] = widgets; + } + } + } - handleChange = (tab) => { - this.hideWidgetsFor(this.state.value); - this.restoreWidgetsFor(tab, true); - this.setState( ({value: pv, prevValue: xx, freezeInstance:fi, freezeSimulation:fs, tabClicked:tc, ...others}) => { - return { - value: tab, - prevValue: pv, - freezeInstance: pv=='define'?false:fi, - freezeSimulation: pv=='define'?false:fs, - tabClicked: !tc, - } - }) - }; + restoreWidgetsFor = (value, rename = false) => { + if (value != "define") { + if (this.widgets[value]) { + let widgets = this.widgets[value] + for (var w in widgets) { + if (rename && !widgets[w].getName().endsWith('(OLD)')) { + widgets[w].setName(widgets[w].getName() + ' (OLD)') + } + widgets[w].show(); + } + } + } + } + + handleChange = tab => { + this.hideWidgetsFor(this.state.value); + this.restoreWidgetsFor(tab, true); + this.setState( ({ value: pv, prevValue: xx, freezeInstance:fi, freezeSimulation:fs, tabClicked:tc, ...others }) => ({ + value: tab, + prevValue: pv, + freezeInstance: pv == 'define' ? false : fi, + freezeSimulation: pv == 'define' ? false : fs, + tabClicked: !tc, + })) + }; - handleTransitionOptionsChange = (e, v) => { - var state = {fastForwardInstantiation: false, fastForwardSimulation: false} - if (v=='Create and Simulate Network') { - state = {fastForwardInstantiation: true, fastForwardSimulation: true} - } - else if (v=='Create Network') { - state = {fastForwardInstantiation: true, fastForwardSimulation: false} - } - this.setState(state) - } + handleTransitionOptionsChange = (e, v) => { + var state = { fastForwardInstantiation: false, fastForwardSimulation: false } + if (v == 'Create and Simulate Network') { + state = { fastForwardInstantiation: true, fastForwardSimulation: true } + } else if (v == 'Create Network') { + state = { fastForwardInstantiation: true, fastForwardSimulation: false } + } + this.setState(state) + } - handleDeactivateInstanceUpdate = (netInstanceWasUpdated) => { - if (netInstanceWasUpdated) { - if (!this.state.freezeInstance) { - this.setState({freezeInstance: true}) - } - } - } + handleDeactivateInstanceUpdate = netInstanceWasUpdated => { + if (netInstanceWasUpdated) { + if (!this.state.freezeInstance) { + this.setState({ freezeInstance: true }) + } + } + } - handleDeactivateSimulationUpdate = (netSimulationWasUpdated) => { - if (netSimulationWasUpdated) { - if (!this.state.freezeSimulation) { - this.setState({freezeSimulation: true, freezeInstance: true}) - } - } - } - - handleTabChangedByToolBar = (tab, args) => { - this.setState(({value: x, prevValue: xx, freezeInstance: fi, freezeSimulation: fs, ...others})=>{ - return { - value: tab, - prevValue: tab, - freezeInstance: args.freezeInstance != undefined ? args.freezeInstance : fi, - freezeSimulation: args.freezeSimulation != undefined ? args.freezeSimulation : fs, - } - }); - } - - render() { - if (this.state.model == null) { - return
- } - else - { - if (this.state.value=='define'){ - var content =
- - - - - - - - -
- } - else { - var content = - } - - return ( -
-
- - - - - - - - -
- - + handleDeactivateSimulationUpdate = netSimulationWasUpdated => { + if (netSimulationWasUpdated) { + if (!this.state.freezeSimulation) { + this.setState({ freezeSimulation: true, freezeInstance: true }) + } + } + } + + handleTabChangedByToolBar = (tab, args) => { + this.setState(({ value: x, prevValue: xx, freezeInstance: fi, freezeSimulation: fs, ...others }) => ({ + value: tab, + prevValue: tab, + freezeInstance: args.freezeInstance != undefined ? args.freezeInstance : fi, + freezeSimulation: args.freezeSimulation != undefined ? args.freezeSimulation : fs, + })); + } + + render () { + if (this.state.model == null) { + return
+ } else { + if (this.state.value == 'define'){ + var content =
+ + + + + + + + +
+ } else { + var content = + } + + return ( +
+
+ + + + + + + + +
+ + - {content} -
- ) - } - } + {content} +
+ ) + } + } } diff --git a/Utils.js b/Utils.js index 25cc8d29..6a9b7cb2 100644 --- a/Utils.js +++ b/Utils.js @@ -1,176 +1,182 @@ -import {execPythonMessage, evalPythonMessage} from '../../js/communication/geppettoJupyter/GeppettoJupyterUtils'; +import { execPythonMessage, evalPythonMessage } from '../../js/communication/geppettoJupyter/GeppettoJupyterUtils'; import React from 'react'; const Utils = { - getAvailableKey: function (model, prefix) { - if (model == undefined) { - return prefix; + getAvailableKey: function (model, prefix) { + if (model == undefined) { + return prefix; + } + // Get New Available ID + var id = prefix; + var i = 2; + while (model[id] != undefined) { + id = prefix + i++; + } + return id; + }, + + getMetadataField: function (key, field) { + if (key == undefined) { + return; + } + var currentObject; + var nextObject = window.metadata; + key.split('.').forEach(item => { + if (item in nextObject) { + currentObject = nextObject[item]; + if ("children" in currentObject) { + nextObject = currentObject["children"]; } - // Get New Available ID - var id = prefix; - var i = 2; - while (model[id] != undefined) { - id = prefix + i++; + } else { + currentObject = undefined; + return; + } + }); + return (currentObject == undefined) ? currentObject : currentObject[field]; + }, + + getHTMLType: function (key) { + var type = this.getMetadataField(key, "type") + + switch (type) { + case "int": + var htmlType = "number" + break; + default: + var htmlType = "text" + break; + } + return htmlType; + + }, + + isObject: function (item) { + return (item && typeof item === 'object' && !Array.isArray(item)); + }, + + mergeDeep: function (target, source) { + let output = Object.assign({}, target); + if (this.isObject(target) && this.isObject(source)) { + Object.keys(source).forEach(key => { + if (this.isObject(source[key])) { + if (!(key in target)) { + Object.assign(output, { [key]: source[key] }); + } else { + output[key] = this.mergeDeep(target[key], source[key]); + } + } else { + Object.assign(output, { [key]: source[key] }); } - return id; - }, - - getMetadataField: function (key, field) { - if (key == undefined) { - return; - } - var currentObject; - var nextObject = window.metadata; - key.split('.').forEach((item) => { - if (item in nextObject) { - currentObject = nextObject[item]; - if ("children" in currentObject) { - nextObject = currentObject["children"]; - } - } - else { - currentObject = undefined; - return; - } + }); + } + return output; + }, + + getFieldsFromMetadataTree: function (tree, callback) { + function iterate (object, path) { + if (Array.isArray(object)) { + object.forEach(function (a, i) { + iterate(a, path.concat(i)); }); - return (currentObject == undefined) ? currentObject : currentObject[field]; - }, - - getHTMLType: function (key) { - var type = this.getMetadataField(key, "type") - - switch (type) { - case "int": - var htmlType = "number" - break; - default: - var htmlType = "text" - break; - } - return htmlType; - - }, - - isObject: function (item) { - return (item && typeof item === 'object' && !Array.isArray(item)); - }, - - mergeDeep: function (target, source) { - let output = Object.assign({}, target); - if (this.isObject(target) && this.isObject(source)) { - Object.keys(source).forEach(key => { - if (this.isObject(source[key])) { - if (!(key in target)) - Object.assign(output, { [key]: source[key] }); - else - output[key] = this.mergeDeep(target[key], source[key]); - } else { - Object.assign(output, { [key]: source[key] }); - } - }); - } - return output; - }, - - getFieldsFromMetadataTree: function (tree, callback) { - function iterate(object, path) { - if (Array.isArray(object)) { - object.forEach(function (a, i) { - iterate(a, path.concat(i)); - }); - return; - } - if (object !== null && typeof object === 'object') { - Object.keys(object).forEach(function (k) { - // Don't add the leaf to path - iterate(object[k], (typeof object[k] === 'object') ? path.concat(k) : path); - - }); - return; - } - - // Push to array of field id. Remove children and create id string - modelFieldsIds.push(path.filter(path => path != 'children').join('.')); - } - - // Iterate the array extracting the fields Ids - var modelFieldsIds = []; - iterate(tree, []); - - // Generate model fields based on ids - var modelFields = []; - modelFieldsIds.filter((v, i, a) => a.indexOf(v) === i).map((id) => modelFields.push(callback(id, 0))) - return modelFields; - }, - - renameKey(path, oldValue, newValue, callback) { - this.execPythonMessage('netpyne_geppetto.rename("' + path + '","' + oldValue + '","' + newValue + '")') - .then((response) => { - callback(response, newValue); - }) - }, - - nameValidation(name) { - // Remove spaces - if((/\s/.test(name))) { - name = name.replace(/\s+/g, "").replace(/^\d+/g, ""); - } - // Remove number at the beginning - else if((/^[0-9]/.test(name))) { - name = name.replace(/\s+/g, "").replace(/^\d+/g, ""); - } - return name; + return; + } + if (object !== null && typeof object === 'object') { + Object.keys(object).forEach(function (k) { + // Don't add the leaf to path + iterate(object[k], (typeof object[k] === 'object') ? path.concat(k) : path); - }, + }); + return; + } + + // Push to array of field id. Remove children and create id string + modelFieldsIds.push(path.filter(path => path != 'children').join('.')); + } + + // Iterate the array extracting the fields Ids + var modelFieldsIds = []; + iterate(tree, []); + + // Generate model fields based on ids + var modelFields = []; + modelFieldsIds.filter((v, i, a) => a.indexOf(v) === i).map(id => modelFields.push(callback(id, 0))) + return modelFields; + }, + + renameKey (path, oldValue, newValue, callback) { + this.execPythonMessage('netpyne_geppetto.rename("' + path + '","' + oldValue + '","' + newValue + '")') + .then(response => { + callback(response, newValue); + }) + }, + + nameValidation (name) { + // Remove spaces + if ((/\s/.test(name))) { + name = name.replace(/\s+/g, "").replace(/^\d+/g, ""); + } else if ((/^[0-9]/.test(name))) { // Remove number at the beginning + name = name.replace(/\s+/g, "").replace(/^\d+/g, ""); + } + return name; + + }, - //FIXME: Hack to remove scaped chars (\\ -> \ and \' -> ') manually - convertToJSON(data){ - if (typeof data === 'string' || data instanceof String){ - return JSON.parse(data.replace(/\\\\/g, '\\').replace(/\\'/g, '\'')) - } - return data - }, - - getErrorResponse(data){ - var parsedData = this.convertToJSON(data) - if (parsedData.hasOwnProperty("type") && parsedData['type'] == 'ERROR'){ - return {'message': parsedData['message'], 'details' : parsedData['details']} - } - return null; - }, - - parsePythonException(exception){ - return

-    },
-
-    handleUpdate(updateCondition, newValue, originalValue, context, componentName) {
-        if((updateCondition) && (newValue != originalValue)) {
-            // if the new value has been changed by the function Utils.nameValidation means that the name convention
-            // has not been respected, so we need to open the dialog and inform the user.
-            context.setState({ currentName: newValue,
-                            errorMessage: "Error",
-                            errorDetails: "Leading digits or whitespaces are not allowed in "+componentName+" names."});
-            return true;
-        } else if ((updateCondition) && (newValue == originalValue)){
-            context.setState({ currentName: newValue });
-            return true;
-        } else if (!(updateCondition) && (newValue == originalValue)) {
-            context.setState({ currentName: newValue,
-                            errorMessage: "Error",
-                            errorDetails: "Name collision detected, the name "+newValue+
-                                        " is already used in this model, please pick another name."});
-            return false;
-        } else if (!(updateCondition) && (newValue != originalValue)) {
-            context.setState({ currentName: newValue,
-                            errorMessage: "Error",
-                            errorDetails: "Leading digits or whitespaces are not allowed in "+componentName+" names."});
-            return false;
-        }
-    },
-
-    execPythonMessage: execPythonMessage,
-    evalPythonMessage: evalPythonMessage
+  // FIXME: Hack to remove scaped chars (\\ -> \ and \' -> ') manually
+  convertToJSON (data){
+    if (typeof data === 'string' || data instanceof String){
+      return JSON.parse(data.replace(/\\\\/g, '\\').replace(/\\'/g, '\''))
+    }
+    return data
+  },
+
+  getErrorResponse (data){
+    var parsedData = this.convertToJSON(data)
+    if (parsedData.type && parsedData['type'] == 'ERROR'){
+      return { 'message': parsedData['message'], 'details' : parsedData['details'] }
+    }
+    return null;
+  },
+
+  parsePythonException (exception){
+    return 

+  },
+
+  handleUpdate (updateCondition, newValue, originalValue, context, componentName) {
+    if ((updateCondition) && (newValue != originalValue)) {
+      /*
+       * if the new value has been changed by the function Utils.nameValidation means that the name convention
+       * has not been respected, so we need to open the dialog and inform the user.
+       */
+      context.setState({
+        currentName: newValue,
+        errorMessage: "Error",
+        errorDetails: "Leading digits or whitespaces are not allowed in " + componentName + " names."
+      });
+      return true;
+    } else if ((updateCondition) && (newValue == originalValue)){
+      context.setState({ currentName: newValue });
+      return true;
+    } else if (!(updateCondition) && (newValue == originalValue)) {
+      context.setState({
+        currentName: newValue,
+        errorMessage: "Error",
+        errorDetails: "Name collision detected, the name " + newValue
+                                        + " is already used in this model, please pick another name."
+      });
+      return false;
+    } else if (!(updateCondition) && (newValue != originalValue)) {
+      context.setState({
+        currentName: newValue,
+        errorMessage: "Error",
+        errorDetails: "Leading digits or whitespaces are not allowed in " + componentName + " names."
+      });
+      return false;
+    }
+  },
+
+  execPythonMessage: execPythonMessage,
+  evalPythonMessage: evalPythonMessage
 }
 
 export default Utils
\ No newline at end of file
diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml
new file mode 100644
index 00000000..0c7a30eb
--- /dev/null
+++ b/WEB-INF/web.xml
@@ -0,0 +1,81 @@
+
+
+
+    org.geppetto.frontend
+
+    
+        contextClass
+        org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext
+    
+    
+        contextConfigLocation
+        /WEB-INF/spring/*.xml
+    
+
+    
+		org.springframework.web.context.request.RequestContextListener
+	
+    
+        org.springframework.web.context.ContextLoaderListener
+    
+    
+        org.apache.shiro.web.env.EnvironmentLoaderListener
+    
+
+    
+        springdispatcher
+        org.springframework.web.servlet.DispatcherServlet
+        
+            contextClass
+            org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext
+        
+        
+            contextConfigLocation
+            /WEB-INF/spring/*.xml
+        
+        1
+    
+
+    
+        springdispatcher
+        /
+    
+
+    
+   		json
+    	application/json
+	
+    
+        
+        TestServlet
+        TestServlet
+        org.geppetto.frontend.TestServlet
+    
+    
+        TestServlet
+        /TestServlet
+    
+
+    
+        ShiroFilter
+        org.apache.shiro.web.servlet.ShiroFilter
+    
+
+    
+        ShiroFilter
+        /*
+        REQUEST
+        FORWARD
+        INCLUDE
+        ERROR
+    
+
+    
+
+
+    
+
+
diff --git a/components/definition/cellRules/NetPyNECellRule.js b/components/definition/cellRules/NetPyNECellRule.js
index 4f48d727..f300d5cc 100644
--- a/components/definition/cellRules/NetPyNECellRule.js
+++ b/components/definition/cellRules/NetPyNECellRule.js
@@ -13,16 +13,16 @@ var PythonMethodControlledSelectField = PythonControlledCapability.createPythonC
 
 export default class NetPyNECellRule extends React.Component {
 
-  constructor(props) {
+  constructor (props) {
     super(props);
     this.state = {
       currentName: props.name,
       errorMessage: undefined,
       errorDetails: undefined
     };
-  };
+  }
 
-  componentDidMount(){
+  componentDidMount (){
     GEPPETTO.on('populations_change', () => {
       this.forceUpdate();
     })
@@ -34,43 +34,45 @@ export default class NetPyNECellRule extends React.Component {
     })
   }
 
-  componentWillUnmount(){
+  componentWillUnmount (){
     GEPPETTO.off('populations_change')
     GEPPETTO.off('cellType_change')
     GEPPETTO.off('cellModel_change')
   }
 
-  handleRenameChange = (event) => {
+  handleRenameChange = event => {
     var storedValue = this.props.name;
     var newValue = Utils.nameValidation(event.target.value);
     var updateCondition = this.props.renameHandler(newValue);
     var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "CellRule");
 
-    if(triggerCondition) {
+    if (triggerCondition) {
       this.triggerUpdate(() => {
         // Rename the population in Python
-        Utils.renameKey('netParams.cellParams', storedValue, newValue, (response, newValue) => { this.renaming = false; });
+        Utils.renameKey('netParams.cellParams', storedValue, newValue, (response, newValue) => {
+          this.renaming = false; 
+        });
         this.renaming = true;
       });
     }
   }
 
-  triggerUpdate(updateMethod) {
-    //common strategy when triggering processing of a value change, delay it, every time there is a change we reset
+  triggerUpdate (updateMethod) {
+    // common strategy when triggering processing of a value change, delay it, every time there is a change we reset
     if (this.updateTimer != undefined) {
       clearTimeout(this.updateTimer);
     }
     this.updateTimer = setTimeout(updateMethod, 1000);
   }
 
-  componentWillReceiveProps(nextProps) {
+  componentWillReceiveProps (nextProps) {
     this.setState({ currentName: nextProps.name });
   }
 
-  postProcessMenuItems(pythonData, selected) {
-    return pythonData.map((name) => (
+  postProcessMenuItems (pythonData, selected) {
+    return pythonData.map(name => (
        -1}
@@ -78,9 +80,9 @@ export default class NetPyNECellRule extends React.Component {
         primaryText={name}
       />
     ));
-  };
+  }
 
-  render() {
+  render () {
     var actions = [
       
-          {children}
-         
+      title={title}
+      open={true}
+      actions={actions}
+      bodyStyle={{ overflow: 'auto' }}
+      style={{ whiteSpace: "pre-wrap" }}>
+      {children}
+     
       : undefined
     )
     return (
@@ -181,5 +183,5 @@ export default class NetPyNECellRule extends React.Component {
         {dialogPop}
       
     );
-  };
-};
+  }
+}
diff --git a/components/definition/cellRules/NetPyNECellRules.js b/components/definition/cellRules/NetPyNECellRules.js
index ca623c87..fe96db54 100644
--- a/components/definition/cellRules/NetPyNECellRules.js
+++ b/components/definition/cellRules/NetPyNECellRules.js
@@ -36,15 +36,13 @@ const styles = {
       borderRadius: 25,
       boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.2), 0 3px 6px 0 rgba(0, 0, 0, 0.19)'
     },
-    icon: {
-      borderRadius: 25 
-    }
+    icon: { borderRadius: 25 }
   }
 }
 
 export default class NetPyNECellRules extends React.Component {
 
-  constructor(props) {
+  constructor (props) {
     super(props);
     this.state = {
       drawerOpen: false,
@@ -76,22 +74,22 @@ export default class NetPyNECellRules extends React.Component {
     this.handleRenameSections = this.handleRenameSections.bind(this);
   }
 
-  selectPage(page, state) {
+  selectPage (page, state) {
     this.setState({ page: page, ...state });
   }
 
-  selectCellRule(cellRule) {
-    this.setState({selectedCellRule: cellRule, selectedSection: undefined, selectedMechanism: undefined});
+  selectCellRule (cellRule) {
+    this.setState({ selectedCellRule: cellRule, selectedSection: undefined, selectedMechanism: undefined });
   }
 
-  handleNewCellRule(defaultCellRules) {
+  handleNewCellRule (defaultCellRules) {
     var key = Object.keys(defaultCellRules)[0];
     var value = defaultCellRules[key];
-    var {value: model} = this.state;
+    var { value: model } = this.state;
 
     // Get New Available ID
     var cellRuleId = Utils.getAvailableKey(model, key);
-    var newCellRule = Object.assign({name: cellRuleId}, value);
+    var newCellRule = Object.assign({ name: cellRuleId }, value);
     // Create Cell Rule Client side
     Utils.execPythonMessage('netpyne_geppetto.netParams.cellParams["' + cellRuleId + '"] = ' + JSON.stringify(value));
     model[cellRuleId] = newCellRule;
@@ -104,18 +102,18 @@ export default class NetPyNECellRules extends React.Component {
     });
   }
 
-  selectSection(section) {
+  selectSection (section) {
     this.setState({ selectedSection: section, selectedMechanism: undefined });
   }
 
-  handleNewSection(defaultSectionValues) {
+  handleNewSection (defaultSectionValues) {
     let key = Object.keys(defaultSectionValues)[0];
     let value = defaultSectionValues[key];
     const { value: model, selectedCellRule } = this.state;
     
     // Get New Available ID
     var sectionId = Utils.getAvailableKey(model[selectedCellRule]['secs'], key);
-    var newSection = Object.assign({name: sectionId}, value);
+    var newSection = Object.assign({ name: sectionId }, value);
     if (model[selectedCellRule]['secs'] == undefined) {
       model[selectedCellRule]['secs'] = {};
       Utils.execPythonMessage('netpyne_geppetto.netParams.cellParams["' + selectedCellRule + '"]["secs"] = {}');
@@ -130,23 +128,23 @@ export default class NetPyNECellRules extends React.Component {
     });
   }
 
-  selectMechanism(mechanism) {
+  selectMechanism (mechanism) {
     this.setState({ selectedMechanism: mechanism });
   }
 
-  handleNewMechanism(mechanism) {
-    const {value: model, selectedCellRule, selectedSection } = this.state;
+  handleNewMechanism (mechanism) {
+    const { value: model, selectedCellRule, selectedSection } = this.state;
     
     // Create Mechanism Client side
     if (model[selectedCellRule].secs[selectedSection]['mechs'] == undefined) {
       model[selectedCellRule].secs[selectedSection]['mechs'] = {};
       Utils.execPythonMessage('netpyne_geppetto.netParams.cellParams["' + selectedCellRule + '"]["secs"]["' + selectedSection + '"]["mechs"] = {}');
-    };
+    }
     var params = {};
     Utils
       .evalPythonMessage("netpyne_geppetto.getMechParams", [mechanism])
-      .then((response) => {
-        response.forEach((param) => params[param] = 0);
+      .then(response => {
+        response.forEach(param => params[param] = 0);
         Utils.execPythonMessage('netpyne_geppetto.netParams.cellParams["' + selectedCellRule + '"]["secs"]["' + selectedSection + '"]["mechs"]["' + mechanism + '"] = ' + JSON.stringify(params));
       })
     this.setState({
@@ -155,15 +153,15 @@ export default class NetPyNECellRules extends React.Component {
     });
   }
 
-  hasSelectedCellRuleBeenRenamed(prevState, currentState) {
+  hasSelectedCellRuleBeenRenamed (prevState, currentState) {
     var currentModel = prevState.value;
     var model = currentState.value;
-    //deal with rename
+    // deal with rename
     if (currentModel != undefined && model != undefined) {
       var oldP = Object.keys(currentModel);
       var newP = Object.keys(model);
       if (oldP.length == newP.length) {
-        //if it's the same lenght there could be a rename
+        // if it's the same lenght there could be a rename
         for (var i = 0; i < oldP.length; i++) {
           if (oldP[i] != newP[i]) {
             if (prevState.selectedCellRule != undefined) {
@@ -178,7 +176,7 @@ export default class NetPyNECellRules extends React.Component {
     return undefined;
   }
 
-  hasSelectedSectionBeenRenamed(prevState, currentState) {
+  hasSelectedSectionBeenRenamed (prevState, currentState) {
     var currentModel = prevState.value;
     var model = this.state.value;
     var currentCellRule = undefined;
@@ -190,7 +188,7 @@ export default class NetPyNECellRules extends React.Component {
     }
 
     if (currentModel != undefined && model != undefined && prevState.selectedCellRule != undefined && currentCellRule != undefined && newCellRule != undefined) {
-      //loop sections
+      // loop sections
       var oldS = Object.keys(currentCellRule.secs);
       var newS = Object.keys(newCellRule.secs);
       if (oldS.length == newS.length) {
@@ -208,7 +206,7 @@ export default class NetPyNECellRules extends React.Component {
     return undefined;
   }
 
-  hasSelectedMechanismBeenRenamed(prevState, currentState) {
+  hasSelectedMechanismBeenRenamed (prevState, currentState) {
     var currentModel = prevState.value;
     var model = this.state.value;
     var currentCellRule = undefined;
@@ -224,7 +222,7 @@ export default class NetPyNECellRules extends React.Component {
       newSection = newCellRule.secs[currentState.selectedSection];
     }
     if (currentModel != undefined && model != undefined && prevState.selectedSection != undefined && currentSection != undefined && newSection != undefined) {
-      //loop mechanisms
+      // loop mechanisms
       var oldM = Object.keys(currentSection.mechs);
       var newM = Object.keys(newSection.mechs);
       if (oldM.length == newM.length) {
@@ -242,29 +240,33 @@ export default class NetPyNECellRules extends React.Component {
     return undefined;
   }
 
-  componentDidUpdate(prevProps, prevState) {
-    //we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable
+  componentDidUpdate (prevProps, prevState) {
+    // we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable
     var newCellRuleName = this.hasSelectedCellRuleBeenRenamed(prevState, this.state);
     if (newCellRuleName !== undefined) {
       this.setState({ selectedCellRule: newCellRuleName, deletedCellRule: undefined });
-    } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) {
-      // logic into this if to check if the user added a new object from the python backend and
-      // if the name convention pass the checks, differently rename this and open dialog to inform.
+    } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) {
+      /*
+       * logic into this if to check if the user added a new object from the python backend and
+       * if the name convention pass the checks, differently rename this and open dialog to inform.
+       */
       var model = this.state.value;
-      for(var m in model) {
-        if((prevState.value !== "") && (!(m in prevState.value))) {
+      for (var m in model) {
+        if ((prevState.value !== "") && (!(m in prevState.value))) {
           var newValue = Utils.nameValidation(m);
-          if(newValue != m) {
+          if (newValue != m) {
             newValue = Utils.getAvailableKey(model, newValue);
             model[newValue] = model[m];
             delete model[m];
-            this.setState({ value: model,
-                            errorMessage: "Error",
-                            errorDetails: "Leading digits or whitespaces are not allowed in CellRule names.\n" +
-                                          m + " has been renamed " + newValue},
-                            function() {
-                              Utils.renameKey('netParams.cellParams', m, newValue, (response, newValue) => {});
-                            }.bind(this));
+            this.setState({
+              value: model,
+              errorMessage: "Error",
+              errorDetails: "Leading digits or whitespaces are not allowed in CellRule names.\n"
+                                          + m + " has been renamed " + newValue
+            },
+            function () {
+              Utils.renameKey('netParams.cellParams', m, newValue, (response, newValue) => {});
+            }.bind(this));
           }
         }
       }
@@ -272,26 +274,30 @@ export default class NetPyNECellRules extends React.Component {
     var newSectionName = this.hasSelectedSectionBeenRenamed(prevState, this.state);
     if (newSectionName !== undefined) {
       this.setState({ selectedSection: newSectionName, deletedSection: undefined });
-    } else if((prevState.value !== undefined)) {
-      // logic into this if to check if the user added a new object from the python backend and
-      // if the name convention pass the checks, differently rename this and open dialog to inform.
+    } else if ((prevState.value !== undefined)) {
+      /*
+       * logic into this if to check if the user added a new object from the python backend and
+       * if the name convention pass the checks, differently rename this and open dialog to inform.
+       */
       var model2 = this.state.value;
       var prevModel = prevState.value;
-      for(var n in model2) {
-        if((prevModel[n] !== undefined) && (Object.keys(model2[n]['secs']).length !== Object.keys(prevModel[n]['secs']).length)) {
+      for (var n in model2) {
+        if ((prevModel[n] !== undefined) && (Object.keys(model2[n]['secs']).length !== Object.keys(prevModel[n]['secs']).length)) {
           var cellRule = model2[n]['secs'];
-          for(var s in cellRule) {
-            if(!(s in prevState.value[n]['secs'])) {
+          for (var s in cellRule) {
+            if (!(s in prevState.value[n]['secs'])) {
               var newValue2 = Utils.nameValidation(s);
-              if(newValue2 != s) {
+              if (newValue2 != s) {
                 newValue2 = Utils.getAvailableKey(model2[n]['secs'], newValue2);
                 model2[n]['secs'][newValue2] = model2[n]['secs'][s];
                 delete model2[n]['secs'][s];
-                this.setState({ value: model2,
+                this.setState({
+                  value: model2,
                   errorMessage: "Error",
-                  errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" +
-                  s + " has been renamed " + newValue2},
-                  () => Utils.renameKey('netParams.cellParams["'+n+'"]["secs"]', s, newValue2, (response, newValue) => {}));
+                  errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n"
+                  + s + " has been renamed " + newValue2
+                },
+                () => Utils.renameKey('netParams.cellParams["' + n + '"]["secs"]', s, newValue2, (response, newValue) => {}));
               }
             }
           }
@@ -304,30 +310,30 @@ export default class NetPyNECellRules extends React.Component {
     }
   }
 
-  handleHierarchyClick = (nextPage) => {
+  handleHierarchyClick = nextPage => {
     const { page, selectedCellRule, value } = this.state;
-    // with this herarchy navigation, the tree buttons in the breadclumb can behave  in 2 different ways
-    // they can move the view to a different level (cellRule -> section) (seccions --> mechanisms) 
-    // or they can add a new cellRule ( or section or mechanims) 
-    // here we chech if we want to jump to a different level or if we want to create a new rule in the current level
-    if (nextPage===page) { 
+    /*
+     * with this herarchy navigation, the tree buttons in the breadclumb can behave  in 2 different ways
+     * they can move the view to a different level (cellRule -> section) (seccions --> mechanisms) 
+     * or they can add a new cellRule ( or section or mechanims) 
+     * here we chech if we want to jump to a different level or if we want to create a new rule in the current level
+     */
+    if (nextPage === page) { 
       if (page === "main") {
-        this.handleNewCellRule({ 'CellRule': {'conds':{}, 'secs':{}} });
+        this.handleNewCellRule({ 'CellRule': { 'conds':{}, 'secs':{} } });
+      } else if (page === "sections") {
+        this.handleNewSection({ 'Section': { 'geom': {}, 'topol': {}, 'mechs': {} } });
       }
-      else if (page === "sections") {
-        this.handleNewSection({ 'Section': {'geom': {}, 'topol': {}, 'mechs': {}} });
-      }
-    }
-    else {
-      this.setState({page: nextPage});
+    } else {
+      this.setState({ page: nextPage });
       if (nextPage == 'sections') { // saves one click if there are no sections
         if (Object.keys(value[selectedCellRule]['secs']).length == 0) {
-          this.handleNewSection({ 'Section': {'geom': {}, 'topol': {}, 'mechs': {}} });
+          this.handleNewSection({ 'Section': { 'geom': {}, 'topol': {}, 'mechs': {} } });
         }
       }
     }
   }
-  shouldComponentUpdate(nextProps, nextState) {
+  shouldComponentUpdate (nextProps, nextState) {
     var itemRenamed = this.hasSelectedCellRuleBeenRenamed(this.state, nextState) !== undefined || this.hasSelectedSectionBeenRenamed(this.state, nextState) !== undefined || this.hasSelectedMechanismBeenRenamed(this.state, nextState) !== undefined;
     var newItemCreated = false;
     var selectionChanged = this.state.selectedCellRule != nextState.selectedCellRule || this.state.selectedSection != nextState.selectedSection || this.state.selectedMechanism != nextState.selectedMechanism;
@@ -344,157 +350,144 @@ export default class NetPyNECellRules extends React.Component {
         newItemCreated = (newItemCreated || oldLength != Object.keys(nextState.value[this.state.selectedCellRule].secs[this.state.selectedSection].mechs).length);
       }
     }
-    var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false;
+    var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails);
     return newModel || newItemCreated || itemRenamed || selectionChanged || pageChanged || errorDialogOpen;
   }
 
-  deleteCellRule(name) {
-    Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['cellParams', name]).then((response) =>{
+  deleteCellRule (name) {
+    Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['cellParams', name]).then(response => {
       var model = this.state.value;
       delete model[name];
-      this.setState({value: model, selectedCellRule: undefined, deletedCellRule: name});
+      this.setState({ value: model, selectedCellRule: undefined, deletedCellRule: name });
     });
-  };
+  }
 
-  deleteMechanism(name) {
-    if(this.state.selectedCellRule != undefined && this.state.selectedSection != undefined) {
-      Utils.evalPythonMessage('netpyne_geppetto.deleteParam', [[this.state.selectedCellRule, this.state.selectedSection], name]).then((response) =>{
+  deleteMechanism (name) {
+    if (this.state.selectedCellRule != undefined && this.state.selectedSection != undefined) {
+      Utils.evalPythonMessage('netpyne_geppetto.deleteParam', [[this.state.selectedCellRule, this.state.selectedSection], name]).then(response => {
         var model = this.state.value;
         delete model[this.state.selectedCellRule].secs[this.state.selectedSection]['mechs'][name];
-        this.setState({value: model, selectedMechanism: undefined});
+        this.setState({ value: model, selectedMechanism: undefined });
       });
     }
-  };
+  }
 
-  deleteSection(name) {
-    if(this.state.selectedCellRule != undefined) {
-      Utils.evalPythonMessage('netpyne_geppetto.deleteParam', [[this.state.selectedCellRule], name]).then((response) =>{
+  deleteSection (name) {
+    if (this.state.selectedCellRule != undefined) {
+      Utils.evalPythonMessage('netpyne_geppetto.deleteParam', [[this.state.selectedCellRule], name]).then(response => {
         var model = this.state.value;
         delete model[this.state.selectedCellRule]['secs'][name];
-        this.setState({value: model, selectedSection: undefined, deletedSection: name});
+        this.setState({ value: model, selectedSection: undefined, deletedSection: name });
       });
     }
-  };
+  }
 
-  handleRenameChildren(childName) {
+  handleRenameChildren (childName) {
     childName = childName.replace(/\s*$/,"");
     var childrenList = Object.keys(this.state.value);
-    for(var i=0 ; childrenList.length > i ; i++) {
-      if(childName === childrenList[i]) {
+    for (var i = 0 ; childrenList.length > i ; i++) {
+      if (childName === childrenList[i]) {
         return false;
       }
     }
     return true;
-  };
+  }
 
-  handleRenameSections(childName, leaf) {
+  handleRenameSections (childName, leaf) {
     childName = childName.replace(/\s*$/,"");
     var childrenList = Object.keys(this.state.value[leaf]['secs']);
-    for(var i=0 ; childrenList.length > i ; i++) {
-      if(childName === childrenList[i]) {
+    for (var i = 0 ; childrenList.length > i ; i++) {
+      if (childName === childrenList[i]) {
         return false;
       }
     }
     return true;
-  };
+  }
 
-  createTooltip(rule) {
+  createTooltip (rule) {
     const { value: model, page, selectedCellRule, selectedSection } = this.state;
 
     switch (rule) {
-      case 'cellRule':
-        if (page!=='main') {
-          if (selectedCellRule && selectedCellRule.length > 8 ) {
-            return selectedCellRule
-          }
-          else {
-            return 'Go back to rule'
-          }
-        }
-        else {
-          return 'Create rule'
+    case 'cellRule':
+      if (page !== 'main') {
+        if (selectedCellRule && selectedCellRule.length > 8 ) {
+          return selectedCellRule
+        } else {
+          return 'Go back to rule'
         }
+      } else {
+        return 'Create rule'
+      }
 
-      case 'section':
-        if (page ==='mechanisms') {
-          if (!!selectedSection && selectedSection.length > 9 ) {
-            return selectedSection
-          }
-          else{
-            return 'Go back to section'
-          }
+    case 'section':
+      if (page === 'mechanisms') {
+        if (!!selectedSection && selectedSection.length > 9 ) {
+          return selectedSection
+        } else {
+          return 'Go back to section'
         }
-        else {
-          if (page == "sections") {
-            return 'Create a section'
-          }
-          else {
-            if (!!selectedCellRule){
-              if (!!model && !!model[selectedCellRule] && Object.keys(model[selectedCellRule]['secs']).length > 0) {
-                return "Explore sections"
-              }
-              else {
-                return "Create first section"
-              }
-            }
-            else {
-              return "No rule selected" 
+      } else {
+        if (page == "sections") {
+          return 'Create a section'
+        } else {
+          if (selectedCellRule){
+            if (!!model && !!model[selectedCellRule] && Object.keys(model[selectedCellRule]['secs']).length > 0) {
+              return "Explore sections"
+            } else {
+              return "Create first section"
             }
+          } else {
+            return "No rule selected" 
           }
         }
+      }
     }
   }
 
-  createLabel(rule){
+  createLabel (rule){
     const { value: model, page, selectedCellRule, selectedSection } = this.state;
     switch (rule) {
-      case 'cellRule':
-        if (page !== 'main'){
-          if (selectedCellRule.length > 8 ){
-            return selectedCellRule.slice(0,7)+'...'
-          }
-          else {
-            return selectedCellRule
-          }
-        }
-        else {
-          return 
+    case 'cellRule':
+      if (page !== 'main'){
+        if (selectedCellRule.length > 8 ){
+          return selectedCellRule.slice(0,7) + '...'
+        } else {
+          return selectedCellRule
         }
+      } else {
+        return 
+      }
 
-      case 'sections':
-        if ( page==='mechanisms' ) {
-          if (selectedSection != undefined) {
-            if (selectedSection.length > 9 ) {
-              return selectedSection.slice(0,7) + "..."
-            }
-            else {
-              return selectedSection
-            }
-          }
-          else {
-            return ''
+    case 'sections':
+      if ( page === 'mechanisms' ) {
+        if (selectedSection != undefined) {
+          if (selectedSection.length > 9 ) {
+            return selectedSection.slice(0,7) + "..."
+          } else {
+            return selectedSection
           }
+        } else {
+          return ''
         }
-        else {
-          if (page == "sections" ) {
-            return 
-          }
-          else {
-            if (!!selectedCellRule) {
-              if (!!model && !!model[selectedCellRule] && Object.keys(model[selectedCellRule]['secs']).length > 0){
-                return 
-              }
-              else return 
-            }
-            else {
-              return ''
+      } else {
+        if (page == "sections" ) {
+          return 
+        } else {
+          if (selectedCellRule) {
+            if (!!model && !!model[selectedCellRule] && Object.keys(model[selectedCellRule]['secs']).length > 0){
+              return 
+            } else {
+              return 
             }
+          } else {
+            return ''
           }
         }
+      }
     }
   }
 
-  render() {
+  render () {
 
     const { value: model, page, selectedCellRule, selectedSection, selectedMechanism, errorMessage, errorDetails } = this.state;
     let selection = null;
@@ -504,13 +497,13 @@ export default class NetPyNECellRules extends React.Component {
 
     const dialogPop = (errorMessage != undefined 
       ? 
-          {errorDetails}
-         
+        title={errorMessage}
+        open={true}
+        actions={actions}
+        bodyStyle={{ overflow: 'auto' }}
+        style={{ whiteSpace: "pre-wrap" }}>
+        {errorDetails}
+       
       : undefined
     );
 
@@ -537,8 +530,7 @@ export default class NetPyNECellRules extends React.Component {
           />
         )
       }
-    }
-    else if (page == "sections") {
+    } else if (page == "sections") {
       const sectionsModel = model[selectedCellRule].secs;
       if ( selectedSection !== undefined && Object.keys(sectionsModel).indexOf(selectedSection) > -1 ) {
         selection = (
@@ -560,8 +552,7 @@ export default class NetPyNECellRules extends React.Component {
           handleClick={this.selectSection} 
         />
       )
-    }
-    else if (page == "mechanisms") {
+    } else if (page == "mechanisms") {
       const mechanismsModel = model[selectedCellRule].secs[selectedSection].mechs;
       if ((selectedMechanism !== undefined) && Object.keys(mechanismsModel).indexOf(selectedMechanism) > -1) {
         selection = (
@@ -591,7 +582,7 @@ export default class NetPyNECellRules extends React.Component {
           
this.setState({page: 'main', selectedCellRule: undefined, selectedSection: undefined, selectedMechanism: undefined})} + handleClick={() => this.setState({ page: 'main', selectedCellRule: undefined, selectedSection: undefined, selectedMechanism: undefined })} /> this.handleHierarchyClick('sections') } data-tooltip={ this.createTooltip('section')} > -

+

{this.createLabel('sections')}

@@ -643,17 +634,17 @@ export default class NetPyNECellRules extends React.Component { ); return ( - - - {content} - {dialogPop} - + + + {content} + {dialogPop} + ); } } diff --git a/components/definition/cellRules/sections/NetPyNESection.js b/components/definition/cellRules/sections/NetPyNESection.js index a1436bbe..f6003247 100644 --- a/components/definition/cellRules/sections/NetPyNESection.js +++ b/components/definition/cellRules/sections/NetPyNESection.js @@ -13,7 +13,7 @@ import RaisedButton from 'material-ui/RaisedButton'; import Utils from '../../../../Utils'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledListComponent = PythonControlledCapability.createPythonControlledControl(ListComponent); var PythonMethodControlledSelectField = PythonControlledCapability.createPythonControlledControlWithPythonDataFetch(SelectField); @@ -23,7 +23,7 @@ const changeColor = 'rgb(0, 188, 212)'; export default class NetPyNESection extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { @@ -37,19 +37,19 @@ export default class NetPyNESection extends React.Component { this.postProcessMenuItems = this.postProcessMenuItems.bind(this); } - setPage(page) { + setPage (page) { this.setState({ page: page }); } select = (index, sectionId) => this.setState({ selectedIndex: index, sectionId: sectionId }); - handleRenameChange = (event) => { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue, this.props.cellRule); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "Section"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { // Rename the population in Python Utils.renameKey("netParams.cellParams['" + this.props.cellRule + "']['secs']", storedValue, newValue, (response, newValue) => { }); @@ -57,15 +57,15 @@ export default class NetPyNESection extends React.Component { } } - triggerUpdate(updateMethod) { - //common strategy when triggering processing of a value change, delay it, every time there is a change we reset + triggerUpdate (updateMethod) { + // common strategy when triggering processing of a value change, delay it, every time there is a change we reset if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); } this.updateTimer = setTimeout(updateMethod, 500); } - getBottomNavigationItem(index, sectionId, label, icon, id) { + getBottomNavigationItem (index, sectionId, label, icon, id) { return this.select(index, sectionId)} /> } - componentWillReceiveProps(nextProps) { - this.setState({ currentName: nextProps.name}); + componentWillReceiveProps (nextProps) { + this.setState({ currentName: nextProps.name }); } - postProcessMenuItems(pythonData, selected) { - if (pythonData[this.props.cellRule]!= undefined) { - return pythonData[this.props.cellRule].map((name) => ( + postProcessMenuItems (pythonData, selected) { + if (pythonData[this.props.cellRule] != undefined) { + return pythonData[this.props.cellRule].map(name => ( )); } - }; + } - render() { + render () { var actions = [ - {children} - + title={title} + open={true} + actions={actions} + bodyStyle={{ overflow: 'auto' }} + style={{ whiteSpace: "pre-wrap" }}> + {children} + : undefined ); @@ -128,8 +128,7 @@ export default class NetPyNESection extends React.Component { />
) - } - else if (this.state.sectionId == "Geometry") { + } else if (this.state.sectionId == "Geometry") { content = (
@@ -154,8 +153,7 @@ export default class NetPyNESection extends React.Component {
) - } - else if (this.state.sectionId == "Topology") { + } else if (this.state.sectionId == "Topology") { content = (
- } - else { + } else { label = name.length > 14 ? `${name.slice(0,10)}...` : name } return (
- this.setState({isHovered: true}) } - onMouseLeave={ () => this.setState({isHovered: false}) } - data-tooltip={isHovered && name.length > 14 ? name : undefined} - className={"rectangularActionButton " + (selected ? "selectedRectangularActionButton " : "")} - onClick={() => this.handleClick()} - > - { label } - - this.handleDialogBox(r) } - textForDialog={name} /> + this.setState({ isHovered: true }) } + onMouseLeave={ () => this.setState({ isHovered: false }) } + data-tooltip={isHovered && name.length > 14 ? name : undefined} + className={"rectangularActionButton " + (selected ? "selectedRectangularActionButton " : "")} + onClick={() => this.handleClick()} + > + { label } + + this.handleDialogBox(r) } + textForDialog={name} />
); } diff --git a/components/definition/cellRules/sections/mechanisms/NetPyNEMechanism.js b/components/definition/cellRules/sections/mechanisms/NetPyNEMechanism.js index 3ee4566b..5c5a044d 100644 --- a/components/definition/cellRules/sections/mechanisms/NetPyNEMechanism.js +++ b/components/definition/cellRules/sections/mechanisms/NetPyNEMechanism.js @@ -2,46 +2,46 @@ import React from 'react'; import TextField from 'material-ui/TextField'; import Utils from '../../../../../Utils'; -var PythonControlledCapability = require('../../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('../geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); export default class NetPyNEMechanism extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { currentName: props.name, mechFields: '' }; - }; + } - componentWillReceiveProps(nextProps) { - this.setState({ currentName: nextProps.name}); - }; + componentWillReceiveProps (nextProps) { + this.setState({ currentName: nextProps.name }); + } renderMechFields = () => { - if (this.state.mechFields=='') { + if (this.state.mechFields == '') { return
- } - else { + } else { var tag = "netParams.cellParams['" + this.props.cellRule + "']['secs']['" + this.props.section + "']['mechs']['" + this.state.currentName + "']" return this.state.mechFields.map((name, i) => - + ) } }; - render() { + render () { var content = [] - if (this.state.currentName!=undefined && this.state.currentName!='') { + if (this.state.currentName != undefined && this.state.currentName != '') { Utils .evalPythonMessage("netpyne_geppetto.getMechParams", [this.state.currentName]) - .then((response) => { - if (JSON.stringify(this.state.mechFields)!=JSON.stringify(response)) - this.setState({mechFields: response}) + .then(response => { + if (JSON.stringify(this.state.mechFields) != JSON.stringify(response)) { + this.setState({ mechFields: response }) + } }) content.push(this.renderMechFields()) - }; + } return (
@@ -57,5 +57,5 @@ export default class NetPyNEMechanism extends React.Component { {content}
); - }; -}; + } +} diff --git a/components/definition/cellRules/sections/mechanisms/NetPyNEMechanismThumbnail.js b/components/definition/cellRules/sections/mechanisms/NetPyNEMechanismThumbnail.js index 2e26a84e..fff9f6e4 100644 --- a/components/definition/cellRules/sections/mechanisms/NetPyNEMechanismThumbnail.js +++ b/components/definition/cellRules/sections/mechanisms/NetPyNEMechanismThumbnail.js @@ -7,9 +7,7 @@ const hoverColor = '#66d2e2'; const changeColor = 'rgb(0, 188, 212)'; const styles = { - main: { - float: 'left' - }, + main: { float: 'left' }, trash: { zIndex:10, marginTop:37, @@ -20,41 +18,40 @@ const styles = { } export default class NetPyNEMechanismThumbnail extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { isHovered: false, dialogOpen: false }; - }; + } - handleClick() { + handleClick () { const { isHovered } = this.state; const { name, selected, handleClick } = this.props; if (handleClick) { - if(selected && isHovered) { - this.setState({dialogOpen: true}); + if (selected && isHovered) { + this.setState({ dialogOpen: true }); } else { handleClick(name, true); } } - }; + } - handleDialogBox(response) { - if(this.props.handleClick && response) { + handleDialogBox (response) { + if (this.props.handleClick && response) { this.props.deleteMethod(this.props.name); } - this.setState({dialogOpen: false}); - }; + this.setState({ dialogOpen: false }); + } - render() { + render () { const { name, selected } = this.props; const { dialogOpen, isHovered } = this.state; let label; if (isHovered && selected) { - label = - } - else { + label = + } else { label = ( {name.length > 14 ? `${name.slice(0,10)}...` : name} @@ -65,8 +62,8 @@ export default class NetPyNEMechanismThumbnail extends React.Component {
this.setState({isHovered: true}) } - onMouseLeave={ () => this.setState({isHovered: false}) } + onMouseEnter={ () => this.setState({ isHovered: true }) } + onMouseLeave={ () => this.setState({ isHovered: false }) } data-tooltip={isHovered && name.length > 10 ? name : undefined} className={"gearThumbButton " + (selected ? "selectedGearButton" : "")} onClick={ (e, v) => this.handleClick(v) } diff --git a/components/definition/cellRules/sections/mechanisms/NetPyNENewMechanism.js b/components/definition/cellRules/sections/mechanisms/NetPyNENewMechanism.js index 86b9fda9..2110effb 100644 --- a/components/definition/cellRules/sections/mechanisms/NetPyNENewMechanism.js +++ b/components/definition/cellRules/sections/mechanisms/NetPyNENewMechanism.js @@ -26,64 +26,60 @@ const styles = { export default class NetPyNENewMechanism extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { open: false, mechanisms: [] }; - }; + } - componentDidMount() { + componentDidMount () { Utils.evalPythonMessage("netpyne_geppetto.getAvailableMechs", []) - .then(response => { - this.setState({mechanisms: response}) - }) - }; + .then(response => { + this.setState({ mechanisms: response }) + }) + } - handleClick = (value) => { - this.setState({open: false}); + handleClick = value => { + this.setState({ open: false }); this.props.handleClick(value); }; - handleButtonClick = (anchor) => { + handleButtonClick = anchor => { const { blockButton, handleHierarchyClick } = this.props; if (!blockButton) { - this.setState({open: true, anchorEl: anchor}) - }; + this.setState({ open: true, anchorEl: anchor }) + } handleHierarchyClick(); }; - createTooltip(){ + createTooltip (){ const { disabled, blockButton } = this.props; if (disabled) { return "No section selected" - } - else { + } else { if (blockButton) { return "Explore mechanisms" - } - else { + } else { return "Add new mechanism" } } } - createLabel(){ + createLabel (){ const { disabled, blockButton } = this.props; if (disabled) { return "" - } - else { + } else { if (blockButton) { return - } - else { + } else { return } } } - render() { + render () { const { disabled } = this.props; const { open, anchorEl, mechanisms } = this.state; @@ -92,12 +88,12 @@ export default class NetPyNENewMechanism extends React.Component { data-tooltip={this.createTooltip()} id="newMechButton" className="gearAddButton" - iconStyle={{color: '#543a73'}} + iconStyle={{ color: '#543a73' }} disabled={disabled} onClick={ e => this.handleButtonClick(e.currentTarget) } > this.setState({open: false}) } + onRequestClose={ () => this.setState({ open: false }) } > this.handleClick(v) }> {mechanisms.map( mechLabel => @@ -119,5 +115,5 @@ export default class NetPyNENewMechanism extends React.Component {
- }; -}; + } +} diff --git a/components/definition/configuration/NetPyNESimConfig.js b/components/definition/configuration/NetPyNESimConfig.js index b2febdea..8e1d707c 100644 --- a/components/definition/configuration/NetPyNESimConfig.js +++ b/components/definition/configuration/NetPyNESimConfig.js @@ -16,28 +16,26 @@ var PythonControlledListComponent = PythonControlledCapability.createPythonContr export default class NetPyNESimConfig extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { model: props.model, selectedIndex: 0, sectionId: "General" }; - }; + } - componentWillReceiveProps(nextProps) { - this.setState({ - model: nextProps.model - }); - }; + componentWillReceiveProps (nextProps) { + this.setState({ model: nextProps.model }); + } select = (index, sectionId) => this.setState({ selectedIndex: index, sectionId: sectionId }); - render() { + render () { var content; if (this.state.sectionId == 'General') { - content = -
+ content + =
@@ -48,7 +46,7 @@ export default class NetPyNESimConfig extends React.Component { - + @@ -63,7 +61,7 @@ export default class NetPyNESimConfig extends React.Component {
-
+
@@ -117,18 +115,17 @@ export default class NetPyNESimConfig extends React.Component {
- } - else if (this.state.sectionId == 'SaveConfiguration') { - content = -
+ } else if (this.state.sectionId == 'SaveConfiguration') { + content + =
{ - !window.isDocker && - + !window.isDocker + && } @@ -147,8 +144,8 @@ export default class NetPyNESimConfig extends React.Component {
-
- +
+ @@ -194,8 +191,8 @@ export default class NetPyNESimConfig extends React.Component {
} else if (this.state.sectionId == 'Record') { - content = -
+ content + =
@@ -206,7 +203,7 @@ export default class NetPyNESimConfig extends React.Component { - + @@ -215,34 +212,33 @@ export default class NetPyNESimConfig extends React.Component {
-
- +
+ - +
} else if (this.state.sectionId == 'ErrorChecking') { - content = -
-
- - - + content + =
+
+ + + +
+
+ + + +
-
- - - -
-
- } - else if (this.state.sectionId=='netParams') { - var content = -
+ } else if (this.state.sectionId == 'netParams') { + var content + =
@@ -268,35 +264,35 @@ export default class NetPyNESimConfig extends React.Component { -
+
-
- - - +
+ + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + +
-
} return ( @@ -324,5 +320,5 @@ export default class NetPyNESimConfig extends React.Component { ); - }; -}; + } +} diff --git a/components/definition/connectivity/NetPyNEConnectivityRule.js b/components/definition/connectivity/NetPyNEConnectivityRule.js index 0456014b..38f61175 100644 --- a/components/definition/connectivity/NetPyNEConnectivityRule.js +++ b/components/definition/connectivity/NetPyNEConnectivityRule.js @@ -19,7 +19,7 @@ var PythonControlledListComponent = PythonControlledCapability.createPythonContr export default class NetPyNEConnectivityRule extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { currentName: props.name, @@ -30,7 +30,7 @@ export default class NetPyNEConnectivityRule extends React.Component { }; } - componentDidMount(){ + componentDidMount (){ GEPPETTO.on('populations_change', () => { this.forceUpdate(); }) @@ -42,29 +42,31 @@ export default class NetPyNEConnectivityRule extends React.Component { }) } - componentWillUnmount(){ + componentWillUnmount (){ GEPPETTO.off('populations_change') GEPPETTO.off('cellType_change') GEPPETTO.off('cellModel_change') } - handleRenameChange = (event) => { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "ConnectionRule"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { // Rename the population in Python - Utils.renameKey('netParams.connParams', storedValue, newValue, (response, newValue) => { this.renaming = false; }); + Utils.renameKey('netParams.connParams', storedValue, newValue, (response, newValue) => { + this.renaming = false; + }); this.renaming = true; }); } } - triggerUpdate(updateMethod) { - //common strategy when triggering processing of a value change, delay it, every time there is a change we reset + triggerUpdate (updateMethod) { + // common strategy when triggering processing of a value change, delay it, every time there is a change we reset if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); } @@ -73,7 +75,7 @@ export default class NetPyNEConnectivityRule extends React.Component { select = (index, sectionId) => this.setState({ selectedIndex: index, sectionId: sectionId }); - getBottomNavigationItem(index, sectionId, label, icon, id) { + getBottomNavigationItem (index, sectionId, label, icon, id) { return ( + postProcessMenuItems (pythonData, selected) { + return pythonData.map(name => ( -1} @@ -97,11 +99,11 @@ export default class NetPyNEConnectivityRule extends React.Component { )); } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps (nextProps) { this.setState({ currentName: nextProps.name }); } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; if (this.state.sectionId == "General") { - var content = -
+ var content + =
{ - return pythonData.map((name) => ()); - }} + postProcessItems={(pythonData, selected) => pythonData.map(name => ())} /> @@ -197,8 +197,7 @@ export default class NetPyNEConnectivityRule extends React.Component { {dialogPop}
- } - else if (this.state.sectionId == "Pre Conditions") { + } else if (this.state.sectionId == "Pre Conditions") { var content =
- } - else if (this.state.sectionId == "Post Conditions") { + } else if (this.state.sectionId == "Post Conditions") { var content =
this.setState({ drawerOpen: !this.state.drawerOpen }); - selectPage(page) { + selectPage (page) { this.setState({ page: page }); } /* Method that handles button click */ - selectConnectivityRule(connectivityRule) { - this.setState({selectedConnectivityRule: connectivityRule}); + selectConnectivityRule (connectivityRule) { + this.setState({ selectedConnectivityRule: connectivityRule }); } - handleNewConnectivityRule() { + handleNewConnectivityRule () { var defaultConnectivityRules = { 'ConnectivityRule': { 'preConds': {}, @@ -56,7 +56,7 @@ export default class NetPyNEConnectivityRules extends Component { // Get New Available ID var connectivityRuleId = Utils.getAvailableKey(model, key); - var newConnectivityRule = Object.assign({name: connectivityRuleId}, value); + var newConnectivityRule = Object.assign({ name: connectivityRuleId }, value); // Create Cell Rule Client side Utils.execPythonMessage('netpyne_geppetto.netParams.connParams["' + connectivityRuleId + '"] = ' + JSON.stringify(value)); model[connectivityRuleId] = newConnectivityRule; @@ -68,15 +68,15 @@ export default class NetPyNEConnectivityRules extends Component { } - hasSelectedConnectivityRuleBeenRenamed(prevState, currentState) { + hasSelectedConnectivityRuleBeenRenamed (prevState, currentState) { var currentModel = prevState.value; var model = currentState.value; - //deal with rename + // deal with rename if (currentModel != undefined && model != undefined) { var oldP = Object.keys(currentModel); var newP = Object.keys(model); if (oldP.length == newP.length) { - //if it's the same lenght there could be a rename + // if it's the same lenght there could be a rename for (var i = 0; i < oldP.length; i++) { if (oldP[i] != newP[i]) { if (prevState.selectedConnectivityRule != undefined) { @@ -92,36 +92,40 @@ export default class NetPyNEConnectivityRules extends Component { } - componentDidUpdate(prevProps, prevState) { - //we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable + componentDidUpdate (prevProps, prevState) { + // we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable var newConnectivityRuleName = this.hasSelectedConnectivityRuleBeenRenamed(prevState, this.state); if (newConnectivityRuleName !== undefined) { this.setState({ selectedConnectivityRule: newConnectivityRuleName, deletedConnectivityRule: undefined }); - } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { - // logic into this if to check if the user added a new object from the python backend and - // if the name convention pass the checks, differently rename this and open dialog to inform. + } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { + /* + * logic into this if to check if the user added a new object from the python backend and + * if the name convention pass the checks, differently rename this and open dialog to inform. + */ var model = this.state.value; - for(var m in model) { - if((prevState.value !== "") && (!(m in prevState.value))) { + for (var m in model) { + if ((prevState.value !== "") && (!(m in prevState.value))) { var newValue = Utils.nameValidation(m); - if(newValue != m) { + if (newValue != m) { newValue = Utils.getAvailableKey(model, newValue); model[newValue] = model[m]; delete model[m]; - this.setState({ value: model, - errorMessage: "Error", - errorDetails: "Leading digits or whitespaces are not allowed in ConnectivityRule names.\n" + - m + " has been renamed " + newValue}, - function() { - Utils.renameKey('netParams.connParams', m, newValue, (response, newValue) => {}); - }.bind(this)); + this.setState({ + value: model, + errorMessage: "Error", + errorDetails: "Leading digits or whitespaces are not allowed in ConnectivityRule names.\n" + + m + " has been renamed " + newValue + }, + function () { + Utils.renameKey('netParams.connParams', m, newValue, (response, newValue) => {}); + }.bind(this)); } } } } } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var itemRenamed = this.hasSelectedConnectivityRuleBeenRenamed(this.state, nextState) !== undefined; var newItemCreated = false; var selectionChanged = this.state.selectedConnectivityRule != nextState.selectedConnectivityRule; @@ -130,30 +134,30 @@ export default class NetPyNEConnectivityRules extends Component { if (!newModel) { newItemCreated = ((Object.keys(this.state.value).length != Object.keys(nextState.value).length)); } - var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false; + var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails); return newModel || newItemCreated || itemRenamed || selectionChanged || pageChanged || errorDialogOpen; } - deleteConnectivityRule(name) { - Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['connParams', name]).then((response) =>{ + deleteConnectivityRule (name) { + Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['connParams', name]).then(response => { var model = this.state.value; delete model[name]; - this.setState({value: model, selectedConnectivityRule: undefined, deletedConnectivityRule: name}); + this.setState({ value: model, selectedConnectivityRule: undefined, deletedConnectivityRule: name }); }); } - handleRenameChildren(childName) { + handleRenameChildren (childName) { childName = childName.replace(/\s*$/,""); var childrenList = Object.keys(this.state.value); - for(var i=0 ; childrenList.length > i ; i++) { - if(childName === childrenList[i]) { + for (var i = 0 ; childrenList.length > i ; i++) { + if (childName === childrenList[i]) { return false; } } return true; } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; var that = this; var model = this.state.value; @@ -187,7 +191,7 @@ export default class NetPyNEConnectivityRules extends Component { handleClick={this.selectConnectivityRule} />); } var selectedConnectivityRule = undefined; - if ((this.state.selectedConnectivityRule !== undefined) && Object.keys(model).indexOf(this.state.selectedConnectivityRule)>-1) { + if ((this.state.selectedConnectivityRule !== undefined) && Object.keys(model).indexOf(this.state.selectedConnectivityRule) > -1) { selectedConnectivityRule = ; } @@ -198,7 +202,7 @@ export default class NetPyNEConnectivityRules extends Component {
this.setState({selectedConnectivityRule: undefined})} + handleClick={() => this.setState({ selectedConnectivityRule: undefined })} /> diff --git a/components/definition/plots/NetPyNEInclude.js b/components/definition/plots/NetPyNEInclude.js index 1dff6d74..165af6ae 100644 --- a/components/definition/plots/NetPyNEInclude.js +++ b/components/definition/plots/NetPyNEInclude.js @@ -9,91 +9,87 @@ import NetPyNEField from '../../general/NetPyNEField'; export default class NetPyNEInclude extends Component { - constructor(props) { + constructor (props) { super(props); this.state = { include: this.getDataTemplate(), mainPopoverOpen: false, label: '' }; - }; + } - componentDidMount() { + componentDidMount () { this.collectInfo(); GEPPETTO.on('populations_change', () => { this.collectInfo(); }) - GEPPETTO.on("population_update_dimension", () => { //different event to avoid triggers on cellParams, stimSourceParams, etc + GEPPETTO.on("population_update_dimension", () => { // different event to avoid triggers on cellParams, stimSourceParams, etc this.collectInfo(); }) - }; - componentWillUnmount(){ + } + componentWillUnmount (){ GEPPETTO.off('populations_change') } - - getDataTemplate = () => { - return { - gids: [], - groups: [], - popids: {}, - exclusive: false - } - } + getDataTemplate = () => ({ + gids: [], + groups: [], + popids: {}, + exclusive: false + }) checkEqual = (a, b) => { // compare if 2 shallow dicts are equal (no DOM, no 2nd lvl, no functions) var aProps = Object.getOwnPropertyNames(a); var bProps = Object.getOwnPropertyNames(b); if (aProps.length != bProps.length) { - return false; + return false; } for (var i = 0; i < aProps.length; i++) { - var propName = aProps[i]; - if (a[propName] !== b[propName]) { - return false; - } + var propName = aProps[i]; + if (a[propName] !== b[propName]) { + return false; + } } return true; } whoIsIncluded = (include, data) => { - // display some information in the selectfield - // about how many pops and cells have been selected + /* + * display some information in the selectfield + * about how many pops and cells have been selected + */ var pops = 0 var cells = 0 var answer = "" if (include.exclusive) { return include.exclusive + ' -- ' + data.gids + ' cells -- all NetStims' - } - else if (include.groups.indexOf('allCells')>-1) { - if (include.groups.indexOf('allNetStims')==-1) { + } else if (include.groups.indexOf('allCells') > -1) { + if (include.groups.indexOf('allNetStims') == -1) { return 'allCells -- ' + data.gids + ' cells' + } else { + return 'all' + ' -- ' + data.gids + ' cells -- all NetStims' } - else { - return 'all'+ ' -- ' + data.gids + ' cells -- all NetStims' - } - } - else { + } else { include.groups.forEach(group => { - if (group!='allNetStims') { + if (group != 'allNetStims') { pops += 1 cells += data[group] } }) cells += include.gids.length Object.keys(include.popids).forEach(key => { - if (include.popids[key].length>0) { + if (include.popids[key].length > 0) { cells += include.popids[key].length - pops +=1 + pops += 1 } }) } - if (pops>0) { + if (pops > 0) { answer += pops + " pops -- " } answer += cells + " cells " - if (include.groups.indexOf('allNetStims')>-1) { + if (include.groups.indexOf('allNetStims') > -1) { answer += " -- all netStims" } return answer @@ -103,8 +99,7 @@ export default class NetPyNEInclude extends Component { var data = [] if (this.state.include.exclusive) { data.push(this.state.include.exclusive) - } - else { + } else { this.state.include.groups.forEach(group => data.push(group)) this.state.include.gids.forEach(gid => data.push(gid)) Object.keys(this.state.include.popids).forEach(key => data.push([key, this.state.include.popids[key]])) @@ -113,116 +108,116 @@ export default class NetPyNEInclude extends Component { .execPythonMessage("netpyne_geppetto." + this.props.model + " = " + JSON.stringify(data)) } - convertFromPython(data) { + convertFromPython (data) { var out = this.getDataTemplate() - data.forEach((element) => { - switch(element.constructor.name) { - case 'Number': - out['gids'].push(element) - break; - case 'String': - element != 'all' ? out['groups'].push(element) : out.exclusive = 'all' - break; - case 'Array': - if (element[1].constructor.name == 'Number') { - out['popids'][element[0]] = [element[1]] - } - else { - out['popids'][element[0]] = element[1] - } - break; - default: - break + data.forEach(element => { + switch (element.constructor.name) { + case 'Number': + out['gids'].push(element) + break; + case 'String': + element != 'all' ? out['groups'].push(element) : out.exclusive = 'all' + break; + case 'Array': + if (element[1].constructor.name == 'Number') { + out['popids'][element[0]] = [element[1]] + } else { + out['popids'][element[0]] = element[1] } + break; + default: + break + } }); return out - } - + } + collectInfo = async () => { const numberOfCellsByPopulation = await Utils.evalPythonMessage("netpyne_geppetto.getGIDs", []) - if (numberOfCellsByPopulation) { - const dataInPythonFormat = await Utils.evalPythonMessage("netpyne_geppetto.getInclude", [this.props.model.split("'")[1]]) + if (numberOfCellsByPopulation) { + const dataInPythonFormat = await Utils.evalPythonMessage("netpyne_geppetto.getInclude", [this.props.model.split("'")[1]]) let included - if (dataInPythonFormat) { + if (dataInPythonFormat) { included = this.convertFromPython(dataInPythonFormat) - } - else { + } else { included = this.convertFromPython([this.props.initialValue]) } let clone = Object.assign({}, numberOfCellsByPopulation) - Object.keys(clone).forEach((key) => clone[key] = false) + Object.keys(clone).forEach(key => clone[key] = false) this.setState({ include: included, secondPopoverOpen: clone, data: numberOfCellsByPopulation, label: this.whoIsIncluded(included, numberOfCellsByPopulation) }) - } + } } - handleMainPopoverOpen = (open, preventDefault=false, target=false) => { + handleMainPopoverOpen = (open, preventDefault = false, target = false) => { // This prevents ghost click -> if (preventDefault) { preventDefault } // close all secondary popovers var clone = Object.assign({}, this.state.secondPopoverOpen) - Object.keys(clone).forEach((key) => {clone[key] = false}) + Object.keys(clone).forEach(key => { + clone[key] = false + }) - if (( open || this.state.mainPopoverOpen ) && !( open && this.state.mainPopoverOpen )){ + if (( open || this.state.mainPopoverOpen ) && !( open && this.state.mainPopoverOpen )){ this.setState({ mainPopoverOpen: open, secondPopoverOpen: clone, - anchorEl: target?target:this.state.anchorEl}) + anchorEl: target ? target : this.state.anchorEl + }) } if (!open) { this.sendToPython() - this.setState({label: this.whoIsIncluded(this.state.include, this.state.data)}) + this.setState({ label: this.whoIsIncluded(this.state.include, this.state.data) }) } } - handleSecondPopoverOpen = (name, open, preventDefault=false, target=false) => { + handleSecondPopoverOpen = (name, open, preventDefault = false, target = false) => { // This prevents ghost click -> if (preventDefault) { preventDefault; } var clone = Object.assign({}, this.state.secondPopoverOpen) - Object.keys(clone).forEach((key) => {clone[key] = (key==name)?open:false}) + Object.keys(clone).forEach(key => { + clone[key] = (key == name) ? open : false + }) if (!this.checkEqual(clone, this.state.secondPopoverOpen)) { this.setState({ secondPopoverOpen: clone, - anchorEl2: target?target:this.state.anchorEl, + anchorEl2: target ? target : this.state.anchorEl, }); - } - else{ + } else { } }; closeSecondPopover = () => { var clone = Object.assign({}, this.state.secondPopoverOpen) - Object.keys(clone).forEach((key) => {clone[key] = false}) + Object.keys(clone).forEach(key => { + clone[key] = false + }) if (!this.checkEqual(clone, this.state.secondPopoverOpen)) { - this.setState({ - secondPopoverOpen: clone, - }); + this.setState({ secondPopoverOpen: clone, }); } } defaultMenus = () => { // [all, allCells, allNetStims] - var mainMenus = this.props.defaultOptions.map(name => { - return this.handleMainMenusClick(name, name=='all'?'exclusive':'groups')} - checked={this.state.include.exclusive==name||this.state.include.groups.indexOf(name)>-1?true:false} - onMouseEnter={(e) => this.closeSecondPopover()} - /> - }) + var mainMenus = this.props.defaultOptions.map(name => this.handleMainMenusClick(name, name == 'all' ? 'exclusive' : 'groups')} + checked={!!(this.state.include.exclusive == name || this.state.include.groups.indexOf(name) > -1)} + onMouseEnter={e => this.closeSecondPopover()} + />) return {mainMenus} @@ -230,35 +225,33 @@ export default class NetPyNEInclude extends Component { variableMenus = (name, size) => { // size: how many sub-menuItems does the menuItem has - var menuItems = Array.from(Array(size).keys()).map(index => { - return this.handleSecondaryMenusClick(name=='gids'?'gids':'popids', name, index)} - checked={this.IsSecondaryMenuChecked(name=='gids'?'gids':'popids', name, index)} - /> - }) - return
+ var menuItems = Array.from(Array(size).keys()).map(index => this.handleSecondaryMenusClick(name == 'gids' ? 'gids' : 'popids', name, index)} + checked={this.IsSecondaryMenuChecked(name == 'gids' ? 'gids' : 'popids', name, index)} + />) + return
-1?true:false:false} - onClick={name!='gids'?(e) => this.handleMainMenusClick(name, 'groups'):(e)=>{}} - onMouseEnter={(e) => this.handleSecondPopoverOpen(name, true, e.preventDefault(), e.currentTarget)} + checked={name != 'gids' ? this.state.include['groups'].indexOf(name) > -1 : false} + onClick={name != 'gids' ? e => this.handleMainMenusClick(name, 'groups') : e => {}} + onMouseEnter={e => this.handleSecondPopoverOpen(name, true, e.preventDefault(), e.currentTarget)} /> + anchorOrigin={{ "horizontal":"right", "vertical":"top" }} + targetOrigin={{ "horizontal":"left", "vertical":"top" }} + > {menuItems}
@@ -266,63 +259,56 @@ export default class NetPyNEInclude extends Component { handleMainMenusClick = (name, group) => { var clone = this.getDataTemplate() - if (name=='all'){ // remove everything else, when 'all' is selected + if (name == 'all'){ // remove everything else, when 'all' is selected clone.exclusive = 'all' - } - else if (name=='allCells') { + } else if (name == 'allCells') { clone['groups'] = ['allCells'] - if (this.state.include['groups'].indexOf('allNetStims')>-1) { + if (this.state.include['groups'].indexOf('allNetStims') > -1) { clone['groups'].push('allNetStims') } - } - else { + } else { var clone = Object.assign({}, this.state.include) - clone[group].indexOf(name)==-1?clone[group].push(name):clone[group].splice( clone[group].indexOf(name), 1 ); + clone[group].indexOf(name) == -1 ? clone[group].push(name) : clone[group].splice( clone[group].indexOf(name), 1 ); clone['exclusive'] = false - if (name in clone['popids']) { //when selecting a whole pop, remove individual selections + if (name in clone['popids']) { // when selecting a whole pop, remove individual selections delete clone['popids'][name] } - if (this.state.include['groups'].indexOf('allCells')>-1 && name!='allNetStims') { //remove 'allCells' if selecting pops or individuals + if (this.state.include['groups'].indexOf('allCells') > -1 && name != 'allNetStims') { // remove 'allCells' if selecting pops or individuals clone['groups'].splice( clone['groups'].indexOf('allCells'), 1 ); } } - this.setState({include: clone}) + this.setState({ include: clone }) } handleSecondaryMenusClick = (group, name, item) => { var clone = Object.assign({}, this.state.include) - if (group=='gids') { - clone[group].indexOf(item)==-1?clone[group].push(item):clone[group].splice( clone[group].indexOf(item), 1 ); - } - else if (group=='popids') { + if (group == 'gids') { + clone[group].indexOf(item) == -1 ? clone[group].push(item) : clone[group].splice( clone[group].indexOf(item), 1 ); + } else if (group == 'popids') { if (name in clone[group]) { - clone[group][name].indexOf(item)==-1?clone[group][name].push(item):clone[group][name].splice( clone[group][name].indexOf(item), 1 ); - } - else { + clone[group][name].indexOf(item) == -1 ? clone[group][name].push(item) : clone[group][name].splice( clone[group][name].indexOf(item), 1 ); + } else { clone[group][name] = [item] } - if (clone['groups'].indexOf(name)>-1) { // when selecting individuals, remove population selection + if (clone['groups'].indexOf(name) > -1) { // when selecting individuals, remove population selection clone['groups'].splice( clone['groups'].indexOf(name), 1 ) } - } - else { + } else { } clone['exclusive'] = false - if (clone['groups'].indexOf('allCells')>-1 && name!='allNetStims') { + if (clone['groups'].indexOf('allCells') > -1 && name != 'allNetStims') { clone['groups'].splice( clone['groups'].indexOf('allCells'), 1 ); } - this.setState({include: clone}) + this.setState({ include: clone }) } IsSecondaryMenuChecked = (group, name, index) => { - if (group=='gids') { - return this.state.include[group].indexOf(index)>-1?true:false - } - else if (group=='popids'){ + if (group == 'gids') { + return this.state.include[group].indexOf(index) > -1 + } else if (group == 'popids'){ if (name in this.state.include[group]) { - return this.state.include[group][name].indexOf(index)>-1?true:false - } - else { + return this.state.include[group][name].indexOf(index) > -1 + } else { return false } } @@ -331,28 +317,28 @@ export default class NetPyNEInclude extends Component { otherMenus = () => { var menuItems = [] for (var key in this.state.data) { - if (key!='gids'){ + if (key != 'gids'){ menuItems.push(this.variableMenus(key, this.state.data[key])) } } return menuItems } - render() { - return
+ render () { + return
this.handleMainPopoverOpen(true, e.preventDefault(), e.currentTarget)} + onClick={e => this.handleMainPopoverOpen(true, e.preventDefault(), e.currentTarget)} /> this.handleMainPopoverOpen(false)} - anchorOrigin={{"horizontal":"left","vertical":"bottom"}} - targetOrigin={{"horizontal":"left","vertical":"top"}} + onRequestClose={e => this.handleMainPopoverOpen(false)} + anchorOrigin={{ "horizontal":"left","vertical":"bottom" }} + targetOrigin={{ "horizontal":"left","vertical":"top" }} > {this.defaultMenus()} @@ -361,5 +347,5 @@ export default class NetPyNEInclude extends Component { {this.otherMenus()}
- }; -}; + } +} diff --git a/components/definition/plots/NetPyNENewPlot.js b/components/definition/plots/NetPyNENewPlot.js index 7a248469..9e664992 100644 --- a/components/definition/plots/NetPyNENewPlot.js +++ b/components/definition/plots/NetPyNENewPlot.js @@ -7,16 +7,14 @@ import FloatingActionButton from 'material-ui/FloatingActionButton'; export default class NetPyNENewPlot extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - open: false, - }; + this.state = { open: false, }; this.handleClick = this.handleClick.bind(this); this.handleButtonClick = this.handleButtonClick.bind(this); - }; + } - handleButtonClick = (event) => { + handleButtonClick = event => { // This prevents ghost click. event.preventDefault(); this.setState({ @@ -26,30 +24,28 @@ export default class NetPyNENewPlot extends React.Component { }; handleRequestClose = () => { - this.setState({ - open: false, - }); + this.setState({ open: false, }); }; - handleClick(event, value) { + handleClick (event, value) { this.handleRequestClose(); this.props.handleClick(value); - }; + } - render() { + render () { return
- + - + @@ -62,5 +58,5 @@ export default class NetPyNENewPlot extends React.Component {
- }; -}; + } +} diff --git a/components/definition/plots/NetPyNEPlotThumbnail.js b/components/definition/plots/NetPyNEPlotThumbnail.js index 64c44f24..2fcf8d52 100644 --- a/components/definition/plots/NetPyNEPlotThumbnail.js +++ b/components/definition/plots/NetPyNEPlotThumbnail.js @@ -6,16 +6,16 @@ const hoverColor = '#66d2e2'; const changeColor = 'rgb(0, 188, 212)'; export default class NetPyNEPlotThumbnail extends React.Component { - constructor(props) { + constructor (props) { super(props); this.handleClick = this.handleClick.bind(this); - }; + } - handleClick() { + handleClick () { this.props.handleClick(this.props.name); - }; + } - render() { + render () { return ( {this.props.name} ); - }; -}; + } +} diff --git a/components/definition/plots/NetPyNEPlots.js b/components/definition/plots/NetPyNEPlots.js index b70a46a9..9dac8a85 100644 --- a/components/definition/plots/NetPyNEPlots.js +++ b/components/definition/plots/NetPyNEPlots.js @@ -17,7 +17,7 @@ import NetPyNEPlotThumbnail from './NetPyNEPlotThumbnail'; export default class NetPyNEPlots extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { selectedPlot: undefined, @@ -25,27 +25,25 @@ export default class NetPyNEPlots extends React.Component { }; this.selectPlot = this.selectPlot.bind(this); this.handleNewPlot = this.handleNewPlot.bind(this); - }; + } - selectPlot(plot) { + selectPlot (plot) { this.setState({ selectedPlot: plot }); - }; + } - handleNewPlot(plot) { + handleNewPlot (plot) { if (this.state.value != undefined) { var model = this.state.value; model[plot] = true; } else { var model = { plot: true } - }; + } Utils .evalPythonMessage("netpyne_geppetto.getAvailablePlots", []) - .then((response) => { + .then(response => { if (response.includes(plot)) { if (plot == "plotLFP") { - var include = { - 'electrodes': ['all'] - } + var include = { 'electrodes': ['all'] } } else if (plot == "plotShape") { var include = { 'includePre': ['all'], @@ -57,10 +55,8 @@ export default class NetPyNEPlots extends React.Component { 'cells2': ['allCells'] } } else { - var include = { - 'include': ['all'] - } - }; + var include = { 'include': ['all'] } + } Utils.execPythonMessage("netpyne_geppetto.simConfig.analysis['" + plot + "'] = " + JSON.stringify(include)); } }); @@ -68,57 +64,57 @@ export default class NetPyNEPlots extends React.Component { value: model, selectedPlot: plot }); - }; + } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var newItemCreated = false; var selectionChanged = this.state.selectedPlot != nextState.selectedPlot; var pageChanged = this.state.page != nextState.page; var newModel = this.state.value == undefined; if (!newModel) { - newItemCreated = Object.keys(this.state.value).length != Object.keys(nextState.value).length; + newItemCreated = Object.keys(this.state.value).length != Object.keys(nextState.value).length; } - return newModel || newItemCreated || selectionChanged || pageChanged;; - }; + return newModel || newItemCreated || selectionChanged || pageChanged; + } - render() { + render () { var plots = []; for (var c in this.state.value) { plots.push(); - }; + } switch (this.state.selectedPlot) { - case "plotRaster": - var selectedPlot = - break; - case "plotSpikeHist": - var selectedPlot = - break; - case "plotSpikeStats": - var selectedPlot = - break; - case "plotRatePSD": - var selectedPlot = - break; - case "plotTraces": - var selectedPlot = - break; - case "plotLFP": - var selectedPlot = - break; - case "plotShape": - var selectedPlot = - break; - case "plotConn": - var selectedPlot = - break; - case "plot2Dnet": - var selectedPlot = - break; - case "granger": - var selectedPlot = - break; - }; + case "plotRaster": + var selectedPlot = + break; + case "plotSpikeHist": + var selectedPlot = + break; + case "plotSpikeStats": + var selectedPlot = + break; + case "plotRatePSD": + var selectedPlot = + break; + case "plotTraces": + var selectedPlot = + break; + case "plotLFP": + var selectedPlot = + break; + case "plotShape": + var selectedPlot = + break; + case "plotConn": + var selectedPlot = + break; + case "plot2Dnet": + var selectedPlot = + break; + case "granger": + var selectedPlot = + break; + } return ( @@ -150,5 +146,5 @@ export default class NetPyNEPlots extends React.Component { ); - }; -}; + } +} diff --git a/components/definition/plots/TimeRange.js b/components/definition/plots/TimeRange.js index fb53ab86..686e3e09 100644 --- a/components/definition/plots/TimeRange.js +++ b/components/definition/plots/TimeRange.js @@ -7,16 +7,16 @@ var PythonControlledAdapterComponent = PythonControlledCapability.createPythonCo export default class TimeRange extends Component { - constructor(props) { + constructor (props) { super(props); - }; + } - render() { + render () { return (
{ + convertToPython={state => { if (state[state.lastUpdated].toString().endsWith(".")) { return undefined; } @@ -30,10 +30,10 @@ export default class TimeRange extends Component { } }} > - - + +
); - }; -}; + } +} diff --git a/components/definition/plots/plotTypes/Plot2Dnet.js b/components/definition/plots/plotTypes/Plot2Dnet.js index 31a14a9f..184142de 100644 --- a/components/definition/plots/plotTypes/Plot2Dnet.js +++ b/components/definition/plots/plotTypes/Plot2Dnet.js @@ -4,35 +4,34 @@ import SelectField from 'material-ui/SelectField'; import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); export default class Plot2Dnet extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plot2Dnet']" return
- + - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotConn.js b/components/definition/plots/plotTypes/PlotConn.js index f5aea46a..efdb6ef7 100644 --- a/components/definition/plots/plotTypes/PlotConn.js +++ b/components/definition/plots/plotTypes/PlotConn.js @@ -3,38 +3,37 @@ import SelectField from 'material-ui/SelectField'; import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); export default class plotConn extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotConn']" return
- + - - - + + + - - - + + + - - - -
- }; -}; + + + +
+ } +} diff --git a/components/definition/plots/plotTypes/PlotGranger.js b/components/definition/plots/plotTypes/PlotGranger.js index 9af2e0cc..f7054d63 100644 --- a/components/definition/plots/plotTypes/PlotGranger.js +++ b/components/definition/plots/plotTypes/PlotGranger.js @@ -4,19 +4,18 @@ import TimeRange from '../TimeRange' import ListComponent from '../../../general/List'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledListComponent = PythonControlledCapability.createPythonControlledControl(ListComponent); export default class PlotGranger extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tags = "simConfig.analysis['granger']" var content = (
@@ -55,5 +54,5 @@ export default class PlotGranger extends React.Component { ); return content; - }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotLFP.js b/components/definition/plots/plotTypes/PlotLFP.js index 1df43550..cae3a9d0 100644 --- a/components/definition/plots/plotTypes/PlotLFP.js +++ b/components/definition/plots/plotTypes/PlotLFP.js @@ -6,7 +6,7 @@ import TimeRange from '../TimeRange' import ListComponent from '../../../general/List'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledListComponent = PythonControlledCapability.createPythonControlledControl(ListComponent); @@ -14,14 +14,12 @@ var PythonControlledSelectField = PythonControlledCapability.createPythonControl export default class PlotLFP extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - plots: '', - }; - }; + this.state = { plots: '', }; + } - render() { + render () { var tag = "simConfig.analysis['plotLFP']" return
@@ -29,7 +27,7 @@ export default class PlotLFP extends React.Component { - + @@ -61,8 +59,8 @@ export default class PlotLFP extends React.Component { - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotRaster.js b/components/definition/plots/plotTypes/PlotRaster.js index 6ea99e9e..ad3be829 100644 --- a/components/definition/plots/plotTypes/PlotRaster.js +++ b/components/definition/plots/plotTypes/PlotRaster.js @@ -6,31 +6,29 @@ import TimeRange from '../TimeRange' import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); export default class PlotRaster extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - checked: false, - }; + this.state = { checked: false, }; this.handleCheckChange = this.handleCheckChange.bind(this); - }; + } handleCheckChange = (event, isCheck) => { - this.setState({Checked: isCheck}) + this.setState({ Checked: isCheck }) }; - render() { + render () { var tag = "simConfig.analysis['plotRaster']" return
@@ -44,15 +42,15 @@ export default class PlotRaster extends React.Component { - + - + - + @@ -60,12 +58,12 @@ export default class PlotRaster extends React.Component { - + - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotRatePSD.js b/components/definition/plots/plotTypes/PlotRatePSD.js index 71d41dae..ca88cdc2 100644 --- a/components/definition/plots/plotTypes/PlotRatePSD.js +++ b/components/definition/plots/plotTypes/PlotRatePSD.js @@ -5,24 +5,23 @@ import TimeRange from '../TimeRange' import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); export default class PlotRatePSD extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotRatePSD']" return
@@ -52,8 +51,8 @@ export default class PlotRatePSD extends React.Component { - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotShape.js b/components/definition/plots/plotTypes/PlotShape.js index 3f270191..63e49938 100644 --- a/components/definition/plots/plotTypes/PlotShape.js +++ b/components/definition/plots/plotTypes/PlotShape.js @@ -5,7 +5,7 @@ import SelectField from 'material-ui/SelectField'; import ListComponent from '../../../general/List'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); @@ -13,21 +13,20 @@ var PythonControlledListComponent = PythonControlledCapability.createPythonContr export default class PlotShape extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotShape']" return
- + - + @@ -59,20 +58,20 @@ export default class PlotShape extends React.Component { - + - + - + - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotSpikeHist.js b/components/definition/plots/plotTypes/PlotSpikeHist.js index 3fdcaeac..93669f46 100644 --- a/components/definition/plots/plotTypes/PlotSpikeHist.js +++ b/components/definition/plots/plotTypes/PlotSpikeHist.js @@ -6,25 +6,24 @@ import TimeRange from '../TimeRange' import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); export default class PlotSpikeHist extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotSpikeHist']" return
@@ -46,8 +45,8 @@ export default class PlotSpikeHist extends React.Component { - +
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotSpikeStats.js b/components/definition/plots/plotTypes/PlotSpikeStats.js index d2c62546..d10d8898 100644 --- a/components/definition/plots/plotTypes/PlotSpikeStats.js +++ b/components/definition/plots/plotTypes/PlotSpikeStats.js @@ -6,25 +6,24 @@ import NetPyNEInclude from '../NetPyNEInclude'; import ListComponent from '../../../general/List'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); var PythonControlledListComponent = PythonControlledCapability.createPythonControlledControl(ListComponent); export default class PlotSpikeStats extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotSpikeStats']" return
@@ -45,5 +44,5 @@ export default class PlotSpikeStats extends React.Component {
- }; -}; + } +} diff --git a/components/definition/plots/plotTypes/PlotTraces.js b/components/definition/plots/plotTypes/PlotTraces.js index 141932d6..4f6884aa 100644 --- a/components/definition/plots/plotTypes/PlotTraces.js +++ b/components/definition/plots/plotTypes/PlotTraces.js @@ -6,25 +6,24 @@ import TimeRange from '../TimeRange' import NetPyNEInclude from '../NetPyNEInclude'; import NetPyNEField from '../../../general/NetPyNEField'; -var PythonControlledCapability = require('../../../../../../js/communication/geppettoJupyter/PythonControlledCapability'); +var PythonControlledCapability = require('geppetto-client/js//communication/geppettoJupyter/PythonControlledCapability'); var PythonControlledCheckbox = PythonControlledCapability.createPythonControlledControl(Checkbox); var PythonControlledTextField = PythonControlledCapability.createPythonControlledControl(TextField); var PythonControlledSelectField = PythonControlledCapability.createPythonControlledControl(SelectField); export default class PlotTraces extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; - }; + this.state = {}; + } - render() { + render () { var tag = "simConfig.analysis['plotTraces']" return
@@ -34,16 +33,16 @@ export default class PlotTraces extends React.Component { - + - + - +
- }; -}; + } +} diff --git a/components/definition/populations/Dimensions.js b/components/definition/populations/Dimensions.js index cd7455f2..0d0dffac 100644 --- a/components/definition/populations/Dimensions.js +++ b/components/definition/populations/Dimensions.js @@ -12,95 +12,94 @@ var PythonControlledTextField = PythonControlledCapability.createPythonControlle */ export default class DimensionsComponent extends Component { - constructor(props) { - super(props); - this.state = { - modelName: props.modelName, - dimension: null - }; - this.popDimensionsOptions = [{ label: 'Number of cells', value: 'numCells' }, { label: 'Density', value: 'density' }, { label: 'Grid spacing', value: 'gridSpacing' }]; + constructor (props) { + super(props); + this.state = { + modelName: props.modelName, + dimension: null + }; + this.popDimensionsOptions = [{ label: 'Number of cells', value: 'numCells' }, { label: 'Density', value: 'density' }, { label: 'Grid spacing', value: 'gridSpacing' }]; - } + } - componentDidUpdate(prevProps, prevState) { - if (this.state.modelName != prevState.modelName) { - this.updateLayout(); - } + componentDidUpdate (prevProps, prevState) { + if (this.state.modelName != prevState.modelName) { + this.updateLayout(); } + } - componentDidMount() { - this.updateLayout(); - } + componentDidMount () { + this.updateLayout(); + } - componentWillReceiveProps(nextProps) { - if (this.state.modelName != nextProps.modelName) { - this.setState({ modelName: nextProps.modelName, dimension: null }); - } + componentWillReceiveProps (nextProps) { + if (this.state.modelName != nextProps.modelName) { + this.setState({ modelName: nextProps.modelName, dimension: null }); } + } - updateLayout() { - let requests = this.popDimensionsOptions.map((popDimensionsOption) => { - //FIXME Better to wrap calls rather than directly accessing objects - return Utils - .evalPythonMessage("'" + popDimensionsOption.value + "' in netpyne_geppetto.netParams.popParams['" + this.state.modelName + "']"); + updateLayout () { + let requests = this.popDimensionsOptions.map(popDimensionsOption => + // FIXME Better to wrap calls rather than directly accessing objects + Utils + .evalPythonMessage("'" + popDimensionsOption.value + "' in netpyne_geppetto.netParams.popParams['" + this.state.modelName + "']") - }); + ); - // Get population dimension by asking each for each key - Promise.all(requests).then((values) => { - var index = values.indexOf(true); - if (index == -1) { - this.setState({ dimension: null }); - } - else { - this.setState({ dimension: this.popDimensionsOptions[index].value }); - } - }); - } + // Get population dimension by asking each for each key + Promise.all(requests).then(values => { + var index = values.indexOf(true); + if (index == -1) { + this.setState({ dimension: null }); + } else { + this.setState({ dimension: this.popDimensionsOptions[index].value }); + } + }); + } - render() { + render () { - return ( -
- - this.setState({ dimension: value })} - > - {(this.popDimensionsOptions != undefined) ? - this.popDimensionsOptions.map(function (popDimensionsOption) { - return () - }) : null} - - - { - this.state.dimension != undefined && this.state.dimension != "" ? - - { - // Set Population Dimension Python Side - Utils - .evalPythonMessage('netpyne_geppetto.netParams.popParams.setParam', [this.props.modelName, this.props.dimensionType, newValue]) - .then(function (response) { - GEPPETTO.trigger("population_update_dimension") - }); - }); - }} - model={"netParams.popParams['" + this.state.modelName + "']['" + this.state.dimension + "']"} - modelName={this.state.modelName} - dimensionType={this.state.dimension} - /> - - : null - } -
- ) - } + return ( +
+ + this.setState({ dimension: value })} + > + {(this.popDimensionsOptions != undefined) + ? this.popDimensionsOptions.map(function (popDimensionsOption) { + return () + }) : null} + + + { + this.state.dimension != undefined && this.state.dimension != "" + ? + { + // Set Population Dimension Python Side + Utils + .evalPythonMessage('netpyne_geppetto.netParams.popParams.setParam', [this.props.modelName, this.props.dimensionType, newValue]) + .then(function (response) { + GEPPETTO.trigger("population_update_dimension") + }); + }); + }} + model={"netParams.popParams['" + this.state.modelName + "']['" + this.state.dimension + "']"} + modelName={this.state.modelName} + dimensionType={this.state.dimension} + /> + + : null + } +
+ ) + } } diff --git a/components/definition/populations/NetPyNEPopulation.js b/components/definition/populations/NetPyNEPopulation.js index 0be7ed48..76e07dc8 100644 --- a/components/definition/populations/NetPyNEPopulation.js +++ b/components/definition/populations/NetPyNEPopulation.js @@ -17,7 +17,7 @@ var PythonControlledTextField = PythonControlledCapability.createPythonControlle export default class NetPyNEPopulation extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { currentName: props.name, @@ -28,17 +28,17 @@ export default class NetPyNEPopulation extends React.Component { }; } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps (nextProps) { this.setState({ currentName: nextProps.name, selectedIndex: 0, sectionId: "General" }); } - setPopulationDimension = (value) => { - //this.setState({ cellModel: value }); + setPopulationDimension = value => { + // this.setState({ cellModel: value }); this.triggerUpdate(() => { // Set Population Dimension Python Side Utils .evalPythonMessage('api.getParametersForCellModel', [value]) - .then((response) => { + .then(response => { var cellModelFields = ""; if (Object.keys(response).length != 0) { @@ -47,13 +47,11 @@ export default class NetPyNEPopulation extends React.Component { // console.log("New Metadata", window.metadata); cellModelFields = []; // Get Fields for new metadata - cellModelFields = Utils.getFieldsFromMetadataTree(response, (key) => { - return ( - - ); - }); + cellModelFields = Utils.getFieldsFromMetadataTree(response, key => ( + + )); } this.setState({ cellModelFields: cellModelFields, cellModel: value }); }); @@ -75,41 +73,41 @@ export default class NetPyNEPopulation extends React.Component { return modelParameters; } - shouldComponentUpdate(nextProps, nextState) { - return this.state.model == undefined || - this.state.currentName != nextState.currentName || - this.state.cellModelFields != nextState.cellModelFields || - this.state.sectionId != nextState.sectionId || - this.state.selectedIndex != nextState.selectedIndex; + shouldComponentUpdate (nextProps, nextState) { + return this.state.model == undefined + || this.state.currentName != nextState.currentName + || this.state.cellModelFields != nextState.cellModelFields + || this.state.sectionId != nextState.sectionId + || this.state.selectedIndex != nextState.selectedIndex; } - handleRenameChange = (event) => { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "Population"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { // Rename the population in Python Utils.renameKey('netParams.popParams', storedValue, newValue, (response, newValue) => { this.renaming = false GEPPETTO.trigger('populations_change'); - }); + }); this.renaming = true; }); } } - triggerUpdate(updateMethod) { - //common strategy when triggering processing of a value change, delay it, every time there is a change we reset + triggerUpdate (updateMethod) { + // common strategy when triggering processing of a value change, delay it, every time there is a change we reset if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); } this.updateTimer = setTimeout(updateMethod, 1000); } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; if (this.state.sectionId == "General") { - var content = -
+ var content + =
{dialogPop}
- } - else if (this.state.sectionId == "SpatialDistribution") { - var content = -
+ } else if (this.state.sectionId == "SpatialDistribution") { + var content + =
@@ -181,8 +178,8 @@ export default class NetPyNEPopulation extends React.Component { name={this.props.name} model={'netParams.popParams'} items={[ - {value: 'yRange', label:'Absolute'}, - {value: 'ynormRange', label:'Normalized'} + { value: 'yRange', label:'Absolute' }, + { value: 'ynormRange', label:'Normalized' } ]} /> @@ -191,16 +188,14 @@ export default class NetPyNEPopulation extends React.Component { name={this.props.name} model={'netParams.popParams'} items={[ - {value: 'zRange', label:'Absolute'}, - {value: 'znormRange', label:'Normalized'} + { value: 'zRange', label:'Absolute' }, + { value: 'znormRange', label:'Normalized' } ]} />
- } - else if (this.state.sectionId == "CellList") { + } else if (this.state.sectionId == "CellList") { var content =
Option to provide individual list of cells. Coming soon ...
- } - else { + } else { var content =
{this.state.cellModelFields}
; } diff --git a/components/definition/populations/NetPyNEPopulations.js b/components/definition/populations/NetPyNEPopulations.js index f200e6ed..b7787fc3 100644 --- a/components/definition/populations/NetPyNEPopulations.js +++ b/components/definition/populations/NetPyNEPopulations.js @@ -10,7 +10,7 @@ import RaisedButton from 'material-ui/RaisedButton/RaisedButton'; export default class NetPyNEPopulations extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { drawerOpen: false, @@ -29,15 +29,15 @@ export default class NetPyNEPopulations extends React.Component { handleToggle = () => this.setState({ drawerOpen: !this.state.drawerOpen }); - hasSelectedPopulationBeenRenamed(prevState, currentState) { + hasSelectedPopulationBeenRenamed (prevState, currentState) { var currentModel = prevState.value; var model = currentState.value; - //deal with rename + // deal with rename if (currentModel != undefined && model != undefined) { var oldP = Object.keys(currentModel); var newP = Object.keys(model); if (oldP.length == newP.length) { - //if it's the same lenght there could be a rename + // if it's the same lenght there could be a rename for (var i = 0; i < oldP.length; i++) { if (oldP[i] != newP[i]) { if (prevState.selectedPopulation != undefined) { @@ -52,37 +52,42 @@ export default class NetPyNEPopulations extends React.Component { return undefined; } - componentDidUpdate(prevProps, prevState) { - //we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable + componentDidUpdate (prevProps, prevState) { + // we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable var newPopulationName = this.hasSelectedPopulationBeenRenamed(prevState, this.state); if (newPopulationName !== undefined) { this.setState({ selectedPopulation: newPopulationName, - populationDeleted: undefined }); - } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { - // logic into this if to check if the user added a new object from the python backend and - // if the name convention pass the checks, differently rename this and open dialog to inform. + populationDeleted: undefined + }); + } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { + /* + * logic into this if to check if the user added a new object from the python backend and + * if the name convention pass the checks, differently rename this and open dialog to inform. + */ var model = this.state.value; - for(var m in model) { - if((prevState.value !== "") && (!(m in prevState.value))) { + for (var m in model) { + if ((prevState.value !== "") && (!(m in prevState.value))) { var newValue = Utils.nameValidation(model[m].name); - if(newValue != model[m].name) { + if (newValue != model[m].name) { newValue = Utils.getAvailableKey(model, newValue); model[newValue] = model[m]; model[newValue].name = newValue; delete model[m]; - this.setState({ value: model, - errorMessage: "Error", - errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + - m + " has been renamed " + newValue}, - () => Utils.renameKey('netParams.popParams', m, newValue, (response, newValue) => GEPPETTO.trigger('populations_change'))); + this.setState({ + value: model, + errorMessage: "Error", + errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + + m + " has been renamed " + newValue + }, + () => Utils.renameKey('netParams.popParams', m, newValue, (response, newValue) => GEPPETTO.trigger('populations_change'))); } } } } } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var itemRenamed = this.hasSelectedPopulationBeenRenamed(this.state, nextState) !== undefined; var newItemCreated = false; var selectionChanged = this.state.selectedPopulation != nextState.selectedPopulation; @@ -91,11 +96,11 @@ export default class NetPyNEPopulations extends React.Component { newItemCreated = ((Object.keys(this.state.value).length != Object.keys(nextState.value).length)); } // check if the dialog has been triggered due name convention or name collision errors. - var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false; + var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails); return newModel || newItemCreated || itemRenamed || selectionChanged || errorDialogOpen; } - handleNewPopulation() { + handleNewPopulation () { var defaultPopulationValues = { 'Population': { 'cellModel': '', 'cellType': '' } } // Get Key and Value var key = Object.keys(defaultPopulationValues)[0]; @@ -117,37 +122,37 @@ export default class NetPyNEPopulations extends React.Component { this.setState({ value: model, selectedPopulation: populationId - }, ()=> GEPPETTO.trigger('populations_change')); + }, () => GEPPETTO.trigger('populations_change')); } /* Method that handles button click */ - selectPopulation(populationName) { - this.setState({selectedPopulation: populationName}); + selectPopulation (populationName) { + this.setState({ selectedPopulation: populationName }); } - deletePopulation(name) { - Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ["popParams", name]).then((response) =>{ + deletePopulation (name) { + Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ["popParams", name]).then(response => { if (response) { var model = this.state.value; delete model[name]; - this.setState({value: model, selectedPopulation: undefined, populationDeleted: name}, ()=> GEPPETTO.trigger('populations_change')); + this.setState({ value: model, selectedPopulation: undefined, populationDeleted: name }, () => GEPPETTO.trigger('populations_change')); } }); } - handleRenameChildren(childName) { + handleRenameChildren (childName) { childName = childName.replace(/\s*$/,""); var childrenList = Object.keys(this.state.value); - for(var i=0 ; childrenList.length > i ; i++) { - if(childName === childrenList[i]) { + for (var i = 0 ; childrenList.length > i ; i++) { + if (childName === childrenList[i]) { return false; } } return true; } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; if (this.state.value != undefined && this.state.value !== '') { var model = this.state.value; @@ -180,7 +185,7 @@ export default class NetPyNEPopulations extends React.Component { handleClick={this.selectPopulation} />); } var selectedPopulation = undefined; - if ((this.state.selectedPopulation !== undefined) && Object.keys(model).indexOf(this.state.selectedPopulation)>-1) { + if ((this.state.selectedPopulation !== undefined) && Object.keys(model).indexOf(this.state.selectedPopulation) > -1) { selectedPopulation = ; } } @@ -202,7 +207,7 @@ export default class NetPyNEPopulations extends React.Component {
this.setState({selectedPopulation: undefined})} + handleClick={() => this.setState({ selectedPopulation: undefined })} /> { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "StimulationSource"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { Utils.renameKey('netParams.stimSourceParams', storedValue, newValue, (response, newValue) => { this.renaming = false GEPPETTO.trigger('stimSources_change'); }); this.renaming = true; - // Update layout has been inserted in the triggerUpdate since this will have to query the backend - // So we need to delay this along with the rename, differently we will face a key issue with netpyne + /* + * Update layout has been inserted in the triggerUpdate since this will have to query the backend + * So we need to delay this along with the rename, differently we will face a key issue with netpyne + */ this.updateLayout(); }); } }; - triggerUpdate(updateMethod) { + triggerUpdate (updateMethod) { if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); - }; + } this.updateTimer = setTimeout(updateMethod, 1000); - }; + } - componentDidMount() { + componentDidMount () { this.updateLayout(); - }; + } - updateLayout() { - var opts = this.stimSourceTypeOptions.map((option) => { return option.type }); + updateLayout () { + var opts = this.stimSourceTypeOptions.map(option => option.type); Utils - .evalPythonMessage("[value == netpyne_geppetto.netParams.stimSourceParams['" + this.state.currentName + "']['type'] for value in "+JSON.stringify(opts)+"]") - .then((responses) => { + .evalPythonMessage("[value == netpyne_geppetto.netParams.stimSourceParams['" + this.state.currentName + "']['type'] for value in " + JSON.stringify(opts) + "]") + .then(responses => { if (responses.constructor.name == "Array"){ responses.forEach( (response, index) => { - if (response && this.state.sourceType!=opts[index]) { + if (response && this.state.sourceType != opts[index]) { this.setState({ sourceType: opts[index] }) } }) } - }); - }; + }); + } - handleStimSourceTypeChange(event, index, value) { + handleStimSourceTypeChange (event, index, value) { Utils.execPythonMessage("netpyne_geppetto.netParams.stimSourceParams['" + this.state.currentName + "']['type'] = '" + value + "'"); this.setState({ sourceType: value }); GEPPETTO.trigger('stimSources_change', this.state.currentName); - }; + } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; if (this.state.sourceType == 'IClamp') { var variableContent = ( @@ -235,8 +237,7 @@ export default class NetPyNEStimulationSource extends React.Component {
); - } - else if (this.state.sourceType == 'SEClamp') { + } else if (this.state.sourceType == 'SEClamp') { var variableContent = (
@@ -259,10 +260,9 @@ export default class NetPyNEStimulationSource extends React.Component {
) - } - else { + } else { var variableContent =
- }; + } return (
@@ -283,9 +283,9 @@ export default class NetPyNEStimulationSource extends React.Component { value={this.state.sourceType} onChange={this.handleStimSourceTypeChange} > - {(this.stimSourceTypeOptions != undefined) ? - this.stimSourceTypeOptions.map(function (stimSourceTypeOption) { - return () + {(this.stimSourceTypeOptions != undefined) + ? this.stimSourceTypeOptions.map(function (stimSourceTypeOption) { + return () }) : null } @@ -295,5 +295,5 @@ export default class NetPyNEStimulationSource extends React.Component { {dialogPop}
); - }; -}; + } +} diff --git a/components/definition/stimulationSources/NetPyNEStimulationSources.js b/components/definition/stimulationSources/NetPyNEStimulationSources.js index caf4894c..728c9999 100644 --- a/components/definition/stimulationSources/NetPyNEStimulationSources.js +++ b/components/definition/stimulationSources/NetPyNEStimulationSources.js @@ -11,7 +11,7 @@ import RaisedButton from 'material-ui/RaisedButton/RaisedButton'; export default class NetPyNEStimulationSources extends Component { - constructor(props) { + constructor (props) { super(props); this.state = { selectedStimulationSource: undefined, @@ -25,78 +25,82 @@ export default class NetPyNEStimulationSources extends Component { this.deleteStimulationSource = this.deleteStimulationSource.bind(this); this.handleRenameChildren = this.handleRenameChildren.bind(this); - }; + } /* Method that handles button click */ - selectStimulationSource(StimulationSource) { - this.setState({selectedStimulationSource: StimulationSource}); - }; + selectStimulationSource (StimulationSource) { + this.setState({ selectedStimulationSource: StimulationSource }); + } - handleNewStimulationSource() { - var defaultStimulationSources = { 'stim_source': { 'type': ''}}; + handleNewStimulationSource () { + var defaultStimulationSources = { 'stim_source': { 'type': '' } }; var key = Object.keys(defaultStimulationSources)[0]; var value = defaultStimulationSources[key]; var model = this.state.value; var StimulationSourceId = Utils.getAvailableKey(model, key); - var newStimulationSource = Object.assign({name: StimulationSourceId}, value); + var newStimulationSource = Object.assign({ name: StimulationSourceId }, value); Utils.execPythonMessage('netpyne_geppetto.netParams.stimSourceParams["' + StimulationSourceId + '"] = ' + JSON.stringify(value)); model[StimulationSourceId] = newStimulationSource; this.setState({ value: model, selectedStimulationSource: StimulationSourceId - }, ()=> GEPPETTO.trigger('stimSources_change')); - }; + }, () => GEPPETTO.trigger('stimSources_change')); + } - hasSelectedStimulationSourceBeenRenamed(prevState, currentState) { + hasSelectedStimulationSourceBeenRenamed (prevState, currentState) { var currentModel = prevState.value; var model = currentState.value; - //deal with rename + // deal with rename if (currentModel != undefined && model != undefined) { var oldP = Object.keys(currentModel); var newP = Object.keys(model); if (oldP.length == newP.length) { - //if it's the same lenght there could be a rename + // if it's the same lenght there could be a rename for (var i = 0; i < oldP.length; i++) { if (oldP[i] != newP[i]) { if (prevState.selectedStimulationSource != undefined) { if (oldP[i] == prevState.selectedStimulationSource) { return newP[i]; - }; - }; - }; - }; - }; - }; + } + } + } + } + } + } return undefined; - }; + } - componentDidUpdate(prevProps, prevState) { + componentDidUpdate (prevProps, prevState) { var newStimulationSourceName = this.hasSelectedStimulationSourceBeenRenamed(prevState, this.state); if (newStimulationSourceName !== undefined) { this.setState({ selectedStimulationSource: newStimulationSourceName, deletedStimulationSource: undefined }); - } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { - // logic into this if to check if the user added a new object from the python backend and - // if the name convention pass the checks, differently rename this and open dialog to inform. + } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { + /* + * logic into this if to check if the user added a new object from the python backend and + * if the name convention pass the checks, differently rename this and open dialog to inform. + */ var model = this.state.value; - for(var m in model) { - if((prevState.value !== "") && (!(m in prevState.value))) { + for (var m in model) { + if ((prevState.value !== "") && (!(m in prevState.value))) { var newValue = Utils.nameValidation(m); - if(newValue != m) { + if (newValue != m) { newValue = Utils.getAvailableKey(model, newValue); model[newValue] = model[m]; delete model[m]; - this.setState({ value: model, - errorMessage: "Error", - errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + - m + " has been renamed " + newValue}, - () => Utils.renameKey('netParams.stimSourceParams', m, newValue, (response, newValue) => GEPPETTO.trigger('stimSources_change'))); + this.setState({ + value: model, + errorMessage: "Error", + errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + + m + " has been renamed " + newValue + }, + () => Utils.renameKey('netParams.stimSourceParams', m, newValue, (response, newValue) => GEPPETTO.trigger('stimSources_change'))); } } } } - }; + } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var itemRenamed = this.hasSelectedStimulationSourceBeenRenamed(this.state, nextState) !== undefined; var newItemCreated = false; var selectionChanged = this.state.selectedStimulationSource != nextState.selectedStimulationSource; @@ -104,31 +108,31 @@ export default class NetPyNEStimulationSources extends Component { var newModel = this.state.value == undefined; if (!newModel) { newItemCreated = ((Object.keys(this.state.value).length != Object.keys(nextState.value).length)); - }; - var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false; + } + var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails); return newModel || newItemCreated || itemRenamed || selectionChanged || pageChanged || errorDialogOpen; - }; + } - deleteStimulationSource(name) { - Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['stimSourceParams', name]).then((response) =>{ + deleteStimulationSource (name) { + Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['stimSourceParams', name]).then(response => { var model = this.state.value; delete model[name]; - this.setState({value: model, selectedStimulationSource: undefined, deletedStimulationSource: name}, ()=> GEPPETTO.trigger('stimSources_change')); + this.setState({ value: model, selectedStimulationSource: undefined, deletedStimulationSource: name }, () => GEPPETTO.trigger('stimSources_change')); }); } - handleRenameChildren(childName) { + handleRenameChildren (childName) { childName = childName.replace(/\s*$/,""); var childrenList = Object.keys(this.state.value); - for(var i=0 ; childrenList.length > i ; i++) { - if(childName === childrenList[i]) { + for (var i = 0 ; childrenList.length > i ; i++) { + if (childName === childrenList[i]) { return false; } } return true; } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; var model = this.state.value; var StimulationSources = []; @@ -156,12 +160,12 @@ export default class NetPyNEStimulationSources extends Component { selected={c == this.state.selectedStimulationSource} deleteMethod={this.deleteStimulationSource} handleClick={this.selectStimulationSource} />); - }; + } var selectedStimulationSource = undefined; - if ((this.state.selectedStimulationSource !== undefined) && Object.keys(model).indexOf(this.state.selectedStimulationSource)>-1) { + if ((this.state.selectedStimulationSource !== undefined) && Object.keys(model).indexOf(this.state.selectedStimulationSource) > -1) { selectedStimulationSource = ; - }; + } var content = ( @@ -172,7 +176,7 @@ export default class NetPyNEStimulationSources extends Component {
this.setState({selectedStimulationSource: undefined})} + handleClick={() => this.setState({ selectedStimulationSource: undefined })} /> ); - }; -}; \ No newline at end of file + } +} \ No newline at end of file diff --git a/components/definition/stimulationTargets/NetPyNEStimulationTarget.js b/components/definition/stimulationTargets/NetPyNEStimulationTarget.js index 3f24d8ea..ea99454e 100644 --- a/components/definition/stimulationTargets/NetPyNEStimulationTarget.js +++ b/components/definition/stimulationTargets/NetPyNEStimulationTarget.js @@ -18,7 +18,7 @@ var PythonMethodControlledSelectField = PythonControlledCapability.createPythonC export default class NetPyNEStimulationTarget extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { currentName: props.name, @@ -32,9 +32,9 @@ export default class NetPyNEStimulationTarget extends React.Component { this.postProcessMenuItems4SynMech = this.postProcessMenuItems4SynMech.bind(this); this.handleSelection = this.handleSelection.bind(this); this.select = this.select.bind(this); - }; + } - componentDidMount(){ + componentDidMount (){ GEPPETTO.on('populations_change', () => { this.forceUpdate(); }) @@ -44,8 +44,8 @@ export default class NetPyNEStimulationTarget extends React.Component { GEPPETTO.on('cellModel_change', () => { this.forceUpdate(); }) - GEPPETTO.on('stimSources_change', (stimulationSourceId) => { - this.forceUpdate(()=>{ + GEPPETTO.on('stimSources_change', stimulationSourceId => { + this.forceUpdate(() => { if (stimulationSourceId !== undefined && stimulationSourceId !== ''){ this.handleSelection(stimulationSourceId) } @@ -56,55 +56,57 @@ export default class NetPyNEStimulationTarget extends React.Component { }) } - componentWillUnmount(){ + componentWillUnmount (){ GEPPETTO.off('populations_change') GEPPETTO.off('cellType_change') GEPPETTO.off('cellModel_change') GEPPETTO.off('stimSources_change') } - componentWillReceiveProps(nextProps) { - if (this.state.currentName!=nextProps.name) { - this.setState({ currentName: nextProps.name, selectedIndex:0, sectionId:'General'}); - }; - }; + componentWillReceiveProps (nextProps) { + if (this.state.currentName != nextProps.name) { + this.setState({ currentName: nextProps.name, selectedIndex:0, sectionId:'General' }); + } + } - handleRenameChange = (event) => { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "StimulationTarget"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { - Utils.renameKey('netParams.stimTargetParams', storedValue, newValue, (response, newValue) => { this.renaming=false;}); - this.renaming=true; + Utils.renameKey('netParams.stimTargetParams', storedValue, newValue, (response, newValue) => { + this.renaming = false; + }); + this.renaming = true; }); } }; - triggerUpdate(updateMethod) { + triggerUpdate (updateMethod) { if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); - }; + } this.updateTimer = setTimeout(updateMethod, 1000); - }; + } - handleSelection = (selection) => { + handleSelection = selection => { Utils .evalPythonMessage("'NetStim' == netpyne_geppetto.netParams.stimSourceParams['" + selection + "']['type']") - .then((response) => { - this.setState({sourceTypeNetStim: response}); + .then(response => { + this.setState({ sourceTypeNetStim: response }); }); }; postProcessMenuItems = (pythonData, selected) => { - if (selected!=Object & selected!='') { + if (selected != Object & selected != ''){ this.handleSelection(selected); - }; - return pythonData.map((name) => ( + } + return pythonData.map(name => ( { - return pythonData.map((name) => ( - - )); - }; + postProcessMenuItems4SynMech = (pythonData, selected) => pythonData.map(name => ( + + )); select = (index, sectionId) => this.setState({ selectedIndex: index, sectionId: sectionId }); - getBottomNavigationItem(index, sectionId, label, icon, id) { + getBottomNavigationItem (index, sectionId, label, icon, id) { return this.select(index, sectionId)} /> - }; + } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; if (this.state.sectionId == "General") { var content = ( @@ -190,39 +190,39 @@ export default class NetPyNEStimulationTarget extends React.Component { if (this.state.sourceTypeNetStim) { var extraContent = (
- - - + + + - - - + + + - - - + + + - - - + + +
); } else { var extraContent =
- }; + } } else if (this.state.sectionId == "Conditions") { - var content = - }; + var content = + } var index = 0; var bottomNavigationItems = []; @@ -243,4 +243,4 @@ export default class NetPyNEStimulationTarget extends React.Component {
); } -}; +} diff --git a/components/definition/stimulationTargets/NetPyNEStimulationTargets.js b/components/definition/stimulationTargets/NetPyNEStimulationTargets.js index 3087273e..c6132d3b 100644 --- a/components/definition/stimulationTargets/NetPyNEStimulationTargets.js +++ b/components/definition/stimulationTargets/NetPyNEStimulationTargets.js @@ -11,10 +11,9 @@ import Dialog from 'material-ui/Dialog/Dialog'; import RaisedButton from 'material-ui/RaisedButton/RaisedButton'; - export default class NetPyNEStimulationTargets extends Component { - constructor(props) { + constructor (props) { super(props); this.state = { selectedStimulationTarget: undefined, @@ -28,112 +27,114 @@ export default class NetPyNEStimulationTargets extends Component { this.deleteStimulationTarget = this.deleteStimulationTarget.bind(this); this.handleRenameChildren = this.handleRenameChildren.bind(this); - }; + } /* Method that handles button click */ - selectStimulationTarget(StimulationTarget) { - this.setState({ - selectedStimulationTarget: StimulationTarget - }); - }; + selectStimulationTarget (StimulationTarget) { + this.setState({ selectedStimulationTarget: StimulationTarget }); + } - handleNewStimulationTarget() { - var defaultStimulationTargets = { 'stim_target': {'source': '', 'conds': {}}}; + handleNewStimulationTarget () { + var defaultStimulationTargets = { 'stim_target': { 'source': '', 'conds': {} } }; var key = Object.keys(defaultStimulationTargets)[0]; var value = defaultStimulationTargets[key]; var model = this.state.value; var StimulationTargetId = Utils.getAvailableKey(model, key); - var newStimulationTarget = Object.assign({name: StimulationTargetId}, value); + var newStimulationTarget = Object.assign({ name: StimulationTargetId }, value); Utils.execPythonMessage('netpyne_geppetto.netParams.stimTargetParams["' + StimulationTargetId + '"] = ' + JSON.stringify(value)); model[StimulationTargetId] = newStimulationTarget; this.setState({ value: model, selectedStimulationTarget: StimulationTargetId }); - }; + } - hasSelectedStimulationTargetBeenRenamed(prevState, currentState) { + hasSelectedStimulationTargetBeenRenamed (prevState, currentState) { var currentModel = prevState.value; var model = currentState.value; - //deal with rename + // deal with rename if (currentModel != undefined && model != undefined) { var oldP = Object.keys(currentModel); var newP = Object.keys(model); if (oldP.length == newP.length) { - //if it's the same lenght there could be a rename + // if it's the same lenght there could be a rename for (var i = 0; i < oldP.length; i++) { if (oldP[i] != newP[i]) { if (prevState.selectedStimulationTarget != undefined) { if (oldP[i] == prevState.selectedStimulationTarget) { return newP[i]; - }; - }; - }; - }; - }; - }; + } + } + } + } + } + } return undefined; - }; + } - componentDidUpdate(prevProps, prevState) { + componentDidUpdate (prevProps, prevState) { var newStimulationTargetName = this.hasSelectedStimulationTargetBeenRenamed(prevState, this.state); if (newStimulationTargetName !== undefined) { this.setState({ selectedStimulationTarget: newStimulationTargetName, deletedStimulationTarget: undefined }); - } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { - // logic into this if to check if the user added a new object from the python backend and - // if the name convention pass the checks, differently rename this and open dialog to inform. + } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { + /* + * logic into this if to check if the user added a new object from the python backend and + * if the name convention pass the checks, differently rename this and open dialog to inform. + */ var model = this.state.value; - for(var m in model) { - if((prevState.value !== "") && (!(m in prevState.value))) { + for (var m in model) { + if ((prevState.value !== "") && (!(m in prevState.value))) { var newValue = Utils.nameValidation(m); - if(newValue != m) { + if (newValue != m) { newValue = Utils.getAvailableKey(model, newValue); model[newValue] = model[m]; delete model[m]; - this.setState({ value: model, - errorMessage: "Error", - errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + - m + " has been renamed " + newValue}, - () => Utils.renameKey('netParams.stimTargetParams', m, newValue, (response, newValue) => {})); + this.setState({ + value: model, + errorMessage: "Error", + errorDetails: "Leading digits or whitespaces are not allowed in Population names.\n" + + m + " has been renamed " + newValue + }, + () => Utils.renameKey('netParams.stimTargetParams', m, newValue, (response, newValue) => {})); } } } } - }; + } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var itemRenamed = this.hasSelectedStimulationTargetBeenRenamed(this.state, nextState) !== undefined; var newItemCreated = false; var selectionChanged = this.state.selectedStimulationTarget != nextState.selectedStimulationTarget; var pageChanged = this.state.page != nextState.page; var newModel = this.state.value == undefined; - if(!newModel){ + if (!newModel){ newItemCreated = ((Object.keys(this.state.value).length != Object.keys(nextState.value).length)); - }; - var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false; + } + var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails); return newModel || newItemCreated || itemRenamed || selectionChanged || pageChanged || errorDialogOpen; - }; + } - deleteStimulationTarget(name) { - Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['stimTargetParams', name]).then((response) =>{ + deleteStimulationTarget (name) { + Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['stimTargetParams', name]).then(response => { var model = this.state.value; delete model[name]; - this.setState({value: model, selectedStimulationTarget: undefined, deletedStimulationTarget: name}); + this.setState({ value: model, selectedStimulationTarget: undefined, deletedStimulationTarget: name }); }); } - handleRenameChildren(childName) { + handleRenameChildren (childName) { childName = childName.replace(/\s*$/,""); var childrenList = Object.keys(this.state.value); - for(var i=0 ; childrenList.length > i ; i++) { - if(childName === childrenList[i]) { + for (var i = 0 ; childrenList.length > i ; i++) { + if (childName === childrenList[i]) { return false; } } return true; } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; var model = this.state.value; var StimulationTargets = []; @@ -161,11 +162,11 @@ export default class NetPyNEStimulationTargets extends Component { selected={c == this.state.selectedStimulationTarget} deleteMethod={this.deleteStimulationTarget} handleClick={this.selectStimulationTarget} />); - }; + } var selectedStimulationTarget = undefined; - if ((this.state.selectedStimulationTarget !== undefined) && Object.keys(model).indexOf(this.state.selectedStimulationTarget)>-1) { + if ((this.state.selectedStimulationTarget !== undefined) && Object.keys(model).indexOf(this.state.selectedStimulationTarget) > -1) { selectedStimulationTarget = ; - }; + } var content = ( @@ -176,7 +177,7 @@ export default class NetPyNEStimulationTargets extends Component {
this.setState({selectedStimulationTarget: undefined})} + handleClick={() => this.setState({ selectedStimulationTarget: undefined })} /> @@ -201,5 +202,5 @@ export default class NetPyNEStimulationTargets extends Component { {dialogPop} ); - }; -}; \ No newline at end of file + } +} \ No newline at end of file diff --git a/components/definition/stimulationTargets/StimulationConditions.js b/components/definition/stimulationTargets/StimulationConditions.js index 2a3fa1d8..db2f853d 100644 --- a/components/definition/stimulationTargets/StimulationConditions.js +++ b/components/definition/stimulationTargets/StimulationConditions.js @@ -11,17 +11,16 @@ var PythonMethodControlledSelectField = PythonControlledCapability.createPythonC export default class StimulationConditions extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; + this.state = {}; this.postProcessMenuItems = this.postProcessMenuItems.bind(this); - }; + } - postProcessMenuItems(pythonData, selected) { - return pythonData.map((name) => ( + postProcessMenuItems (pythonData, selected) { + return pythonData.map(name => ( -1} @@ -29,9 +28,9 @@ export default class StimulationConditions extends React.Component { primaryText={name} /> )); - }; + } - render() { + render () { var content = (
@@ -67,8 +66,8 @@ export default class StimulationConditions extends React.Component { model={'netParams.stimTargetParams'} conds={"conds"} items={[ - {value: 'x', label:'Absolute'}, - {value: 'xnorm', label:'Normalized'} + { value: 'x', label:'Absolute' }, + { value: 'xnorm', label:'Normalized' } ]} /> @@ -78,8 +77,8 @@ export default class StimulationConditions extends React.Component { model={'netParams.stimTargetParams'} conds={"conds"} items={[ - {value: 'y', label:'Absolute'}, - {value: 'ynorm', label:'Normalized'} + { value: 'y', label:'Absolute' }, + { value: 'ynorm', label:'Normalized' } ]} /> @@ -89,8 +88,8 @@ export default class StimulationConditions extends React.Component { model={'netParams.stimTargetParams'} conds={"conds"} items={[ - {value: 'z', label:'Absolute'}, - {value: 'znorm', label:'Normalized'} + { value: 'z', label:'Absolute' }, + { value: 'znorm', label:'Normalized' } ]} /> @@ -103,5 +102,5 @@ export default class StimulationConditions extends React.Component { ); return content; - }; -}; + } +} diff --git a/components/definition/synapses/NetPyNESynapse.js b/components/definition/synapses/NetPyNESynapse.js index 30a42a2a..46071428 100644 --- a/components/definition/synapses/NetPyNESynapse.js +++ b/components/definition/synapses/NetPyNESynapse.js @@ -12,7 +12,7 @@ var PythonControlledTextField = PythonControlledCapability.createPythonControlle export default class NetPyNESynapse extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { currentName: props.name, @@ -21,72 +21,72 @@ export default class NetPyNESynapse extends React.Component { errorDetails: undefined }; this.synMechModOptions = [ - { mod: 'Exp2Syn' }, {mod: 'ExpSyn'} + { mod: 'Exp2Syn' }, { mod: 'ExpSyn' } ]; this.handleSynMechModChange = this.handleSynMechModChange.bind(this); - }; + } - componentWillReceiveProps(nextProps) { - if (this.state.currentName!=nextProps.name){ - this.setState({ currentName: nextProps.name, synMechMod: null}); - }; - }; + componentWillReceiveProps (nextProps) { + if (this.state.currentName != nextProps.name){ + this.setState({ currentName: nextProps.name, synMechMod: null }); + } + } - handleRenameChange = (event) => { + handleRenameChange = event => { var storedValue = this.props.name; var newValue = Utils.nameValidation(event.target.value); var updateCondition = this.props.renameHandler(newValue); var triggerCondition = Utils.handleUpdate(updateCondition, newValue, event.target.value, this, "Synapses"); - if(triggerCondition) { + if (triggerCondition) { this.triggerUpdate(() => { // Rename the population in Python Utils.renameKey('netParams.synMechParams', storedValue, newValue, (response, newValue) => { - this.renaming=false; + this.renaming = false; GEPPETTO.trigger('synapses_change'); }); - this.renaming=true; - // Update layout has been inserted in the triggerUpdate since this will have to query the backend - // So we need to delay this along with the rename, differently we will face a key issue with netpyne + this.renaming = true; + /* + * Update layout has been inserted in the triggerUpdate since this will have to query the backend + * So we need to delay this along with the rename, differently we will face a key issue with netpyne + */ this.updateLayout(); }); } } - triggerUpdate(updateMethod) { - //common strategy when triggering processing of a value change, delay it, every time there is a change we reset + triggerUpdate (updateMethod) { + // common strategy when triggering processing of a value change, delay it, every time there is a change we reset if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); } this.updateTimer = setTimeout(updateMethod, 1000); - }; + } - componentDidMount() { + componentDidMount () { this.updateLayout(); - }; + } - updateLayout() { + updateLayout () { Utils .evalPythonMessage("[value == netpyne_geppetto.netParams.synMechParams['" + this.state.currentName + "']['mod'] for value in ['ExpSyn', 'Exp2Syn']]") - .then((response) => { + .then(response => { if (response[0]) { - this.setState({synMechMod: "ExpSyn"}) - } - else if(response[1]) { - this.setState({synMechMod: "Exp2Syn"}) - } - else { - this.setState({synMechMod: ""}) + this.setState({ synMechMod: "ExpSyn" }) + } else if (response[1]) { + this.setState({ synMechMod: "Exp2Syn" }) + } else { + this.setState({ synMechMod: "" }) } }); - }; + } - handleSynMechModChange(event, index, value) { + handleSynMechModChange (event, index, value) { Utils.execPythonMessage("netpyne_geppetto.netParams.synMechParams['" + this.state.currentName + "']['mod'] = '" + value + "'"); this.setState({ synMechMod: value }); - }; + } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; - if (this.state.synMechMod=='' || this.state.synMechMod==undefined) { + if (this.state.synMechMod == '' || this.state.synMechMod == undefined) { var content =
- } - else { + } else { var content = (
@@ -117,13 +116,13 @@ export default class NetPyNESynapse extends React.Component { /> - {(this.state.synMechMod=="Exp2Syn")?
+ {(this.state.synMechMod == "Exp2Syn") ?
-
: null} +
: null} ); - }; -}; + } +} diff --git a/components/definition/synapses/NetPyNESynapses.js b/components/definition/synapses/NetPyNESynapses.js index 5191b263..1b7ab07e 100644 --- a/components/definition/synapses/NetPyNESynapses.js +++ b/components/definition/synapses/NetPyNESynapses.js @@ -1,4 +1,4 @@ -import React,{ Component } from 'react'; +import React,{ Component } from 'react'; import Card, { CardHeader, CardText } from 'material-ui/Card'; import Utils from '../../../Utils'; @@ -12,7 +12,7 @@ import RaisedButton from 'material-ui/RaisedButton/RaisedButton'; export default class NetPyNESynapses extends Component { - constructor(props) { + constructor (props) { super(props); this.state = { selectedSynapse: undefined, @@ -26,78 +26,82 @@ export default class NetPyNESynapses extends Component { this.deleteSynapse = this.deleteSynapse.bind(this); this.handleRenameChildren = this.handleRenameChildren.bind(this); - }; + } /* Method that handles button click */ - selectSynapse(Synapse) { - this.setState({selectedSynapse: Synapse}); - }; + selectSynapse (Synapse) { + this.setState({ selectedSynapse: Synapse }); + } - handleNewSynapse() { - var defaultSynapses = {'Synapse': {'mod': ''}}; + handleNewSynapse () { + var defaultSynapses = { 'Synapse': { 'mod': '' } }; var key = Object.keys(defaultSynapses)[0]; var value = defaultSynapses[key]; var model = this.state.value; var SynapseId = Utils.getAvailableKey(model, key); - var newSynapse = Object.assign({name: SynapseId}, value); + var newSynapse = Object.assign({ name: SynapseId }, value); Utils.execPythonMessage('netpyne_geppetto.netParams.synMechParams["' + SynapseId + '"] = ' + JSON.stringify(value)); model[SynapseId] = newSynapse; this.setState({ value: model, selectedSynapse: SynapseId - }, ()=> GEPPETTO.trigger('synapses_change')); - }; + }, () => GEPPETTO.trigger('synapses_change')); + } - hasSelectedSynapseBeenRenamed(prevState, currentState) { + hasSelectedSynapseBeenRenamed (prevState, currentState) { var currentModel = prevState.value; var model = currentState.value; - //deal with rename + // deal with rename if (currentModel != undefined && model != undefined) { var oldP = Object.keys(currentModel); var newP = Object.keys(model); if (oldP.length == newP.length) { - //if it's the same lenght there could be a rename + // if it's the same lenght there could be a rename for (var i = 0; i < oldP.length; i++) { if (oldP[i] != newP[i]) { if (prevState.selectedSynapse != undefined) { if (oldP[i] == prevState.selectedSynapse) { return newP[i]; - }; - }; - }; - }; - }; - }; + } + } + } + } + } + } return undefined; - }; + } - componentDidUpdate(prevProps, prevState) { + componentDidUpdate (prevProps, prevState) { var newSynapseName = this.hasSelectedSynapseBeenRenamed(prevState, this.state); if (newSynapseName !== undefined) { this.setState({ selectedSynapse: newSynapseName, deletedSynapse: undefined }); - } else if((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { - // logic into this if to check if the user added a new object from the python backend and - // if the name convention pass the checks, differently rename this and open dialog to inform. + } else if ((prevState.value !== undefined) && (Object.keys(prevState.value).length !== Object.keys(this.state.value).length)) { + /* + * logic into this if to check if the user added a new object from the python backend and + * if the name convention pass the checks, differently rename this and open dialog to inform. + */ var model = this.state.value; - for(var m in model) { - if((prevState.value !== "") && (!(m in prevState.value))) { + for (var m in model) { + if ((prevState.value !== "") && (!(m in prevState.value))) { var newValue = Utils.nameValidation(m); - if(newValue != m) { + if (newValue != m) { newValue = Utils.getAvailableKey(model, newValue); model[newValue] = model[m]; delete model[m]; - this.setState({ value: model, - errorMessage: "Error", - errorDetails: "Leading digits or whitespaces are not allowed in Synapses names.\n" + - m + " has been renamed " + newValue}, - () => Utils.renameKey('netParams.synMechParams', m, newValue, (response, newValue) => GEPPETTO.trigger('synapses_change'))); + this.setState({ + value: model, + errorMessage: "Error", + errorDetails: "Leading digits or whitespaces are not allowed in Synapses names.\n" + + m + " has been renamed " + newValue + }, + () => Utils.renameKey('netParams.synMechParams', m, newValue, (response, newValue) => GEPPETTO.trigger('synapses_change'))); } } } } - }; + } - shouldComponentUpdate(nextProps, nextState) { + shouldComponentUpdate (nextProps, nextState) { var itemRenamed = this.hasSelectedSynapseBeenRenamed(this.state, nextState) !== undefined; var newItemCreated = false; var selectionChanged = this.state.selectedSynapse != nextState.selectedSynapse; @@ -105,31 +109,31 @@ export default class NetPyNESynapses extends Component { var newModel = this.state.value == undefined; if (!newModel) { newItemCreated = ((Object.keys(this.state.value).length != Object.keys(nextState.value).length)); - }; - var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails) ? true : false; + } + var errorDialogOpen = (this.state.errorDetails !== nextState.errorDetails); return newModel || newItemCreated || itemRenamed || selectionChanged || pageChanged || errorDialogOpen; - }; + } - deleteSynapse(name) { - Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['synMechParams', name]).then((response) =>{ + deleteSynapse (name) { + Utils.evalPythonMessage('netpyne_geppetto.deleteParam', ['synMechParams', name]).then(response => { var model = this.state.value; delete model[name]; - this.setState({value: model, selectedSynapse: undefined, deletedSynapse: name}, ()=> GEPPETTO.trigger('synapses_change')); + this.setState({ value: model, selectedSynapse: undefined, deletedSynapse: name }, () => GEPPETTO.trigger('synapses_change')); }); } - handleRenameChildren(childName) { + handleRenameChildren (childName) { childName = childName.replace(/\s*$/,""); var childrenList = Object.keys(this.state.value); - for(var i=0 ; childrenList.length > i ; i++) { - if(childName === childrenList[i]) { + for (var i = 0 ; childrenList.length > i ; i++) { + if (childName === childrenList[i]) { return false; } } return true; } - render() { + render () { var actions = [ - {children} - : undefined; + var dialogPop = (this.state.errorMessage != undefined) ? + {children} + : undefined; var model = this.state.value; var Synapses = []; for (var c in model) { Synapses.push(); - }; + } var selectedSynapse = undefined; if ((this.state.selectedSynapse !== undefined) && Object.keys(model).indexOf(this.state.selectedSynapse) > -1) { selectedSynapse = ; - }; + } return ( @@ -181,7 +185,7 @@ export default class NetPyNESynapses extends Component {
this.setState({selectedSynapse: undefined})} + handleClick={() => this.setState({ selectedSynapse: undefined })} />
diff --git a/components/general/AdapterComponent.js b/components/general/AdapterComponent.js index db7e9a2d..c937dc0b 100644 --- a/components/general/AdapterComponent.js +++ b/components/general/AdapterComponent.js @@ -9,54 +9,53 @@ import React, { Component } from 'react'; export default class AdapterComponent extends Component { - constructor(props) { - super(props); - /** - * the state is constructed dynamically from the id props of each children - * in this way we are declaring a controlled component that can handle his own - * state when this is modified by a new input or action of the user - **/ - this.stateBuilder = {}; - this.props.children.forEach( (child, index) => { - this.stateBuilder[child.props.id] = ''; - }); - this.state = this.stateBuilder; - - this.handleChildChange = this.handleChildChange.bind(this); + constructor (props) { + super(props); + /** + * the state is constructed dynamically from the id props of each children + * in this way we are declaring a controlled component that can handle his own + * state when this is modified by a new input or action of the user + * + */ + this.stateBuilder = {}; + this.props.children.forEach( (child, index) => { + this.stateBuilder[child.props.id] = ''; + }); + this.state = this.stateBuilder; + + this.handleChildChange = this.handleChildChange.bind(this); + } + componentDidUpdate (prevProps, prevState) { + var newValue = this.props.convertFromPython(prevProps, prevState, this.props.value); + if (newValue != undefined){ + this.setState(newValue); } - componentDidUpdate(prevProps, prevState) { - var newValue = this.props.convertFromPython(prevProps, prevState, this.props.value); - if (newValue != undefined){ - this.setState(newValue); - } - } - - handleChildChange(event, value) { - // Update State - var newState =this.state; - newState['lastUpdated']= event.target.id; - newState[event.target.id]=value; - this.setState(newState) - - // Call to conversion function - var newValue = this.props.convertToPython(this.state); - if (newValue != undefined && this.state.value != newValue){ - this.props.onChange(null, null, newValue); - } - } - - render() { - const childrenWithExtraProp = React.Children.map(this.props.children, child => { - return React.cloneElement(child, { - onChange: this.handleChildChange, - value: this.state[child.props.id] - }); - }); - - return ( -
- {childrenWithExtraProp} -
- ) + } + + handleChildChange (event, value) { + // Update State + var newState = this.state; + newState['lastUpdated'] = event.target.id; + newState[event.target.id] = value; + this.setState(newState) + + // Call to conversion function + var newValue = this.props.convertToPython(this.state); + if (newValue != undefined && this.state.value != newValue){ + this.props.onChange(null, null, newValue); } + } + + render () { + const childrenWithExtraProp = React.Children.map(this.props.children, child => React.cloneElement(child, { + onChange: this.handleChildChange, + value: this.state[child.props.id] + })); + + return ( +
+ {childrenWithExtraProp} +
+ ) + } } \ No newline at end of file diff --git a/components/general/DeleteDialogBox.js b/components/general/DeleteDialogBox.js index 9f6619a7..5d8b1fd8 100644 --- a/components/general/DeleteDialogBox.js +++ b/components/general/DeleteDialogBox.js @@ -13,48 +13,48 @@ import FlatButton from 'material-ui/FlatButton'; export default class DeleteDialogBox extends React.Component { - constructor(props) { - super(props); - this.state = { - open: props.open, - response: false - }; + constructor (props) { + super(props); + this.state = { + open: props.open, + response: false }; + } - componentDidUpdate(prevProps, prevState) { - if(prevProps.open != this.props.open) { - this.setState({open: this.props.open}); - } + componentDidUpdate (prevProps, prevState) { + if (prevProps.open != this.props.open) { + this.setState({ open: this.props.open }); } + } - render() { - const actions = [ - this.props.onDialogResponse(false)} - />, - this.props.onDialogResponse(true)} - />, - ]; + render () { + const actions = [ + this.props.onDialogResponse(false)} + />, + this.props.onDialogResponse(true)} + />, + ]; - return ( -
- - {"Do you want to remove "+this.props.textForDialog+" ?"} - -
- ); - }; + return ( +
+ + {"Do you want to remove " + this.props.textForDialog + " ?"} + +
+ ); + } } diff --git a/components/general/FileBrowser.js b/components/general/FileBrowser.js index c1d4242c..0785815b 100644 --- a/components/general/FileBrowser.js +++ b/components/general/FileBrowser.js @@ -8,108 +8,103 @@ import Dialog from 'material-ui/Dialog'; export default class FileBrowser extends React.Component { - constructor(props) { - super(props); - this.handleClickVisualize = this.handleClickVisualize.bind(this); + constructor (props) { + super(props); + this.handleClickVisualize = this.handleClickVisualize.bind(this); - this.state = {}; + this.state = {}; + } + + getDirList (treeData, rowInfo) { + if (rowInfo != undefined) { + var path = rowInfo.node.path; + } else { + var path = "" } - getDirList(treeData, rowInfo) { - if (rowInfo != undefined) { - var path = rowInfo.node.path; + Utils + .evalPythonMessage('netpyne_geppetto.getDirList', [path, this.props.exploreOnlyDirs, this.props.filterFiles]) + .then(dirList => { + if (treeData != [] && treeData.length > 0) { + rowInfo.node.children = dirList; + rowInfo.node.expanded = true; + rowInfo.node.load = true; + var newTreeData = changeNodeAtPath({ treeData: treeData, path: rowInfo.path, newNode: rowInfo.node, getNodeKey: ({ treeIndex }) => treeIndex }); + } else { + var newTreeData = dirList; } - else{ - var path = "" + if (!this.props.exploreOnlyDirs || rowInfo == undefined){ + this.setState({ selection: undefined }) + } else { + this.setState({ selection: rowInfo.node }) } - - Utils - .evalPythonMessage('netpyne_geppetto.getDirList', [path, this.props.exploreOnlyDirs, this.props.filterFiles]) - .then((dirList) => { - if (treeData != [] && treeData.length > 0) { - rowInfo.node.children = dirList; - rowInfo.node.expanded = true; - rowInfo.node.load = true; - var newTreeData = changeNodeAtPath({ treeData: treeData, path: rowInfo.path, newNode: rowInfo.node, getNodeKey: ({ treeIndex }) => treeIndex }); - } - else { - var newTreeData = dirList; - } - if (!this.props.exploreOnlyDirs || rowInfo == undefined){ - this.setState({ selection: undefined }) - } - else{ - this.setState({ selection: rowInfo.node }) - } - this.refs.tree.updateTreeData(newTreeData); - }); - } + this.refs.tree.updateTreeData(newTreeData); + }); + } - handleClickVisualize(event, rowInfo) { - if (rowInfo.node.load == false) { - this.getDirList(this.refs.tree.state.treeData, rowInfo); - } - else if (this.props.exploreOnlyDirs || (rowInfo.node.children == undefined && rowInfo.node.load == undefined)) { - this.setState({ selection: rowInfo.node }) - } + handleClickVisualize (event, rowInfo) { + if (rowInfo.node.load == false) { + this.getDirList(this.refs.tree.state.treeData, rowInfo); + } else if (this.props.exploreOnlyDirs || (rowInfo.node.children == undefined && rowInfo.node.load == undefined)) { + this.setState({ selection: rowInfo.node }) } + } - componentDidUpdate(prevProps, prevState) { - if (prevProps.open == false && this.props.open) { - this.getDirList([]); - } + componentDidUpdate (prevProps, prevState) { + if (prevProps.open == false && this.props.open) { + this.getDirList([]); } + } - render() { - const actions = [ - this.props.onRequestClose()} - style={{ marginRight: 16 }} - />, - this.props.onRequestClose(this.state.selection)} - disabled={!this.state.selection} - /> - ]; + render () { + const actions = [ + this.props.onRequestClose()} + style={{ marginRight: 16 }} + />, + this.props.onRequestClose(this.state.selection)} + disabled={!this.state.selection} + /> + ]; - var selectMessage=this.props.exploreOnlyDirs?"Select a folder. ":"Select a file. "; - return ( + var selectMessage = this.props.exploreOnlyDirs ? "Select a folder. " : "Select a file. "; + return ( - -
- {selectMessage} + +
+ {selectMessage} These paths are relative to:
- {window.isDocker ? " the folder you shared with docker (your mounted volume)" : - {window.currentFolder}} -
- < Tree - id="TreeContainerCutting" - style={{ width: "100%", height: "400px", float: 'left'}} - treeData={[]} - handleClick={this.handleClickVisualize} - rowHeight={30} - activateParentsNodeOnClick={this.props.exploreOnlyDirs} - ref="tree" - /> -
- ) - } -}; + {window.isDocker ? " the folder you shared with docker (your mounted volume)" + : {window.currentFolder}} +
+ < Tree + id="TreeContainerCutting" + style={{ width: "100%", height: "400px", float: 'left' }} + treeData={[]} + handleClick={this.handleClickVisualize} + rowHeight={30} + activateParentsNodeOnClick={this.props.exploreOnlyDirs} + ref="tree" + /> +
+ ) + } +} FileBrowser.defaultProps = { - exploreOnlyDirs: false, - filterFiles: false + exploreOnlyDirs: false, + filterFiles: false }; - diff --git a/components/general/List.js b/components/general/List.js index 10c2fecf..52b7bde0 100644 --- a/components/general/List.js +++ b/components/general/List.js @@ -8,267 +8,251 @@ import FontIcon from 'material-ui/FontIcon'; */ export default class ListComponent extends Component { - constructor(props) { - super(props); - this.state = { - model: props.model, - children: (props.realType == 'dict' || props.realType == 'dict(dict())') ? {} : [], - newItemValue: '' - }; - this.addChild = this.addChild.bind(this); - this.handleNewItemChange = this.handleNewItemChange.bind(this); - } + constructor (props) { + super(props); + this.state = { + model: props.model, + children: (props.realType == 'dict' || props.realType == 'dict(dict())') ? {} : [], + newItemValue: '' + }; + this.addChild = this.addChild.bind(this); + this.handleNewItemChange = this.handleNewItemChange.bind(this); + } - isValid(value) { - switch (this.props.realType) { - case 'list(float)': - var valid = (value.match(/^-?\d*(\.\d+)?$/)); - break; - case 'list(list(float))': - var valid = true; - value.split(',').forEach(element => { - if (!element.match(/^-?\d*(\.\d+)?$/)) { - valid = false; - } - }); - break; - case 'dict': - var valid = (value.match(/:/g) || []).length == 1 && !value.startsWith(':') && !value.endsWith(':'); - break; - case 'dict(dict())': - var valid = true; - var value = this.state.newItemValue.replace(/[ "']/g, ''); + isValid (value) { + switch (this.props.realType) { + case 'list(float)': + var valid = (value.match(/^-?\d*(\.\d+)?$/)); + break; + case 'list(list(float))': + var valid = true; + value.split(',').forEach(element => { + if (!element.match(/^-?\d*(\.\d+)?$/)) { + valid = false; + } + }); + break; + case 'dict': + var valid = (value.match(/:/g) || []).length == 1 && !value.startsWith(':') && !value.endsWith(':'); + break; + case 'dict(dict())': + var valid = true; + var value = this.state.newItemValue.replace(/[ "']/g, ''); - if ((value.match(/;/g) || []).length != 0) { - valid = false; - } - else { - if ((value.match(/{/g) || []).length != 1 || (value.match(/}/g) || []).length != 1) { - valid = false; - } - else { - if (value.indexOf('{') > value.indexOf('}') || !value.endsWith('}')) { - valid = false; - } - else { - var subDict = value.match(/\{(.*?)\}/)[1]; - if ((subDict.match(/:/g) || []).length - 1 != (subDict.match(/,/g) || []).length)  { - valid = false; - } - else { - subDict.split(',').forEach(element => { - if ((element.match(/:/g) || []).length != 1 || element.startsWith(':') || element.endsWith(':')) { - valid = false; - } - }); - var reminder = value.replace('{' + subDict + '}', ''); - if ((reminder.match(/:/g) || []).length != 1 || !reminder.endsWith(':')) { - valid = false; - } - } - } - } + if ((value.match(/;/g) || []).length != 0) { + valid = false; + } else { + if ((value.match(/{/g) || []).length != 1 || (value.match(/}/g) || []).length != 1) { + valid = false; + } else { + if (value.indexOf('{') > value.indexOf('}') || !value.endsWith('}')) { + valid = false; + } else { + var subDict = value.match(/\{(.*?)\}/)[1]; + if ((subDict.match(/:/g) || []).length - 1 != (subDict.match(/,/g) || []).length) { + valid = false; + } else { + subDict.split(',').forEach(element => { + if ((element.match(/:/g) || []).length != 1 || element.startsWith(':') || element.endsWith(':')) { + valid = false; } - break; - default: - var valid = true; - break; + }); + var reminder = value.replace('{' + subDict + '}', ''); + if ((reminder.match(/:/g) || []).length != 1 || !reminder.endsWith(':')) { + valid = false; + } + } + } } - return valid; + } + break; + default: + var valid = true; + break; } + return valid; + } - getErrorMessage() { - switch (this.props.realType) { - case 'list(float)': - var message = 'Only float numbers are allowed.'; - break; - case 'list(list(float))': - var message = 'Only comma separated float numbers are allowed.'; - break; - case 'dict': - var message = 'Key:Value pairs must be separated by colon : '; - break; - case 'dict(dict())': - var message = 'Incorrect format. Example -> v_soma : { sec: soma, loc: 0.5, var: v}'; - break - default: - var message = 'No a valid value'; - break; - } - return message; + getErrorMessage () { + switch (this.props.realType) { + case 'list(float)': + var message = 'Only float numbers are allowed.'; + break; + case 'list(list(float))': + var message = 'Only comma separated float numbers are allowed.'; + break; + case 'dict': + var message = 'Key:Value pairs must be separated by colon : '; + break; + case 'dict(dict())': + var message = 'Incorrect format. Example -> v_soma : { sec: soma, loc: 0.5, var: v}'; + break + default: + var message = 'No a valid value'; + break; } + return message; + } - handleNewItemChange(event) { - this.setState({ newItemValue: event.target.value, newItemErrorText: '' }) - } + handleNewItemChange (event) { + this.setState({ newItemValue: event.target.value, newItemErrorText: '' }) + } - addChild() { - if (this.state.newItemValue != '' && this.isValid(this.state.newItemValue)) { - var children = this.state.children; - switch (this.props.realType) { - case 'list(list(float))': - var newValue = '[' + this.state.newItemValue + ']'; - children.push(newValue); - break; - case 'dict': - var newValue = this.state.newItemValue.split(':').map(entry => { - return entry - }); - if (!isNaN(newValue[1])) { - newValue[1] = parseFloat(newValue[1]) - } - children[newValue[0]] = newValue[1]; - break; - case 'dict(dict())': - var key = this.state.newItemValue.split(':')[0].replace(/[ "']/g, ''); - children[key] = {} - var newValue = this.state.newItemValue.match(/\{(.*?)\}/)[1].replace(/[ "']/g, '').split(',').map(entry => { - return entry.split(':') - }); - newValue.forEach(entry => { - if (!isNaN(entry[1])) { - entry[1] = parseFloat(entry[1]) - } - children[key][entry[0]] = entry[1] - }) - break; - default: - var newValue = this.state.newItemValue; - children.push(newValue); - break; - } - // Call to conversion function - this.convertToPython(children); - } - else { - this.setState({ newItemErrorText: this.getErrorMessage() }) + addChild () { + if (this.state.newItemValue != '' && this.isValid(this.state.newItemValue)) { + var children = this.state.children; + switch (this.props.realType) { + case 'list(list(float))': + var newValue = '[' + this.state.newItemValue + ']'; + children.push(newValue); + break; + case 'dict': + var newValue = this.state.newItemValue.split(':').map(entry => entry); + if (!isNaN(newValue[1])) { + newValue[1] = parseFloat(newValue[1]) } + children[newValue[0]] = newValue[1]; + break; + case 'dict(dict())': + var key = this.state.newItemValue.split(':')[0].replace(/[ "']/g, ''); + children[key] = {} + var newValue = this.state.newItemValue.match(/\{(.*?)\}/)[1].replace(/[ "']/g, '').split(',').map(entry => entry.split(':')); + newValue.forEach(entry => { + if (!isNaN(entry[1])) { + entry[1] = parseFloat(entry[1]) + } + children[key][entry[0]] = entry[1] + }) + break; + default: + var newValue = this.state.newItemValue; + children.push(newValue); + break; + } + // Call to conversion function + this.convertToPython(children); + } else { + this.setState({ newItemErrorText: this.getErrorMessage() }) } + } - removeChild(childIndex) { - var children = this.state.children; - if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { + removeChild (childIndex) { + var children = this.state.children; + if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { - delete children[childIndex]; - } - else { - children.splice(childIndex, 1); - } - // Call to conversion function - this.convertToPython(children); + delete children[childIndex]; + } else { + children.splice(childIndex, 1); } + // Call to conversion function + this.convertToPython(children); + } - convertToPython(children) { - // Update State - this.setState({ children: children, newItemValue: '' }); + convertToPython (children) { + // Update State + this.setState({ children: children, newItemValue: '' }); - if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { - var newValue = children; - } - else { - var newValue = this.state.children.map((child, i) => { - switch (this.props.realType) { - case 'list(float)': - var childConverted = parseFloat(child) - break; - case 'list(list(float))': - var childConverted = JSON.parse(child); - break; - default: - var childConverted = child; - break; - } - return childConverted; - }) - } - - if (newValue != undefined && this.state.value != newValue && this.props.onChange != undefined) { - this.props.onChange(null, null, newValue); + if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { + var newValue = children; + } else { + var newValue = this.state.children.map((child, i) => { + switch (this.props.realType) { + case 'list(float)': + var childConverted = parseFloat(child) + break; + case 'list(list(float))': + var childConverted = JSON.parse(child); + break; + default: + var childConverted = child; + break; } + return childConverted; + }) } - convertFromPython(prevProps, prevState, value) { - if (value != undefined && prevProps.value != value && value != '') { - if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { - return (typeof value == 'string') ? JSON.parse(value) : value; - } - else { - if (!Array.isArray(value)) { - value = [value]; - } - return value.map((child, i) => { - return (typeof child == 'string') ? child : JSON.stringify(child); - }); - } + if (newValue != undefined && this.state.value != newValue && this.props.onChange != undefined) { + this.props.onChange(null, null, newValue); + } + } + convertFromPython (prevProps, prevState, value) { + if (value != undefined && prevProps.value != value && value != '') { + if (this.props.realType == 'dict' || this.props.realType == 'dict(dict())') { + return (typeof value == 'string') ? JSON.parse(value) : value; + } else { + if (!Array.isArray(value)) { + value = [value]; } + return value.map((child, i) => (typeof child == 'string') ? child : JSON.stringify(child)); + } + } + } - componentDidUpdate(prevProps, prevState) { - var newValue = this.convertFromPython(prevProps, prevState, this.props.value); - if (newValue != undefined) { - this.setState({ children: newValue }); - } + componentDidUpdate (prevProps, prevState) { + var newValue = this.convertFromPython(prevProps, prevState, this.props.value); + if (newValue != undefined) { + this.setState({ children: newValue }); } + } - render() { - var childrenWithExtraProp = Object.keys(this.state.children).map((key, index) => { - key = key.toString(); - if (this.props.realType == 'dict') { - var value = key + ' : ' + JSON.stringify(this.state.children[key]); - } - else if (this.props.realType == 'dict(dict())') { - var value = key + ': ' + JSON.stringify(this.state.children[key]).replace(/["']/g, '').replace(/[:]/g, ': ').replace(/[,]/g, ', '); - } - else { - var value = this.state.children[key]; - } - return
- - this.removeChild(key)} - tooltip='Remove item from the list' - > - - -
- }); + render () { + var childrenWithExtraProp = Object.keys(this.state.children).map((key, index) => { + key = key.toString(); + if (this.props.realType == 'dict') { + var value = key + ' : ' + JSON.stringify(this.state.children[key]); + } else if (this.props.realType == 'dict(dict())') { + var value = key + ': ' + JSON.stringify(this.state.children[key]).replace(/["']/g, '').replace(/[:]/g, ': ').replace(/[,]/g, ', '); + } else { + var value = this.state.children[key]; + } + return
+ + this.removeChild(key)} + tooltip='Remove item from the list' + > + + +
+ }); - return ( -
- e.key === 'Enter' ? this.addChild() : null } - value={this.state.newItemValue} - style={{ width: '100%' }} - errorText={this.state.newItemErrorText} - /> - {!this.state.newItemErrorText && - + e.key === 'Enter' ? this.addChild() : null } + value={this.state.newItemValue} + style={{ width: '100%' }} + errorText={this.state.newItemErrorText} + /> + {!this.state.newItemErrorText + && - + - } + } - {childrenWithExtraProp.length > 0 &&
{childrenWithExtraProp}
} -
- ) - } + {childrenWithExtraProp.length > 0 &&
{childrenWithExtraProp}
} +
+ ) + } } diff --git a/components/general/NetPyNEAddNew.js b/components/general/NetPyNEAddNew.js index e2e8df26..9878f0f3 100644 --- a/components/general/NetPyNEAddNew.js +++ b/components/general/NetPyNEAddNew.js @@ -4,20 +4,19 @@ import FloatingActionButton from 'material-ui/FloatingActionButton'; export default class NetPyNEAddNew extends React.Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - }; + this.state = {}; this.handleClick = this.handleClick.bind(this); - }; + } - handleClick() { + handleClick () { if (this.props.handleClick) { this.props.handleClick(); - }; - }; + } + } - render() { + render () { return ( ); - }; -}; + } +} const styles = { diff --git a/components/general/NetPyNECoordsRange.js b/components/general/NetPyNECoordsRange.js index c3d13fdb..d5195b7c 100644 --- a/components/general/NetPyNECoordsRange.js +++ b/components/general/NetPyNECoordsRange.js @@ -11,98 +11,90 @@ var PythonControlledAdapterComponent = PythonControlledCapability.createPythonCo export default class NetPyNECoordsRange extends Component { - constructor(props) { + constructor (props) { super(props); - this.state = { - rangeType: undefined, - }; + this.state = { rangeType: undefined, }; this._isMounted = false; - }; + } - triggerUpdate(updateMethod) { - //common strategy when triggering processing of a value change, delay it, every time there is a change we reset + triggerUpdate (updateMethod) { + // common strategy when triggering processing of a value change, delay it, every time there is a change we reset if (this.updateTimer != undefined) { clearTimeout(this.updateTimer); } this.updateTimer = setTimeout(updateMethod, 1000); } - componentDidUpdate(prevProps, prevState) { - if (this.props.name != prevProps.name) { + componentDidUpdate (prevProps, prevState) { + if (this.props.name != prevProps.name) { this.triggerUpdate(() => { - var message = 'netpyne_geppetto.' + this.props.model + "['" + this.props.name + "']" + ((this.props.conds!=undefined)?"['" + this.props.conds + "']" : ""); + var message = 'netpyne_geppetto.' + this.props.model + "['" + this.props.name + "']" + ((this.props.conds != undefined) ? "['" + this.props.conds + "']" : ""); Utils - .evalPythonMessage("[key in "+message+" for key in ['"+this.props.items[0].value+"', '"+this.props.items[1].value+"']]") - .then((response) => { + .evalPythonMessage("[key in " + message + " for key in ['" + this.props.items[0].value + "', '" + this.props.items[1].value + "']]") + .then(response => { if (response[0] && this._isMounted === true) { - this.setState({rangeType: this.props.items[0].value}); - } - else if (response[1] && this._isMounted === true){ - this.setState({rangeType: this.props.items[1].value}); + this.setState({ rangeType: this.props.items[0].value }); + } else if (response[1] && this._isMounted === true){ + this.setState({ rangeType: this.props.items[1].value }); + } else if (this._isMounted === true) { + this.setState({ rangeType: undefined }); } - else if (this._isMounted === true) { - this.setState({rangeType: undefined}); - } - }); + }); }); - } else if (this.props.conds!=prevProps.conds) { + } else if (this.props.conds != prevProps.conds) { this.updateLayout(); - }; - }; + } + } - componentDidMount() { + componentDidMount () { this._isMounted = true; this.updateLayout(); - }; + } - updateLayout() { - var message = 'netpyne_geppetto.' + this.props.model + "['" + this.props.name + "']" + ((this.props.conds!=undefined)?"['" + this.props.conds + "']":""); + updateLayout () { + var message = 'netpyne_geppetto.' + this.props.model + "['" + this.props.name + "']" + ((this.props.conds != undefined) ? "['" + this.props.conds + "']" : ""); Utils - .evalPythonMessage("[key in "+message+" for key in ['"+this.props.items[0].value+"', '"+this.props.items[1].value+"']]") - .then((response) => { + .evalPythonMessage("[key in " + message + " for key in ['" + this.props.items[0].value + "', '" + this.props.items[1].value + "']]") + .then(response => { if (response[0] && this._isMounted === true) { - this.setState({rangeType: this.props.items[0].value}); - } - else if (response[1] && this._isMounted === true){ - this.setState({rangeType: this.props.items[1].value}); + this.setState({ rangeType: this.props.items[0].value }); + } else if (response[1] && this._isMounted === true){ + this.setState({ rangeType: this.props.items[1].value }); + } else if (this._isMounted === true) { + this.setState({ rangeType: undefined }); } - else if (this._isMounted === true) { - this.setState({rangeType: undefined}); - } - }); - }; + }); + } - createMenuItems = () => { - return this.props.items.map((obj) => ( - - )); - }; + createMenuItems = () => this.props.items.map(obj => ( + + )); - componentWillUnmount() { + componentWillUnmount () { this._isMounted = false; } - render() { - if (this.props.conds!=undefined) { + render () { + if (this.props.conds != undefined) { var meta = this.props.model + "." + this.props.conds + "." + this.props.items[0].value; var path = this.props.model + "['" + this.props.name + "']['" + this.props.conds + "']['" + this.state.rangeType + "']"; } else { var meta = this.props.model + '.' + this.props.items[0].value; var path = this.props.model + "['" + this.props.name + "']['" + this.state.rangeType + "']"; - }; - var min = this.props.id+"MinRange"; - var max = this.props.id+"MaxRange"; + } + var min = this.props.id + "MinRange"; + var max = this.props.id + "MaxRange"; return (
this.setState({ rangeType: value })} @@ -110,15 +102,16 @@ export default class NetPyNECoordsRange extends Component { {this.createMenuItems()} - {(this.state.rangeType != undefined) ? -
+ {(this.state.rangeType != undefined) + ?
{ - if (!state[state.lastUpdated].toString().endsWith(".") && - ((!isNaN(parseFloat(state[min]))) && (!isNaN(parseFloat(state[max]))))) { + convertToPython={state => { + if (!state[state.lastUpdated].toString().endsWith(".") + && ((!isNaN(parseFloat(state[min]))) && (!isNaN(parseFloat(state[max]))))) { return [parseFloat(state[min]), parseFloat(state[max])]; - }} + } + } } convertFromPython={(prevProps, prevState, value) => { if (value != undefined && prevProps.value != value && value != '') { @@ -126,16 +119,17 @@ export default class NetPyNECoordsRange extends Component { output[min] = value[0]; output[max] = value[1]; return output; - }} + } + } } > - - + +
- : null} + : null}
); - }; -}; + } +} diff --git a/components/general/NetPyNEField.js b/components/general/NetPyNEField.js index c3d271c0..789ddaaf 100644 --- a/components/general/NetPyNEField.js +++ b/components/general/NetPyNEField.js @@ -5,157 +5,150 @@ import MenuItem from 'material-ui/MenuItem'; import Utils from '../../Utils'; export default class NetPyNEField extends Component { - constructor(props) { - super(props); - this.state = { - openHelp: false - }; + constructor (props) { + super(props); + this.state = { openHelp: false }; - } + } - handleOpenHelp = (help) => { - this.setState({ openHelp: true, helpText: help }); + handleOpenHelp = help => { + this.setState({ openHelp: true, helpText: help }); }; handleCloseHelp = () => { - this.setState({ openHelp: false }); + this.setState({ openHelp: false }); }; - setErrorMessage(value) { - return new Promise((resolve, reject) => { - if (this.realType == 'func') { - if (value != "" && value != undefined) { - Utils.evalPythonMessage('netpyne_geppetto.validateFunction', [value]).then((response) => { - if (!response) { - resolve({ errorMsg: 'Not a valid function' }) - } - else { - resolve({ errorMsg: '' }) - } - }); - } - else { - resolve({ errorMsg: '' }) - } - } - else if (this.realType == 'float') { - if (isNaN(value)) { - resolve({ errorMsg: 'Only float allowed' }) - } - else { - resolve({ errorMsg: '' }) - } - } + setErrorMessage (value) { + return new Promise((resolve, reject) => { + if (this.realType == 'func') { + if (value != "" && value != undefined) { + Utils.evalPythonMessage('netpyne_geppetto.validateFunction', [value]).then(response => { + if (!response) { + resolve({ errorMsg: 'Not a valid function' }) + } else { + resolve({ errorMsg: '' }) + } + }); + } else { + resolve({ errorMsg: '' }) + } + } else if (this.realType == 'float') { + if (isNaN(value)) { + resolve({ errorMsg: 'Only float allowed' }) + } else { + resolve({ errorMsg: '' }) + } } - ); - }; + } + ); + } - prePythonSyncProcessing(value){ - if (value == '') { - if (this.default != undefined) { - return this.default; - } - else if (!this.model.split(".")[0].startsWith('simConfig') || this.model.split(".")[1].startsWith('analysis')) { - Utils.execPythonMessage('del netpyne_geppetto.' + this.model) - } + prePythonSyncProcessing (value){ + if (value == '') { + if (this.default != undefined) { + return this.default; + } else if (!this.model.split(".")[0].startsWith('simConfig') || this.model.split(".")[1].startsWith('analysis')) { + Utils.execPythonMessage('del netpyne_geppetto.' + this.model) } - return value; + } + return value; } - render() { - var help = Utils.getMetadataField(this.props.id, "help"); - if (help != undefined && help != '') { - var helpComponent =
this.handleOpenHelp(help)}> - } - modal={true} - open={this.state.openHelp} - onRequestClose={this.handleCloseHelp} - > - {this.state.helpText} - -
+ render () { + var help = Utils.getMetadataField(this.props.id, "help"); + if (help != undefined && help != '') { + var helpComponent =
this.handleOpenHelp(help)}> + } + modal={true} + open={this.state.openHelp} + onRequestClose={this.handleCloseHelp} + > + {this.state.helpText} + +
+ } + + const childWithProp = React.Children.map(this.props.children, child => { + var extraProps = {} + if (["SelectField", "TextField", "Checkbox", "PythonControlledControlWithPythonDataFetch"].indexOf(child.type.name) == -1) { + extraProps['validate'] = this.setErrorMessage; + extraProps['prePythonSyncProcessing'] = this.prePythonSyncProcessing; + + var dataSource = Utils.getMetadataField(this.props.id, "suggestions"); + if (dataSource != '') { + extraProps['dataSource'] = dataSource; + } } - - const childWithProp = React.Children.map(this.props.children, (child) => { - var extraProps = {} - if (["SelectField", "TextField", "Checkbox", "PythonControlledControlWithPythonDataFetch"].indexOf(child.type.name) == -1) { - extraProps['validate'] = this.setErrorMessage; - extraProps['prePythonSyncProcessing'] = this.prePythonSyncProcessing; - - var dataSource = Utils.getMetadataField(this.props.id, "suggestions"); - if (dataSource != '') { - extraProps['dataSource'] = dataSource; - } - } - var floatingLabelText = Utils.getMetadataField(this.props.id, "label"); - extraProps['label'] = floatingLabelText; - - if (child.type.name != "Checkbox") { - extraProps['floatingLabelText'] = floatingLabelText; - } - - var type = Utils.getHTMLType(this.props.id); - if (type != '') { - extraProps['type'] = type; - } - - if (child.type.name == "PythonControlledControl") { - var realType = Utils.getMetadataField(this.props.id, "type"); - extraProps['realType'] = realType; - } - - var hintText = Utils.getMetadataField(this.props.id, "hintText"); - if (hintText != '') { - extraProps['hintText'] = hintText; - } - - var default_value = Utils.getMetadataField(this.props.id, "default"); - if (default_value != '') { - extraProps['default'] = default_value; - } - - var options = Utils.getMetadataField(this.props.id, "options"); - if (options) { - extraProps['children'] = options.map((name) => ( - - )); - } - - return React.cloneElement(child, extraProps); - }); - - var classes = []; - if (!this.props.noStyle) { - classes.push("netpyneField"); + var floatingLabelText = Utils.getMetadataField(this.props.id, "label"); + extraProps['label'] = floatingLabelText; + + if (child.type.name != "Checkbox") { + extraProps['floatingLabelText'] = floatingLabelText; } - if (this.props.className) { - classes.push(this.props.className); + + var type = Utils.getHTMLType(this.props.id); + if (type != '') { + extraProps['type'] = type; } - if (classes.length > 0) { - var className = { className: classes.join(" ") } + + if (child.type.name == "PythonControlledControl") { + var realType = Utils.getMetadataField(this.props.id, "type"); + extraProps['realType'] = realType; + } + + var hintText = Utils.getMetadataField(this.props.id, "hintText"); + if (hintText != '') { + extraProps['hintText'] = hintText; + } + + var default_value = Utils.getMetadataField(this.props.id, "default"); + if (default_value != '') { + extraProps['default'] = default_value; + } + + var options = Utils.getMetadataField(this.props.id, "options"); + if (options) { + extraProps['children'] = options.map(name => ( + + )); } - return ( -
-
- {childWithProp} -
- {helpComponent} -
-
- ); + return React.cloneElement(child, extraProps); + }); + + var classes = []; + if (!this.props.noStyle) { + classes.push("netpyneField"); + } + if (this.props.className) { + classes.push(this.props.className); + } + if (classes.length > 0) { + var className = { className: classes.join(" ") } + } + + return ( +
+
+ {childWithProp} +
+ {helpComponent} +
+
+ ); } } diff --git a/components/general/NetPyNEHome.js b/components/general/NetPyNEHome.js index 8e2f7743..1943cf90 100644 --- a/components/general/NetPyNEHome.js +++ b/components/general/NetPyNEHome.js @@ -5,12 +5,12 @@ import { pink400 } from 'material-ui/styles/colors'; import NavigationChevronRight from 'material-ui/svg-icons/navigation/chevron-right'; -export default ({handleClick, selection}) => ( +export default ({ handleClick, selection }) => ( handleClick()} > diff --git a/components/general/NetPyNEThumbnail.js b/components/general/NetPyNEThumbnail.js index 3e68c8ba..09e7990c 100644 --- a/components/general/NetPyNEThumbnail.js +++ b/components/general/NetPyNEThumbnail.js @@ -4,7 +4,7 @@ import DeleteDialogBox from './DeleteDialogBox'; export default class NetPyNEThumbnail extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { isHovered: false, @@ -12,59 +12,57 @@ export default class NetPyNEThumbnail extends React.Component { } this.handleClick = this.handleClick.bind(this); this.handleDialogBox = this.handleDialogBox.bind(this); - }; + } - handleClick() { + handleClick () { if (this.props.handleClick) { - if(this.props.selected && this.state.isHovered) { - this.setState({dialogOpen: true}); + if (this.props.selected && this.state.isHovered) { + this.setState({ dialogOpen: true }); } else { this.props.handleClick(this.props.name, true); } } - }; + } - handleDialogBox(response) { - if(this.props.handleClick && response) { + handleDialogBox (response) { + if (this.props.handleClick && response) { this.props.deleteMethod(this.props.name); } - this.setState({dialogOpen: false}); + this.setState({ dialogOpen: false }); } - render() { - const { name, selected } = this.props; - const { dialogOpen, isHovered } = this.state; + render () { + const { name, selected } = this.props; + const { dialogOpen, isHovered } = this.state; - let label; - if (isHovered && selected) { - label = "" - } - else { - if (name.length > 14) { - label = name.slice(0,11)+"..." - } - else { - label = name - } + let label; + if (isHovered && selected) { + label = "" + } else { + if (name.length > 14) { + label = name.slice(0,11) + "..." + } else { + label = name } - return ( -
- this.setState({isHovered: true})} - onMouseLeave={() => this.setState({isHovered: false})} - data-tooltip={isHovered && name.length > 14 ? name : undefined} - iconClassName={(this.state.isHovered && selected) ? "fa fa-trash-o" : ""} - className={"actionButton " + (selected ? "selectedActionButton" : "")} - onClick={()=>this.handleClick()} - > - {label} - - -
- ); - }; -}; + } + return ( +
+ this.setState({ isHovered: true })} + onMouseLeave={() => this.setState({ isHovered: false })} + data-tooltip={isHovered && name.length > 14 ? name : undefined} + iconClassName={(this.state.isHovered && selected) ? "fa fa-trash-o" : ""} + className={"actionButton " + (selected ? "selectedActionButton" : "")} + onClick={() => this.handleClick()} + > + {label} + + +
+ ); + } +} diff --git a/components/general/Slider.js b/components/general/Slider.js index 48dc45b3..96cb8e6d 100644 --- a/components/general/Slider.js +++ b/components/general/Slider.js @@ -8,45 +8,43 @@ import TextField from 'material-ui/TextField'; */ export default class NetPyNESlider extends Component { - constructor(props) { - super(props); - this.state = { - value: 0.5 - }; - } - - componentDidUpdate(prevProps, prevState) { - if (this.props.value != undefined && prevProps.value != this.props.value) { - this.setState({ value: this.props.value }); - } + constructor (props) { + super(props); + this.state = { value: 0.5 }; + } + + componentDidUpdate (prevProps, prevState) { + if (this.props.value != undefined && prevProps.value != this.props.value) { + this.setState({ value: this.props.value }); } + } handleSlider = (event, value) => { - this.setState({ value: value }); + this.setState({ value: value }); - this.props.onChange(event, null, value); + this.props.onChange(event, null, value); }; - render() { - return ( -
-

- {this.props.label} -

- - - this.handleSlider(event, event.target.value)} - /> - -
- ); + render () { + return ( +
+

+ {this.props.label} +

+ + + this.handleSlider(event, event.target.value)} + /> + +
+ ); } } \ No newline at end of file diff --git a/components/instantiation/NetPyNEInstantiated.js b/components/instantiation/NetPyNEInstantiated.js index b546f0fc..20edd2a9 100644 --- a/components/instantiation/NetPyNEInstantiated.js +++ b/components/instantiation/NetPyNEInstantiated.js @@ -10,259 +10,257 @@ import MenuItem from 'material-ui/MenuItem'; import Utils from '../../Utils'; const styles = { - modal: { - position: 'absolute !important', - backgroundColor: 'rgba(0, 0, 0, 0.6)', - zIndex: '999', - height: '100%', - width: '100%', - top: 0 - }, + modal: { + position: 'absolute !important', + backgroundColor: 'rgba(0, 0, 0, 0.6)', + zIndex: '999', + height: '100%', + width: '100%', + top: 0 + }, - menuItemDiv: { - fontSize: '12px', - lineHeight: '28px' - }, + menuItemDiv: { + fontSize: '12px', + lineHeight: '28px' + }, - menuItem: { - lineHeight: '28px', - minHeight: '28px' - }, - instantiatedContainer: { - height: '100%', - width: '100%', - position: 'fixed' - }, - controlpanelBtn: { - position: 'absolute', - left: 34, - top: 16 - }, - plotBtn: { - position: 'absolute', - left: 34, - top: 317 - } + menuItem: { + lineHeight: '28px', + minHeight: '28px' + }, + instantiatedContainer: { + height: '100%', + width: '100%', + position: 'fixed' + }, + controlpanelBtn: { + position: 'absolute', + left: 34, + top: 16 + }, + plotBtn: { + position: 'absolute', + left: 34, + top: 317 + } }; const plots = [ - {id: 'connectionPlot', primaryText: 'Connectivity', plotName: 'Connections Plot', plotMethod: 'plotConn', plotType: false}, - {id: '2dNetPlot', primaryText: '2D network', plotName: '2D Net Plot', plotMethod: 'plot2Dnet', plotType: false}, - {id: 'shapePlot', primaryText: 'Cell shape', plotName: 'Shape Plot', plotMethod: 'plotShape', plotType: false}, - {id: 'tracesPlot', primaryText: 'Cell traces', plotName: 'Traces Plot', plotMethod: 'plotTraces', plotType: false}, - {id: 'rasterPlot', primaryText: 'Raster plot', plotName: 'Raster Plot', plotMethod: 'plotRaster', plotType: false}, - {id: 'spikePlot', primaryText: 'Spike histogram', plotName: 'Spike Hist Plot', plotMethod: 'plotSpikeHist', plotType: false}, - {id: 'spikeStatsPlot', primaryText: 'Spike stats', plotName: 'Spike Stats Plot', plotMethod: 'plotSpikeStats', plotType: false}, - {id: 'ratePSDPlot', primaryText: 'Rate PSD', plotName: 'Rate PSD Plot', plotMethod: 'plotRatePSD', plotType: false}, - {id: 'LFPTimeSeriesPlot', primaryText: 'LFP time-series', plotName: 'LFP Time Series Plot', plotMethod: 'plotLFP', plotType: 'timeSeries'}, - {id: 'LFPLocationsPlot', primaryText: 'LFP PSD', plotName: 'LFP PSD Plot', plotMethod: 'plotLFP', plotType: 'PSD'}, - {id: 'LFPSpectrogramPlot', primaryText: 'LFP spectrogram', plotName: 'LFP Spectrogram Plot', plotMethod: 'plotLFP', plotType: 'spectrogram'}, - {id: 'LFPLocationsPlot', primaryText: 'LFP locations', plotName: 'LFP Locations Plot', plotMethod: 'plotLFP', plotType: 'locations'}, - {id: 'grangerPlot', primaryText: 'Granger causality plot', plotName: 'Granger Plot', plotMethod: 'granger', plotType: false}, - {id: 'rxdConcentrationPlot',primaryText: 'RxD concentration plot', plotName: 'RxD concentration plot', plotMethod: 'plotRxDConcentration', plotType: false} + { id: 'connectionPlot', primaryText: 'Connectivity', plotName: 'Connections Plot', plotMethod: 'plotConn', plotType: false }, + { id: '2dNetPlot', primaryText: '2D network', plotName: '2D Net Plot', plotMethod: 'plot2Dnet', plotType: false }, + { id: 'shapePlot', primaryText: 'Cell shape', plotName: 'Shape Plot', plotMethod: 'plotShape', plotType: false }, + { id: 'tracesPlot', primaryText: 'Cell traces', plotName: 'Traces Plot', plotMethod: 'plotTraces', plotType: false }, + { id: 'rasterPlot', primaryText: 'Raster plot', plotName: 'Raster Plot', plotMethod: 'plotRaster', plotType: false }, + { id: 'spikePlot', primaryText: 'Spike histogram', plotName: 'Spike Hist Plot', plotMethod: 'plotSpikeHist', plotType: false }, + { id: 'spikeStatsPlot', primaryText: 'Spike stats', plotName: 'Spike Stats Plot', plotMethod: 'plotSpikeStats', plotType: false }, + { id: 'ratePSDPlot', primaryText: 'Rate PSD', plotName: 'Rate PSD Plot', plotMethod: 'plotRatePSD', plotType: false }, + { id: 'LFPTimeSeriesPlot', primaryText: 'LFP time-series', plotName: 'LFP Time Series Plot', plotMethod: 'plotLFP', plotType: 'timeSeries' }, + { id: 'LFPLocationsPlot', primaryText: 'LFP PSD', plotName: 'LFP PSD Plot', plotMethod: 'plotLFP', plotType: 'PSD' }, + { id: 'LFPSpectrogramPlot', primaryText: 'LFP spectrogram', plotName: 'LFP Spectrogram Plot', plotMethod: 'plotLFP', plotType: 'spectrogram' }, + { id: 'LFPLocationsPlot', primaryText: 'LFP locations', plotName: 'LFP Locations Plot', plotMethod: 'plotLFP', plotType: 'locations' }, + { id: 'grangerPlot', primaryText: 'Granger causality plot', plotName: 'Granger Plot', plotMethod: 'granger', plotType: false }, + { id: 'rxdConcentrationPlot',primaryText: 'RxD concentration plot', plotName: 'RxD concentration plot', plotMethod: 'plotRxDConcentration', plotType: false } ]; export default class NetPyNEInstantiated extends React.Component { - constructor(props) { - super(props); - this.state = { - model: props.model, - controlPanelHidden: true, - plotButtonOpen: false, - openDialog: false, - bringItToFront: 0 - }; + constructor (props) { + super(props); + this.state = { + model: props.model, + controlPanelHidden: true, + plotButtonOpen: false, + openDialog: false, + bringItToFront: 0 + }; - this.widgets = []; - this.plotFigure = this.plotFigure.bind(this); - this.newPlotWidget = this.newPlotWidget.bind(this); - this.getOpenedWidgets = this.getOpenedWidgets.bind(this); - this.handleClick = this.handleClick.bind(this); - this.handleRequestClose = this.handleRequestClose.bind(this); - } + this.widgets = []; + this.plotFigure = this.plotFigure.bind(this); + this.newPlotWidget = this.newPlotWidget.bind(this); + this.getOpenedWidgets = this.getOpenedWidgets.bind(this); + this.handleClick = this.handleClick.bind(this); + this.handleRequestClose = this.handleRequestClose.bind(this); + } handleCloseDialog = () => { - this.setState({ openDialog: false }); + this.setState({ openDialog: false }); }; - newPlotWidget(name, svgResponse, data, i, total) { - var s = svgResponse; - var that = this; - G.addWidget(1).then(w => { - if (total == 0) { - w.setName(name); - } - else { - w.setName(name + " " + i); - } - w.$el.append(s); - var svg = $(w.$el).find("svg")[0]; - svg.removeAttribute('width'); - svg.removeAttribute('height'); - svg.setAttribute('width', '100%'); - svg.setAttribute('height', '98%'); - that.widgets.push(w); - if (i < total) { - that.newPlotWidget(name, data[i++], data, i++, total) - } - w.showHistoryIcon(false); - w.showHelpIcon(false); - }); + newPlotWidget (name, svgResponse, data, i, total) { + var s = svgResponse; + var that = this; + G.addWidget(1).then(w => { + if (total == 0) { + w.setName(name); + } else { + w.setName(name + " " + i); + } + w.$el.append(s); + var svg = $(w.$el).find("svg")[0]; + svg.removeAttribute('width'); + svg.removeAttribute('height'); + svg.setAttribute('width', '100%'); + svg.setAttribute('height', '98%'); + that.widgets.push(w); + if (i < total) { + that.newPlotWidget(name, data[i++], data, i++, total) + } + w.showHistoryIcon(false); + w.showHelpIcon(false); + }); } - processError(response, plotName) { - var parsedResponse = Utils.getErrorResponse(response); - if (parsedResponse) { - this.setState({ - dialogTitle: "NetPyNE returned an error plotting " + plotName, - dialogMessage: parsedResponse['message'] + "\n " + parsedResponse['details'], - openDialog: true - }); - return true; - } - return false; + processError (response, plotName) { + var parsedResponse = Utils.getErrorResponse(response); + if (parsedResponse) { + this.setState({ + dialogTitle: "NetPyNE returned an error plotting " + plotName, + dialogMessage: parsedResponse['message'] + "\n " + parsedResponse['details'], + openDialog: true + }); + return true; + } + return false; } - plotFigure(plotName, plotMethod, plotType=false) { - Utils.evalPythonMessage('netpyne_geppetto.getPlot', [plotMethod, plotType], false) - .then(response => { - //TODO Fix this, use just JSON - if(typeof response === 'string'){ - if (response.startsWith("{") && response.endsWith("}")) { - if (this.processError(response, plotName)){ - return; - } - } - if (response.startsWith("[") && response.endsWith("]")) { - response = eval(response); - } - } - if ($.isArray(response)) { - this.newPlotWidget(plotName, response[0], response, 0, response.length - 1); - } - else if (response == -1) { - this.processError(response, plotName) - } - else { - this.newPlotWidget(plotName, response, response, 0, 0); - } - }); + plotFigure (plotName, plotMethod, plotType = false) { + Utils.evalPythonMessage('netpyne_geppetto.getPlot', [plotMethod, plotType], false) + .then(response => { + // TODO Fix this, use just JSON + if (typeof response === 'string'){ + if (response.startsWith("{") && response.endsWith("}")) { + if (this.processError(response, plotName)){ + return; + } + } + if (response.startsWith("[") && response.endsWith("]")) { + response = eval(response); + } + } + if ($.isArray(response)) { + this.newPlotWidget(plotName, response[0], response, 0, response.length - 1); + } else if (response == -1) { + this.processError(response, plotName) + } else { + this.newPlotWidget(plotName, response, response, 0, 0); + } + }); } - getOpenedWidgets() { - return this.widgets; + getOpenedWidgets () { + return this.widgets; } - showWidgets(visible) { - GEPPETTO.WidgetFactory.getController(GEPPETTO.Widgets.POPUP).then(controller => { - controller.widgets.forEach(widget => { - if (visible){ - widget.show() - } - else{ - widget.hide() - } - }) + showWidgets (visible) { + GEPPETTO.WidgetFactory.getController(GEPPETTO.Widgets.POPUP).then(controller => { + controller.widgets.forEach(widget => { + if (visible){ + widget.show() + } else { + widget.hide() + } }) + }) } - componentDidMount() { - this.refs.canvas.engine.setLinesThreshold(10000); - this.refs.canvas.displayAllInstances(); - GEPPETTO.on(GEPPETTO.Events.Control_panel_close, ()=>{ - this.setState({bringItToFront: 0}) - this.showWidgets(true) - }); + componentDidMount () { + this.refs.canvas.engine.setLinesThreshold(10000); + this.refs.canvas.displayAllInstances(); + GEPPETTO.on(GEPPETTO.Events.Control_panel_close, () => { + this.setState({ bringItToFront: 0 }) + this.showWidgets(true) + }); } - componentWillUnmount(){ + componentWillUnmount (){ GEPPETTO.off(GEPPETTO.Events.Control_panel_close) } - handleClick(event) { - // This prevents ghost click. - event.preventDefault(); + handleClick (event) { + // This prevents ghost click. + event.preventDefault(); - this.setState({ - plotButtonOpen: true, - anchorEl: event.currentTarget, - }); + this.setState({ + plotButtonOpen: true, + anchorEl: event.currentTarget, + }); } - handleRequestClose() { - this.setState({ - plotButtonOpen: false, - }); + handleRequestClose () { + this.setState({ plotButtonOpen: false, }); } - render() { - var controls; - if (this.props.page == 'simulate') { - controls = ( - - {plots.map((plot, index) => {return { this.plotFigure(plot.plotName, plot.plotMethod, plot.plotType)}} />})} - - ); - } + render () { + var controls; + if (this.props.page == 'simulate') { + controls = ( + + {plots.map((plot, index) => { + this.plotFigure(plot.plotName, plot.plotMethod, plot.plotType) + }} />)} + + ); + } - return ( -
- -
- - -
- { $('#controlpanel').show(); this.showWidgets(false); this.setState({bringItToFront: 1})}} - icon={"fa-list"} - id={"ControlPanelButton"} /> -
- - - {controls} - -
- } - bodyStyle={{ overflow: 'auto' }} - style={{ whiteSpace: "pre-wrap" }} - open={this.state.openDialog} - onRequestClose={this.handleCloseDialog} - > - {this.state.dialogMessage} - -
+ return ( +
+ +
+ + +
+ { + $('#controlpanel').show(); this.showWidgets(false); this.setState({ bringItToFront: 1 }) + }} + icon={"fa-list"} + id={"ControlPanelButton"} /> +
+ + + {controls} + +
+ } + bodyStyle={{ overflow: 'auto' }} + style={{ whiteSpace: "pre-wrap" }} + open={this.state.openDialog} + onRequestClose={this.handleCloseDialog} + > + {this.state.dialogMessage} + +
- ); + ); } } \ No newline at end of file diff --git a/components/settings/NetPyNETabs.js b/components/settings/NetPyNETabs.js index af7ba7d5..f4c22316 100644 --- a/components/settings/NetPyNETabs.js +++ b/components/settings/NetPyNETabs.js @@ -6,67 +6,66 @@ import FlatButton from 'material-ui/FlatButton'; import NavigationExpandMoreIcon from 'material-ui/svg-icons/navigation/expand-more'; - export default class NetPyNETabs extends React.Component { - constructor(props) { - super(props); - this.state = { - simulateTabLabel: 'Create network', - label: 'define', - transitionOptionsHovered: false - } + constructor (props) { + super(props); + this.state = { + simulateTabLabel: 'Create network', + label: 'define', + transitionOptionsHovered: false + } - this.handleTransitionOptionsChange = this.handleTransitionOptionsChange.bind(this); + this.handleTransitionOptionsChange = this.handleTransitionOptionsChange.bind(this); - } + } - componentDidUpdate (prevProps, prevState) { - if (this.props.label!=prevProps.label) { - this.setState({label:this.props.label}); - } + componentDidUpdate (prevProps, prevState) { + if (this.props.label != prevProps.label) { + this.setState({ label:this.props.label }); } + } - handleTransitionOptionsChange(e, v) { - this.setState({ simulateTabLabel: v }); - this.props.handleTransitionOptionsChange(e, v) - } + handleTransitionOptionsChange (e, v) { + this.setState({ simulateTabLabel: v }); + this.props.handleTransitionOptionsChange(e, v) + } - getLabelStyle(label) { - var style = { color: 'white', fontWeight: 400 } - if (label == this.state.label) { - style['fontWeight'] = 600; - } - return style; + getLabelStyle (label) { + var style = { color: 'white', fontWeight: 400 } + if (label == this.state.label) { + style['fontWeight'] = 600; } + return style; + } - getBackgroundStyle(label) { - var color = '#543a73'; - if (label == this.state.label || (label == 'simulate' && this.state.transitionOptionsHovered)) { - color = '#634587'; - } - return color; + getBackgroundStyle (label) { + var color = '#543a73'; + if (label == this.state.label || (label == 'simulate' && this.state.transitionOptionsHovered)) { + color = '#634587'; } + return color; + } - render() { + render () { - return
- this.props.handleChange('define')} style={{ flex: 1, borderRadius: 10, marginLeft: 5 }} backgroundColor={this.getBackgroundStyle('define')} hoverColor={'#5e4081'} labelStyle={this.getLabelStyle('define')} label="Define your Network" /> - this.props.handleChange('simulate')} style={{ flex: 1, borderRadius: 10, marginLeft: 5 }} backgroundColor={this.getBackgroundStyle('simulate')} hoverColor={'#5e4081'} labelStyle={this.getLabelStyle('simulate')} label={this.state.simulateTabLabel} /> - this.setState({ transitionOptionsHovered: true })} onMouseLeave={() => this.setState({ transitionOptionsHovered: false })}>} - onChange={this.handleTransitionOptionsChange} - useLayerForClickAway={true} - targetOrigin={{ horizontal: "right", vertical: "top" }} - anchorOrigin={{ horizontal: "right", vertical: "bottom" }} - > - - - - -
- } + return
+ this.props.handleChange('define')} style={{ flex: 1, borderRadius: 10, marginLeft: 5 }} backgroundColor={this.getBackgroundStyle('define')} hoverColor={'#5e4081'} labelStyle={this.getLabelStyle('define')} label="Define your Network" /> + this.props.handleChange('simulate')} style={{ flex: 1, borderRadius: 10, marginLeft: 5 }} backgroundColor={this.getBackgroundStyle('simulate')} hoverColor={'#5e4081'} labelStyle={this.getLabelStyle('simulate')} label={this.state.simulateTabLabel} /> + this.setState({ transitionOptionsHovered: true })} onMouseLeave={() => this.setState({ transitionOptionsHovered: false })}>} + onChange={this.handleTransitionOptionsChange} + useLayerForClickAway={true} + targetOrigin={{ horizontal: "right", vertical: "top" }} + anchorOrigin={{ horizontal: "right", vertical: "bottom" }} + > + + + + +
+ } } diff --git a/components/settings/NetPyNEToolBar.js b/components/settings/NetPyNEToolBar.js index a3c6a445..9964ce1a 100644 --- a/components/settings/NetPyNEToolBar.js +++ b/components/settings/NetPyNEToolBar.js @@ -18,7 +18,7 @@ const ImportIcon = props => ; export default class NetPyNEToolBar extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { openDialogBox: false, @@ -27,56 +27,56 @@ export default class NetPyNEToolBar extends React.Component { } } - handleMenuItemClick = (action) => { - this.setState({action:action, openDialogBox:true, open: false}) + handleMenuItemClick = action => { + this.setState({ action:action, openDialogBox:true, open: false }) } - render() { + render () { if (this.state.openDialogBox){ - switch(this.state.action){ - case 'Load': - var content = this.setState({ openDialogBox: false })} - changeTab={this.props.changeTab} - /> - break; - case 'Save': - var content = this.setState({ openDialogBox: false })} - changeTab={this.props.changeTab} - /> - break; - case 'ImportHLS': - var content = this.setState({ openDialogBox: false })} - changeTab={this.props.changeTab} - mode ={"IMPORT"}/> - break; - case 'ExportHLS': - var content = this.setState({ openDialogBox: false })} - changeTab={this.props.changeTab} - mode ={"EXPORT"} - /> - break; - case 'ImportCellTemplate': - var content = this.setState({ openDialogBox: false })} - /> - break; - case 'NewModel': - var content = this.setState({ openDialogBox: false })} - changeTab={this.props.changeTab} - /> - break; + switch (this.state.action){ + case 'Load': + var content = this.setState({ openDialogBox: false })} + changeTab={this.props.changeTab} + /> + break; + case 'Save': + var content = this.setState({ openDialogBox: false })} + changeTab={this.props.changeTab} + /> + break; + case 'ImportHLS': + var content = this.setState({ openDialogBox: false })} + changeTab={this.props.changeTab} + mode ={"IMPORT"}/> + break; + case 'ExportHLS': + var content = this.setState({ openDialogBox: false })} + changeTab={this.props.changeTab} + mode ={"EXPORT"} + /> + break; + case 'ImportCellTemplate': + var content = this.setState({ openDialogBox: false })} + /> + break; + case 'NewModel': + var content = this.setState({ openDialogBox: false })} + changeTab={this.props.changeTab} + /> + break; } } @@ -95,11 +95,11 @@ export default class NetPyNEToolBar extends React.Component { docked={false} width={265} open={this.state.open} - onRequestChange={(open) => this.setState({ open })} + onRequestChange={open => this.setState({ open })} >
-

GUI Version 0.5.2

+

GUI Version 0.5.2

this.handleMenuItemClick('NewModel')} leftIcon={} /> @@ -111,5 +111,5 @@ export default class NetPyNEToolBar extends React.Component { {content}
- } + } } diff --git a/components/settings/actions/ActionDialog.js b/components/settings/actions/ActionDialog.js index a44619ce..8fcb4b6f 100644 --- a/components/settings/actions/ActionDialog.js +++ b/components/settings/actions/ActionDialog.js @@ -4,13 +4,9 @@ import FlatButton from 'material-ui/FlatButton/FlatButton'; import RaisedButton from 'material-ui/RaisedButton/RaisedButton'; import Utils from '../../../Utils'; -const styles = { - cancel: { - marginRight: 10 - } -} +const styles = { cancel: { marginRight: 10 } } export default class ActionDialog extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { open: this.props.open, @@ -21,28 +17,26 @@ export default class ActionDialog extends React.Component { componentDidUpdate = (prevProps, prevState) => { if (this.props.open != prevProps.open) { - this.setState({ - open: this.props.open - }); + this.setState({ open: this.props.open }); } } performAction = () => { if (this.props.isFormValid === undefined || this.props.isFormValid()){ GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, this.props.message); - this.closeDialog(); + this.closeDialog(); Utils .evalPythonMessage(this.props.command, [this.props.args]) .then(response => { if (!this.processError(response)) { - if (this.props.args.tab!=undefined) { + if (this.props.args.tab != undefined) { this.props.changeTab(this.props.args.tab, this.props.args); } - if (this.props.args.tab=='simulate') { + if (this.props.args.tab == 'simulate') { GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL); GEPPETTO.Manager.loadModel(response); GEPPETTO.CommandController.log("The NetPyNE model " + this.props.args.tab + " was completed"); - } + } if (this.props.args.action == "deleteModel") { GEPPETTO.WidgetFactory.getController(GEPPETTO.Widgets.POPUP).then(controller => { controller.widgets.forEach(widget => { @@ -53,30 +47,30 @@ export default class ActionDialog extends React.Component { GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); this.props.onRequestClose(); } - }); + }); } } closeDialog = () => { - this.setState({ open: false, errorMessage: undefined, errorDetails: undefined}) + this.setState({ open: false, errorMessage: undefined, errorDetails: undefined }) } cancelDialog = () => { - this.setState({ open: false, errorMessage: undefined, errorDetails: undefined}) + this.setState({ open: false, errorMessage: undefined, errorDetails: undefined }) this.props.onRequestClose(); } - processError = (response) => { + processError = response => { var parsedResponse = Utils.getErrorResponse(response); if (parsedResponse) { GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); - this.setState({ open: true, errorMessage: parsedResponse['message'], errorDetails: parsedResponse['details']}) + this.setState({ open: true, errorMessage: parsedResponse['message'], errorDetails: parsedResponse['details'] }) return true; } return false; } - render() { + render () { if (this.state.open) { var cancelAction = ; if (this.state.errorMessage == undefined) { @@ -86,8 +80,7 @@ export default class ActionDialog extends React.Component { ]; var content = this.props.children; - } - else { + } else { var actions = [ cancelAction, this.closeDialog()} + onRequestClose={() => this.closeDialog()} > {content} @@ -115,4 +108,4 @@ export default class ActionDialog extends React.Component { } return null; } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/components/settings/actions/ImportCellParams.js b/components/settings/actions/ImportCellParams.js index d49407e4..53632d9a 100644 --- a/components/settings/actions/ImportCellParams.js +++ b/components/settings/actions/ImportCellParams.js @@ -8,35 +8,21 @@ import NetPyNEField from '../../general/NetPyNEField'; const styles = { card: { - main: { - padding: 10, float: 'left', width: '100%' - }, - title: { - paddingBottom: 0 - }, - cancel: { - marginRight: 16 - } + main: { padding: 10, float: 'left', width: '100%' }, + title: { paddingBottom: 0 }, + cancel: { marginRight: 16 } }, mods: { - container: { - width: '100%', float: 'left', marginTop: '15px' - }, - leftSubContainer: { - float: 'left', width: '50%' - }, - rightSubContainer: { - float: 'right', width: '50%' - }, - checkbox: { - width: '90%' - } + container: { width: '100%', float: 'left', marginTop: '15px' }, + leftSubContainer: { float: 'left', width: '50%' }, + rightSubContainer: { float: 'right', width: '50%' }, + checkbox: { width: '90%' } } } export default class ImportCellParams extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { label: 'NewCellRule', @@ -48,34 +34,34 @@ export default class ImportCellParams extends React.Component { explorerDialogOpen: false, exploreOnlyDirs: false, }; - }; + } - updateCheck(name) { - this.setState(({[name]: pv}) => ({ [name]: !pv})); - }; + updateCheck (name) { + this.setState(({ [name]: pv }) => ({ [name]: !pv })); + } - showExplorerDialog(explorerParameter, exploreOnlyDirs) { + showExplorerDialog (explorerParameter, exploreOnlyDirs) { this.setState({ explorerDialogOpen: true, explorerParameter: explorerParameter, exploreOnlyDirs: exploreOnlyDirs }); - }; + } - closeExplorerDialog(fieldValue) { + closeExplorerDialog (fieldValue) { var newState = { explorerDialogOpen: false }; if (fieldValue) { switch (this.state.explorerParameter) { - case "fileName": - newState["fileName"] = fieldValue.path; - break; - case "modFolder": - newState["modFolder"] = fieldValue.path; - break; - default: - throw ("Not a valid parameter!"); + case "fileName": + newState["fileName"] = fieldValue.path; + break; + case "modFolder": + newState["modFolder"] = fieldValue.path; + break; + default: + throw ("Not a valid parameter!"); } } this.setState(newState); - }; + } - render() { + render () { const cellArgs = this.refs.cellArgs ? this.refs.cellArgs.state.children : {} const { label, fileName, cellName, modFolder, importSynMechs, compileMod, explorerDialogOpen, exploreOnlyDirs } = this.state; @@ -155,5 +141,5 @@ export default class ImportCellParams extends React.Component { ) - }; -}; + } +} diff --git a/components/settings/actions/ImportExportHLS.js b/components/settings/actions/ImportExportHLS.js index a463dcf9..168775c4 100644 --- a/components/settings/actions/ImportExportHLS.js +++ b/components/settings/actions/ImportExportHLS.js @@ -8,174 +8,171 @@ import FileBrowser from '../../general/FileBrowser'; import ActionDialog from './ActionDialog'; export default class ImportExportHLS extends React.Component { - constructor(props) { - super(props); - this.state = { - fileName: "output", - netParamsPath: "", - netParamsModuleName: "", - netParamsVariable: "netParams", - simConfigPath: "", - simConfigModuleName: "", - simConfigVariable: "simConfig", - modFolder: "", - loadMod: '', - compileMod: false, - explorerDialogOpen: false, - explorerParameter: "", - exploreOnlyDirs: false, - filterFiles: false, - netParamsHovered: 'hidden' - } - - this.isFormValid = this.isFormValid.bind(this); + constructor (props) { + super(props); + this.state = { + fileName: "output", + netParamsPath: "", + netParamsModuleName: "", + netParamsVariable: "netParams", + simConfigPath: "", + simConfigModuleName: "", + simConfigVariable: "simConfig", + modFolder: "", + loadMod: '', + compileMod: false, + explorerDialogOpen: false, + explorerParameter: "", + exploreOnlyDirs: false, + filterFiles: false, + netParamsHovered: 'hidden' } - isFormValid(){ - if (this.props.mode == 'IMPORT'){ - // FIXME: Set to undefine to show error text. No particularly elegant - if (this.state.loadMod === ''){ - this.setState({loadMod: undefined}) - } - return this.state.loadMod !== undefined && this.state.loadMod !== '' - } - else{ - return true; - } - } + this.isFormValid = this.isFormValid.bind(this); + } - showExplorerDialog(explorerParameter, exploreOnlyDirs, filterFiles) { - this.setState({ explorerDialogOpen: true, explorerParameter: explorerParameter, exploreOnlyDirs: exploreOnlyDirs, filterFiles: filterFiles }) + isFormValid (){ + if (this.props.mode == 'IMPORT'){ + // FIXME: Set to undefine to show error text. No particularly elegant + if (this.state.loadMod === ''){ + this.setState({ loadMod: undefined }) + } + return this.state.loadMod !== undefined && this.state.loadMod !== '' + } else { + return true; } + } + + showExplorerDialog (explorerParameter, exploreOnlyDirs, filterFiles) { + this.setState({ explorerDialogOpen: true, explorerParameter: explorerParameter, exploreOnlyDirs: exploreOnlyDirs, filterFiles: filterFiles }) + } - closeExplorerDialog(fieldValue) { - var newState = { explorerDialogOpen: false }; - if (fieldValue) { - var fileName = fieldValue.path.replace(/^.*[\\\/]/, ''); - var fileNameNoExtension = fileName.replace(/\.[^/.]+$/, ""); - var path = fieldValue.path.split(fileName).slice(0, -1).join(''); - switch (this.state.explorerParameter) { - case "netParamsPath": - newState["netParamsPath"] = path; - newState["simConfigPath"] = path; - newState["netParamsModuleName"] = fileNameNoExtension; - newState["simConfigModuleName"] = fileNameNoExtension; - break; - case "simConfigPath": - newState["simConfigPath"] = path; - newState["simConfigModuleName"] = fileNameNoExtension; - break; - case "modFolder": - newState["modFolder"] = fieldValue.path; - break; - default: - throw ("Not a valid parameter!"); - } - } - this.setState(newState); + closeExplorerDialog (fieldValue) { + var newState = { explorerDialogOpen: false }; + if (fieldValue) { + var fileName = fieldValue.path.replace(/^.*[\\\/]/, ''); + var fileNameNoExtension = fileName.replace(/\.[^/.]+$/, ""); + var path = fieldValue.path.split(fileName).slice(0, -1).join(''); + switch (this.state.explorerParameter) { + case "netParamsPath": + newState["netParamsPath"] = path; + newState["simConfigPath"] = path; + newState["netParamsModuleName"] = fileNameNoExtension; + newState["simConfigModuleName"] = fileNameNoExtension; + break; + case "simConfigPath": + newState["simConfigPath"] = path; + newState["simConfigModuleName"] = fileNameNoExtension; + break; + case "modFolder": + newState["modFolder"] = fieldValue.path; + break; + default: + throw ("Not a valid parameter!"); + } } + this.setState(newState); + } - render() { - switch(this.props.mode) { - case 'IMPORT': - var content = -
- this.showExplorerDialog('netParamsPath', false, '.py')} - floatingLabelText="NetParams file: (click to select)" - underlineStyle={{borderWidth:'1px'}} - errorText={this.state.netParamsPath?'path: '+this.state.netParamsPath:''} - errorStyle={{color: grey400}} - /> - this.setState({ netParamsVariable: event.target.value })} /> + render () { + switch (this.props.mode) { + case 'IMPORT': + var content + =
+ this.showExplorerDialog('netParamsPath', false, '.py')} + floatingLabelText="NetParams file: (click to select)" + underlineStyle={{ borderWidth:'1px' }} + errorText={this.state.netParamsPath ? 'path: ' + this.state.netParamsPath : ''} + errorStyle={{ color: grey400 }} + /> + this.setState({ netParamsVariable: event.target.value })} /> + this.showExplorerDialog('simConfigPath', false, '.py')} + floatingLabelText="SimConfig file: (click to select)" + underlineStyle={{ borderWidth:'1px' }} + errorText={this.state.simConfigPath ? 'path: ' + this.state.simConfigPath : ''} + errorStyle={{ color: grey400 }} + /> + this.setState({ simConfigVariable: event.target.value })} /> +
+ this.setState({ loadMod: value })} + > + + + this.showExplorerDialog('simConfigPath', false, '.py')} - floatingLabelText="SimConfig file: (click to select)" - underlineStyle={{borderWidth:'1px'}} - errorText={this.state.simConfigPath?'path: '+this.state.simConfigPath:''} - errorStyle={{color: grey400}} + className="netpyneFieldNoWidth" + style={{ float: 'left', width: '48%', cursor: 'pointer', marginTop: -20 }} + floatingLabelText="Path to mod files" + disabled={this.state.loadMod === '' ? true : !this.state.loadMod} + value={this.state.modFolder} + onClick={() => this.showExplorerDialog('modFolder', true, false)} + readOnly /> - this.setState({ simConfigVariable: event.target.value })} /> -
- this.setState({loadMod: value})} - > - - - - this.showExplorerDialog('modFolder', true, false)} - readOnly - /> -
- this.setState((oldState) => { - return { - compileMod: !oldState.compileMod, - }; - })} - /> -
- this.closeExplorerDialog(selection)} /> +
+ this.setState(oldState => ({ compileMod: !oldState.compileMod, }))} + />
+ this.closeExplorerDialog(selection)} /> +
- var command = 'netpyne_geppetto.importModel'; - var message = 'IMPORTING MODEL'; - var buttonLabel = 'Import' - var title = 'Import from Python scripts' - break; - case 'EXPORT': - var content = - {this.setState({fileName: v})}} + var command = 'netpyne_geppetto.importModel'; + var message = 'IMPORTING MODEL'; + var buttonLabel = 'Import' + var title = 'Import from Python scripts' + break; + case 'EXPORT': + var content + = { + this.setState({ fileName: v }) + }} /> - var command = 'netpyne_geppetto.exportHLS'; - var message = 'EXPORTING MODEL'; - var buttonLabel = 'Export' - var title = 'Export as Python script' - break - } - return ( - - {content} - - ) + var command = 'netpyne_geppetto.exportHLS'; + var message = 'EXPORTING MODEL'; + var buttonLabel = 'Export' + var title = 'Export as Python script' + break } + return ( + + {content} + + ) + } } \ No newline at end of file diff --git a/components/settings/actions/LoadFile.js b/components/settings/actions/LoadFile.js index e0ce2ea8..da981c5c 100644 --- a/components/settings/actions/LoadFile.js +++ b/components/settings/actions/LoadFile.js @@ -1,6 +1,6 @@ import React from 'react'; -import {List, ListItem} from 'material-ui/List'; -import { orange500, blue500, grey400} from 'material-ui/styles/colors'; +import { List, ListItem } from 'material-ui/List'; +import { orange500, blue500, grey400 } from 'material-ui/styles/colors'; import Checkbox from 'material-ui/Checkbox'; import MenuItem from 'material-ui/MenuItem'; import TextField from 'material-ui/TextField'; @@ -9,14 +9,14 @@ import FileBrowser from '../../general/FileBrowser'; import ActionDialog from './ActionDialog'; const loadOptions = [ - {label: 'High-level Network Parameters (netParams)', label2: 'Cell rules, connectivity rules, etc', state: 'loadNetParams'}, - {label: 'Simulation Configuration (simConfig)', label2: 'duration, recorded variables, etc', state: 'loadSimCfg'}, - {label: 'Instantiated Network', label2: 'All cells, connections, etc', state: 'loadNet'}, - {label: 'Simulation Data', label2: 'Spikes, traces, etc', state: 'loadSimData'} + { label: 'High-level Network Parameters (netParams)', label2: 'Cell rules, connectivity rules, etc', state: 'loadNetParams' }, + { label: 'Simulation Configuration (simConfig)', label2: 'duration, recorded variables, etc', state: 'loadSimCfg' }, + { label: 'Instantiated Network', label2: 'All cells, connections, etc', state: 'loadNet' }, + { label: 'Simulation Data', label2: 'Spikes, traces, etc', state: 'loadSimData' } ] export default class LoadFile extends React.Component { - constructor(props) { + constructor (props) { super(props); this.state = { jsonModelFolder: "", @@ -37,45 +37,47 @@ export default class LoadFile extends React.Component { } - showExplorerDialog(explorerParameter, exploreOnlyDirs) { + showExplorerDialog (explorerParameter, exploreOnlyDirs) { this.setState({ explorerDialogOpen: true, explorerParameter: explorerParameter, exploreOnlyDirs: exploreOnlyDirs }) } - closeExplorerDialog(fieldValue) { + closeExplorerDialog (fieldValue) { var newState = { explorerDialogOpen: false }; if (fieldValue) { let fileName = fieldValue.path.replace(/^.*[\\\/]/, ''); let path = fieldValue.path.split(fileName).slice(0, -1).join(''); switch (this.state.explorerParameter) { - case "modFolder": - newState["modFolder"] = fieldValue.path; - newState["modPath"] = path; - break; - case "jsonModelFolder": - newState["jsonModelFolder"] = fieldValue.path; - newState["jsonPath"] = path; - break; - default: - throw ("Not a valid parameter!"); + case "modFolder": + newState["modFolder"] = fieldValue.path; + newState["modPath"] = path; + break; + case "jsonModelFolder": + newState["jsonModelFolder"] = fieldValue.path; + newState["jsonPath"] = path; + break; + default: + throw ("Not a valid parameter!"); } } this.setState(newState); } - isFormValid(){ + isFormValid (){ // FIXME: Set to undefine to show error text. No particularly elegant if (this.state.areModFieldsRequired === ''){ - this.setState({areModFieldsRequired: undefined}) + this.setState({ areModFieldsRequired: undefined }) } return this.state.areModFieldsRequired !== undefined && this.state.areModFieldsRequired !== '' } - render() { - // freeze instance means we will get the latest instance, so it will not be required an update of the instance in the future. - // similar for simulation - // tab controls whether we want to move to a different tab or to stay where we are. undefined == 'I dont want to move to other tab' - let freezeInstance = this.state.loadNet ? true : false - let freezeSimulation = freezeInstance && this.state.loadSimData ? true : false + render () { + /* + * freeze instance means we will get the latest instance, so it will not be required an update of the instance in the future. + * similar for simulation + * tab controls whether we want to move to a different tab or to stay where we are. undefined == 'I dont want to move to other tab' + */ + let freezeInstance = !!this.state.loadNet + let freezeSimulation = !!(freezeInstance && this.state.loadSimData) let tab = this.state.loadSimData || this.state.loadNet ? 'simulate' : 'define' return ( @@ -85,40 +87,40 @@ export default class LoadFile extends React.Component { message = {'LOADING FILE'} isFormValid={this.isFormValid} command ={'netpyne_geppetto.loadModel'} - args={{...this.state, tab:tab, freezeInstance: freezeInstance, freezeSimulation: freezeSimulation}} + args={{ ...this.state, tab:tab, freezeInstance: freezeInstance, freezeSimulation: freezeSimulation }} {...this.props} > -
+
this.showExplorerDialog('jsonModelFolder', false)} - underlineStyle={{borderWidth:'1px'}} - errorText={this.state.jsonPath!=''?'path: '+this.state.jsonPath:''} - errorStyle={{color: grey400}} + underlineStyle={{ borderWidth:'1px' }} + errorText={this.state.jsonPath != '' ? 'path: ' + this.state.jsonPath : ''} + errorStyle={{ color: grey400 }} /> - {loadOptions.map((loadOption, index) => {return 1 ? "20px" : "-10px"}} + {loadOptions.map((loadOption, index) => 1 ? "20px" : "-10px" }} key={index} - leftCheckbox= { this.setState(({[loadOption.state]: oldState, ...others}) => {return {[loadOption.state]: !oldState}})} checked={this.state[loadOption.state]} />} + leftCheckbox= { this.setState(({ [loadOption.state]: oldState, ...others }) => ({ [loadOption.state]: !oldState }))} checked={this.state[loadOption.state]} />} primaryText={loadOption.label} secondaryText={loadOption.label2} - />}) + />) }
this.setState({areModFieldsRequired: value})} + onChange={(event, index, value) => this.setState({ areModFieldsRequired: value })} > @@ -126,25 +128,25 @@ export default class LoadFile extends React.Component { this.showExplorerDialog('modFolder', true)} - underlineStyle={{borderWidth:'1px'}} + underlineStyle={{ borderWidth:'1px' }} errorText={this.state.modPath != '' ? 'path: ' + this.state.modPath : ''} - errorStyle={{color: grey400}} + errorStyle={{ color: grey400 }} /> -
+
this.setState(oldState => ({compileMod: this.state.areModFieldsRequired?!oldState.compileMod:false}))} + onCheck={() => this.setState(oldState => ({ compileMod: this.state.areModFieldsRequired ? !oldState.compileMod : false }))} />
- this.closeExplorerDialog(selection)} /> + this.closeExplorerDialog(selection)} />
diff --git a/components/settings/actions/NewModel.js b/components/settings/actions/NewModel.js index bb0a9385..74ea6621 100644 --- a/components/settings/actions/NewModel.js +++ b/components/settings/actions/NewModel.js @@ -2,23 +2,23 @@ import React from 'react'; import ActionDialog from './ActionDialog'; export default class NewModel extends React.Component { - constructor(props) { - super(props); - } + constructor (props) { + super(props); + } - render() { - return ( - -

The current model will be deleted

-
- ) - } + render () { + return ( + +

The current model will be deleted

+
+ ) + } } \ No newline at end of file diff --git a/components/settings/actions/SaveFile.js b/components/settings/actions/SaveFile.js index 8ef9b9c0..bfef9e13 100644 --- a/components/settings/actions/SaveFile.js +++ b/components/settings/actions/SaveFile.js @@ -1,63 +1,63 @@ import React from 'react'; import Checkbox from 'material-ui/Checkbox'; import TextField from 'material-ui/TextField'; -import {List, ListItem} from 'material-ui/List'; +import { List, ListItem } from 'material-ui/List'; import Utils from '../../../Utils'; import ActionDialog from './ActionDialog'; const saveOptions = [ - {label: 'High-level Network Parameters (netParams)', label2: 'Cell rules, connectivity rules, etc', state: 'loadNetParams'}, - {label: 'Simulation Configuration (simConfig)', label2: 'duration, recorded variables, etc', state: 'loadSimCfg'}, - {label: 'Instantiated Network', label2: 'All cells, connections, etc', state: 'loadNet'}, - {label: 'Simulation Data', label2: 'Spikes, traces, etc', state: 'loadSimData'} + { label: 'High-level Network Parameters (netParams)', label2: 'Cell rules, connectivity rules, etc', state: 'loadNetParams' }, + { label: 'Simulation Configuration (simConfig)', label2: 'duration, recorded variables, etc', state: 'loadSimCfg' }, + { label: 'Instantiated Network', label2: 'All cells, connections, etc', state: 'loadNet' }, + { label: 'Simulation Data', label2: 'Spikes, traces, etc', state: 'loadSimData' } ] export default class SaveFile extends React.Component { - constructor(props) { - super(props); - this.state = { - fileName: 'output', - netParams: true, - simConfig: true, - simData: true, - netCells: true - } - + constructor (props) { + super(props); + this.state = { + fileName: 'output', + netParams: true, + simConfig: true, + simData: true, + netCells: true } + + } - componentDidMount () { - Utils.evalPythonMessage('netpyne_geppetto.doIhaveInstOrSimData', []) - .then(response => { - this.setState({disableNetCells: !response['haveInstance'], disableSimData: !response['haveSimData'], netCells:response['haveInstance'], simData: response['haveSimData']}) - } - ) - } + componentDidMount () { + Utils.evalPythonMessage('netpyne_geppetto.doIhaveInstOrSimData', []) + .then(response => { + this.setState({ disableNetCells: !response['haveInstance'], disableSimData: !response['haveSimData'], netCells:response['haveInstance'], simData: response['haveSimData'] }) + } + ) + } - render() { - return ( - - this.setState({ fileName: event.target.value })} - /> - - {saveOptions.map((saveOption, index) => {return 1 ? "20px" : "-10px"}} - key={index} - leftCheckbox= { this.setState(({[saveOption.state]: oldState, ...others}) => {return {[saveOption.state]: !oldState}})} checked={this.state[saveOption.state]}/>} - primaryText={saveOption.label} - secondaryText={saveOption.label2} - />})} - - - ) - } + render () { + return ( + + this.setState({ fileName: event.target.value })} + /> + + {saveOptions.map((saveOption, index) => 1 ? "20px" : "-10px" }} + key={index} + leftCheckbox= { this.setState(({ [saveOption.state]: oldState, ...others }) => ({ [saveOption.state]: !oldState }))} checked={this.state[saveOption.state]}/>} + primaryText={saveOption.label} + secondaryText={saveOption.label2} + />)} + + + ) + } } \ No newline at end of file diff --git a/components/transition/Transition.js b/components/transition/Transition.js index 974d52a6..1222ffad 100644 --- a/components/transition/Transition.js +++ b/components/transition/Transition.js @@ -7,154 +7,156 @@ import FlatButton from 'material-ui/FlatButton'; import Utils from '../../Utils'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; -import {pink400} from 'material-ui/styles/colors'; +import { pink400 } from 'material-ui/styles/colors'; -const RocketIcon = (props) => (); +const RocketIcon = props => (); export default class Transition extends React.Component { - constructor(props) { - super(props); - this.state = { - openDialog: false, - haveInstData: false, - parallelSimulation: false, - instantiateButtonHovered: false, - simulateButtonHovered: false - }; - } + constructor (props) { + super(props); + this.state = { + openDialog: false, + haveInstData: false, + parallelSimulation: false, + instantiateButtonHovered: false, + simulateButtonHovered: false + }; + } - componentDidUpdate (prevProps, prevState) { - if (this.props.clickOnTab!=prevProps.clickOnTab) { - if (this.props.tab!=prevProps.tab && this.props.tab=='simulate') { - if (this.props.fastForwardSimulation) { // re instantiate and re simulate network - this.setState({openDialog: true}) - } - else if (this.props.fastForwardInstantiation) { // re instantiate network but do not simulate - this.instantiate({usePrevInst: false}) - } - else { - if (!this.state.haveInstData) { // if there is no previous instance data - Utils.evalPythonMessage('netpyne_geppetto.doIhaveInstOrSimData', []) - .then(response => { - //FIXME: Checking if the contructor name is an array is clearly the wrong approach - if (response.constructor.name=='Array'){ - this.instantiate({usePrevInst: this.props.fastForwardInstantiation?false:response[0]}) - } - else if (response.haveInstance){ - this.instantiate({usePrevInst: true, haveInstData: true}) - } - }) - } - else { // if has prev instance data - this.instantiate({usePrevInst: true}) - } + componentDidUpdate (prevProps, prevState) { + if (this.props.clickOnTab != prevProps.clickOnTab) { + if (this.props.tab != prevProps.tab && this.props.tab == 'simulate') { + if (this.props.fastForwardSimulation) { // re instantiate and re simulate network + this.setState({ openDialog: true }) + } else if (this.props.fastForwardInstantiation) { // re instantiate network but do not simulate + this.instantiate({ usePrevInst: false }) + } else { + if (!this.state.haveInstData) { // if there is no previous instance data + Utils.evalPythonMessage('netpyne_geppetto.doIhaveInstOrSimData', []) + .then(response => { + // FIXME: Checking if the contructor name is an array is clearly the wrong approach + if (response.constructor.name == 'Array'){ + this.instantiate({ usePrevInst: this.props.fastForwardInstantiation ? false : response[0] }) + } else if (response.haveInstance){ + this.instantiate({ usePrevInst: true, haveInstData: true }) } - } + }) + } else { // if has prev instance data + this.instantiate({ usePrevInst: true }) + } } + } } + } - instantiate = (args) => { - GEPPETTO.CommandController.log("The NetPyNE model is getting instantiated..."); - GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.INSTANTIATING_MODEL); - this.closeTransition(); - Utils.evalPythonMessage('netpyne_geppetto.instantiateNetPyNEModelInGeppetto', [args]) - .then(response => { - if (!this.processError(response)) { - GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL); - if (!args.usePrevInst) this.props.handleDeactivateInstanceUpdate(true) - GEPPETTO.Manager.loadModel(response); - GEPPETTO.CommandController.log("The NetPyNE model instantiation was completed"); - GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); - this.setState({haveInstData: true}) - } - }); + instantiate = args => { + GEPPETTO.CommandController.log("The NetPyNE model is getting instantiated..."); + GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.INSTANTIATING_MODEL); + this.closeTransition(); + Utils.evalPythonMessage('netpyne_geppetto.instantiateNetPyNEModelInGeppetto', [args]) + .then(response => { + if (!this.processError(response)) { + GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL); + if (!args.usePrevInst) { + this.props.handleDeactivateInstanceUpdate(true) + } + GEPPETTO.Manager.loadModel(response); + GEPPETTO.CommandController.log("The NetPyNE model instantiation was completed"); + GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); + this.setState({ haveInstData: true }) + } + }); } simulate = () => { - this.setState({openDialog: false}) - GEPPETTO.CommandController.log("The NetPyNE model is getting simulated..."); - GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.RUNNING_SIMULATION); - this.closeTransition(); - Utils.evalPythonMessage('netpyne_geppetto.simulateNetPyNEModelInGeppetto ', [{ - usePrevInst: this.props.freezeInstance, parallelSimulation: this.state.parallelSimulation, cores:this.state.cores}]) - .then(response => { - if (!this.processError(response)) { - GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL); - this.props.handleDeactivateSimulationUpdate(true) - if (!this.props.freezeInstance) this.props.handleDeactivateInstanceUpdate(true) - GEPPETTO.Manager.loadModel(response); - GEPPETTO.CommandController.log("The NetPyNE model simulation was completed"); - GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); - this.setState({haveInstData: true}) + this.setState({ openDialog: false }) + GEPPETTO.CommandController.log("The NetPyNE model is getting simulated..."); + GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.RUNNING_SIMULATION); + this.closeTransition(); + Utils.evalPythonMessage('netpyne_geppetto.simulateNetPyNEModelInGeppetto ', [{ usePrevInst: this.props.freezeInstance, parallelSimulation: this.state.parallelSimulation, cores:this.state.cores }]) + .then(response => { + if (!this.processError(response)) { + GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL); + this.props.handleDeactivateSimulationUpdate(true) + if (!this.props.freezeInstance) { + this.props.handleDeactivateInstanceUpdate(true) } + GEPPETTO.Manager.loadModel(response); + GEPPETTO.CommandController.log("The NetPyNE model simulation was completed"); + GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); + this.setState({ haveInstData: true }) + } }); } - processError(response) { - var parsedResponse = Utils.getErrorResponse(response); - if (parsedResponse) { - GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); - this.setState({ openDialog: true, errorMessage: parsedResponse['message'], errorDetails: parsedResponse['details'] }) - return true; - } - return false; + processError (response) { + var parsedResponse = Utils.getErrorResponse(response); + if (parsedResponse) { + GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner); + this.setState({ openDialog: true, errorMessage: parsedResponse['message'], errorDetails: parsedResponse['details'] }) + return true; + } + return false; } closeTransition = () => { - this.setState({ openDialog: false }); + this.setState({ openDialog: false }); } render () { - var children = this.state.errorDetails?Utils.parsePythonException(this.state.errorDetails):null - var title = this.state.errorMessage?this.state.errorMessage:"NetPyNE"; + var children = this.state.errorDetails ? Utils.parsePythonException(this.state.errorDetails) : null + var title = this.state.errorMessage ? this.state.errorMessage : "NetPyNE"; - if (this.state.openDialog) { - if (this.state.errorMessage==undefined) { - children = ( -
-
We are about to instantiate and simulate your network, this could take some time.
- this.setState((oldState) => {return {parallelSimulation: !oldState.parallelSimulation}})} style={{ marginTop: '35px' }} id="runParallelSimulation" /> - this.setState({ cores: event.target.value })} className="netpyneRightField" type="number"/> -
- ) - var actions = [{this.closeTransition()}} primary={true} key={"cancelActionBtn"} />, this.simulate()} id={"okRunSimulation"} primary={true} keyboardFocused={true} key={"runSimulationButton"} />]; - } - else{ - var actions = {this.closeTransition()}} key={"cancelActionBtn"} primary={true} /> - } - } - - if (this.props.tab=='simulate' ) { - var refreshInstanceButton = ( - this.instantiate({usePrevInst: false})} style={{position: 'absolute', right: 30, top: 60, width:'24px', height:'24px'}} tooltip={this.props.freezeInstance?"Your network is in sync":"Synchronise network"} tooltipPosition="bottom-left" disabled={this.props.freezeInstance} tooltipStyles={{marginTop: -37, marginRight:10}}> - - - ) - var refreshSimulationButton = ( - this.setState({openDialog: true})} style={{position: 'absolute', right: 30, top: 110, width:'24px', height:'24px'}} tooltip={this.props.freezeSimulation?"You have already simulated your network":"Simulate your network"} tooltipPosition="bottom-left" disabled={this.props.freezeSimulation} tooltipStyles={{marginTop: -38, marginRight:10}}> - - - ) - } - - return ( + if (this.state.openDialog) { + if (this.state.errorMessage == undefined) { + children = (
- {refreshInstanceButton} - {refreshSimulationButton} - - {children} - +
We are about to instantiate and simulate your network, this could take some time.
+ this.setState(oldState => ({ parallelSimulation: !oldState.parallelSimulation }))} style={{ marginTop: '35px' }} id="runParallelSimulation" /> + this.setState({ cores: event.target.value })} className="netpyneRightField" type="number"/>
+ ) + var actions = [ { + this.closeTransition() + }} primary={true} key={"cancelActionBtn"} />, this.simulate()} id={"okRunSimulation"} primary={true} keyboardFocused={true} key={"runSimulationButton"} />]; + } else { + var actions = { + this.closeTransition() + }} key={"cancelActionBtn"} primary={true} /> + } + } + + if (this.props.tab == 'simulate' ) { + var refreshInstanceButton = ( + this.instantiate({ usePrevInst: false })} style={{ position: 'absolute', right: 30, top: 60, width:'24px', height:'24px' }} tooltip={this.props.freezeInstance ? "Your network is in sync" : "Synchronise network"} tooltipPosition="bottom-left" disabled={this.props.freezeInstance} tooltipStyles={{ marginTop: -37, marginRight:10 }}> + + ) + var refreshSimulationButton = ( + this.setState({ openDialog: true })} style={{ position: 'absolute', right: 30, top: 110, width:'24px', height:'24px' }} tooltip={this.props.freezeSimulation ? "You have already simulated your network" : "Simulate your network"} tooltipPosition="bottom-left" disabled={this.props.freezeSimulation} tooltipStyles={{ marginTop: -38, marginRight:10 }}> + + + ) + } + + return ( +
+ {refreshInstanceButton} + {refreshSimulationButton} + + {children} + +
+ ) } } diff --git a/css/colors.less b/css/colors.less index 658f6ec1..4eac2be3 100644 --- a/css/colors.less +++ b/css/colors.less @@ -5,4 +5,4 @@ @background_color_body_50: rgb(195, 195, 195); @background_color_body_73: rgb(195, 195, 195); @background_color_body_100: rgb(195, 195, 195); -@background_color_widget: rgb(255,255,255); \ No newline at end of file +@background_color_widget: rgb(255,255,255); diff --git a/tests/appbarTest.js b/tests/appbarTest.js index 3952b035..544cc416 100644 --- a/tests/appbarTest.js +++ b/tests/appbarTest.js @@ -1,9 +1,9 @@ -function clickOnTree(casper, file) { - casper.then(function(){ +function clickOnTree (casper, file) { + casper.then(function (){ this.wait(500) }) - casper.then(function(){ - let text = casper.evaluate(function(item) { + casper.then(function (){ + let text = casper.evaluate(function (item) { let leaves = document.getElementById("TreeContainerCutting_component").getElementsByTagName("span"); let out = {} for (var i = 0 ; i < leaves.length ; i++) { @@ -13,7 +13,7 @@ function clickOnTree(casper, file) { }, file) this.echo(text) }) - return casper.evaluate(function(item) { + return casper.evaluate(function (item) { let leaves = document.getElementById("TreeContainerCutting_component").getElementsByTagName("span"); for (var i = 0 ; i < leaves.length ; i++) { if (leaves[i].textContent == item) { @@ -27,230 +27,230 @@ function clickOnTree(casper, file) { } // ----------------------------------------------------------------------------------- // -function treeSelection(casper, sequence, test) { - casper.eachThen(sequence, function(response){ +function treeSelection (casper, sequence, test) { + casper.eachThen(sequence, function (response){ test.assert(clickOnTree(this, response.data), "click " + response.data + "folder") }) } // ----------------------------------------------------------------------------------- // -function importCellTemplate(casper, test, toolbox) { - casper.then(function() { +function importCellTemplate (casper, test, toolbox) { + casper.then(function () { toolbox.create2rules(this, test, "Populations", "newPopulationButton", "Population") }) - casper.then(function() { + casper.then(function () { toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellType\']", "PYR") toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellModel\']", "HH") }) - casper.then(function() { + casper.then(function () { populatePopDimension(this, test, toolbox) }) - casper.then(function() { + casper.then(function () { toolbox.create2rules(this, test, "CellRules", "newCellRuleButton", "CellRule") }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'conds\'][\'cellType\']", "PYRMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'conds\'][\'cellModel\']", "HHMenuItem") }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.then(function() { - this.waitUntilVisible('button[id="appBar"]', function(){ + casper.then(function () { + this.waitUntilVisible('button[id="appBar"]', function (){ this.click('button[id="appBar"]') }) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarImportCellTemplate"]', function(){ - this.wait(3000, function(){ + casper.then(function () { + this.waitUntilVisible('span[id="appBarImportCellTemplate"]', function (){ + this.wait(3000, function (){ this.click('span[id="appBarImportCellTemplate"]') - }) + }) }) }) - casper.then(function(){ + casper.then(function (){ toolbox.setInputValue(this, test, "importCellTemplateName", "CellRule") }) - casper.then(function(){ + casper.then(function (){ toolbox.setInputValue(this, test, "importCellTemplateCellName", "PTcell") }) - casper.then(function() { - this.waitUntilVisible('input[id="importCellTemplateFile"]', function(){ + casper.then(function () { + this.waitUntilVisible('input[id="importCellTemplateFile"]', function (){ this.click('input[id="importCellTemplateFile"]') }) }) - casper.then(function(){ + casper.then(function (){ treeSelection(this, ["tests", "cells", "PTcell_simple.hoc"], test) }) - casper.then(function(){ - this.wait(1000, function() { - this.waitUntilVisible('button[id="browserAccept"]', function(){ + casper.then(function (){ + this.wait(1000, function () { + this.waitUntilVisible('button[id="browserAccept"]', function (){ this.click('button[id="browserAccept"]') }) }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function(){ + casper.then(function (){ toolbox.clickCheckBox(this, test, "importCellTemplateCompileMods"); }) - casper.then(function(){ + casper.then(function (){ this.wait(500) }) - casper.then(function() { - this.waitUntilVisible('input[id="importCellTemplateModFile"]', function(){ + casper.then(function () { + this.waitUntilVisible('input[id="importCellTemplateModFile"]', function (){ this.click('input[id="importCellTemplateModFile"]') }) }) - casper.then(function(){ + casper.then(function (){ treeSelection(this, ["tests", "mod"], test) }) - casper.then(function(){ - this.wait(1000, function() { - this.waitUntilVisible('button[id="browserAccept"]', function(){ + casper.then(function (){ + this.wait(1000, function () { + this.waitUntilVisible('button[id="browserAccept"]', function (){ this.click('button[id="browserAccept"]') }) }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function(){ - this.click("button[id='appBarPerformActionButton']", function(){ + casper.then(function (){ + this.click("button[id='appBarPerformActionButton']", function (){ this.echo('Importing PTcell.hoc this will take some time....') }) }) - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { test.assert(true, "Completed PTcell_simple.hoc import") }, null, 40000) }) - casper.then(function() { - this.waitUntilVisible('button[id="simulateNetwork"]', function() { + casper.then(function () { + this.waitUntilVisible('button[id="simulateNetwork"]', function () { this.click('button[id="simulateNetwork"]') }) }) - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { - test.assert(this.evaluate(function() { + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { + test.assert(this.evaluate(function () { return CanvasContainer.engine.getRealMeshesForInstancePath("network.Population[0]")[0].visible }), "Cell Imported correctly") }, null, 120000) }) - casper.then(function(){ + casper.then(function (){ clearModel(this, test, toolbox) }) } // ----------------------------------------------------------------------------------- // -function importHLS(casper, test, toolbox, tut3=true) { +function importHLS (casper, test, toolbox, tut3 = true) { casper.then(function () { - this.waitUntilVisible('button[id="appBar"]', function(){ + this.waitUntilVisible('button[id="appBar"]', function (){ this.click('button[id="appBar"]') }) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarImportHLS"]', function(){ - this.wait(3000, function(){ + casper.then(function () { + this.waitUntilVisible('span[id="appBarImportHLS"]', function (){ + this.wait(3000, function (){ this.click('span[id="appBarImportHLS"]') }) }) }) - casper.then(function() { - this.waitUntilVisible('input[id="appBarImportFileName"]', function(){ + casper.then(function () { + this.waitUntilVisible('input[id="appBarImportFileName"]', function (){ this.click('input[id="appBarImportFileName"]') }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { + casper.then(function () { test.assert(clickOnTree(this, (tut3 ? 'tests' : 'output.py')), "click " + (tut3 ? "tests" : "output.py") + " folder") }) - casper.then(function(){ + casper.then(function (){ if (!tut3) { this.bypass(2) } }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { + casper.then(function () { test.assert(clickOnTree(this, 'tut3.py'), "click tut3.py file") }) - casper.then(function(){ - this.wait(1000, function() { - this.waitUntilVisible('button[id="browserAccept"]', function(){ + casper.then(function (){ + this.wait(1000, function () { + this.waitUntilVisible('button[id="browserAccept"]', function (){ this.click('button[id="browserAccept"]') }) }) }) - casper.then(function(){ - this.waitWhileVisible("div[id='TreeContainerCutting_component']", function(){ + casper.then(function (){ + this.waitWhileVisible("div[id='TreeContainerCutting_component']", function (){ this.echo(tut3 ? 'tut3.py selection OK' : 'output.py selection OK') }) }) - casper.then(function(){ - this.wait(1000, function() { - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ + casper.then(function (){ + this.wait(1000, function () { + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ this.click('button[id="appBarPerformActionButton"]') }) }) }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.then(function(){ + casper.then(function (){ test.assertExist('input[id="appBarImportFileName"]', "specify if mod files required before importing HLS OK") }) - casper.then(function() { + casper.then(function () { toolbox.click(this, 'appBarImportRequiresMod') }) - casper.then(function(){ + casper.then(function (){ toolbox.click(this, 'appBarImportRequiresModNo', 'span') }) - casper.then(function(){ - this.wait(1000, function() { - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ + casper.then(function (){ + this.wait(1000, function () { + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ this.click('button[id="appBarPerformActionButton"]') }) }) }) - casper.then(function() { + casper.then(function () { this.waitWhileVisible('input[id="appBarImportFileName"]') - this.waitWhileVisible('div[id="loading-spinner"]', function() { + this.waitWhileVisible('div[id="loading-spinner"]', function () { test.assert(true, "Completed HLS import") }, 40000) }) @@ -258,15 +258,15 @@ function importHLS(casper, test, toolbox, tut3=true) { // ----------------------------------------------------------------------------------- // -function instantiateNetwork(casper, test, toolbox) { - casper.then(function() { - this.waitUntilVisible('button[id="simulateNetwork"]', function() { +function instantiateNetwork (casper, test, toolbox) { + casper.then(function () { + this.waitUntilVisible('button[id="simulateNetwork"]', function () { this.click('button[id="simulateNetwork"]') }) }) - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { - test.assert(this.evaluate(function() { + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { + test.assert(this.evaluate(function () { return CanvasContainer.engine.getRealMeshesForInstancePath("network.S[10]")[0].visible }), "Instance created with 40 cells") }, 40000) @@ -275,72 +275,72 @@ function instantiateNetwork(casper, test, toolbox) { // ----------------------------------------------------------------------------------- // -function simulateNetwork(casper, test, toolbox) { +function simulateNetwork (casper, test, toolbox) { casper.thenClick('#PlotButton'); - casper.then(function() { + casper.then(function () { this.waitUntilVisible('span[id="rasterPlot"]'); }) - casper.thenEvaluate(function() { + casper.thenEvaluate(function () { document.getElementById('rasterPlot').click(); }); - casper.then(function() { - this.wait(2000, function(){ + casper.then(function () { + this.wait(2000, function (){ test.assertDoesntExist('div[id="rasterPlot"]', "Network has not been simulated") }) }) - casper.then(function() { + casper.then(function () { var info = this.getElementInfo('button[id="launchSimulationButton"]'); - this.mouse.click(info.x - 4, info.y - 4); //move a bit away from corner + this.mouse.click(info.x - 4, info.y - 4); // move a bit away from corner }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { - this.waitWhileVisible('div[role="menu"]', function() { //wait for menu to close + casper.then(function () { + this.waitWhileVisible('div[role="menu"]', function () { // wait for menu to close test.assertDoesntExist('div[role="menu"]', "Plot Menu is gone"); }); }) - casper.then(function(){ - this.waitUntilVisible('button[id="launchSimulationButton"]', function(){ + casper.then(function (){ + this.waitUntilVisible('button[id="launchSimulationButton"]', function (){ this.click('button[id="launchSimulationButton"]') }) }) - casper.then(function(){ - this.waitUntilVisible('button[id="okRunSimulation"]', function(){ + casper.then(function (){ + this.waitUntilVisible('button[id="okRunSimulation"]', function (){ this.click('button[id="okRunSimulation"]') }) }) - casper.then(function(){ - this.waitWhileVisible('div[id="loading-spinner"', function(){ + casper.then(function (){ + this.waitWhileVisible('div[id="loading-spinner"', function (){ this.click('#PlotButton') }) }) - casper.then(function() { + casper.then(function () { this.waitUntilVisible('span[id="rasterPlot"]'); }) - casper.thenEvaluate(function() { + casper.thenEvaluate(function () { document.getElementById('rasterPlot').click(); }); - casper.then(function() { - this.waitUntilVisible('div[id="Popup1"]', function() { + casper.then(function () { + this.waitUntilVisible('div[id="Popup1"]', function () { this.waitUntilVisible('g[id="figure_1"]') this.waitUntilVisible('g[id="axes_1"]') }) }) - casper.then(function() { - toolbox.click(this, "launchSimulationButton", "button"); //move a bit away from corner + casper.then(function () { + toolbox.click(this, "launchSimulationButton", "button"); // move a bit away from corner }) - casper.then(function() { - this.waitWhileVisible('div[role="menu"]', function() { //wait for menu to close + casper.then(function () { + this.waitWhileVisible('div[role="menu"]', function () { // wait for menu to close test.assertDoesntExist('div[role="menu"]', "Plot Menu is gone"); }); }) @@ -348,103 +348,103 @@ function simulateNetwork(casper, test, toolbox) { // ----------------------------------------------------------------------------------- // -function saveNetwork(casper, test, toolbox) { +function saveNetwork (casper, test, toolbox) { casper.then(function () { - this.waitUntilVisible('button[id="appBar"]', function(){ + this.waitUntilVisible('button[id="appBar"]', function (){ this.click('button[id="appBar"]') }) }) - casper.then(function(){ + casper.then(function (){ this.wait(2000) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarSave"]', function(){ + casper.then(function () { + this.waitUntilVisible('span[id="appBarSave"]', function (){ this.click('span[id="appBarSave"]') }) }) - casper.then(function(){ - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ + casper.then(function (){ + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ this.click('button[id="appBarPerformActionButton"]') }) }) - casper.then(function() { - this.waitWhileVisible('button[id="appBarPerformActionButton"]', function(){ + casper.then(function () { + this.waitWhileVisible('button[id="appBarPerformActionButton"]', function (){ this.echo("Saved model in json format") }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1500) }) } // ----------------------------------------------------------------------------------- // -function openNetwork(casper, test, toolbox) { +function openNetwork (casper, test, toolbox) { casper.then(function () { - this.waitUntilVisible('button[id="appBar"]', function() { + this.waitUntilVisible('button[id="appBar"]', function () { this.click('button[id="appBar"]') }) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarOpen"]', function() { + casper.then(function () { + this.waitUntilVisible('span[id="appBarOpen"]', function () { this.click('span[id="appBarOpen"]') }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { - this.waitUntilVisible('input[id="loadJsonFile"]', function() { + casper.then(function () { + this.waitUntilVisible('input[id="loadJsonFile"]', function () { this.click('input[id="loadJsonFile"]') }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { + casper.then(function () { test.assert(clickOnTree(this, 'output.json'), "click output.json file") }) - casper.then(function(){ - this.wait(1000, function() { + casper.then(function (){ + this.wait(1000, function () { this.click('button[id="browserAccept"]') }) }) - casper.then(function(){ - this.wait(1000, function() { + casper.then(function (){ + this.wait(1000, function () { this.click('button[id="appBarPerformActionButton"]') }) }) - casper.then(function() { - this.waitWhileVisible('input[id="loadJsonFile"]', function() { + casper.then(function () { + this.waitWhileVisible('input[id="loadJsonFile"]', function () { test.assert(false, 'Trying to loaded a model without specifying if mod files are required') }, function (){ this.echo("Check if mod files are required OK") }, 1000) }) - casper.then(function() { + casper.then(function () { toolbox.click(this, 'appBarLoadRequiresMod') }) - casper.then(function(){ + casper.then(function (){ toolbox.click(this, 'appBarLoadRequiresModNo', 'span') }) - casper.then(function(){ - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ - this.evaluate(function() { + casper.then(function (){ + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ + this.evaluate(function () { document.getElementById("appBarPerformActionButton").click() }) }) }) - casper.then(function(){ + casper.then(function (){ this.waitWhileVisible('button[id="appBarPerformActionButton"]') }) - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { test.assert(true, "Completed Model load") }, 40000) }) @@ -452,62 +452,62 @@ function openNetwork(casper, test, toolbox) { // ----------------------------------------------------------------------------------- // -function exploreOpenedModel(casper, test, toolbox) { - casper.then(function() { +function exploreOpenedModel (casper, test, toolbox) { + casper.then(function () { this.waitWhileVisible('div[id="loading-spinner"]') }) - casper.then( function(){ - test.assert(this.evaluate(function() { + casper.then( function (){ + test.assert(this.evaluate(function () { return document.getElementById("launchSimulationButton").textContent == "You have already simulated your network" }) , "Launch simulation button is lock ") }) - casper.then(function(){ - test.assert(this.evaluate(function() { + casper.then(function (){ + test.assert(this.evaluate(function () { return document.getElementById("refreshInstanciatedNetworkButton").textContent == "Your network is in sync" }) , "Sync instance button is lock ") }) casper.thenClick('#PlotButton') - casper.then(function() { + casper.then(function () { toolbox.testPlotButton(casper, test, "rasterPlot") }) - casper.then(function() { + casper.then(function () { toolbox.testPlotButton(casper, test, "connectionPlot") }) - casper.then(function() { - toolbox.click(this, "launchSimulationButton", "button"); //move a bit away from corner + casper.then(function () { + toolbox.click(this, "launchSimulationButton", "button"); // move a bit away from corner }) - casper.then(function(){ + casper.then(function (){ this.wait(2000) }) } // ----------------------------------------------------------------------------------- // -function exportHLS(casper, test, toolbox) { +function exportHLS (casper, test, toolbox) { casper.then(function () { - this.waitUntilVisible('button[id="appBar"]', function(){ + this.waitUntilVisible('button[id="appBar"]', function (){ this.click('button[id="appBar"]') }) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarExportHLS"]', function(){ + casper.then(function () { + this.waitUntilVisible('span[id="appBarExportHLS"]', function (){ this.click('span[id="appBarExportHLS"]') }) }) - casper.then(function(){ - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ + casper.then(function (){ + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ this.click('button[id="appBarPerformActionButton"]') }) }) - casper.then(function(){ + casper.then(function (){ this.waitWhileVisible('button[id="appBarPerformActionButton"]') }) - casper.then(function(){ - this.waitWhileVisible('div[id="loading-spinner', function(){ + casper.then(function (){ + this.waitWhileVisible('div[id="loading-spinner', function (){ this.echo("HLS were saved") }) }) @@ -515,60 +515,60 @@ function exportHLS(casper, test, toolbox) { // ----------------------------------------------------------------------------------- // -function clearModel(casper, test, toolbox) { +function clearModel (casper, test, toolbox) { casper.then(function () { - this.waitUntilVisible('button[id="appBar"]', function(){ + this.waitUntilVisible('button[id="appBar"]', function (){ this.click('button[id="appBar"]') }) }) - casper.then(function() { - this.waitUntilVisible('span[id="appBarNew"]', function(){ + casper.then(function () { + this.waitUntilVisible('span[id="appBarNew"]', function (){ this.click('span[id="appBarNew"]') }) }) - casper.then(function(){ - this.waitUntilVisible('button[id="appBarPerformActionButton"]', function(){ - this.evaluate(function() { + casper.then(function (){ + this.waitUntilVisible('button[id="appBarPerformActionButton"]', function (){ + this.evaluate(function () { document.getElementById("appBarPerformActionButton").click() }) }) }) - casper.then(function(){ + casper.then(function (){ this.waitWhileVisible('button[id="appBarPerformActionButton"]') }) - casper.then(function(){ + casper.then(function (){ this.wait(1500) }) - casper.then(function() { - this.waitUntilVisible('div[id="Populations"]', function(){ + casper.then(function () { + this.waitUntilVisible('div[id="Populations"]', function (){ this.click('div[id="Populations"]') }) }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function(){ + casper.then(function (){ test.assertDoesntExist('input[id="populationName"]', "Model deleted") }) } // ---------------------------------------------------------------------- // -function populatePopDimension(casper, test, toolbox) { - casper.then(function() { +function populatePopDimension (casper, test, toolbox) { + casper.then(function () { toolbox.click(this, "popParamsDimensionsSelect", "div"); }) - casper.then(function() { // check all menuItems exist + casper.then(function () { // check all menuItems exist toolbox.assertExist(this, test, "popParamSnumCells", "span"); }); - casper.thenClick("#popParamSnumCells", function() { + casper.thenClick("#popParamSnumCells", function () { toolbox.setInputValue(this, test, "popParamsDimensions", "1") }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) } diff --git a/tests/cellParamsTest.js b/tests/cellParamsTest.js index ad47fccc..5e373753 100644 --- a/tests/cellParamsTest.js +++ b/tests/cellParamsTest.js @@ -1,39 +1,41 @@ var require = patchRequire(require); var rangeComponentTest = require('./rangeComponentTest') -/******************************************************************************* +/** + ****************************************************************************** * ------------------------------- CELL-PARAMS -------------------------------- * - ********************************************************************************/ -function populateCellRule(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function populateCellRule (casper, test, toolbox) { + casper.then(function () { toolbox.active = { cardID: "CellRules", buttonID: "newCellRuleButton", tabID: false } }) - casper.then(function() { // populate cellRule + casper.then(function () { // populate cellRule toolbox.assertExist(this, test, "cellRuleName") toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'conds\'][\'cellType\']", "PYRMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'conds\'][\'cellModel\']", "HHMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'conds\'][\'pop\']", "newPopMenuItem") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { + casper.then(function () { rangeComponentTest.populateRangeComponent(this, test, toolbox, "CellParams") // populate RangeComponent }) } -//----------------------------------------------------------------------------// -function checkCellParamsValues(casper, test, toolbox, name, cellType, cellModel, pop, rangeEmpty = false) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function checkCellParamsValues (casper, test, toolbox, name, cellType, cellModel, pop, rangeEmpty = false) { + casper.then(function () { toolbox.getInputValue(this, test, "cellRuleName", name) toolbox.getSelectFieldValue(this, test, "netParams.cellParams[\'" + name + "\'][\'conds\'][\'cellType\']", cellType) toolbox.getSelectFieldValue(this, test, "netParams.cellParams[\'" + name + "\'][\'conds\'][\'cellModel\']", cellModel) toolbox.getSelectFieldValue(this, test, "netParams.cellParams[\'" + name + "\'][\'conds\'][\'pop\']", pop) }) - casper.then(function() { + casper.then(function () { if (rangeEmpty) { rangeComponentTest.checkRangeComponentIsEmpty(this, test, toolbox, "CellParams") } else { @@ -42,163 +44,165 @@ function checkCellParamsValues(casper, test, toolbox, name, cellType, cellModel, }) } -//----------- going to section page ---------- -function testSectionAndMechanisms(casper, test, toolbox) { +// ----------- going to section page ---------- +function testSectionAndMechanisms (casper, test, toolbox) { toolbox.message(casper, "going to section page") - casper.thenClick('button[id="newSectionButton"]', function() { //go to "section" page + casper.thenClick('button[id="newSectionButton"]', function () { // go to "section" page this.waitUntilVisible('button[id="Section"]', function () { test.assertExist('button[id="Section"]', "landed in section page") }) }) - casper.thenClick('#newSectionButton', function() { //create section 2 + casper.thenClick('#newSectionButton', function () { // create section 2 toolbox.getInputValue(this, test, "cellParamsSectionName", "Section2") }); - casper.thenClick('button[id="Section"]') //focus on section 1 + casper.thenClick('button[id="Section"]') // focus on section 1 // ----------- going to "Geometry" tab in "section" page ---------- - casper.then(function() { + casper.then(function () { toolbox.active.buttonID = "newSectionButton" toolbox.active.tabID = "sectionGeomTab" }) - casper.thenClick("#sectionGeomTab", function() { //go to "geometry" tab in "section" page + casper.thenClick("#sectionGeomTab", function () { // go to "geometry" tab in "section" page this.echo("going to Geometry tab") }) - casper.then(function() { // polulate geometry + casper.then(function () { // polulate geometry populateSectionGeomTab(this, test, toolbox) }) - casper.then(function() { // go to general tab and come back to geometry tab + casper.then(function () { // go to general tab and come back to geometry tab toolbox.leaveReEnterTab(this, test, "sectionGeomTab", "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'diam\']", "sectionGeneralTab", "cellParamsSectionName") }) - casper.then(function() { // check values remain the same + casper.then(function () { // check values remain the same checkSectionGeomTabValues(this, test, toolbox, "CellRule", "Section") }) - casper.then(function() { // try to delete an item from pt3d component + casper.then(function () { // try to delete an item from pt3d component toolbox.deleteListItem(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'pt3d\']1") }) - casper.thenClick('button[id="Section2"]', function() { // change to rule 2 + casper.thenClick('button[id="Section2"]', function () { // change to rule 2 this.echo("go to section 2 -> values must be empty") this.wait(2500) // let python populate fields }) - casper.then(function() { // check values must be empty + casper.then(function () { // check values must be empty checkSectionGeomTabValues(this, test, toolbox, "CellRule", "Section2", "", "", "", "", "", "") }) - casper.thenClick('button[id="Section"]', function() { // back to section 1 + casper.thenClick('button[id="Section"]', function () { // back to section 1 this.echo("go to section 1 -> values must be populated") - this.wait(2500) //let pyhton populate fields + this.wait(2500) // let pyhton populate fields }) - casper.then(function() { // check values must be populated (except 1 listItem that was deleted) + casper.then(function () { // check values must be populated (except 1 listItem that was deleted) checkSectionGeomTabValues(this, test, toolbox, "CellRule", "Section", "") }) - //----------- going to "Topology" tab in "section" page ---------- - casper.thenClick("#sectionTopoTab", function() { // go to "Topology" tab in "section" page - this.wait(2500) //let python populate fields + // ----------- going to "Topology" tab in "section" page ---------- + casper.thenClick("#sectionTopoTab", function () { // go to "Topology" tab in "section" page + this.wait(2500) // let python populate fields toolbox.active.tabID = "sectionTopoTab" }) - casper.then(function() { // populate "topology" tab in "section" page + casper.then(function () { // populate "topology" tab in "section" page populateSectionTopoTab(this, test, toolbox) }) - casper.then(function() { // move to another tab and comeback + casper.then(function () { // move to another tab and comeback toolbox.leaveReEnterTab(this, test, "sectionTopoTab", "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'topol\'][\'parentSec\']", "sectionGeneralTab", "cellParamsSectionName", "div") }) - casper.then(function() { // check fields remain the same + casper.then(function () { // check fields remain the same checkSectionTopoTabValues(this, test, toolbox, "CellRule", "Section", "Section", "1", "0") }) - casper.thenClick('button[id="Section2"]', function() { // change to rule 2 + casper.thenClick('button[id="Section2"]', function () { // change to rule 2 this.echo("go to section 2 -> values must be empty") this.wait(2500) // let python populate fields }) - casper.then(function() { // check values must be empty + casper.then(function () { // check values must be empty checkSectionTopoTabValues(this, test, toolbox, "CellRule", "Section2", "", "", "") }) - casper.thenClick('button[id="Section"]', function() { // back to section 1 + casper.thenClick('button[id="Section"]', function () { // back to section 1 this.echo("go to section 1 -> values must be populated") - this.wait(2500) //let pyhton populate fields + this.wait(2500) // let pyhton populate fields }) - casper.then(function() { // check values must be populated (except 1 listItem that was deleted) + casper.then(function () { // check values must be populated (except 1 listItem that was deleted) checkSectionTopoTabValues(this, test, toolbox, "CellRule", "Section", "Section", "1", "0") }) - //----------- going to "Mechanism" page ---------- - casper.thenClick("#sectionGeneralTab", function() { //Go to Mechs page - this.waitUntilVisible('button[id="newMechButton"]', function() { + // ----------- going to "Mechanism" page ---------- + casper.thenClick("#sectionGeneralTab", function () { // Go to Mechs page + this.waitUntilVisible('button[id="newMechButton"]', function () { toolbox.message(this, "going to mechanisms page...") }) }) - casper.thenClick("#newMechButton", function() { // check landing in Mech page + casper.thenClick("#newMechButton", function () { // check landing in Mech page test.assertDoesntExist('button[id="Section"]', "landed in Mechanisms page"); }) - casper.then(function() { + casper.then(function () { toolbox.active.buttonID = "newMechButton" toolbox.active.tabID = false }) - casper.then(function() { //fill mech values + casper.then(function () { // fill mech values populateMechs(this, test, toolbox) }) - casper.then(function() { //check values are correct while moving between mechs + casper.then(function () { // check values are correct while moving between mechs checkMechs(this, test, toolbox) }) - casper.thenClick('#newSectionButton', function() { // leave Mech page and go to Section page + casper.thenClick('#newSectionButton', function () { // leave Mech page and go to Section page this.click("#newMechButton") }) - casper.then(function() { //go back to Mechs page - this.waitUntilVisible('button[id="mechThumbhh"]', function() { + casper.then(function () { // go back to Mechs page + this.waitUntilVisible('button[id="mechThumbhh"]', function () { test.assertExist('button[id="mechThumbhh"]', "landed back to Mech page") }) }) - casper.then(function() { // check mechs fields remain the same + casper.then(function () { // check mechs fields remain the same checkMechs(this, test, toolbox) }) - casper.then(function() { + casper.then(function () { this.echo("delete mechanisms:") }) - casper.then(function() { // del pas mech + casper.then(function () { // del pas mech toolbox.delThumbnail(this, test, "mechThumbpas") }) - casper.then(function() { // del fastpas mech + casper.then(function () { // del fastpas mech toolbox.delThumbnail(this, test, "mechThumbfastpas") }) - casper.thenClick('button[id="newSectionButton"]', function() { // go back to --sections-- + casper.thenClick('button[id="newSectionButton"]', function () { // go back to --sections-- }); - casper.then(function() { //delete section 2 + casper.then(function () { // delete section 2 this.echo("delete section 2:") toolbox.delThumbnail(this, test, "Section2") }) - casper.thenClick('button[id="Section"]', function() { + casper.thenClick('button[id="Section"]', function () { toolbox.renameRule(this, test, "cellParamsSectionName", "newSec") // rename section }) - casper.thenClick('button[id="newCellRuleButton"]', function() { // go back to cellRule + casper.thenClick('button[id="newCellRuleButton"]', function () { // go back to cellRule this.echo("went back to cellParams page...") }) } -/******************************************************************************* +/** + ****************************************************************************** * ---------------------------- CELL-PARAMS -- SECTION ------------------------ * - ********************************************************************************/ -function populateSectionGeomTab(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function populateSectionGeomTab (casper, test, toolbox) { + casper.then(function () { toolbox.setInputValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'diam\']", "20") toolbox.setInputValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'L\']", "30") toolbox.setInputValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'Ra\']", "100") @@ -206,150 +210,128 @@ function populateSectionGeomTab(casper, test, toolbox) { toolbox.addListItem(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'pt3d\']", "10,0,0") toolbox.addListItem(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'geom\'][\'pt3d\']", "20,0,0") }) - casper.then(function() { - casper.wait(2500) //let python receive values + casper.then(function () { + casper.wait(2500) // let python receive values }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkSectionGeomTabValues(casper, test, toolbox, ruleName, sectionName, p2 = "[20,0,0]", p1 = "[10,0,0]", d = "20", l = "30", r = "100", c = "1") { - casper.then(function() { +function checkSectionGeomTabValues (casper, test, toolbox, ruleName, sectionName, p2 = "[20,0,0]", p1 = "[10,0,0]", d = "20", l = "30", r = "100", c = "1") { + casper.then(function () { toolbox.getInputValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'diam\']", d) toolbox.getInputValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'L\']", l) toolbox.getInputValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'Ra\']", r) toolbox.getInputValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'cm\']", c) }) - casper.then(function() { + casper.then(function () { if (p2) { toolbox.getListItemValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'pt3d\']1", p2) } }) - casper.then(function() { + casper.then(function () { if (p1) { toolbox.getListItemValue(this, test, "netParams.cellParams[\'" + ruleName + "\'][\'secs\'][\'" + sectionName + "\'][\'geom\'][\'pt3d\']0", p1) } }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function populateSectionTopoTab(casper, test, toolbox) { - casper.then(function() { //populate "topology" tab in "section" page +function populateSectionTopoTab (casper, test, toolbox) { + casper.then(function () { // populate "topology" tab in "section" page toolbox.setSelectFieldValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'topol\'][\'parentSec\']", "SectionMenuItem") toolbox.setInputValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'topol\'][\'parentX\']", "1") toolbox.setInputValue(this, test, "netParams.cellParams[\'CellRule\'][\'secs\'][\'Section\'][\'topol\'][\'childX\']", "0") }) - casper.then(function() { - casper.wait(2500) //let python receive values + casper.then(function () { + casper.wait(2500) // let python receive values }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkSectionTopoTabValues(casper, test, toolbox, cellRuleName, sectionName, parentSec, pX, cX) { - casper.then(function() { +function checkSectionTopoTabValues (casper, test, toolbox, cellRuleName, sectionName, parentSec, pX, cX) { + casper.then(function () { toolbox.getSelectFieldValue(this, test, "netParams.cellParams[\'" + cellRuleName + "\'][\'secs\'][\'" + sectionName + "\'][\'topol\'][\'parentSec\']", parentSec) toolbox.getInputValue(this, test, "netParams.cellParams[\'" + cellRuleName + "\'][\'secs\'][\'" + sectionName + "\'][\'topol\'][\'parentX\']", pX) toolbox.getInputValue(this, test, "netParams.cellParams[\'" + cellRuleName + "\'][\'secs\'][\'" + sectionName + "\'][\'topol\'][\'childX\']", cX) }) } -/******************************************************************************** +/** + ******************************************************************************* * ---------------------------- CELL-PARAMS -- MECHS -------------------------- * - ********************************************************************************/ + ******************************************************************************* + */ -function populateMechs(casper, test, toolbox) { - casper.then(function() { // add HH mechanism and populate fields +function populateMechs (casper, test, toolbox) { + casper.then(function () { // add HH mechanism and populate fields this.echo("add HH mech") - populateMech(this, test, toolbox, "hh", { - n: "mechNamegnabar", v: "0.1"}, { - n: "mechNamegkbar", v: "0.2"}, { - n: "mechNamegl", v: "0.3"}, { - n: "mechNameel", v: "0.4"}, + populateMech(this, test, toolbox, "hh", { n: "mechNamegnabar", v: "0.1" }, { n: "mechNamegkbar", v: "0.2" }, { n: "mechNamegl", v: "0.3" }, { n: "mechNameel", v: "0.4" }, true ) }) - casper.then(function() { // add PAS mechanism and populate fields + casper.then(function () { // add PAS mechanism and populate fields this.echo("add PAS mech") - populateMech(this, test, toolbox, "pas", { - n: "mechNameg", v: "0.5"}, { - n: "mechNamee", v: "0.6"}, { - n: "", v: ""}, { - n: "", v: ""} + populateMech(this, test, toolbox, "pas", { n: "mechNameg", v: "0.5" }, { n: "mechNamee", v: "0.6" }, { n: "", v: "" }, { n: "", v: "" } ) }) - casper.then(function() { // add FASTPAS mechanism and populate fields + casper.then(function () { // add FASTPAS mechanism and populate fields this.echo("add FASTPAS mech") - populateMech(this, test, toolbox, "fastpas", { - n: "mechNameg", v: "0.7"}, { - n: "mechNamee", v: "0.8"}, { - n: "", v: ""}, { - n: "", v: ""} + populateMech(this, test, toolbox, "fastpas", { n: "mechNameg", v: "0.7" }, { n: "mechNamee", v: "0.8" }, { n: "", v: "" }, { n: "", v: "" } ) }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkMechs(casper, test, toolbox) { - casper.then(function() { // check values after coming back to HH mech +function checkMechs (casper, test, toolbox) { + casper.then(function () { // check values after coming back to HH mech this.echo("check HH fields") - checkMechValues(this, test, toolbox, "mechThumbhh", "hh", { - n: "mechNamegnabar", v: "0.1"}, { - n: "mechNamegkbar", v: "0.2"}, { - n: "mechNamegl", v: "0.3"}, { - n: "mechNameel", v: "0.4"} + checkMechValues(this, test, toolbox, "mechThumbhh", "hh", { n: "mechNamegnabar", v: "0.1" }, { n: "mechNamegkbar", v: "0.2" }, { n: "mechNamegl", v: "0.3" }, { n: "mechNameel", v: "0.4" } ) }) - casper.then(function() { // check values after coming back to PAS mech + casper.then(function () { // check values after coming back to PAS mech this.echo("check PAS fields") - checkMechValues(this, test, toolbox, "mechThumbpas", "pas", { - n: "mechNameg", v: "0.5"}, { - n: "mechNamee", v: "0.6"}, { - n: "", v: ""}, { - n: "", v: ""} + checkMechValues(this, test, toolbox, "mechThumbpas", "pas", { n: "mechNameg", v: "0.5" }, { n: "mechNamee", v: "0.6" }, { n: "", v: "" }, { n: "", v: "" } ) }) - casper.then(function() { // check values after coming back to HH mech + casper.then(function () { // check values after coming back to HH mech this.echo("check FASTPAS fields") - checkMechValues(this, test, toolbox, "mechThumbfastpas", "fastpas", { - n: "mechNameg", v: "0.7"}, { - n: "mechNamee", v: "0.8"}, { - n: "", v: ""}, { - n: "", v: ""} + checkMechValues(this, test, toolbox, "mechThumbfastpas", "fastpas", { n: "mechNameg", v: "0.7" }, { n: "mechNamee", v: "0.8" }, { n: "", v: "" }, { n: "", v: "" } ) }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function populateMech(casper, test, toolbox, mechName, v1, v2, v3, v4, doNotOpenSelectField=false) { - {doNotOpenSelectField ? null : casper.thenClick('#newMechButton', function() { // click SelectField and check MenuItem exist +function populateMech (casper, test, toolbox, mechName, v1, v2, v3, v4, doNotOpenSelectField = false) { + {doNotOpenSelectField ? null : casper.thenClick('#newMechButton', function () { // click SelectField and check MenuItem exist this.waitUntilVisible('span[id="' + mechName + '"]') })} - casper.thenClick("#" + mechName, function() { // click add mech and populate fields + casper.thenClick("#" + mechName, function () { // click add mech and populate fields toolbox.getInputValue(this, test, "singleMechName", mechName) toolbox.setInputValue(this, test, v1.n, v1.v); toolbox.setInputValue(this, test, v2.n, v2.v); v3.v ? toolbox.setInputValue(this, test, v3.n, v3.v) : {}; v4.v ? toolbox.setInputValue(this, test, v4.n, v4.v) : {}; }) - casper.then(function() { + casper.then(function () { casper.wait(2500) // for python to receive data }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkMechValues(casper, test, toolbox, mechThumb, mech, v1, v2, v3, v4) { +function checkMechValues (casper, test, toolbox, mechThumb, mech, v1, v2, v3, v4) { casper.thenClick('button[id="' + mechThumb + '"]') - casper.then(function() { + casper.then(function () { casper.wait(2500) // for python to populate fields }) - casper.then(function() { // check Fields + casper.then(function () { // check Fields toolbox.getInputValue(this, test, "singleMechName", mech) toolbox.getInputValue(this, test, v1.n, v1.v); toolbox.getInputValue(this, test, v2.n, v2.v); @@ -358,85 +340,83 @@ function checkMechValues(casper, test, toolbox, mechThumb, mech, v1, v2, v3, v4) }); } -/******************************************************************************* +/** + ****************************************************************************** * ----------------------- CELL-PARAMS -- Full check -------------------------- * - ********************************************************************************/ -function exploreCellRuleAfterRenaming(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function exploreCellRuleAfterRenaming (casper, test, toolbox) { + casper.then(function () { toolbox.active.buttonID = "newCellRuleButton" toolbox.active.tabID = false }) - casper.then(function() { + casper.then(function () { checkCellParamsValues(this, test, toolbox, "newCellRule", "PYR", "HH", "newPop") }) - casper.thenClick('button[id="newSectionButton"]', function() { //go to "sections" + casper.thenClick('button[id="newSectionButton"]', function () { // go to "sections" test.assertExist('button[id="newSectionButton"]', "landed in section") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { - this.waitUntilVisible('button[id="newSec"]', function() { + casper.then(function () { + this.waitUntilVisible('button[id="newSec"]', function () { this.click('button[id="newSec"]') }) }) - casper.then(function() { - this.wait(2500) //wait for python to populate fields + casper.then(function () { + this.wait(2500) // wait for python to populate fields toolbox.active.buttonID = "newSectionButton" }) - casper.then(function() { // check section name + casper.then(function () { // check section name toolbox.getInputValue(this, test, "cellParamsSectionName", "newSec") }) - casper.thenClick("#sectionGeomTab", function() { // go to Geometry tab - this.wait(2500) //wait for python to populate fields + casper.thenClick("#sectionGeomTab", function () { // go to Geometry tab + this.wait(2500) // wait for python to populate fields toolbox.active.tabID = "sectionGeomTab" }) - casper.then(function() { + casper.then(function () { checkSectionGeomTabValues(this, test, toolbox, "newCellRule", "newSec", "") }) - casper.thenClick("#sectionTopoTab", function() { // go to Topology tab - casper.wait(2500) //wait for python to populate fields + casper.thenClick("#sectionTopoTab", function () { // go to Topology tab + casper.wait(2500) // wait for python to populate fields toolbox.active.tabID = "sectionTopoTab" }) - casper.then(function() { + casper.then(function () { checkSectionTopoTabValues(this, test, toolbox, "newCellRule", "newSec", "", "1", "0") }) - casper.thenClick("#sectionGeneralTab", function() { //go to "general tab" in "section" page + casper.thenClick("#sectionGeneralTab", function () { // go to "general tab" in "section" page this.waitUntilVisible('button[id="newMechButton"]') }) - casper.then(function() { // go to mechs page + casper.then(function () { // go to mechs page toolbox.click(this, "newMechButton", "button") }) - casper.then(function() { // wait for button to appear + casper.then(function () { // wait for button to appear this.waitUntilVisible('button[id="mechThumbhh"]') }) - casper.then(function() { // select HH thumbnail + casper.then(function () { // select HH thumbnail this.click('button[id="mechThumbhh"]') toolbox.active.buttonID = "newMechButton" toolbox.active.tabID = false }) - casper.then(function() { // check values - checkMechValues(this, test, toolbox, "mechThumbhh", "hh", { - n: "mechNamegnabar", v: "0.1"}, { - n: "mechNamegkbar", v: "0.2"}, { - n: "mechNamegl", v: "0.3"}, { - n: "mechNameel", v: "0.4"} + casper.then(function () { // check values + checkMechValues(this, test, toolbox, "mechThumbhh", "hh", { n: "mechNamegnabar", v: "0.1" }, { n: "mechNamegkbar", v: "0.2" }, { n: "mechNamegl", v: "0.3" }, { n: "mechNameel", v: "0.4" } ) }) - casper.then(function() { // check pas and fastpas Thumbnails don't exist + casper.then(function () { // check pas and fastpas Thumbnails don't exist toolbox.assertDoesntExist(this, test, "mechThumbpas", "button") toolbox.assertDoesntExist(this, test, "mechThumbpasfast", "button") }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { populateCellRule: populateCellRule, checkCellParamsValues: checkCellParamsValues, diff --git a/tests/connParamsTest.js b/tests/connParamsTest.js index 55ac1366..6af31465 100644 --- a/tests/connParamsTest.js +++ b/tests/connParamsTest.js @@ -1,10 +1,12 @@ var require = patchRequire(require); var rangeComponentTest = require('./rangeComponentTest') -/******************************************************************************* +/** + ****************************************************************************** * ------------------------------- CONN-PARAMS -------------------------------- * - ********************************************************************************/ -function populateConnRule(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function populateConnRule (casper, test, toolbox) { + casper.then(function () { toolbox.active = { cardID: "Connections", buttonID: "newConnectivityRuleButton", @@ -12,10 +14,10 @@ function populateConnRule(casper, test, toolbox) { } toolbox.assertExist(this, test, "ConnectivityName", "input", "conn name exist") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { // check all fields exist + casper.then(function () { // check all fields exist toolbox.addListItem(this, test, "netParams.connParams[\'ConnectivityRule\'][\'sec\']", "soma") toolbox.addListItem(this, test, "netParams.connParams[\'ConnectivityRule\'][\'loc\']", "0.5") toolbox.addListItem(this, test, "netParams.connParams[\'ConnectivityRule\'][\'sec\']", "dend") @@ -30,43 +32,43 @@ function populateConnRule(casper, test, toolbox) { toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'synMech\']", "SynapseMenuItem") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "preCondsConnTab", "netParams.connParams[\'ConnectivityRule\'][\'preConds\'][\'pop\']", "div") }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'preConds\'][\'pop\']", "PopulationMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'preConds\'][\'cellModel\']", "IFMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'preConds\'][\'cellType\']", "GCMenuItem") rangeComponentTest.populateRangeComponent(this, test, toolbox, "PreConn") }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "postCondsConnTab", "netParams.connParams[\'ConnectivityRule\'][\'postConds\'][\'pop\']", "div") }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'postConds\'][\'pop\']", "Population2MenuItem") toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'postConds\'][\'cellModel\']", "IziMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.connParams[\'ConnectivityRule\'][\'postConds\'][\'cellType\']", "BCMenuItem") }) - casper.then(function() { - this.wait(2500) //let python receive values + casper.then(function () { + this.wait(2500) // let python receive values }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "generalConnTab", "ConnectivityName", "input") }) } -//----------------------------------------------------------------------------// -function checkConnRuleValues(casper, test, toolbox, name="ConnectivityRule", empty=false) { +// ----------------------------------------------------------------------------// +function checkConnRuleValues (casper, test, toolbox, name = "ConnectivityRule", empty = false) { toolbox.active = { cardID: "Connections", buttonID: "newConnectivityRuleButton", tabID: false } - casper.then(function() { // check all fields exist + casper.then(function () { // check all fields exist if (empty) { test.assertDoesntExist('input[id="netParams.connParams[\'"' + name + '"\'][\'sec\']0"]', "sec list is empty") test.assertDoesntExist('input[id="netParams.connParams[\'"' + name + '"\'][\'loc\']0"]', "loc list is empty") @@ -85,11 +87,11 @@ function checkConnRuleValues(casper, test, toolbox, name="ConnectivityRule", emp toolbox.getInputValue(this, test, "netParams.connParams[\'" + name + "\'][\'synsPerConn\']", !empty ? "4" : "") toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'synMech\']", !empty ? "Synapse" : "") }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "preCondsConnTab", "netParams.connParams[\'" + name + "\'][\'preConds\'][\'pop\']", "div") }) - casper.then(function() { + casper.then(function () { toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'preConds\'][\'pop\']", !empty ? "Population" : "") toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'preConds\'][\'cellModel\']", !empty ? "IF" : "") toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'preConds\'][\'cellType\']", !empty ? "GC" : "") @@ -99,22 +101,22 @@ function checkConnRuleValues(casper, test, toolbox, name="ConnectivityRule", emp rangeComponentTest.testRangeComponent(this, test, toolbox, "PreConn") } }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "postCondsConnTab", "netParams.connParams[\'" + name + "\'][\'postConds\'][\'pop\']", "div") }) - casper.then(function() { + casper.then(function () { toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'postConds\'][\'pop\']", !empty ? "Population2" : "") toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'postConds\'][\'cellModel\']", !empty ? "Izi" : "") toolbox.getSelectFieldValue(this, test, "netParams.connParams[\'" + name + "\'][\'postConds\'][\'cellType\']", !empty ? "BC" : "") rangeComponentTest.checkRangeComponentIsEmpty(this, test, toolbox, "PostConn") }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "generalConnTab", "ConnectivityName", "input") }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { populateConnRule: populateConnRule, checkConnRuleValues: checkConnRuleValues diff --git a/tests/netpyne-tests.js b/tests/netpyne-tests.js index c49e9732..df01dd51 100644 --- a/tests/netpyne-tests.js +++ b/tests/netpyne-tests.js @@ -15,35 +15,37 @@ if (urlBase == null || urlBase == undefined) { urlBase = "http://localhost:8888/"; } -casper.test.begin('NetPyNE projects tests', function suite(test) { +casper.test.begin('NetPyNE projects tests', function suite (test) { casper.options.viewportSize = { width: 1340, height: 768 }; casper.options.waitTimeout = 10000 - casper.on("page.error", function(msg, trace) { + casper.on("page.error", function (msg, trace) { this.echo("Error: " + msg, "ERROR"); }); - // UNCOMMENT OUT to get the javascript logs (console.log). Particularly useful for debugginf purpose - // casper.on('remote.message', function(message) { - // this.echo('remote message caught: ' + message); - // }); + /* + * UNCOMMENT OUT to get the javascript logs (console.log). Particularly useful for debugginf purpose + * casper.on('remote.message', function(message) { + * this.echo('remote message caught: ' + message); + * }); + */ // show page level errors - casper.on('resource.received', function(resource) { + casper.on('resource.received', function (resource) { var status = resource.status; if (status >= 400) { this.echo('URL: ' + resource.url + ' Status: ' + resource.status); } }); - //load netpyne main landing page - casper.start(urlBase + "geppetto", function() { + // load netpyne main landing page + casper.start(urlBase + "geppetto", function () { this.echo("Load : " + urlBase); - //wait for the loading spinner to go away, meaning netpyne has loaded - this.waitWhileVisible('div[id="loading-spinner"]', function() { - this.wait(5000, function() { //test some expected HTML elements in landing page + // wait for the loading spinner to go away, meaning netpyne has loaded + this.waitWhileVisible('div[id="loading-spinner"]', function () { + this.wait(5000, function () { // test some expected HTML elements in landing page this.echo("I've waited for netpyne to load."); test.assertTitle("NetPyNE", "NetPyNE title is ok"); test.assertExists('div[id="widgetContainer"]', "NetPyNE loads the initial widgetsContainer"); @@ -52,66 +54,66 @@ casper.test.begin('NetPyNE projects tests', function suite(test) { }, null, 40000); }); - casper.then(function() { //test HTML elements in landing page + casper.then(function () { // test HTML elements in landing page this.echo("######## Testing landping page contents and layout ######## ", "INFO"); testLandingPage(test); }); - casper.then(function() { // test adding a population using UI + casper.then(function () { // test adding a population using UI toolbox.header(this, "test appbar") testAppbar(test); }); - casper.then(function() { // test adding a population using UI + casper.then(function () { // test adding a population using UI toolbox.header(this, "test popParams fields") testPopParamsFields(test); }); - casper.then(function() { // test adding a cell rule using UI + casper.then(function () { // test adding a cell rule using UI toolbox.header(this, "test cellparams fields") testCellParamsFields(test); }); - casper.then(function() { // test adding a synapse rule using UI + casper.then(function () { // test adding a synapse rule using UI toolbox.header(this, "test synMechParams fields") testSynMechParamsFields(test); }); - casper.then(function() { // test adding a connection using UI + casper.then(function () { // test adding a connection using UI toolbox.header(this, "test connParams fields") testConnParamsFields(test); }); - casper.then(function() { // test adding a stimulus source using UI + casper.then(function () { // test adding a stimulus source using UI toolbox.header(this, "test stimSourceParams fields") testStimSourceFields(test); }); - casper.then(function() { // test adding a stimulus target using UI + casper.then(function () { // test adding a stimulus target using UI toolbox.header(this, "test stimTargetParams fields") testStimTargetFields(test); }); - casper.then(function() { // test config + casper.then(function () { // test config toolbox.header(this, "test simConfig fields") testSimConfigFields(test); }); - casper.then(function() { + casper.then(function () { toolbox.header(this, "load network") testLoadNetwork(test) }) - casper.then(function() { //test explore network tab functionality + casper.then(function () { // test explore network tab functionality toolbox.header(this, "Explore Network Functionality") testExploreNetwork(test); }); - casper.then(function() { //test simulate network tab functionality + casper.then(function () { // test simulate network tab functionality toolbox.header(this, "Simulate Network Functionality") testSimulateNetwork(test); }); - casper.run(function() { + casper.run(function () { test.done(); }); }); @@ -119,8 +121,8 @@ casper.test.begin('NetPyNE projects tests', function suite(test) { /** * Test existence of HTML elements expected when main landing page is reached */ -function testLandingPage(test) { - casper.then(function() { +function testLandingPage (test) { + casper.then(function () { toolbox.assertExist(this, test, "Populations", "div") toolbox.assertExist(this, test, "CellRules", "div") toolbox.assertExist(this, test, "Synapses", "div") @@ -135,11 +137,11 @@ function testLandingPage(test) { /** * Load consoles and test they toggle */ -function testConsoles(test) { - casper.then(function() { //test existence and toggling of console +function testConsoles (test) { + casper.then(function () { // test existence and toggling of console loadConsole(test, 'pythonConsoleButton', "pythonConsole"); }); - casper.then(function() { //test existence and toggling of console + casper.then(function () { // test existence and toggling of console loadConsole(test, 'consoleButton', "console"); }); } @@ -147,34 +149,36 @@ function testConsoles(test) { /** * Load console, and test it hides/shows fine */ -function loadConsole(test, consoleButton, consoleContainer) { - casper.thenClick('li[id="'+consoleButton+'"]', function(){ - this.waitUntilVisible('div[id="' + consoleContainer + '"]', function() { +function loadConsole (test, consoleButton, consoleContainer) { + casper.thenClick('li[id="' + consoleButton + '"]', function (){ + this.waitUntilVisible('div[id="' + consoleContainer + '"]', function () { this.echo(consoleContainer + ' loaded.'); test.assertExists('div[id="' + consoleContainer + '"]', consoleContainer + " exists"); }) }); - casper.thenClick('li[id="'+consoleButton+'"]', function() { - this.waitWhileVisible('div[id="' + consoleContainer + '"]', function() { + casper.thenClick('li[id="' + consoleButton + '"]', function () { + this.waitWhileVisible('div[id="' + consoleContainer + '"]', function () { this.echo(consoleContainer + ' hidden.'); test.assertNotVisible('div[id="' + consoleContainer + '"]', consoleContainer + " no longer visible"); }); }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) } -/****************************************************************************** +/** + ***************************************************************************** * appbar * - ******************************************************************************/ -function testAppbar(test) { + ***************************************************************************** + */ +function testAppbar (test) { toolbox.message(casper, "import cell template and compile mod files") - casper.then(function() { + casper.then(function () { appbarTest.importCellTemplate(this, test, toolbox) }) toolbox.message(casper, "import HLS") - casper.then(function() { + casper.then(function () { appbarTest.importHLS(this, test, toolbox) }) @@ -183,41 +187,41 @@ function testAppbar(test) { appbarTest.instantiateNetwork(this, test, toolbox) }) - casper.then(function(){ + casper.then(function (){ appbarTest.simulateNetwork(this, test, toolbox) }) toolbox.message(casper, "save model") - casper.then(function(){ + casper.then(function (){ appbarTest.saveNetwork(this, test, toolbox) }) toolbox.message(casper, "delete model") - casper.then(function(){ + casper.then(function (){ appbarTest.clearModel(this, test, toolbox) }) toolbox.message(casper, "open model") - casper.then(function(){ + casper.then(function (){ appbarTest.openNetwork(this, test, toolbox) }) - casper.then(function(){ + casper.then(function (){ appbarTest.exploreOpenedModel(this, test, toolbox) }) toolbox.message(casper, "export HLS") - casper.then(function(){ + casper.then(function (){ appbarTest.exportHLS(this, test, toolbox) }) toolbox.message(casper, "delete model") - casper.then(function(){ + casper.then(function (){ appbarTest.clearModel(this, test, toolbox) }) toolbox.message(casper, "import HLS") - casper.then(function() { + casper.then(function () { appbarTest.importHLS(this, test, toolbox, false) }) @@ -227,324 +231,340 @@ function testAppbar(test) { }) toolbox.message(casper, "delete model") - casper.then(function(){ + casper.then(function (){ appbarTest.clearModel(this, test, toolbox) }) - casper.then(function() { - this.wait(1000, function(){ + casper.then(function () { + this.wait(1000, function (){ this.click("#Populations") }) }) } -/****************************************************************************** +/** + ***************************************************************************** * popParams * - ******************************************************************************/ -function testPopParamsFields(test) { + ***************************************************************************** + */ +function testPopParamsFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "Populations", "newPopulationButton", "Population") }) toolbox.message(casper, "populate") - casper.then(function() { //populate rule 1 + casper.then(function () { // populate rule 1 popParamsTest.populatePopParams(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { // focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "Population2", "populationName") }) - casper.then(function() { // check rule 2 is empty + casper.then(function () { // check rule 2 is empty popParamsTest.checkPopParamsValues(this, test, toolbox, "Population2", true) }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "Population", "populationName") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated popParamsTest.checkPopParamsValues(this, test, toolbox, "Population") }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "Population2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "Population", "populationName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "populationName", "newPop") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated popParamsTest.checkPopParamsValues(this, test, toolbox, "newPop") }) - casper.then(function() { // add rules to test other cards + casper.then(function () { // add rules to test other cards popParamsTest.addTestPops(this, test, toolbox) }) toolbox.message(casper, "leave") - casper.thenClick('#Populations', function() { + casper.thenClick('#Populations', function () { toolbox.assertDoesntExist(this, test, "newPopulationButton", "button", "collapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * cellParams * - ******************************************************************************/ -function testCellParamsFields(test) { + ***************************************************************************** + */ +function testCellParamsFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "CellRules", "newCellRuleButton", "CellRule") }) toolbox.message(casper, "populate") - casper.then(function() { //populate rule 1 + casper.then(function () { // populate rule 1 cellParamsTest.populateCellRule(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { // focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "CellRule2", "cellRuleName") }) - casper.then(function() { // check fields are not copy to rule 2 + casper.then(function () { // check fields are not copy to rule 2 cellParamsTest.checkCellParamsValues(this, test, toolbox, "CellRule2", "", "", "", true) }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "CellRule", "cellRuleName") }) - casper.then(function() { // check fields remain the same + casper.then(function () { // check fields remain the same cellParamsTest.checkCellParamsValues(this, test, toolbox, "CellRule", "PYR", "HH", "newPop") }) - casper.then(function() { // test Sections and Mechanisms + casper.then(function () { // test Sections and Mechanisms cellParamsTest.testSectionAndMechanisms(this, test, toolbox) }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "CellRule2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "CellRule", "cellRuleName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "cellRuleName", "newCellRule") }) - casper.then(function() { + casper.then(function () { cellParamsTest.exploreCellRuleAfterRenaming(this, test, toolbox) // re-explore whole rule }) toolbox.message(casper, "leave") - casper.thenClick('#CellRules', function() { + casper.thenClick('#CellRules', function () { toolbox.assertDoesntExist(this, test, "newCellRuleButton", "collapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * synMechParams * - ******************************************************************************/ -function testSynMechParamsFields(test) { + ***************************************************************************** + */ +function testSynMechParamsFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "Synapses", "newSynapseButton", "Synapse") }) toolbox.message(casper, "populate") - casper.then(function() { //populate rule 1 + casper.then(function () { // populate rule 1 synMechParamsTest.populateSynMech(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { // focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "Synapse2", "synapseName") }) - casper.then(function() { // check rule 2 is empty + casper.then(function () { // check rule 2 is empty synMechParamsTest.checkSynMechEmpty(this, test, toolbox, "Synapse2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "Synapse", "synapseName") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated synMechParamsTest.checkSynMechValues(this, test, toolbox, "Synapse") }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "Synapse2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "Synapse", "synapseName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "synapseName", "newSyn") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated synMechParamsTest.checkSynMechValues(this, test, toolbox, "newSyn") }) - casper.then(function() { //add rules to test other cards + casper.then(function () { // add rules to test other cards synMechParamsTest.addTestSynMech(this, test, toolbox) }) toolbox.message(casper, "leave") - casper.thenClick('#Synapses', function() { + casper.thenClick('#Synapses', function () { toolbox.assertDoesntExist(this, test, "newSynapseButton", "collapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * connParams * - ******************************************************************************/ -function testConnParamsFields(test) { + ***************************************************************************** + */ +function testConnParamsFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "Connections", "newConnectivityRuleButton", "ConnectivityRule") }) toolbox.message(casper, "populate") - casper.then(function() { //populate rule 1 + casper.then(function () { // populate rule 1 connParamsTest.populateConnRule(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { //focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "ConnectivityRule2", "ConnectivityName") }) - casper.then(function() { // check rule 2 is empty + casper.then(function () { // check rule 2 is empty connParamsTest.checkConnRuleValues(this, test, toolbox, "ConnectivityRule2", true) }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "ConnectivityRule", "ConnectivityName") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated connParamsTest.checkConnRuleValues(this, test, toolbox, "ConnectivityRule") }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "ConnectivityRule2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "ConnectivityRule", "ConnectivityName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "ConnectivityName", "newRule") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated connParamsTest.checkConnRuleValues(this, test, toolbox, "newRule") }) toolbox.message(casper, "leave") - casper.thenClick('#Connections', function() { + casper.thenClick('#Connections', function () { toolbox.assertDoesntExist(this, test, "newConnectivityRuleButton", "colapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * stimSourceParams * - ******************************************************************************/ -function testStimSourceFields(test) { + ***************************************************************************** + */ +function testStimSourceFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "StimulationSources", "newStimulationSourceButton", "stim_source") }) toolbox.message(casper, "populate") - casper.then(function() { // populate rule 1 + casper.then(function () { // populate rule 1 stimSourceParamsTest.populateStimSourceRule(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { // focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "stim_source2", "sourceName") }) - casper.then(function() { // check rule 2 is empty + casper.then(function () { // check rule 2 is empty stimSourceParamsTest.checkStimSourceEmpty(this, test, toolbox, "stim_source2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "stim_source", "sourceName") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated stimSourceParamsTest.checkStimSourceValues(this, test, toolbox, "stim_source") }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "stim_source2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "stim_source", "sourceName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "sourceName", "newStimSource") }) - casper.then(function() { // delete delete delete delete + casper.then(function () { // delete delete delete delete this.wait(2000) }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated stimSourceParamsTest.checkStimSourceValues(this, test, toolbox, "newStimSource") }) toolbox.message(casper, "leave") - casper.thenClick('#StimulationSources', function() { + casper.thenClick('#StimulationSources', function () { toolbox.assertDoesntExist(this, test, "newStimulationSourceButton", "collapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * stimTargetParams * - ******************************************************************************/ -function testStimTargetFields(test) { + ***************************************************************************** + */ +function testStimTargetFields (test) { toolbox.message(casper, "create") - casper.then(function() { // create 2 rules + casper.then(function () { // create 2 rules toolbox.create2rules(this, test, "StimulationTargets", "newStimulationTargetButton", "stim_target") }) toolbox.message(casper, "populate") - casper.then(function() { // populate rule 1 + casper.then(function () { // populate rule 1 stimTargetParamsTest.populateStimTargetRule(this, test, toolbox) }) toolbox.message(casper, "check") - casper.then(function() { // focus on rule 2 + casper.then(function () { // focus on rule 2 this.echo("moved to second rule -> should be empty") toolbox.selectThumbRule(this, test, "stim_target2", "targetName") }) - casper.then(function() { // check rule 2 is empty + casper.then(function () { // check rule 2 is empty stimTargetParamsTest.checkStimTargetValues(this, test, toolbox, "stim_target2", true) }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 this.echo("moved to first rule -> should be populated") toolbox.selectThumbRule(this, test, "stim_target", "targetName") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated stimTargetParamsTest.checkStimTargetValues(this, test, toolbox, "stim_target") }) toolbox.message(casper, "rename") - casper.then(function() { // delete rule 2 + casper.then(function () { // delete rule 2 toolbox.delThumbnail(this, test, "stim_target2") }) - casper.then(function() { //focus on rule 1 + casper.then(function () { // focus on rule 1 toolbox.selectThumbRule(this, test, "stim_target", "targetName") }) - casper.then(function() { //rename rule 1 + casper.then(function () { // rename rule 1 toolbox.renameRule(this, test, "targetName", "newStimTarget") }) - casper.then(function() { // check rule 1 is populated + casper.then(function () { // check rule 1 is populated stimTargetParamsTest.checkStimTargetValues(this, test, toolbox, "newStimTarget") }) toolbox.message(casper, "leave") - casper.thenClick('#StimulationTargets', function() { + casper.thenClick('#StimulationTargets', function () { toolbox.assertDoesntExist(this, test, "newStimulationTargetButton", "collapse card") }); } -/******************************************************************************* +/** + ****************************************************************************** * simConfig * - ******************************************************************************/ -function testSimConfigFields(test) { - casper.then(function() { + ***************************************************************************** + */ +function testSimConfigFields (test) { + casper.then(function () { simConfigTest.setSimConfigParams(this, test, toolbox) }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { + casper.then(function () { simConfigTest.getSimConfigParams(this, test, toolbox) }) } -/******************************************************************************* +/** + ****************************************************************************** * load network * - ******************************************************************************/ -function testLoadNetwork(test) { - casper.then(function() { - this.reload(function() { + ***************************************************************************** + */ +function testLoadNetwork (test) { + casper.then(function () { + this.reload(function () { this.echo("reloading webpage", "INFO") }) }) - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { - this.wait(5000, function() { //test some expected HTML elements in landing page + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { + this.wait(5000, function () { // test some expected HTML elements in landing page this.echo("I've waited for netpyne to load."); test.assertTitle("NetPyNE", "NetPyNE title is ok"); test.assertExists('div[id="widgetContainer"]', "NetPyNE loads the initial widgetsContainer"); @@ -552,27 +572,29 @@ function testLoadNetwork(test) { }); }, null, 40000); }) - casper.then(function() { //test full netpyne loop using a demo project - var demo = "from netpyne_ui.tests.tut3 import netParams, simConfig \n" + - "netpyne_geppetto.netParams=netParams \n" + - "netpyne_geppetto.simConfig=simConfig"; + casper.then(function () { // test full netpyne loop using a demo project + var demo = "from netpyne_ui.tests.tut3 import netParams, simConfig \n" + + "netpyne_geppetto.netParams=netParams \n" + + "netpyne_geppetto.simConfig=simConfig"; simulationTest.loadModelUsingPython(this, test, toolbox, demo); }); } -/******************************************************************************* +/** + ****************************************************************************** * explore network * - ******************************************************************************/ -function testExploreNetwork(test) { - casper.then(function() { + ***************************************************************************** + */ +function testExploreNetwork (test) { + casper.then(function () { this.echo("------Testing explore network"); test.assertExists('button[id="simulateNetwork"]', "Explore network button exists"); }) - casper.thenClick('#simulateNetwork', function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { + casper.thenClick('#simulateNetwork', function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { simulationTest.canvasComponentsTests(this, test); }, 40000) }) - casper.then(function() { + casper.then(function () { this.echo("Testing meshes for network exist and are visible"); simulationTest.testMeshVisibility(this, test, true, "network.S[0]"); simulationTest.testMeshVisibility(this, test, true, "network.S[1]"); @@ -581,53 +603,55 @@ function testExploreNetwork(test) { simulationTest.testMeshVisibility(this, test, true, "network.S[19]"); }) casper.thenClick('#PlotButton'); - casper.then(function() { //wait for plot menu to become visible - this.waitUntilVisible('div[role="menu"]', function() { + casper.then(function () { // wait for plot menu to become visible + this.waitUntilVisible('div[role="menu"]', function () { test.assertExists('div[role="menu"]', "Drop down Plot Menu Exists"); }) }) - casper.then(function() { // test connection plot comes up + casper.then(function () { // test connection plot comes up simulationTest.testPlotButton(this, test, "connectionPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "2dNetPlot", "Popup1"); }) - casper.then(function(){ // test shape plot comes up + casper.then(function (){ // test shape plot comes up simulationTest.testPlotButton(this, test, "shapePlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { var info = this.getElementInfo('button[id="PlotButton"]'); - this.mouse.click(info.x - 4, info.y - 4); //move a bit away from corner + this.mouse.click(info.x - 4, info.y - 4); // move a bit away from corner }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { - this.waitWhileVisible('div[role="menu"]', function() { //wait for menu to close + casper.then(function () { + this.waitWhileVisible('div[role="menu"]', function () { // wait for menu to close test.assertDoesntExist('div[role="menu"]', "Drop down Plot Menu is gone"); }); }) casper.thenClick('#ControlPanelButton'); - casper.then(function() { //test initial load values in control panel + casper.then(function () { // test initial load values in control panel simulationTest.testControlPanelValues(this, test, 43); }); casper.thenClick('#ControlPanelButton'); } -/******************************************************************************* +/** + ****************************************************************************** * simulate network * - ******************************************************************************/ -function testSimulateNetwork(test) { - casper.thenClick('#launchSimulationButton', function(){ + ***************************************************************************** + */ +function testSimulateNetwork (test) { + casper.thenClick('#launchSimulationButton', function (){ this.waitUntilVisible('button[id="okRunSimulation"]') }); - casper.thenClick('#okRunSimulation', function() { - this.waitWhileVisible('button[id="okRunSimulation"]', function() { + casper.thenClick('#okRunSimulation', function () { + this.waitWhileVisible('button[id="okRunSimulation"]', function () { this.echo("Dialog disappeared"); }) }); - casper.then(function() { - this.waitWhileVisible('div[id="loading-spinner"]', function() { + casper.then(function () { + this.waitWhileVisible('div[id="loading-spinner"]', function () { this.echo("Loading spinner disappeared"); this.echo("Testing meshes for network exist and are visible"); simulationTest.testMeshVisibility(this, test, true, "network.S[0]"); @@ -638,38 +662,38 @@ function testSimulateNetwork(test) { }, 150000); }) casper.thenClick('#PlotButton'); - casper.then(function() { - this.waitUntilVisible('div[role="menu"]', function() { + casper.then(function () { + this.waitUntilVisible('div[role="menu"]', function () { test.assertExists('div[role="menu"]', "Drop down Plot Menu Exists"); }) }) - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "rasterPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "spikePlot", "Popup1"); }); - casper.then(function(){ + casper.then(function (){ simulationTest.testPlotButton(this, test, "spikeStatsPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "ratePSDPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "tracesPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { simulationTest.testPlotButton(this, test, "grangerPlot", "Popup1"); }); - casper.then(function() { + casper.then(function () { var info = this.getElementInfo('button[id="PlotButton"]'); - this.mouse.click(info.x - 4, info.y - 4); //move a bit away from corner + this.mouse.click(info.x - 4, info.y - 4); // move a bit away from corner }) - casper.then(function(){ + casper.then(function (){ this.wait(1000) }) - casper.then(function() { - this.waitWhileVisible('div[role="menu"]', function() { + casper.then(function () { + this.waitWhileVisible('div[role="menu"]', function () { test.assertDoesntExist('div[role="menu"]', "Drop down Plot Menu is gone"); }) }) diff --git a/tests/popParamsTest.js b/tests/popParamsTest.js index 7bc1646e..d7984d6d 100644 --- a/tests/popParamsTest.js +++ b/tests/popParamsTest.js @@ -1,46 +1,48 @@ var require = patchRequire(require); var rangeComponentTest = require('./rangeComponentTest') -/******************************************************************************* +/** + ****************************************************************************** * PopParams * - *******************************************************************************/ -function populatePopParams(casper, test, toolbox) { - casper.then(function() { + ****************************************************************************** + */ +function populatePopParams (casper, test, toolbox) { + casper.then(function () { toolbox.active = { cardID: "Populations", buttonID: "newPopulationButton", tabID: false } }) - casper.then(function() { //populate fields + casper.then(function () { // populate fields test.assertExists("#populationName", "Pop name Exists"); toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellType\']", "PYR") toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellModel\']", "HH") }) - casper.then(function() { // populate dimension component + casper.then(function () { // populate dimension component populatePopDimension(this, test, toolbox) }) - casper.then(function() { - this.wait(2500) //let python receive data + casper.then(function () { + this.wait(2500) // let python receive data toolbox.active.tabID = "spatialDistPopTab" }) - casper.thenClick('#spatialDistPopTab', function() { //go to second tab (spatial distribution) + casper.thenClick('#spatialDistPopTab', function () { // go to second tab (spatial distribution) this.echo("changed tab") rangeComponentTest.populateRangeComponent(casper, test, toolbox, "PopParams") // populate RangeComponent }) } -//----------------------------------------------------------------------------// -function checkPopParamsValues(casper, test, toolbox, ruleName, empty = false) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function checkPopParamsValues (casper, test, toolbox, ruleName, empty = false) { + casper.then(function () { toolbox.active.tabID = false }) - casper.then(function() { // check fields remained the same after renaiming and closing card + casper.then(function () { // check fields remained the same after renaiming and closing card toolbox.getInputValue(this, test, "populationName", ruleName); toolbox.getInputValue(this, test, "netParams.popParams[\'" + ruleName + "\'][\'cellType\']", !empty ? "PYR" : ""); toolbox.getInputValue(this, test, "netParams.popParams[\'" + ruleName + "\'][\'cellModel\']", !empty ? "HH" : ""); }) - casper.then(function() { //check dimension + casper.then(function () { // check dimension if (empty) { toolbox.assertDoesntExist(this, test, "popParamsDimensions"); } else { @@ -48,12 +50,12 @@ function checkPopParamsValues(casper, test, toolbox, ruleName, empty = false) { } }) - casper.thenClick('#spatialDistPopTab', function() { //go to second tab (spatial distribution) + casper.thenClick('#spatialDistPopTab', function () { // go to second tab (spatial distribution) this.wait(2500) // wait for python to populate fields toolbox.active.tabID = "spatialDistPopTab" }) - casper.then(function() { + casper.then(function () { if (empty) { rangeComponentTest.checkRangeComponentIsEmpty(this, test, toolbox, "PopParams") } else { @@ -61,58 +63,58 @@ function checkPopParamsValues(casper, test, toolbox, ruleName, empty = false) { } }) } -//----------------------------------------------------------------------------// -function populatePopDimension(casper, test, toolbox) { - casper.then(function() { - toolbox.click(this, "popParamsDimensionsSelect", "div"); //click dimension SelectList +// ----------------------------------------------------------------------------// +function populatePopDimension (casper, test, toolbox) { + casper.then(function () { + toolbox.click(this, "popParamsDimensionsSelect", "div"); // click dimension SelectList }) - casper.then(function() { // check all menuItems exist + casper.then(function () { // check all menuItems exist toolbox.assertExist(this, test, "popParamSnumCells", "span"); toolbox.assertExist(this, test, "popParamSdensity", "span"); toolbox.assertExist(this, test, "popParamSgridSpacing", "span"); }); - casper.thenClick("#popParamSnumCells", function() { //check 1st menuItem displays input field + casper.thenClick("#popParamSnumCells", function () { // check 1st menuItem displays input field toolbox.setInputValue(this, test, "popParamsDimensions", "20") }) - casper.then(function() { // let python receive changes + casper.then(function () { // let python receive changes this.wait(2500) }) } -//----------------------------------------------------------------------------// -function addTestPops(casper, test, toolbox) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function addTestPops (casper, test, toolbox) { + casper.then(function () { toolbox.active.tabID = false }) toolbox.message(casper, "extra pops to test other cards") - casper.thenClick('button[id="newPopulationButton"]', function() { //add new population - this.waitUntilVisible('input[id="populationName"]', function() { + casper.thenClick('button[id="newPopulationButton"]', function () { // add new population + this.waitUntilVisible('input[id="populationName"]', function () { test.assertExists('input[id="populationName"]', "rule added"); }) }) - casper.then(function() { //populate fields + casper.then(function () { // populate fields toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellType\']", "GC") toolbox.setInputValue(this, test, "netParams.popParams[\'Population\'][\'cellModel\']", "IF") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.thenClick('button[id="newPopulationButton"]', function() { //add new population - this.waitUntilVisible('button[id="Population2"]', function() { + casper.thenClick('button[id="newPopulationButton"]', function () { // add new population + this.waitUntilVisible('button[id="Population2"]', function () { test.assertExists('button[id="Population2"]', "rule added"); }) }) - casper.then(function() { //populate fields + casper.then(function () { // populate fields toolbox.setInputValue(this, test, "netParams.popParams[\'Population2\'][\'cellType\']", "BC") toolbox.setInputValue(this, test, "netParams.popParams[\'Population2\'][\'cellModel\']", "Izi") }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { addTestPops: addTestPops, populatePopParams: populatePopParams, diff --git a/tests/rangeComponentTest.js b/tests/rangeComponentTest.js index 51fc3c46..346eea3a 100644 --- a/tests/rangeComponentTest.js +++ b/tests/rangeComponentTest.js @@ -1,12 +1,14 @@ -/******************************************************************************* +/** + ****************************************************************************** * RangeComponent * - *******************************************************************************/ -function populateRangeComponent(casper, test, toolbox, model) { - casper.then(function() { + ****************************************************************************** + */ +function populateRangeComponent (casper, test, toolbox, model) { + casper.then(function () { this.echo("explore range component") exploreRangeComponent(this, test, toolbox, model) }) - casper.then(function() { // populate fields with correct and wrong values + casper.then(function () { // populate fields with correct and wrong values this.echo("set values on range component") toolbox.setInputValue(this, test, "xRange" + model + "MinRange", "0.1") toolbox.setInputValue(this, test, "xRange" + model + "MaxRange", "0.9") @@ -15,49 +17,49 @@ function populateRangeComponent(casper, test, toolbox, model) { toolbox.setInputValue(this, test, "zRange" + model + "MinRange", "0.2") toolbox.setInputValue(this, test, "zRange" + model + "MaxRange", "A") }) - casper.then(function() { //let python receive data + casper.then(function () { // let python receive data this.wait(2000) }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function exploreRangeComponent(casper, test, toolbox, model) { - casper.then(function() { +function exploreRangeComponent (casper, test, toolbox, model) { + casper.then(function () { exploreRangeAxis(this, test, toolbox, model, "x", "Normalized"); exploreRangeAxis(this, test, toolbox, model, "y", "Absolute"); exploreRangeAxis(this, test, toolbox, model, "z", "Normalized"); }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function exploreRangeAxis(casper, test, toolbox, model, axis, norm) { +function exploreRangeAxis (casper, test, toolbox, model, axis, norm) { var elementID = axis + "Range" + model + "Select" var secondElementID = axis + "Range" + model + norm + "MenuItem" - casper.then(function() { + casper.then(function () { toolbox.click(this, elementID) }) - casper.then(function() { - this.waitUntilVisible('span[id="' + secondElementID + '"]') //wait for dropDownMenu animation + casper.then(function () { + this.waitUntilVisible('span[id="' + secondElementID + '"]') // wait for dropDownMenu animation }) - casper.then(function() { + casper.then(function () { toolbox.click(this, secondElementID, "span") }) - casper.then(function() { + casper.then(function () { this.waitWhileVisible('span[id="' + secondElementID + '"]') }) - casper.then(function() { + casper.then(function () { toolbox.assertExist(this, test, elementID.replace("Select", "") + "MinRange", "input", "min limit in range " + axis + " Exist") toolbox.assertExist(this, test, elementID.replace("Select", "") + "MaxRange", "input", "max limit in range " + axis + " Exist") }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function testRangeComponent(casper, test, toolbox, model) { - casper.then(function() { - this.wait(1500, function() { // let pyhton populate fields +function testRangeComponent (casper, test, toolbox, model) { + casper.then(function () { + this.wait(1500, function () { // let pyhton populate fields toolbox.getInputValue(this, test, "xRange" + model + "MinRange", "0.1"); toolbox.getInputValue(this, test, "xRange" + model + "MaxRange", "0.9"); toolbox.getInputValue(this, test, "yRange" + model + "MinRange", "100"); @@ -68,10 +70,10 @@ function testRangeComponent(casper, test, toolbox, model) { }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkRangeComponentIsEmpty(casper, test, toolbox, model) { - casper.wait(1000, function() { //wait for python to populate fields +function checkRangeComponentIsEmpty (casper, test, toolbox, model) { + casper.wait(1000, function () { // wait for python to populate fields toolbox.assertDoesntExist(this, test, "xRange" + model + "MinRange"); toolbox.assertDoesntExist(this, test, "xRange" + model + "MaxRange"); toolbox.assertDoesntExist(this, test, "yRange" + model + "MinRange"); @@ -81,7 +83,7 @@ function checkRangeComponentIsEmpty(casper, test, toolbox, model) { }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { exploreRangeAxis: exploreRangeAxis, testRangeComponent: testRangeComponent, diff --git a/tests/simConfigTest.js b/tests/simConfigTest.js index dc83d0bf..3eb9e645 100644 --- a/tests/simConfigTest.js +++ b/tests/simConfigTest.js @@ -1,7 +1,7 @@ -//----------------------------------------------------------------------------// -function setSimConfigParams(casper, test, toolbox) { - casper.then(function() { - this.waitUntilVisible('div[id="Configuration"]', function() { +// ----------------------------------------------------------------------------// +function setSimConfigParams (casper, test, toolbox) { + casper.then(function () { + this.waitUntilVisible('div[id="Configuration"]', function () { toolbox.active = { cardID: "Configuration", buttonID: "configGeneral", @@ -15,7 +15,7 @@ function setSimConfigParams(casper, test, toolbox) { this.wait(1500) }) - casper.then(function() { + casper.then(function () { toolbox.setInputValue(this, test, "simConfig.duration", "999"); toolbox.setInputValue(this, test, "simConfig.dt", "0.0249"); toolbox.getInputValue(this, test, "simConfig.printRunTime", "false"); @@ -26,10 +26,10 @@ function setSimConfigParams(casper, test, toolbox) { toolbox.deleteListItem(this, test, "simConfig.seeds2"); toolbox.addListItem(this, test, "simConfig.seeds", "fakeII: 654321") }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.then(function() { + casper.then(function () { toolbox.clickCheckBox(this, test, "simConfig.createNEURONObj"); toolbox.clickCheckBox(this, test, "simConfig.createPyStruct"); toolbox.clickCheckBox(this, test, "simConfig.addSynMechs"); @@ -45,14 +45,14 @@ function setSimConfigParams(casper, test, toolbox) { toolbox.clickCheckBox(this, test, "simConfig.cvode_active"); }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.thenClick("#configRecord", function() { //go to record tab - this.wait(2500); //let python populate fields + casper.thenClick("#configRecord", function () { // go to record tab + this.wait(2500); // let python populate fields toolbox.active.tabID = "configRecord" }); - casper.then(function() { + casper.then(function () { toolbox.addListItem(this, test, "simConfig.recordCells", "22") toolbox.addListItem(this, test, "simConfig.recordLFP", "1,2,3") toolbox.addListItem(this, test, "simConfig.recordTraces", "Vsoma: {sec: soma, loc: 0.5, var: v}") @@ -61,56 +61,58 @@ function setSimConfigParams(casper, test, toolbox) { toolbox.clickCheckBox(this, test, "simConfig.recordStim"); }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.thenClick("#configSaveConfiguration", function() { //go to saveConfig tab - this.wait(2500) //let python populate fields + casper.thenClick("#configSaveConfiguration", function () { // go to saveConfig tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "configSaveConfiguration" }); - casper.then(function() { + casper.then(function () { toolbox.assertExist(this, test, "simConfig.simLabel") toolbox.assertExist(this, test, "simConfig.saveDataInclude") toolbox.assertExist(this, test, "simConfig.backupCfgFile") toolbox.getInputValue(this, test, "simConfig.filename", "model_output"); toolbox.getlistItemValues(this, test, "simConfig.saveDataInclude", ['netParams', 'netCells', 'netPops', 'simConfig', 'simData']) }) - casper.then(function() { + casper.then(function () { toolbox.clickCheckBox(this, test, "simConfig.saveCellSecs"); toolbox.clickCheckBox(this, test, "simConfig.saveCellConns"); toolbox.clickCheckBox(this, test, "simConfig.timestampFilename"); toolbox.clickCheckBox(this, test, "simConfig.savePickle"); toolbox.clickCheckBox(this, test, "simConfig.saveJson"); toolbox.clickCheckBox(this, test, "simConfig.saveMat"); - // toolbox.clickCheckBox(this, test, "simConfig.saveHDF5"); - // toolbox.clickCheckBox(this, test, "simConfig.saveDpk"); - // toolbox.clickCheckBox(this, test, "simConfig.saveDat"); - // toolbox.clickCheckBox(this, test, "simConfig.saveCSV"); + /* + * toolbox.clickCheckBox(this, test, "simConfig.saveHDF5"); + * toolbox.clickCheckBox(this, test, "simConfig.saveDpk"); + * toolbox.clickCheckBox(this, test, "simConfig.saveDat"); + * toolbox.clickCheckBox(this, test, "simConfig.saveCSV"); + */ toolbox.clickCheckBox(this, test, "simConfig.saveTiming"); }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.thenClick("#configErrorChecking", function() { //go to checkError tab - this.wait(2500) //let python populate fields + casper.thenClick("#configErrorChecking", function () { // go to checkError tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "configErrorChecking" }); - casper.then(function() { + casper.then(function () { toolbox.clickCheckBox(this, test, "simConfig.checkErrors"); toolbox.clickCheckBox(this, test, "simConfig.checkErrorsVerbose"); }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.thenClick("#confignetParams", function() { //go to network configuration tab - this.wait(2500) //let python populate fields + casper.thenClick("#confignetParams", function () { // go to network configuration tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "confignetParams" }); - casper.then(function() { + casper.then(function () { toolbox.assertExist(this, test, "netParams.scaleConnWeightModels") toolbox.setInputValue(this, test, "netParams.scale", "2"); toolbox.setInputValue(this, test, "netParams.defaultWeight", "3"); @@ -125,18 +127,18 @@ function setSimConfigParams(casper, test, toolbox) { toolbox.getSelectFieldValue(this, test, "netParams.shape", "cuboid") toolbox.addListItem(this, test, "netParams.scaleConnWeightModels", "0: 0.001") }) - casper.then(function() { + casper.then(function () { this.wait(3000) }) } -//----------------------------------------------------------------------------// -function getSimConfigParams(casper, test, toolbox) { - casper.thenClick("#configGeneral", function() { //go to network configuration tab - this.wait(2500) //let python populate fields +// ----------------------------------------------------------------------------// +function getSimConfigParams (casper, test, toolbox) { + casper.thenClick("#configGeneral", function () { // go to network configuration tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "configGeneral" }); - casper.then(function() { + casper.then(function () { toolbox.getInputValue(this, test, "simConfig.duration", "999"); toolbox.getInputValue(this, test, "simConfig.dt", "0.0249"); toolbox.getlistItemValues(this, test, "simConfig.hParams", ['celsius : 6.3', 'v_init : -65', "fake : 123456"]) @@ -156,11 +158,11 @@ function getSimConfigParams(casper, test, toolbox) { toolbox.testCheckBoxValue(this, test, "simConfig.cvode_active", true); }) - casper.thenClick("#configRecord", function() { //go to record tab - this.wait(3500); //let python populate fields + casper.thenClick("#configRecord", function () { // go to record tab + this.wait(3500); // let python populate fields toolbox.active.tabID = "configRecord" }); - casper.then(function() { + casper.then(function () { toolbox.getListItemValue(this, test, "simConfig.recordCells0", "22") toolbox.getListItemValue(this, test, "simConfig.recordLFP0", "[1,2,3]") toolbox.getListItemValue(this, test, "simConfig.recordTraces0", "Vsoma: {sec: soma, loc: 0.5, var: v}") @@ -169,38 +171,40 @@ function getSimConfigParams(casper, test, toolbox) { toolbox.testCheckBoxValue(this, test, "simConfig.recordStim", true); }) - casper.thenClick("#configSaveConfiguration", function() { //go to saveConfig tab - this.wait(2500) //let python populate fields + casper.thenClick("#configSaveConfiguration", function () { // go to saveConfig tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "configSaveConfiguration" }); - casper.then(function() { + casper.then(function () { toolbox.testCheckBoxValue(this, test, "simConfig.saveCellSecs", false); toolbox.testCheckBoxValue(this, test, "simConfig.saveCellConns", false); toolbox.testCheckBoxValue(this, test, "simConfig.timestampFilename", true); toolbox.testCheckBoxValue(this, test, "simConfig.savePickle", true); toolbox.testCheckBoxValue(this, test, "simConfig.saveJson", true); toolbox.testCheckBoxValue(this, test, "simConfig.saveMat", true); - // toolbox.testCheckBoxValue(this, test, "simConfig.saveHDF5", true); - // toolbox.testCheckBoxValue(this, test, "simConfig.saveDpk", true); - // toolbox.testCheckBoxValue(this, test, "simConfig.saveDat", true); - // toolbox.testCheckBoxValue(this, test, "simConfig.saveCSV", true); + /* + * toolbox.testCheckBoxValue(this, test, "simConfig.saveHDF5", true); + * toolbox.testCheckBoxValue(this, test, "simConfig.saveDpk", true); + * toolbox.testCheckBoxValue(this, test, "simConfig.saveDat", true); + * toolbox.testCheckBoxValue(this, test, "simConfig.saveCSV", true); + */ toolbox.testCheckBoxValue(this, test, "simConfig.saveTiming", true); }) - casper.thenClick("#configErrorChecking", function() { //go to checkError tab - this.wait(2500) //let python populate fields + casper.thenClick("#configErrorChecking", function () { // go to checkError tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "configErrorChecking" }); - casper.then(function() { + casper.then(function () { toolbox.testCheckBoxValue(this, test, "simConfig.checkErrors", true); toolbox.testCheckBoxValue(this, test, "simConfig.checkErrorsVerbose", true); }) - casper.thenClick("#confignetParams", function() { //go to network configuration tab - this.wait(2500) //let python populate fields + casper.thenClick("#confignetParams", function () { // go to network configuration tab + this.wait(2500) // let python populate fields toolbox.active.tabID = "confignetParams" }); - casper.then(function() { + casper.then(function () { toolbox.getInputValue(this, test, "netParams.scale", "2"); toolbox.getInputValue(this, test, "netParams.defaultWeight", "3"); toolbox.getInputValue(this, test, "netParams.defaultDelay", "4"); @@ -214,7 +218,7 @@ function getSimConfigParams(casper, test, toolbox) { }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { getSimConfigParams: getSimConfigParams, setSimConfigParams: setSimConfigParams diff --git a/tests/simulationTest.js b/tests/simulationTest.js index 2b38bb49..a3d82007 100644 --- a/tests/simulationTest.js +++ b/tests/simulationTest.js @@ -1,98 +1,102 @@ -/******************************************************************************* +/** + ****************************************************************************** * load network * - ******************************************************************************/ -function loadModelUsingPython(casper, test, toolbox, demo) { - casper.then(function() { + ***************************************************************************** + */ +function loadModelUsingPython (casper, test, toolbox, demo) { + casper.then(function () { this.echo("Loading demo for further testing ", "INFO"); - this.evaluate(function(demo) { + this.evaluate(function (demo) { var kernel = IPython.notebook.kernel; kernel.execute(demo); }, demo); }); - casper.then(function() { + casper.then(function () { this.waitUntilVisible('#Populations') }) - casper.thenClick('#Populations', function() { - this.waitUntilVisible('button[id="newPopulationButton"]', function() { + casper.thenClick('#Populations', function () { + this.waitUntilVisible('button[id="newPopulationButton"]', function () { this.echo("Population view loaded"); }); }); - casper.then(function() { //test first population exists after demo is loaded + casper.then(function () { // test first population exists after demo is loaded testPopulation(this, test, toolbox, "button#S", "S", "HH", "PYR", "20"); }); - casper.then(function() { //test second population exists after demo is loaded + casper.then(function () { // test second population exists after demo is loaded testPopulation(this, test, toolbox, "button#M", "M", "HH", "PYR", "20"); }); - casper.thenClick('#CellRules', function() { - this.waitUntilVisible('button[id="newCellRuleButton"]', function() { + casper.thenClick('#CellRules', function () { + this.waitUntilVisible('button[id="newCellRuleButton"]', function () { this.echo("Cell Rule view loaded"); }); }) - casper.then(function() { //test a cell rule exists after demo is loaded + casper.then(function () { // test a cell rule exists after demo is loaded testCellRule(this, test, toolbox, "button#PYRrule", "PYRrule", 'div[id="netParams.cellParams[\'PYRrule\'][\'conds\'][\'cellType\']"]', 'div[id="netParams.cellParams[\'PYRrule\'][\'conds\'][\'cellModel\']"]'); }); } -//------------------------------------------------------------------------------ -function testPopulation(casper, test, toolbox, buttonSelector, expectedName, expectedCellModel, expectedCellType, expectedDimensions) { - casper.then(function() { +// ------------------------------------------------------------------------------ +function testPopulation (casper, test, toolbox, buttonSelector, expectedName, expectedCellModel, expectedCellType, expectedDimensions) { + casper.then(function () { toolbox.active = { cardID: "Populations", buttonID: "newPopulationButton", tabID: false } this.echo("------Testing population button " + buttonSelector); - this.waitUntilVisible(buttonSelector, function() { + this.waitUntilVisible(buttonSelector, function () { test.assertExists(buttonSelector, "Population " + expectedName + " correctly created"); }) }) casper.thenClick('#' + expectedName); // click pop thumbnail - casper.then(function() { //let python populate fields - this.wait(2000, function() { + casper.then(function () { // let python populate fields + this.wait(2000, function () { this.echo("I've waited a second for metadata to be populated") }); }); - casper.then(function() { //test metadata contents + casper.then(function () { // test metadata contents toolbox.getInputValue(this, test, "populationName", expectedName); toolbox.getInputValue(this, test, "netParams.popParams[\'" + expectedName + "\'][\'cellModel\']", expectedCellModel); toolbox.getInputValue(this, test, "netParams.popParams[\'" + expectedName + "\'][\'cellType\']", expectedCellType); toolbox.getInputValue(this, test, "popParamsDimensions", expectedDimensions); }); } -//------------------------------------------------------------------------------ -function testCellRule(casper, test, toolbox, buttonSelector, expectedName, expectedCellModelId, expectedCellTypeId) { - casper.then(function() { +// ------------------------------------------------------------------------------ +function testCellRule (casper, test, toolbox, buttonSelector, expectedName, expectedCellModelId, expectedCellTypeId) { + casper.then(function () { toolbox.active = { cardID: "CellRules", buttonID: "newCellRuleButton", tabID: false } this.echo("------Testing cell rules button " + buttonSelector); - this.waitUntilVisible(buttonSelector, function() { + this.waitUntilVisible(buttonSelector, function () { this.echo('Cell Rule button exists.'); this.click('#' + expectedName); }) }) - casper.then(function() { //give it some time to allow metadata to load - this.wait(1000, function() { + casper.then(function () { // give it some time to allow metadata to load + this.wait(1000, function () { this.echo("I've waited a second for metadata to be populated") }); }); - casper.then(function() { //test contents of metadata + casper.then(function () { // test contents of metadata toolbox.getInputValue(this, test, "cellRuleName", expectedName); test.assertExists(expectedCellModelId, "cellRullCellModel exists"); test.assertExists(expectedCellTypeId, "cellRullCellType exists"); }); } -/******************************************************************************* +/** + ****************************************************************************** * ExploreNetwork & SimulateNetwork * - *******************************************************************************/ -function canvasComponentsTests(casper, test) { - casper.then(function() { + ****************************************************************************** + */ +function canvasComponentsTests (casper, test) { + casper.then(function () { this.echo("Testing existence of few simulation controls") test.assertExists('button[id="panLeftBtn"]', "Pan left button present"); test.assertExists('button[id="panUpBtn"]', "Pan up button present"); @@ -104,46 +108,46 @@ function canvasComponentsTests(casper, test) { test.assertExists('button[id="ControlPanelButton"]', "Control panel "); }); } -//------------------------------------------------------------------------------ -function testMeshVisibility(casper, test, visible, variableName) { - casper.then(function() { - var visibility = this.evaluate(function(variableName) { +// ------------------------------------------------------------------------------ +function testMeshVisibility (casper, test, visible, variableName) { + casper.then(function () { + var visibility = this.evaluate(function (variableName) { var visibility = CanvasContainer.engine.getRealMeshesForInstancePath(variableName)[0].visible; return visibility; }, variableName); test.assertEquals(visibility, visible, variableName + " visibility correct"); }); } -//------------------------------------------------------------------------------ -function testPlotButton(casper, test, plotButton, expectedPlot) { - casper.then(function() { +// ------------------------------------------------------------------------------ +function testPlotButton (casper, test, plotButton, expectedPlot) { + casper.then(function () { test.assertExists('span[id="' + plotButton + '"]', "Menu option " + plotButton + "Exists"); }) - casper.thenEvaluate(function(plotButton, expectedPlot) { - document.getElementById(plotButton).click(); //Click on plot option + casper.thenEvaluate(function (plotButton, expectedPlot) { + document.getElementById(plotButton).click(); // Click on plot option }, plotButton, expectedPlot); - casper.then(function() { - this.waitUntilVisible('div[id="' + expectedPlot + '"]', function() { + casper.then(function () { + this.waitUntilVisible('div[id="' + expectedPlot + '"]', function () { test.assertExists('div[id="' + expectedPlot + '"]', expectedPlot + " (" + plotButton + ") exists"); }) }) - casper.then(function() { //test plot has certain elements that are render if plot succeeded + casper.then(function () { // test plot has certain elements that are render if plot succeeded waitForPlotGraphElement(this, test, "figure_1"); waitForPlotGraphElement(this, test, "axes_1"); }); - casper.thenEvaluate(function(expectedPlot) { + casper.thenEvaluate(function (expectedPlot) { window[expectedPlot].destroy(); }, expectedPlot); - casper.then(function(){ - this.waitWhileVisible('div[id="' + expectedPlot + '"]', function() { + casper.then(function (){ + this.waitWhileVisible('div[id="' + expectedPlot + '"]', function () { test.assertDoesntExist('div[id="' + expectedPlot + '"]', expectedPlot + " (" + plotButton + ") no longer exists"); }); }) - casper.then(function() { - var plotError = test.assertEvalEquals(function() { + casper.then(function () { + var plotError = test.assertEvalEquals(function () { var error = document.getElementById("netPyneDialog") == undefined; if (!error) { document.getElementById("netPyneDialog").click(); @@ -152,35 +156,35 @@ function testPlotButton(casper, test, plotButton, expectedPlot) { }, true, "Open plot for action: " + plotButton); }); } -//------------------------------------------------------------------------------ -function waitForPlotGraphElement(casper, test, elementID) { - casper.then(function() { - this.waitUntilVisible('g[id="' + elementID + '"]', function() { +// ------------------------------------------------------------------------------ +function waitForPlotGraphElement (casper, test, elementID) { + casper.then(function () { + this.waitUntilVisible('g[id="' + elementID + '"]', function () { test.assertExists('g[id="' + elementID + '"]', "Element " + elementID + " exists"); }); }) } -//------------------------------------------------------------------------------ -function testControlPanelValues(casper, test, values) { - casper.then(function() { - this.waitUntilVisible('div#controlpanel', function() { +// ------------------------------------------------------------------------------ +function testControlPanelValues (casper, test, values) { + casper.then(function () { + this.waitUntilVisible('div#controlpanel', function () { test.assertVisible('div#controlpanel', "The control panel is correctly open."); - var rows = casper.evaluate(function() { + var rows = casper.evaluate(function () { return $(".standard-row").length; }); test.assertEquals(rows, values, "The control panel opened with right amount of rows"); }); }); - casper.thenEvaluate(function() { + casper.thenEvaluate(function () { $("#controlpanel").remove(); }); - casper.then(function(){ - this.waitWhileVisible('div#controlpanel', function() { + casper.then(function (){ + this.waitWhileVisible('div#controlpanel', function () { test.assertDoesntExist('div#controlpanel', "Control Panel went away"); }); }) } -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ module.exports = { testPlotButton: testPlotButton, testMeshVisibility: testMeshVisibility, diff --git a/tests/stimSourceParamsTest.js b/tests/stimSourceParamsTest.js index 508f8f3c..7df9bad6 100644 --- a/tests/stimSourceParamsTest.js +++ b/tests/stimSourceParamsTest.js @@ -1,32 +1,34 @@ -/******************************************************************************* +/** + ****************************************************************************** * --------------------------- STIM-SOURCE-PARAMS ----------------------------- * - ********************************************************************************/ -function populateStimSourceRule(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function populateStimSourceRule (casper, test, toolbox) { + casper.then(function () { toolbox.active = { cardID: "StimulationSources", buttonID: "newStimulationSourceButton", tabID: false } }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { //check name and source type + casper.then(function () { // check name and source type toolbox.getInputValue(this, test, "sourceName", "stim_source") toolbox.getSelectFieldValue(this, test, "stimSourceSelect", "") }) - casper.then(function() { + casper.then(function () { this.echo("VClamp") this.wait(500) }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "stimSourceSelect", "VClampMenuItem") }) - casper.then(function() { // select VClamp source + casper.then(function () { // select VClamp source toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'tau1\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'tau2\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'gain\']", "") @@ -35,15 +37,15 @@ function populateStimSourceRule(casper, test, toolbox) { toolbox.assertDoesntExist(this, test, "netParams.stimSourceParams[\'stim_source\'][\'amp\']0") }) - casper.then(function() { + casper.then(function () { this.echo("NetStim") this.wait(500) }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "stimSourceSelect", "NetStimMenuItem") }) - casper.then(function() { // select NetStim source and check correct params + casper.then(function () { // select NetStim source and check correct params toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'rate\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'interval\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'number\']", "") @@ -51,52 +53,52 @@ function populateStimSourceRule(casper, test, toolbox) { toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'noise\']", "") }) - casper.then(function() { + casper.then(function () { this.echo("Alpha Synapse") casper.wait(500) }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "stimSourceSelect", "AlphaSynapseMenuItem") }) - casper.then(function() { // select AlphaSynapseMenuItem source and check correct params + casper.then(function () { // select AlphaSynapseMenuItem source and check correct params toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'onset\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'tau\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'gmax\']", "") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'e\']", "") }) - casper.then(function() { + casper.then(function () { this.echo("IClamp") casper.wait(500) }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "stimSourceSelect", "IClampMenuItem") }) - casper.then(function() { // select ICLamp source and check correct params + casper.then(function () { // select ICLamp source and check correct params toolbox.setInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'del\']", "1") toolbox.setInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'dur\']", "2") toolbox.setInputValue(this, test, "netParams.stimSourceParams[\'stim_source\'][\'amp\']", "3") }) - casper.then(function() { + casper.then(function () { this.wait(2000) }) } -//----------------------------------------------------------------------------// -function checkStimSourceEmpty(casper, test, toolbox, name) { - casper.then(function() { //check name and source type +// ----------------------------------------------------------------------------// +function checkStimSourceEmpty (casper, test, toolbox, name) { + casper.then(function () { // check name and source type toolbox.getInputValue(this, test, "sourceName", name) toolbox.getSelectFieldValue(this, test, "stimSourceSelect", "") }) } -//----------------------------------------------------------------------------// -function checkStimSourceValues(casper, test, toolbox, name) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function checkStimSourceValues (casper, test, toolbox, name) { + casper.then(function () { toolbox.getInputValue(this, test, "sourceName", name) toolbox.getSelectFieldValue(this, test, "stimSourceSelect", "IClamp") toolbox.getInputValue(this, test, "netParams.stimSourceParams[\'" + name + "\'][\'del\']", "1") @@ -105,7 +107,7 @@ function checkStimSourceValues(casper, test, toolbox, name) { }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { checkStimSourceEmpty: checkStimSourceEmpty, checkStimSourceValues: checkStimSourceValues, diff --git a/tests/stimTargetParamsTest.js b/tests/stimTargetParamsTest.js index 3b20ee20..652a17b9 100644 --- a/tests/stimTargetParamsTest.js +++ b/tests/stimTargetParamsTest.js @@ -1,79 +1,81 @@ var require = patchRequire(require); var rangeComponentTest = require('./rangeComponentTest') -/******************************************************************************* +/** + ****************************************************************************** * --------------------------- STIM-TARGET-PARAMS ----------------------------- * - ********************************************************************************/ -function populateStimTargetRule(casper, test, toolbox) { - casper.then(function() { + ******************************************************************************* + */ +function populateStimTargetRule (casper, test, toolbox) { + casper.then(function () { toolbox.active = { cardID: "StimulationTargets", buttonID: "newStimulationTargetButton", tabID: false } }) - casper.then(function() { + casper.then(function () { this.wait(2500) }) - casper.then(function() { + casper.then(function () { toolbox.getInputValue(this, test, "targetName", "stim_target") toolbox.setSelectFieldValue(this, test, "netParams.stimTargetParams[\'stim_target\'][\'source\']", "newStimSourceMenuItem") toolbox.setInputValue(this, test, "netParams.stimTargetParams['stim_target']['sec']", "soma") toolbox.setInputValue(this, test, "netParams.stimTargetParams['stim_target']['loc']", "0.5") }) - casper.then(function() { - this.wait(2500) //for python to receive data + casper.then(function () { + this.wait(2500) // for python to receive data }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "stimTargetCondsTab", "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'cellList\']", "input") }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'pop\']", "PopulationMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'cellModel\']", "IFMenuItem") toolbox.setSelectFieldValue(this, test, "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'cellType\']", "GCMenuItem") }) - casper.then(function() { // test range component + casper.then(function () { // test range component rangeComponentTest.populateRangeComponent(this, test, toolbox, "StimTarget"); }); - casper.then(function() { + casper.then(function () { toolbox.addListItem(this, test, "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'cellList\']", "0") toolbox.addListItem(this, test, "netParams.stimTargetParams[\'stim_target\'][\'conds\'][\'cellList\']", "3") }) - casper.then(function() { - this.wait(2500) //for python to receibe data + casper.then(function () { + this.wait(2500) // for python to receibe data }) } -//----------------------------------------------------------------------------// -function checkStimTargetValues(casper, test, toolbox, name, empty = false) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function checkStimTargetValues (casper, test, toolbox, name, empty = false) { + casper.then(function () { toolbox.active.tabID = false }) - casper.then(function() { // + casper.then(function () { // toolbox.getInputValue(this, test, "targetName", name) toolbox.getSelectFieldValue(this, test, "netParams.stimTargetParams[\'" + name + "\'][\'source\']", !empty ? "newStimSource" : "") toolbox.getInputValue(this, test, "netParams.stimTargetParams['" + name + "']['sec']", !empty ? "soma" : "") toolbox.getInputValue(this, test, "netParams.stimTargetParams['" + name + "']['loc']", !empty ? "0.5" : "") }) - casper.then(function() { + casper.then(function () { toolbox.moveToTab(this, test, "stimTargetCondsTab", "netParams.stimTargetParams[\'" + name + "\'][\'conds\'][\'cellList\']", "input") }) - casper.then(function() { + casper.then(function () { toolbox.getSelectFieldValue(this, test, "netParams.stimTargetParams[\'" + name + "\'][\'conds\'][\'pop\']", !empty ? "Population" : "") toolbox.getSelectFieldValue(this, test, "netParams.stimTargetParams[\'" + name + "\'][\'conds\'][\'cellModel\']", !empty ? "IF" : "") toolbox.getSelectFieldValue(this, test, "netParams.stimTargetParams[\'" + name + "\'][\'conds\'][\'cellType\']", !empty ? "GC" : "") }) - casper.then(function() { + casper.then(function () { if (empty) { rangeComponentTest.checkRangeComponentIsEmpty(this, test, toolbox, "StimTarget") } else { rangeComponentTest.testRangeComponent(this, test, toolbox, "StimTarget") // check data remained the same } }) - casper.then(function() { + casper.then(function () { if (empty) { toolbox.assertDoesntExist(this, test, "netParams.stimTargetParams[\'" + name + "\'][\'conds\'][\'cellList\']0") } else { @@ -83,7 +85,7 @@ function checkStimTargetValues(casper, test, toolbox, name, empty = false) { }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { checkStimTargetValues: checkStimTargetValues, populateStimTargetRule: populateStimTargetRule diff --git a/tests/synMechParamsTest.js b/tests/synMechParamsTest.js index 47e41bb1..a97b02dc 100644 --- a/tests/synMechParamsTest.js +++ b/tests/synMechParamsTest.js @@ -1,36 +1,38 @@ -/******************************************************************************* +/** + ****************************************************************************** * ----------------------------- SYNMECH-PARAMS ------------------------------- * - ********************************************************************************/ -function populateSynMech(casper, test, toolbox) { - casper.then(function() { //check rule name exist + ******************************************************************************* + */ +function populateSynMech (casper, test, toolbox) { + casper.then(function () { // check rule name exist toolbox.active = { cardID: "Synapses", buttonID: "newSynapseButton", tabID: false } - this.waitUntilVisible('input[id="synapseName"]', function() { + this.waitUntilVisible('input[id="synapseName"]', function () { test.assertExist('input[id="synapseName"]', "synapse Name exist"); }) }) - casper.then(function() { + casper.then(function () { toolbox.setSelectFieldValue(this, test, "synapseModSelect", "Exp2Syn") }) - casper.then(function() { + casper.then(function () { toolbox.setInputValue(this, test, "netParams.synMechParams[\'Synapse\'][\'tau1\']", "0.1"); toolbox.setInputValue(this, test, "netParams.synMechParams[\'Synapse\'][\'tau2\']", "10"); toolbox.setInputValue(this, test, "netParams.synMechParams[\'Synapse\'][\'e\']", "-70"); }) - casper.then(function() { + casper.then(function () { this.wait(2500) // for python to receive data }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkSynMechValues(casper, test, toolbox, name = "Synapse", mod = "Exp2Syn", tau2 = "10", tau1 = "0.1", e = "-70") { - casper.then(function() { +function checkSynMechValues (casper, test, toolbox, name = "Synapse", mod = "Exp2Syn", tau2 = "10", tau1 = "0.1", e = "-70") { + casper.then(function () { toolbox.getInputValue(this, test, "synapseName", name) toolbox.getSelectFieldValue(this, test, "synapseModSelect", mod) toolbox.getInputValue(this, test, "netParams.synMechParams[\'" + name + "\'][\'e\']", e) @@ -39,11 +41,11 @@ function checkSynMechValues(casper, test, toolbox, name = "Synapse", mod = "Exp2 }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// -function checkSynMechEmpty(casper, test, toolbox, name) { - casper.then(function() { //assert new Synapse rule does not displays params before selectiong a "mod" - this.waitUntilVisible("#synapseName", function() { +function checkSynMechEmpty (casper, test, toolbox, name) { + casper.then(function () { // assert new Synapse rule does not displays params before selectiong a "mod" + this.waitUntilVisible("#synapseName", function () { toolbox.getSelectFieldValue(this, test, "synapseModSelect", "") toolbox.assertDoesntExist(this, test, "netParams.synMechParams[\'" + name + "\'][\'e\']"); toolbox.assertDoesntExist(this, test, "netParams.synMechParams[\'" + name + "\'][\'tau1\']"); @@ -52,22 +54,22 @@ function checkSynMechEmpty(casper, test, toolbox, name) { }) } -//----------------------------------------------------------------------------// -function addTestSynMech(casper, test, toolbox) { +// ----------------------------------------------------------------------------// +function addTestSynMech (casper, test, toolbox) { toolbox.message(casper, "extra synMech to test other cards") - casper.thenClick('button[id="newSynapseButton"]', function() { //add new population - this.waitUntilVisible('input[id="synapseName"]', function() { + casper.thenClick('button[id="newSynapseButton"]', function () { // add new population + this.waitUntilVisible('input[id="synapseName"]', function () { test.assertExists('input[id="synapseName"]', "rule added"); }) }) - casper.thenClick('button[id="newSynapseButton"]', function() { //add new population - this.waitUntilVisible('input[id="synapseName"]', function() { + casper.thenClick('button[id="newSynapseButton"]', function () { // add new population + this.waitUntilVisible('input[id="synapseName"]', function () { test.assertExists('input[id="synapseName"]', "rule added"); }) }) } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// module.exports = { addTestSynMech: addTestSynMech, populateSynMech: populateSynMech, diff --git a/tests/toolbox.js b/tests/toolbox.js index 5881edfe..a44f4324 100644 --- a/tests/toolbox.js +++ b/tests/toolbox.js @@ -1,183 +1,181 @@ -/******************************************************************************* +/** + ****************************************************************************** * functions * - *******************************************************************************/ -function moveToTab(casper, test, tabID, elementID, elementType) { - casper.then(function() { + ****************************************************************************** + */ +function moveToTab (casper, test, tabID, elementID, elementType) { + casper.then(function () { toolbox.active.tabID = tabID - this.click('button[id="' + tabID + '"]', function() { + this.click('button[id="' + tabID + '"]', function () { this.echo("changing tab...") }) }) - casper.then(function() { - this.waitUntilVisible(elementType + '[id="' + elementID + '"]', function() { + casper.then(function () { + this.waitUntilVisible(elementType + '[id="' + elementID + '"]', function () { test.assertExist(elementType + '[id="' + elementID + '"]', "changed tab") }) }) - casper.then(function() { + casper.then(function () { this.wait(2000) }) } -//----------------------------------------------------------------------------// -function leaveReEnterTab(casper, test, mainTabID, mainTabElementID, secondTabID, SecondTabElementID, mainElementType = "input") { - casper.thenClick('button[id="' + secondTabID + '"]', function() { +// ----------------------------------------------------------------------------// +function leaveReEnterTab (casper, test, mainTabID, mainTabElementID, secondTabID, SecondTabElementID, mainElementType = "input") { + casper.thenClick('button[id="' + secondTabID + '"]', function () { this.waitUntilVisible('input[id="' + SecondTabElementID + '"]') }); - casper.thenClick('button[id="' + mainTabID + '"]', function() { - this.wait(1500) //for python to re-populate fields + casper.thenClick('button[id="' + mainTabID + '"]', function () { + this.wait(1500) // for python to re-populate fields }) - casper.then(function() { - this.waitUntilVisible(mainElementType + '[id="' + mainTabElementID + '"]', function() { + casper.then(function () { + this.waitUntilVisible(mainElementType + '[id="' + mainTabElementID + '"]', function () { this.echo("leave and re-enter " + mainTabID + " tab") }) }) - casper.then(function() { + casper.then(function () { this.wait(2000) // for python to repopulate tab }) } -//----------------------------------------------------------------------------// -function leaveReEnterRule(casper, test, mainThumbID, secondThumbID, elementID, type = "input") { - casper.thenClick('button[id="' + secondThumbID + '"]', function() { //move to another Rule thumbnail - this.waitUntilVisible(type + '[id="' + elementID + '"]', function() { +// ----------------------------------------------------------------------------// +function leaveReEnterRule (casper, test, mainThumbID, secondThumbID, elementID, type = "input") { + casper.thenClick('button[id="' + secondThumbID + '"]', function () { // move to another Rule thumbnail + this.waitUntilVisible(type + '[id="' + elementID + '"]', function () { this.wait(2000) }) }) - casper.thenClick('button[id="' + mainThumbID + '"]', function() { - this.waitUntilVisible(type + '[id="' + elementID + '"]', function() { + casper.thenClick('button[id="' + mainThumbID + '"]', function () { + this.waitUntilVisible(type + '[id="' + elementID + '"]', function () { this.echo("moved to different Rule and came back") }) }) - casper.then(function() { + casper.then(function () { this.wait(2000) }) } -//----------------------------------------------------------------------------// -function create2rules(casper, test, cardID, addButtonID, ruleThumbID) { - casper.then(function() { - this.waitUntilVisible('div[id="' + cardID + '"]', function() { - this.click('div[id="' + cardID + '"]'); //open Card +// ----------------------------------------------------------------------------// +function create2rules (casper, test, cardID, addButtonID, ruleThumbID) { + casper.then(function () { + this.waitUntilVisible('div[id="' + cardID + '"]', function () { + this.click('div[id="' + cardID + '"]'); // open Card }) }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.then(function() { // check ADD button exist - this.waitUntilVisible('button[id="' + addButtonID + '"]', function() { + casper.then(function () { // check ADD button exist + this.waitUntilVisible('button[id="' + addButtonID + '"]', function () { test.assertExist('button[id="' + addButtonID + '"]', "open card") }); }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.thenClick('button[id="' + addButtonID + '"]', function() { //add new rule - this.waitUntilVisible('button[id="' + ruleThumbID + '"]', function() { + casper.thenClick('button[id="' + addButtonID + '"]', function () { // add new rule + this.waitUntilVisible('button[id="' + ruleThumbID + '"]', function () { test.assertExist('button[id="' + ruleThumbID + '"]', "rule added"); }) }) - casper.then(function() { + casper.then(function () { this.wait(1000) }) - casper.thenClick('button[id="' + addButtonID + '"]', function() { //add new rule - this.waitUntilVisible('button[id="' + ruleThumbID + '2"]', function() { + casper.thenClick('button[id="' + addButtonID + '"]', function () { // add new rule + this.waitUntilVisible('button[id="' + ruleThumbID + '2"]', function () { test.assertExist('button[id="' + ruleThumbID + '2"]', "rule added"); }) }) - casper.thenClick('button[id="' + ruleThumbID + '"]', function() { // focus on first rule + casper.thenClick('button[id="' + ruleThumbID + '"]', function () { // focus on first rule this.wait(2500) }) } -//----------------------------------------------------------------------------// -function renameRule(casper, test, elementID, value) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function renameRule (casper, test, elementID, value) { + casper.then(function () { this.waitUntilVisible('input[id="' + elementID + '"]') }) - casper.then(function() { - this.sendKeys('input[id="' + elementID + '"]', value, { - reset: true - }) + casper.then(function () { + this.sendKeys('input[id="' + elementID + '"]', value, { reset: true }) }) - casper.then(function() { //let python re-populate fields + casper.then(function () { // let python re-populate fields this.wait(2000) }) - casper.then(function() { + casper.then(function () { var currentValue = this.getElementAttribute('input[id="' + elementID + '"]', 'value'); test.assertEqual(currentValue, value, "Rule renamed to: " + value) }) } -//----------------------------------------------------------------------------// -function selectThumbRule(casper, test, thumbID, nameFieldID) { // select a thumbnailRule and wait to load data - casper.thenClick('button[id="' + thumbID + '"]', function() { // focus on rule 1 +// ----------------------------------------------------------------------------// +function selectThumbRule (casper, test, thumbID, nameFieldID) { // select a thumbnailRule and wait to load data + casper.thenClick('button[id="' + thumbID + '"]', function () { // focus on rule 1 this.waitUntilVisible('input[id="' + nameFieldID + '"]') }) - casper.then(function() { + casper.then(function () { this.wait(2000) }) } -//----------------------------------------------------------------------------// -function delThumbnail(casper, test, elementID) { - casper.then(function() { // click thumbnail - this.waitUntilVisible('button[id="' + elementID + '"]', function() { +// ----------------------------------------------------------------------------// +function delThumbnail (casper, test, elementID) { + casper.then(function () { // click thumbnail + this.waitUntilVisible('button[id="' + elementID + '"]', function () { this.mouse.click('button[id="' + elementID + '"]'); }) }) - casper.then(function() { // move mouse into thumbnail + casper.then(function () { // move mouse into thumbnail this.mouse.move('button[id="' + elementID + '"]') }) - casper.then(function() { + casper.then(function () { this.wait(500) }) - casper.then(function() { //click thumbnail + casper.then(function () { // click thumbnail this.mouse.click('button[id="' + elementID + '"]') }) - casper.then(function() { //confirm deletion - this.waitUntilVisible('button[id="confirmDeletion"]', function() { + casper.then(function () { // confirm deletion + this.waitUntilVisible('button[id="confirmDeletion"]', function () { this.click('button[id="confirmDeletion"]') }) }) - casper.then(function() { - this.waitWhileVisible('button[id="' + elementID + '"]', function() { + casper.then(function () { + this.waitWhileVisible('button[id="' + elementID + '"]', function () { test.assertDoesntExist('button[id="' + elementID + '"]', elementID + " button deleted") }) }) } -//----------------------------------------------------------------------------// -function setInputValue(casper, test, elementID, value) { - casper.then(function() { - this.waitUntilVisible('input[id="' + elementID + '"]', function() {}) +// ----------------------------------------------------------------------------// +function setInputValue (casper, test, elementID, value) { + casper.then(function () { + this.waitUntilVisible('input[id="' + elementID + '"]', function () {}) }) - casper.thenEvaluate(function(elementID, value) { //this hack breaks for latest React!!!!! + casper.thenEvaluate(function (elementID, value) { // this hack breaks for latest React!!!!! var element = document.getElementById(elementID); - var ev = new Event('input', { - bubbles: true - }); + var ev = new Event('input', { bubbles: true }); ev.simulated = true; element.value = value; element.dispatchEvent(ev); }, elementID, value); - casper.then(function() { + casper.then(function () { test.assert(true, value + " set for: " + elementID) }) } -//----------------------------------------------------------------------------// -function getInputValue(casper, test, elementID, expectedValue, times = 3) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function getInputValue (casper, test, elementID, expectedValue, times = 3) { + casper.then(function () { this.waitUntilVisible('input[id="' + elementID + '"]') }) - casper.then(function() { - var value = this.evaluate(function(elementID) { + casper.then(function () { + var value = this.evaluate(function (elementID) { return $('input[id="' + elementID + '"]').val(); }, elementID); @@ -186,24 +184,22 @@ function getInputValue(casper, test, elementID, expectedValue, times = 3) { }) } -//----------------------------------------------------------------------------// -function getlistItemValues(casper, test, elementID, expectedValues, times = 3) { - var elementIDs = expectedValues.map((elem, i)=>{return elementID+i}) +// ----------------------------------------------------------------------------// +function getlistItemValues (casper, test, elementID, expectedValues, times = 3) { + var elementIDs = expectedValues.map((elem, i) => elementID + i) var failed = false - casper.then(function(){ - this.each(elementIDs, function(self, el) { - self.waitUntilVisible('input[id="' + el +'"]') + casper.then(function (){ + this.each(elementIDs, function (self, el) { + self.waitUntilVisible('input[id="' + el + '"]') }) }) - casper.then(function() { - var values = elementIDs.map((el) => { - return this.evaluate(function(el) { - return $('input[id="' + el + '"]').val(); - }, el); - }) - expectedValues.forEach((el)=>{ - if (values.indexOf(el)==-1) { + casper.then(function () { + var values = elementIDs.map(el => this.evaluate(function (el) { + return $('input[id="' + el + '"]').val(); + }, el)) + expectedValues.forEach(el => { + if (values.indexOf(el) == -1) { // required in case python fails to update field secondChance(this, test, values, expectedValues, elementID, getlistItemValues, times) var failed = true @@ -215,51 +211,51 @@ function getlistItemValues(casper, test, elementID, expectedValues, times = 3) { }) } -//----------------------------------------------------------------------------// -function setSelectFieldValue(casper, test, selectFieldID, menuItemID) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function setSelectFieldValue (casper, test, selectFieldID, menuItemID) { + casper.then(function () { this.waitUntilVisible('div[id="' + selectFieldID + '"]') }) - casper.thenEvaluate(function(selectFieldID) { + casper.thenEvaluate(function (selectFieldID) { document.getElementById(selectFieldID).scrollIntoView(); }, selectFieldID); - casper.then(function() { // click selectField + casper.then(function () { // click selectField var info = casper.getElementInfo('div[id="' + selectFieldID + '"]'); this.mouse.click(info.x + 1, info.y + 1) }) - casper.then(function() { - this.wait(500) //wait for the menuitem animation to finish + casper.then(function () { + this.wait(500) // wait for the menuitem animation to finish }) - casper.then(function() { // click menuItem - this.waitUntilVisible('span[id="' + menuItemID + '"]', function() { + casper.then(function () { // click menuItem + this.waitUntilVisible('span[id="' + menuItemID + '"]', function () { var info = this.getElementInfo('span[id="' + menuItemID + '"]'); this.mouse.click(info.x + 1, info.y + 1) }) }) - casper.then(function() { // click outside selectField + casper.then(function () { // click outside selectField var info = this.getElementInfo('div[id="' + selectFieldID + '"]'); this.mouse.click(info.x - 10, info.y) }) - casper.then(function() { - this.wait(500) //wait for MenuItem animation to vanish + casper.then(function () { + this.wait(500) // wait for MenuItem animation to vanish }) - casper.then(function() { //check value is ok - this.waitWhileVisible('span[id="' + menuItemID + '"]', function() { + casper.then(function () { // check value is ok + this.waitWhileVisible('span[id="' + menuItemID + '"]', function () { this.echo("click on " + menuItemID) }) }) } -//----------------------------------------------------------------------------// -function getSelectFieldValue(casper, test, elementID, expected, times = 3) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function getSelectFieldValue (casper, test, elementID, expected, times = 3) { + casper.then(function () { this.waitUntilVisible('div[id="' + elementID + '"]') }) - casper.then(function() { - var value = this.evaluate(function(elementID) { + casper.then(function () { + var value = this.evaluate(function (elementID) { return document.getElementById(elementID).getElementsByTagName("div")[0].textContent; }, elementID) @@ -267,44 +263,44 @@ function getSelectFieldValue(casper, test, elementID, expected, times = 3) { }); } -//----------------------------------------------------------------------------// -function addListItem(casper, test, elementID, value) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function addListItem (casper, test, elementID, value) { + casper.then(function () { setInputValue(this, test, elementID, value) }) - casper.then(function() { + casper.then(function () { click(this, elementID + "AddButton", "button") }) } -//----------------------------------------------------------------------------// -function deleteListItem(casper, test, elementID) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function deleteListItem (casper, test, elementID) { + casper.then(function () { this.waitUntilVisible('button[id="' + elementID + 'RemoveButton"]') }) casper.thenClick('button[id="' + elementID + 'RemoveButton"]') - casper.then(function() { + casper.then(function () { this.waitWhileVisible('input[id="' + elementID + '"]') }) - casper.then(function() { + casper.then(function () { this.echo("item removed from list: " + elementID) this.wait(2000) }) } -//----------------------------------------------------------------------------// -function getListItemValue(casper, test, elementID, value, times = 3) { - casper.then(function() { - this.waitUntilVisible('input[id="' + elementID + '"]', function() {}, function() { +// ----------------------------------------------------------------------------// +function getListItemValue (casper, test, elementID, value, times = 3) { + casper.then(function () { + this.waitUntilVisible('input[id="' + elementID + '"]', function () {}, function () { secondChance(this, test, 'not-visible', value, elementID, getListItemValue, times) }) }) - casper.thenBypassIf(function() { + casper.thenBypassIf(function () { return (!this.visible('input[id="' + elementID + '"]') && times > 0) }) - casper.then(function() { - var newValue = this.evaluate(function(elementID) { + casper.then(function () { + var newValue = this.evaluate(function (elementID) { return $('input[id="' + elementID + '"]').val(); }, elementID); // required in case python fails to update field @@ -312,126 +308,128 @@ function getListItemValue(casper, test, elementID, value, times = 3) { }) } -//----------------------------------------------------------------------------// -function testCheckBoxValue(casper, test, elementID, expectedName, times = 3) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function testCheckBoxValue (casper, test, elementID, expectedName, times = 3) { + casper.then(function () { this.waitUntilVisible('input[id="' + elementID + '"]') }) - casper.then(function() { - var name = casper.evaluate(function(elementID) { + casper.then(function () { + var name = casper.evaluate(function (elementID) { return $('input[id="' + elementID + '"]').prop('checked'); }, elementID); secondChance(this, test, name, expectedName, elementID, testCheckBoxValue, times) }) } -//----------------------------------------------------------------------------// -function clickCheckBox(casper, test, elementID) { - casper.then(function() { - this.waitUntilVisible('input[id="' + elementID + '"]', function() { +// ----------------------------------------------------------------------------// +function clickCheckBox (casper, test, elementID) { + casper.then(function () { + this.waitUntilVisible('input[id="' + elementID + '"]', function () { this.click('input[id="' + elementID + '"]'); }); }) } -//----------------------------------------------------------------------------// -function assertExist(casper, test, elementID, component = "input", message = false) { - casper.then(function() { - this.waitUntilVisible(component + '[id="' + elementID + '"]', function() { +// ----------------------------------------------------------------------------// +function assertExist (casper, test, elementID, component = "input", message = false) { + casper.then(function () { + this.waitUntilVisible(component + '[id="' + elementID + '"]', function () { test.assertExist(component + '[id="' + elementID + '"]', message ? message : component + ": " + elementID + " exist") }) }) } -//----------------------------------------------------------------------------// -function assertDoesntExist(casper, test, elementID, component = "input", message = false) { - casper.then(function() { - this.waitWhileVisible(component + '[id="' + elementID + '"]', function() { +// ----------------------------------------------------------------------------// +function assertDoesntExist (casper, test, elementID, component = "input", message = false) { + casper.then(function () { + this.waitWhileVisible(component + '[id="' + elementID + '"]', function () { test.assertDoesntExist(component + '[id="' + elementID + '"]', message ? message : component + ": " + elementID + " doesn't exist") }) }) } -//----------------------------------------------------------------------------// -function message(casper, message) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function message (casper, message) { + casper.then(function () { this.echo("<" + message.toUpperCase() + ">", "INFO") }) } -//----------------------------------------------------------------------------// -function header(casper, message) { - casper.then(function() { - this.echo("#".repeat(message.length+10), "INFO") +// ----------------------------------------------------------------------------// +function header (casper, message) { + casper.then(function () { + this.echo("#".repeat(message.length + 10), "INFO") this.echo(" ".repeat(5) + message.toUpperCase() + " ".repeat(5), "INFO"); - this.echo("#".repeat(message.length+10), "INFO") + this.echo("#".repeat(message.length + 10), "INFO") }) } -//----------------------------------------------------------------------------// -function click(casper, elementID, type = "div") { - casper.then(function() { +// ----------------------------------------------------------------------------// +function click (casper, elementID, type = "div") { + casper.then(function () { this.waitUntilVisible(type + '[id="' + elementID + '"]') }) - casper.then(function() { - this.evaluate(function(elementID) { + casper.then(function () { + this.evaluate(function (elementID) { document.getElementById(elementID).scrollIntoView(); }, elementID); }) - casper.then(function() { + casper.then(function () { this.waitUntilVisible(type + '[id="' + elementID + '"]') }) - casper.then(function() { + casper.then(function () { this.wait(500) // wait for animation in dropDownMenu to complete }) - casper.then(function() { + casper.then(function () { var info = this.getElementInfo(type + '[id="' + elementID + '"]'); - this.mouse.click(info.x + 1, info.y + 1); //move a bit away from corner + this.mouse.click(info.x + 1, info.y + 1); // move a bit away from corner }) - casper.then(function() { + casper.then(function () { this.echo("Click on " + elementID) this.wait(300) }) } -//------------------------------------------------------------------------------ -function refresh(casper, test, expected, got, times) { - // "active" object points to the current: "Card", "Add-newRule-Button" and "Tab" - // to allow refreshing in case a field did not get the correct value - casper.then(function() { +// ------------------------------------------------------------------------------ +function refresh (casper, test, expected, got, times) { + /* + * "active" object points to the current: "Card", "Add-newRule-Button" and "Tab" + * to allow refreshing in case a field did not get the correct value + */ + casper.then(function () { this.echo("WARNING--> expected: " + expected + " got: " + (got ? got : "empty") + " trying again " + (3 - times) + "/3", "WARNING") }) - casper.then(function() { + casper.then(function () { this.click('div[id="' + toolbox.active.cardID + '"]') }) - casper.then(function() { - this.waitWhileVisible('div[id="' + toolbox.active.buttonID + '"]', function() { + casper.then(function () { + this.waitWhileVisible('div[id="' + toolbox.active.buttonID + '"]', function () { this.click('div[id="' + toolbox.active.cardID + '"]') }) }) - casper.then(function() { + casper.then(function () { if (toolbox.active.tabID) { - this.waitUntilVisible('button[id="' + toolbox.active.tabID + '"]', function() { + this.waitUntilVisible('button[id="' + toolbox.active.tabID + '"]', function () { this.click('button[id="' + toolbox.active.tabID + '"]') }) } else { this.waitUntilVisible('button[id="' + toolbox.active.buttonID + '"]') } }) - casper.then(function() { + casper.then(function () { this.wait(2000) }) } -//----------------------------------------------------------------------------// -function secondChance(casper, test, value, expectedValue, elementID, callback, times) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function secondChance (casper, test, value, expectedValue, elementID, callback, times) { + casper.then(function () { if (value != expectedValue && times > 0) { --times - this.then(function() { + this.then(function () { refresh(this, test, expectedValue, value, times) }) - this.then(function() { + this.then(function () { callback(this, test, elementID, expectedValue, times) }) } else { @@ -439,36 +437,36 @@ function secondChance(casper, test, value, expectedValue, elementID, callback, t } }) } -//----------------------------------------------------------------------------// -function testPlotButton(casper, test, plotButton) { - casper.then(function() { +// ----------------------------------------------------------------------------// +function testPlotButton (casper, test, plotButton) { + casper.then(function () { this.waitUntilVisible('span[id="' + plotButton + '"]'); }) - casper.thenEvaluate(function(plotButton) { + casper.thenEvaluate(function (plotButton) { document.getElementById(plotButton).click(); }, plotButton); - casper.then(function() { - this.waitUntilVisible('div[id="Popup1"]', function() { + casper.then(function () { + this.waitUntilVisible('div[id="Popup1"]', function () { test.assertExists('div[id="Popup1"]', plotButton + " exists"); }) }) - casper.then(function() { - this.waitUntilVisible('g[id="figure_1"]') - this.waitUntilVisible('g[id="axes_1"]') + casper.then(function () { + this.waitUntilVisible('g[id="figure_1"]') + this.waitUntilVisible('g[id="axes_1"]') }); - casper.thenEvaluate(function() { + casper.thenEvaluate(function () { window['Popup1'].destroy(); }); - casper.then(function(){ - this.waitWhileVisible('div[id="Popup1"]', function() { + casper.then(function (){ + this.waitWhileVisible('div[id="Popup1"]', function () { test.assertDoesntExist('div[id="Popup1"]', plotButton + " was destroyed successfully"); }); }) - casper.then(function() { - var plotError = test.assertEvalEquals(function() { + casper.then(function () { + var plotError = test.assertEvalEquals(function () { var error = document.getElementById("netPyneDialog") == undefined; if (!error) { document.getElementById("netPyneDialog").click(); @@ -477,7 +475,7 @@ function testPlotButton(casper, test, plotButton) { }, true, "no error on: " + plotButton); }); } -//----------------------------------------------------------------------------// +// ----------------------------------------------------------------------------// var toolbox = module.exports = { click: click, header: header, @@ -501,6 +499,6 @@ var toolbox = module.exports = { testCheckBoxValue: testCheckBoxValue, assertExist: assertExist, assertDoesntExist: assertDoesntExist, - active: {}, - testPlotButton: testPlotButton + active: {}, + testPlotButton: testPlotButton }