diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..899759d --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +src/common/lua.js +src/visualizers/widgets/TextEditor/lib/* +src/common/js-yaml.min.js +src/visualizers/Visualizers.json diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..a5ea9d5 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,18 @@ +env: + browser: true + mocha: true + es6: true +extends: 'eslint:recommended' +rules: + indent: + - error + - 4 + linebreak-style: + - error + - unix + quotes: + - error + - single + semi: + - error + - always diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..e688987 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,3 @@ +{ + "esversion": 6 +} diff --git a/src/common/GraphChecker.js b/src/common/GraphChecker.js index 7d8efe5..e735a2f 100644 --- a/src/common/GraphChecker.js +++ b/src/common/GraphChecker.js @@ -1,3 +1,4 @@ +/* globals define */ define([ 'deepforge/js-yaml.min' ], function( @@ -148,28 +149,11 @@ define([ GraphChecker.prototype = new Importer(); - // Check if two models are isomorphic - var modelMatches = function(gmeNodes, text) { - var nodes = convertNodes(gmeNodes), - soln = yaml.load(text); - - nodes.concat(soln).forEach(node => { - node.next = node.next || []; - node.attributes = node.attributes || {}; - }); - - return _modelMatches(nodes, soln); - }; - //////////////// Operators //////////////// + // Check if two models are isomorphic var _modelMatches = function(soln, nodes) { var nodeMap = createMap(nodes), - solnMap = createMap(soln), - sInits, // soln start nodes - nInits, // 'nodes' start nodes - resMap = {}, // soln node id to node id - solnIds = soln.map(n => n.id), - nodeIds = nodes.map(n => n.id); + solnMap = createMap(soln); if (nodes.length !== soln.length) { return false; @@ -187,8 +171,7 @@ define([ }; var getMostConstrained = function(soln, nodes) { - var options = soln.map(sn => [sn, nodes.filter(n => nodesMatch(sn, n))]), - startId; + var options = soln.map(sn => [sn, nodes.filter(n => nodesMatch(sn, n))]); options.sort((a, b) => b[1].length < a[1].length); return options[0]; @@ -199,8 +182,7 @@ define([ nodes = Object.keys(nodeMap).map(id => nodeMap[id]), snode = solnMap[id], options, - used, - node; + used; mappings = mappings || {}; @@ -247,14 +229,16 @@ define([ snext.push(startId); } + var inferNext = (prev, curr) => { + mappings2 = inferGraph(curr, solnMap, nodeMap, mappings2); + return prev && mappings; + }; + for (var i = options.length; i--;) { mappings[id] = options[i].id; // need to clone the object mappings2 = clone(mappings); - result = snext.reduce((prev, curr) => { - mappings2 = inferGraph(curr, solnMap, nodeMap, mappings2); - return prev && mappings; - }, true); + result = snext.reduce(inferNext, true); if (result) { return mappings2; diff --git a/src/common/layer-args.js b/src/common/layer-args.js index 012e092..223213a 100644 --- a/src/common/layer-args.js +++ b/src/common/layer-args.js @@ -1,3 +1,4 @@ +/* globals define*/ define([ ], function( ) { @@ -25,7 +26,6 @@ define([ var createLayerDict = function(core, meta) { var node, names = Object.keys(meta), - attributes, layers = {}; for (var i = names.length; i--;) { diff --git a/src/decorators/OperationDecorator/EasyDAG/OperationDecorator.EasyDAGWidget.js b/src/decorators/OperationDecorator/EasyDAG/OperationDecorator.EasyDAGWidget.js index 83078cf..10ea65f 100644 --- a/src/decorators/OperationDecorator/EasyDAG/OperationDecorator.EasyDAGWidget.js +++ b/src/decorators/OperationDecorator/EasyDAG/OperationDecorator.EasyDAGWidget.js @@ -28,6 +28,7 @@ define([ _.extend(OperationDecorator.prototype, DecoratorBase.prototype); + OperationDecorator.prototype.DECORATOR_ID = DECORATOR_ID; OperationDecorator.prototype.expand = function() { DecoratorBase.prototype.expand.call(this); // Add the ports for data inputs/outputs @@ -36,7 +37,7 @@ define([ //var outputs = this._node.outputs; }; - OperationDecorator.prototype._highlightPort = function(name) { + OperationDecorator.prototype._highlightPort = function(/*name*/) { // Highlight port with the given name // TODO }; diff --git a/src/plugins/CreateExecution/CreateExecution.js b/src/plugins/CreateExecution/CreateExecution.js index 61de1e1..e2eee8d 100644 --- a/src/plugins/CreateExecution/CreateExecution.js +++ b/src/plugins/CreateExecution/CreateExecution.js @@ -60,7 +60,7 @@ define([ } return this.createExecution(this.activeNode) - .then(node => { + .then(() => { this.result.setSuccess(true); callback(null, this.result); }) @@ -103,7 +103,7 @@ define([ ); }) .then(() => { // datamapping is set! - this.updateReferences(copies, dataMapping) + this.updateReferences(copies, dataMapping); this.boxOperations(opTuples.map(o => o[0]), tgtNode); return this.save(`Created execution of ${name}`); }) @@ -152,8 +152,7 @@ define([ CreateExecution.prototype.sortIOByName = function (container) { return container.sort((a, b) => // sort by name - this.core.getAttribute(a, 'name') < this.core.getAttribute(b, 'name') - ? 1 : -1 + this.core.getAttribute(a, 'name') < this.core.getAttribute(b, 'name') ? 1 : -1 ); }; diff --git a/src/plugins/CreateTorchMeta/CreateTorchMeta.js b/src/plugins/CreateTorchMeta/CreateTorchMeta.js index 8b2d5eb..9449cf2 100644 --- a/src/plugins/CreateTorchMeta/CreateTorchMeta.js +++ b/src/plugins/CreateTorchMeta/CreateTorchMeta.js @@ -51,8 +51,7 @@ define([ CreateTorchMeta.prototype.main = function (callback) { // Use self to access core, project, result, logger etc from PluginBase. // These are all instantiated at this point. - var self = this, - nodeObject; + var self = this; if (!this.META.Language) { callback('"Language" container required to run plugin', this.result); diff --git a/src/plugins/ExecutePipeline/Templates.js b/src/plugins/ExecutePipeline/Templates.js index d008bb6..93887d0 100644 --- a/src/plugins/ExecutePipeline/Templates.js +++ b/src/plugins/ExecutePipeline/Templates.js @@ -1,3 +1,4 @@ +/*globals define*/ define([ 'text!./entry.ejs', 'text!./main.ejs', diff --git a/src/plugins/GenerateArchitecture/GenerateArchitecture.js b/src/plugins/GenerateArchitecture/GenerateArchitecture.js index 7e2f835..f26c092 100644 --- a/src/plugins/GenerateArchitecture/GenerateArchitecture.js +++ b/src/plugins/GenerateArchitecture/GenerateArchitecture.js @@ -65,7 +65,7 @@ define([ for (var i = 0; i < layers.length; i++) { if (layers[i][Constants.NEXT].length > 1) { // no support for - console.error('No support for parallel layers... yet'); + this.logger.error('No support for parallel layers... yet'); break; } else { // args diff --git a/src/plugins/GenerateArchitecture/dimensionality.js b/src/plugins/GenerateArchitecture/dimensionality.js index 34e2be9..aed0bd7 100644 --- a/src/plugins/GenerateArchitecture/dimensionality.js +++ b/src/plugins/GenerateArchitecture/dimensionality.js @@ -1,3 +1,4 @@ +/* globals define */ define([ 'SimpleNodes/Constants', 'deepforge/lua' diff --git a/src/plugins/ImportTorch/nn.js b/src/plugins/ImportTorch/nn.js index 254b040..4c5cab8 100644 --- a/src/plugins/ImportTorch/nn.js +++ b/src/plugins/ImportTorch/nn.js @@ -1,3 +1,4 @@ +/* globals define */ // This is the searcher for the mock library define([ 'deepforge/layer-args', @@ -10,10 +11,10 @@ define([ ) { 'use strict'; - var nop = function() {}; var createSearcher = function(plugin) { var core = plugin.core, META = plugin.META, + logger = plugin.logger.fork('nn'), parent = plugin.tgtNode, LayerDict = createLayerDict(core, META); @@ -41,8 +42,7 @@ define([ }; Layer.prototype._node = function() { - var attrs = this._attrs, - name, + var name, node, value; @@ -83,11 +83,11 @@ define([ this._outputs = []; }; - Container.prototype.add = function(self, tlayer) { - console.error('Add is not overridden!'); + Container.prototype.add = function() { + logger.error('Add is not overridden!'); }; - var Sequential = function(attrs, args) { + var Sequential = function(/*attrs, args*/) { Container.call(this); }; @@ -95,8 +95,7 @@ define([ Sequential.prototype.add = function(self, tlayer) { var layer = tlayer.get('_node'), - nodes = layer._inputs, - conn; + nodes = layer._inputs; // If this._inputs is empty, add the layer to the inputs list if (this._inputs.length === 0) { // first node @@ -146,15 +145,12 @@ define([ var CreateLayer = function(type) { var res = luajs.newContext()._G, attrs = [].slice.call(arguments, 1), - proto, node; if (LAYERS[type]) { node = new LAYERS[type](LayerDict[type] || [], attrs); - proto = LAYERS[type].prototype; } else { // Call generic Layer with type name node = new Layer(type, LayerDict[type] || [], attrs); - proto = Layer.prototype; } res.set('_node', node); diff --git a/src/visualizers/Visualizers.json b/src/visualizers/Visualizers.json index 4fd5ce4..4fdc21b 100644 --- a/src/visualizers/Visualizers.json +++ b/src/visualizers/Visualizers.json @@ -1,44 +1,44 @@ [ - { - "id": "AutoViz", - "title": "AutoViz", - "panel": "panels/AutoViz/AutoVizPanel", - "DEBUG_ONLY": false - }, - { - "id": "EasyDAG", - "title": "EasyDAG", - "panel": "panels/EasyDAG/EasyDAGPanel", - "DEBUG_ONLY": false - }, - { - "id": "ArchEditor", - "title": "ArchEditor", - "panel": "panels/ArchEditor/ArchEditorPanel", - "DEBUG_ONLY": false - }, - { - "id": "TextEditor", - "title": "TextEditor", - "panel": "panels/TextEditor/TextEditorPanel", - "DEBUG_ONLY": false - }, - { - "id": "OperationEditor", - "title": "OperationEditor", - "panel": "panels/OperationEditor/OperationEditorPanel", - "DEBUG_ONLY": false - }, - { - "id": "PipelineEditor", - "title": "PipelineEditor", - "panel": "panels/PipelineEditor/PipelineEditorPanel", - "DEBUG_ONLY": false - }, - { - "id": "ExecutionView", - "title": "ExecutionView", - "panel": "panels/ExecutionView/ExecutionViewPanel", - "DEBUG_ONLY": false - } -] \ No newline at end of file + { + "id": "AutoViz", + "title": "AutoViz", + "panel": "panels/AutoViz/AutoVizPanel", + "DEBUG_ONLY": false + }, + { + "id": "EasyDAG", + "title": "EasyDAG", + "panel": "panels/EasyDAG/EasyDAGPanel", + "DEBUG_ONLY": false + }, + { + "id": "ArchEditor", + "title": "ArchEditor", + "panel": "panels/ArchEditor/ArchEditorPanel", + "DEBUG_ONLY": false + }, + { + "id": "TextEditor", + "title": "TextEditor", + "panel": "panels/TextEditor/TextEditorPanel", + "DEBUG_ONLY": false + }, + { + "id": "OperationEditor", + "title": "OperationEditor", + "panel": "panels/OperationEditor/OperationEditorPanel", + "DEBUG_ONLY": false + }, + { + "id": "PipelineEditor", + "title": "PipelineEditor", + "panel": "panels/PipelineEditor/PipelineEditorPanel", + "DEBUG_ONLY": false + }, + { + "id": "ExecutionView", + "title": "ExecutionView", + "panel": "panels/ExecutionView/ExecutionViewPanel", + "DEBUG_ONLY": false + } +] diff --git a/src/visualizers/panels/ArchEditor/ArchEditorControl.js b/src/visualizers/panels/ArchEditor/ArchEditorControl.js index a8316fb..2eee28c 100644 --- a/src/visualizers/panels/ArchEditor/ArchEditorControl.js +++ b/src/visualizers/panels/ArchEditor/ArchEditorControl.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define */ /*jshint browser: true*/ /** * Generated by VisualizerGenerator 1.7.0 from webgme on Tue May 17 2016 11:25:46 GMT-0400 (EDT). @@ -42,32 +42,32 @@ define([ } // Add layer type (base class's base class) - desc.layerType = null; - if (desc.baseName) { - var node = this._client.getNode(id), - base = this._client.getNode(node.getMetaTypeId()), - layerType = this._client.getNode(base.getBaseId()); - - if (layerType) { - desc.layerType = layerType.getAttribute(nodePropertyNames.Attributes.name); - } - } + desc.layerType = null; + if (desc.baseName) { + var node = this._client.getNode(id), + base = this._client.getNode(node.getMetaTypeId()), + layerType = this._client.getNode(base.getBaseId()); + + if (layerType) { + desc.layerType = layerType.getAttribute(nodePropertyNames.Attributes.name); + } + } } return desc; }; ArchEditorControl.prototype._getValidInitialNodes = function() { return this._client.getChildrenMeta(this._currentNodeId).items - // For now, anything is possible! - // FIXME - .map(info => this._getAllDescendentIds(info.id)) - .reduce((prev, curr) => prev.concat(curr)) - // Filter all abstract nodes - .filter(nodeId => { - return !this._client.getNode(nodeId).isAbstract(); - }) - .map(id => this._getObjectDescriptor(id)) - .filter(obj => !obj.isConnection && obj.name !== 'Connection'); + // For now, anything is possible! + // FIXME + .map(info => this._getAllDescendentIds(info.id)) + .reduce((prev, curr) => prev.concat(curr)) + // Filter all abstract nodes + .filter(nodeId => { + return !this._client.getNode(nodeId).isAbstract(); + }) + .map(id => this._getObjectDescriptor(id)) + .filter(obj => !obj.isConnection && obj.name !== 'Connection'); }; return ArchEditorControl; diff --git a/src/visualizers/panels/ExecutionView/ExecutionViewControl.js b/src/visualizers/panels/ExecutionView/ExecutionViewControl.js index 704fb1a..e2306b7 100644 --- a/src/visualizers/panels/ExecutionView/ExecutionViewControl.js +++ b/src/visualizers/panels/ExecutionView/ExecutionViewControl.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define */ /*jshint browser: true*/ /** * Generated by VisualizerGenerator 1.7.0 from webgme on Tue May 24 2016 10:15:19 GMT-0500 (CDT). @@ -6,12 +6,10 @@ define([ 'panels/PipelineEditor/PipelineEditorControl', - 'underscore', - 'js/NodePropertyNames' + 'underscore' ], function ( PipelineEditorControl, - _, - nodePropertyNames + _ ) { 'use strict'; @@ -28,5 +26,22 @@ define([ /* * * * * * * * Visualizer content update callbacks * * * * * * * */ ExecutionViewControl.prototype.TERRITORY_RULE = {children: 4}; + ExecutionViewControl.prototype.updateTerritory = function() { + var nodeId = this._currentNodeId; + + // activeNode rules + this._territories = {}; + + this._territoryId = this._client.addUI(this, events => { + this._eventCallback(events); + }); + + this._territories[nodeId] = {children: 0}; // Territory "rule" + this._client.updateTerritory(this._territoryId, this._territories); + + this._territories[nodeId] = this.TERRITORY_RULE; + this._client.updateTerritory(this._territoryId, this._territories); + }; + return ExecutionViewControl; }); diff --git a/src/visualizers/panels/ForgeActionButton/Actions.js b/src/visualizers/panels/ForgeActionButton/Actions.js index 969f1da..02fe167 100644 --- a/src/visualizers/panels/ForgeActionButton/Actions.js +++ b/src/visualizers/panels/ForgeActionButton/Actions.js @@ -1,15 +1,12 @@ -/*globals WebGMEGlobal*/ +/*globals define*/ // These are actions defined for specific meta types. They are evaluated from // the context of the ForgeActionButton define([], function() { - var ROOT_ID = '', - CREATE_MODEL_TXT = 'Create new model'; - - var createNewArchitecture = function(type) { + var createNewArchitecture = function() { return createNew.call(this, 'Architecture'); }; - var createNewPipeline = function(type) { + var createNewPipeline = function() { return createNew.call(this, 'Pipeline'); }; @@ -28,8 +25,7 @@ define([], function() { var downloadButton = function() { var id = this._currentNodeId, node = this.client.getNode(id), - hash = node.getAttribute('data'), - url; + hash = node.getAttribute('data'); if (hash) { return '/rest/blob/download/' + hash; diff --git a/src/visualizers/panels/ForgeActionButton/ForgeActionButton.js b/src/visualizers/panels/ForgeActionButton/ForgeActionButton.js index 8d3c72f..40b2de2 100644 --- a/src/visualizers/panels/ForgeActionButton/ForgeActionButton.js +++ b/src/visualizers/panels/ForgeActionButton/ForgeActionButton.js @@ -32,7 +32,6 @@ define([ var baseName, node = this.client.getNode(nodeId), base = this.client.getNode(node.getMetaTypeId()), - base, actions, i; diff --git a/src/visualizers/panels/OperationEditor/OperationEditorControl.js b/src/visualizers/panels/OperationEditor/OperationEditorControl.js index 43057e7..92bb3b5 100644 --- a/src/visualizers/panels/OperationEditor/OperationEditorControl.js +++ b/src/visualizers/panels/OperationEditor/OperationEditorControl.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define */ /*jshint browser: true*/ /** * Generated by VisualizerGenerator 1.7.0 from webgme on Wed May 18 2016 12:00:46 GMT-0500 (CDT). diff --git a/src/visualizers/panels/PipelineEditor/PipelineEditorControl.js b/src/visualizers/panels/PipelineEditor/PipelineEditorControl.js index e079c8d..c929e5b 100644 --- a/src/visualizers/panels/PipelineEditor/PipelineEditorControl.js +++ b/src/visualizers/panels/PipelineEditor/PipelineEditorControl.js @@ -78,8 +78,7 @@ define([ // Add the operation definitions to the territory var metanodes = this._client.getAllMetaNodes(), - operation = metanodes.find(n => n.getAttribute('name') === 'Operation'), - operations; + operation = metanodes.find(n => n.getAttribute('name') === 'Operation'); // Get all the meta nodes that are instances of Operations metanodes.map(n => n.getId()) @@ -410,7 +409,7 @@ define([ .then(result => { if (result.status === STORAGE_CONSTANTS.SYNCED) { // Throw out the changes... warn the user? - console.log('SYNCED!'); + this._logger.info('SYNCED!'); } else { // Throw out the changes... warn the user? this._logger.warn(`Could not create operation after ${srcOpName}`); @@ -418,16 +417,6 @@ define([ }) .fail(err => this._logger.error(`Could not create operation after ${srcOpName}: ${err}`)); - // Create the connection between the given data ports! - //connId = this._client.createChild({ - //parentId: parentId, - //baseId: this.getConnectionId() -//}); - //this._client.makePointer(connId, 'src', srcPortId); - //this._client.makePointer(connId, 'dst', dstPortId); - // - //this._client.completeTransaction(`Created ${typeId} operation after ${nodeId}`); - console.log('doing stuff with the core'); } else if (pairs.length > 1) { // Else, prompt! // TODO diff --git a/src/visualizers/widgets/ArchEditor/ArchEditorWidget.js b/src/visualizers/widgets/ArchEditor/ArchEditorWidget.js index afd69ca..41ccce5 100644 --- a/src/visualizers/widgets/ArchEditor/ArchEditorWidget.js +++ b/src/visualizers/widgets/ArchEditor/ArchEditorWidget.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define*/ /*jshint browser: true*/ /** @@ -18,7 +18,7 @@ define([ 'use strict'; var ArchEditorWidget, - WIDGET_CLASS = 'arch-editor', + // WIDGET_CLASS = 'arch-editor', DEFAULT_COLOR = '#ffb74d', LAYER_COLORS = { Containers: '#ffb74d', diff --git a/src/visualizers/widgets/ArchEditor/Layer.js b/src/visualizers/widgets/ArchEditor/Layer.js index a193c22..b4ecc03 100644 --- a/src/visualizers/widgets/ArchEditor/Layer.js +++ b/src/visualizers/widgets/ArchEditor/Layer.js @@ -1,7 +1,10 @@ +/*globals define*/ define([ - 'widgets/EasyDAG/DAGItem' + 'widgets/EasyDAG/DAGItem', + 'underscore' ], function( - DAGItem + DAGItem, + _ ) { var Layer = function(parentEl, desc) { this.id = desc.id; diff --git a/src/visualizers/widgets/OperationEditor/OperationEditorWidget.js b/src/visualizers/widgets/OperationEditor/OperationEditorWidget.js index 693089c..beb2667 100644 --- a/src/visualizers/widgets/OperationEditor/OperationEditorWidget.js +++ b/src/visualizers/widgets/OperationEditor/OperationEditorWidget.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define */ /*jshint browser: true*/ /** @@ -15,8 +15,8 @@ define([ ) { 'use strict'; - var OperationEditorWidget, - WIDGET_CLASS = 'operation-editor'; + var OperationEditorWidget; + //WIDGET_CLASS = 'operation-editor'; OperationEditorWidget = function (logger, container) { TextEditorWidget.call(this, logger, container); @@ -26,21 +26,21 @@ define([ OperationEditorWidget.prototype.getHeader = function (desc) { // Add comment about the inputs, attributes and references - var inputs = desc.inputs.map(pair => `-- ${pair[0]} (${pair[1]})`).join('\n'), - refs = desc.references.map(name => `-- ${name}`).join('\n'), - header = [ + var inputs = desc.inputs.map(pair => `-- ${pair[0]} (${pair[1]})`).join('\n'), + refs = desc.references.map(name => `-- ${name}`).join('\n'), + header = [ `-- Editing "${desc.name}"`, - `-- `, - `-- Defined variables:` - ]; + '-- ', + '-- Defined variables:' + ]; if (inputs) { header.push(inputs); - } + } if (refs) { header.push(refs); - } - header.push(`--`); + } + header.push('--'); return header.join('\n'); }; diff --git a/src/visualizers/widgets/PipelineEditor/OperationNode.js b/src/visualizers/widgets/PipelineEditor/OperationNode.js index 9bafb4b..317507f 100644 --- a/src/visualizers/widgets/PipelineEditor/OperationNode.js +++ b/src/visualizers/widgets/PipelineEditor/OperationNode.js @@ -14,11 +14,11 @@ define([ _.extend(OperationNode.prototype, DAGItem.prototype); - OperationNode.prototype.updatePort = function(desc) { + OperationNode.prototype.updatePort = function(/*desc*/) { // TODO }; - OperationNode.prototype.addPort = function(desc) { + OperationNode.prototype.addPort = function(/*desc*/) { // TODO }; diff --git a/src/visualizers/widgets/TextEditor/TextEditorWidget.js b/src/visualizers/widgets/TextEditor/TextEditorWidget.js index c6aa557..767daa1 100644 --- a/src/visualizers/widgets/TextEditor/TextEditorWidget.js +++ b/src/visualizers/widgets/TextEditor/TextEditorWidget.js @@ -1,4 +1,4 @@ -/*globals define, WebGMEGlobal*/ +/*globals define*/ /*jshint browser: true*/ /** @@ -7,9 +7,11 @@ define([ './lib/ace', + 'underscore', 'css!./styles/TextEditorWidget.css' ], function ( - ace + ace, + _ ) { 'use strict'; @@ -20,38 +22,32 @@ define([ this._logger = logger.fork('Widget'); this._el = container; - this.editor = ace.edit(this._el[0]); - this.editor.getSession().setMode('ace/mode/lua'); + this.editor = ace.edit(this._el[0]); + this.editor.getSession().setMode('ace/mode/lua'); - // Get the config from component settings for themes - // TODO - this.editor.setOptions({ + // Get the config from component settings for themes + // TODO + this.editor.setOptions({ fontSize: '12pt' }); - this.editor.$blockScrolling = Infinity; - this.DELAY = 250; - // this.editor.setTheme('ace/theme/monokai'); + this.editor.$blockScrolling = Infinity; + this.DELAY = 250; + // this.editor.setTheme('ace/theme/monokai'); this.editor.on('input', _.debounce(this.saveText.bind(this), this.DELAY)); - this.currentHeader = ''; - this.activeNode = null; + this.currentHeader = ''; + this.activeNode = null; this._initialize(); this._logger.debug('ctor finished'); }; TextEditorWidget.prototype._initialize = function () { - var width = this._el.width(), - height = this._el.height(), - self = this; - // set widget class this._el.addClass(WIDGET_CLASS); }; - TextEditorWidget.prototype.onWidgetContainerResize = function (width, height) { - // TODO - //this.editor.setSize(width, height); + TextEditorWidget.prototype.onWidgetContainerResize = function () { }; // Adding/Removing/Updating items @@ -61,21 +57,21 @@ define([ TextEditorWidget.prototype.addNode = function (desc) { // Set the current text based on the given - // Create the header + // Create the header var header = this.getHeader(desc) + '\n'; - this.activeNode = desc.id; + this.activeNode = desc.id; this.editor.setValue(header + desc.text, -1); - this.currentHeader = header; + this.currentHeader = header; }; TextEditorWidget.prototype.saveText = function () { var text = this.editor.getValue().replace(this.currentHeader, ''); if (this.activeNode) { this.saveTextFor(this.activeNode, text); - } else { + } else { this._logger.error(`Active node is invalid! (${this.activeNode})`); - } + } }; TextEditorWidget.prototype.removeNode = function (gmeId) { @@ -85,10 +81,10 @@ define([ } }; - TextEditorWidget.prototype.updateNode = function (desc) { + TextEditorWidget.prototype.updateNode = function (/*desc*/) { // TODO: Handle concurrent editing... Currently, last save wins and there are no - // updates after opening the node. Supporting multiple users editing the same - // operation/layer is important but more work than it is worth for now + // updates after opening the node. Supporting multiple users editing the same + // operation/layer is important but more work than it is worth for now //var currentText = this.editor.getValue().replace(this.currentHeader, ''); //if (this.activeNode === desc.id && desc.text !== currentText) { //this.addNode(desc); diff --git a/test/globals.js b/test/globals.js index 47c82ac..b75bb36 100644 --- a/test/globals.js +++ b/test/globals.js @@ -1,5 +1,4 @@ // This is used by the test/plugins tests -/*globals requireJS*/ /*jshint node:true*/ /** * @author pmeijer / https://github.com/pmeijer @@ -16,14 +15,13 @@ var testFixture = require('webgme/test/_globals'), var WebGME = testFixture.WebGME, gmeConfig = require(WEBGME_CONFIG_PATH), getGmeConfig = function getGmeConfig() { - 'use strict'; - // makes sure that for each request it returns with a unique object and tests will not interfere - if (!gmeConfig) { - // if some tests are deleting or unloading the config - gmeConfig = require(WEBGME_CONFIG_PATH); - } - return JSON.parse(JSON.stringify(gmeConfig)); -}; + // makes sure that for each request it returns with a unique object and tests will not interfere + if (!gmeConfig) { + // if some tests are deleting or unloading the config + gmeConfig = require(WEBGME_CONFIG_PATH); + } + return JSON.parse(JSON.stringify(gmeConfig)); + }; WebGME.addToRequireJsPaths(gmeConfig); diff --git a/test/plugins/CreateExecution/CreateExecution.spec.js b/test/plugins/CreateExecution/CreateExecution.spec.js index 8e80994..6087999 100644 --- a/test/plugins/CreateExecution/CreateExecution.spec.js +++ b/test/plugins/CreateExecution/CreateExecution.spec.js @@ -61,7 +61,7 @@ describe('CreateExecution', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/1', + activeNode: '/1' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { diff --git a/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js b/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js index 22aa8b2..c6bd75f 100644 --- a/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js +++ b/test/plugins/CreateTorchMeta/CreateTorchMeta.spec.js @@ -66,7 +66,7 @@ describe('CreateTorchMeta', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/960660211', + activeNode: '/960660211' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { @@ -90,7 +90,7 @@ describe('CreateTorchMeta', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/960660211', + activeNode: '/960660211' }, META_NAMES = [ // Some Torch layer names to look up 'ReLU', @@ -136,7 +136,7 @@ describe('CreateTorchMeta', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/960660211', + activeNode: '/960660211' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { @@ -186,7 +186,7 @@ describe('CreateTorchMeta', function () { project: project, commitHash: commitHash, branchName: 'test', - activeNode: '/960660211', + activeNode: '/960660211' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { diff --git a/test/plugins/ExecutePipeline/ExecutePipeline.js b/test/plugins/ExecutePipeline/ExecutePipeline.js index f5cec60..eb164ae 100644 --- a/test/plugins/ExecutePipeline/ExecutePipeline.js +++ b/test/plugins/ExecutePipeline/ExecutePipeline.js @@ -68,7 +68,7 @@ describe.skip('ExecutePipeline', function () { commitHash: commitHash, namespace: 'pipeline', branchName: 'test', - activeNode: '/s', + activeNode: '/s' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { diff --git a/test/plugins/GenerateArchitecture/GenerateArchitecture.spec.js b/test/plugins/GenerateArchitecture/GenerateArchitecture.spec.js index 3d5b5f6..ec19aa6 100644 --- a/test/plugins/GenerateArchitecture/GenerateArchitecture.spec.js +++ b/test/plugins/GenerateArchitecture/GenerateArchitecture.spec.js @@ -6,7 +6,6 @@ 'use strict'; var testFixture = require('../../globals'), path = testFixture.path, - jszip = require('jszip'), fs = require('fs'), TEST_CASE_DIR = path.join(__dirname, '..', '..', 'test-cases', 'generated-code'), SEED_DIR = path.join(testFixture.DF_SEED_DIR, 'devTests'); @@ -68,7 +67,7 @@ describe('GenerateArchitecture', function () { namespace: 'nn', commitHash: commitHash, branchName: 'test', - activeNode: '/4', + activeNode: '/4' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { @@ -105,7 +104,7 @@ describe('GenerateArchitecture', function () { namespace: 'nn', commitHash: commitHash, branchName: 'test', - activeNode: id, + activeNode: id }, expected = fs.readFileSync(path.join(TEST_CASE_DIR, name), 'utf8') .replace(/\n$/, ''); @@ -120,16 +119,6 @@ describe('GenerateArchitecture', function () { var blobClient = new BlobClient(gmeConfig, logger); blobClient.getObjectAsString(codeHash, (err, actual) => { - // Unzip first... - var zip = new jszip(), - filename, - actual; - - //zip.load(obj); - //filename = Object.keys(zip.files) - //.filter(name => name.indexOf('.lua') > -1)[0]; - - //actual = zip.files[filename].asText(); expect(actual).to.equal(expected); done(); }); diff --git a/test/plugins/GenerateYaml/GenerateYaml.spec.js b/test/plugins/GenerateYaml/GenerateYaml.spec.js index 4df998d..c3f3dc4 100644 --- a/test/plugins/GenerateYaml/GenerateYaml.spec.js +++ b/test/plugins/GenerateYaml/GenerateYaml.spec.js @@ -13,7 +13,6 @@ describe('GenerateYaml', function () { expect = testFixture.expect, logger = testFixture.logger.fork('GenerateYaml'), PluginCliManager = testFixture.WebGME.PluginCliManager, - GraphChecker = testFixture.requirejs('deepforge/GraphChecker'), projectName = 'testProject', pluginName = 'GenerateYaml', project, @@ -31,7 +30,7 @@ describe('GenerateYaml', function () { }) .then(function () { var importParam = { - projectSeed: testFixture.path.join(BASE_DIR, 'devTests', 'devTests.webgmex'), + projectSeed: path.join(BASE_DIR, 'devTests', 'devTests.webgmex'), projectName: projectName, branchName: 'master', logger: logger, diff --git a/test/plugins/ImportTorch/ImportTorch.spec.js b/test/plugins/ImportTorch/ImportTorch.spec.js index f618495..f3a48d7 100644 --- a/test/plugins/ImportTorch/ImportTorch.spec.js +++ b/test/plugins/ImportTorch/ImportTorch.spec.js @@ -34,7 +34,6 @@ describe('ImportTorch', function () { blobClient = new BlobClient(gmeConfig, logger), projectName = 'testProject', pluginName = 'ImportTorch', - rootNode, checker, core, project, @@ -65,7 +64,6 @@ describe('ImportTorch', function () { project = importResult.project; commitHash = importResult.commitHash; core = importResult.core; - rootNode = importResult.rootNode; checker = new GraphChecker({ core: core, ignore: { @@ -101,7 +99,7 @@ describe('ImportTorch', function () { namespace: 'nn', commitHash: commitHash, branchName: 'test', - activeNode: '', + activeNode: '' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { @@ -119,7 +117,7 @@ describe('ImportTorch', function () { namespace: 'nn', project: project, branchName: 'test', - activeNode: '', + activeNode: '' }, data = fs.readFileSync(path.join(TEST_CASE_DIR, name), 'utf8'), ymlFile = path.join(YAML_DIR, name.replace(/lua$/, 'yml')), diff --git a/test/plugins/ImportYaml/ImportYaml.spec.js b/test/plugins/ImportYaml/ImportYaml.spec.js index b06197c..f81d91a 100644 --- a/test/plugins/ImportYaml/ImportYaml.spec.js +++ b/test/plugins/ImportYaml/ImportYaml.spec.js @@ -13,7 +13,6 @@ describe('ImportYaml', function () { var gmeConfig = testFixture.getGmeConfig(), Q = testFixture.Q, GraphChecker = testFixture.requirejs('deepforge/GraphChecker'), - TEST_CASE_DIR = path.join(__dirname, '..', '..', 'test-cases', 'code'), YAML_DIR = path.join(__dirname, '..', '..', 'test-cases', 'models'), expect = testFixture.expect, logger = testFixture.logger.fork('ImportYaml'), @@ -22,7 +21,6 @@ describe('ImportYaml', function () { blobClient = new BlobClient(gmeConfig, logger), projectName = 'testProject', pluginName = 'ImportYaml', - rootNode, checker, core, project, @@ -53,7 +51,6 @@ describe('ImportYaml', function () { project = importResult.project; commitHash = importResult.commitHash; core = importResult.core; - rootNode = importResult.rootNode; checker = new GraphChecker({ core: core, ignore: { @@ -85,7 +82,7 @@ describe('ImportYaml', function () { namespace: 'nn', commitHash: commitHash, branchName: 'test', - activeNode: '', + activeNode: '' }; manager.executePlugin(pluginName, pluginConfig, context, function (err, pluginResult) { @@ -103,7 +100,7 @@ describe('ImportYaml', function () { namespace: 'nn', project: project, branchName: 'test', - activeNode: '', + activeNode: '' }, data = fs.readFileSync(path.join(YAML_DIR, name), 'utf8'), ymlFile = path.join(YAML_DIR, name.replace(/lua$/, 'yml')), diff --git a/test/utils/utils.spec.js b/test/utils/utils.spec.js index 39f9542..b74196d 100644 --- a/test/utils/utils.spec.js +++ b/test/utils/utils.spec.js @@ -13,10 +13,7 @@ var testFixture = require('../globals'), describe('utils', function () { var gmeConfig = testFixture.getGmeConfig(), GraphChecker = testFixture.requirejs('deepforge/GraphChecker'), - expect = testFixture.expect, - path = testFixture.path, MODELS_DIR = path.join(__dirname, '..', 'test-cases', 'models'), - BASE_DIR = path.join(__dirname, '..', 'common'), logger = testFixture.logger.fork('utils'), projectName = 'testProject', Q = testFixture.Q,