From 6f0559edacace15ea53d3dc626d8a574ad911b13 Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Mon, 30 Jan 2017 13:22:31 +0100 Subject: [PATCH] New component for sending edges message to runtime, refs noflo/noflo-ui#328 --- component.json | 6 ++++-- components/SendEdges.coffee | 32 ++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 components/SendEdges.coffee diff --git a/component.json b/component.json index cc538c7..22ade6f 100644 --- a/component.json +++ b/component.json @@ -31,7 +31,8 @@ "components/ListenNetwork.coffee", "components/SendComponent.coffee", "components/SendGraph.coffee", - "components/ListComponents.coffee" + "components/ListComponents.coffee", + "components/SendEdges.coffee" ], "json": [ "spec/data/component.json", @@ -51,8 +52,9 @@ "ListGraphs": "components/ListGraphs.coffee", "ListNetworks": "components/ListNetworks.coffee", "SendComponent": "components/SendComponent.coffee", + "SendEdges": "components/SendEdges.coffee", "SendGraph": "components/SendGraph.coffee", "SendGraphChanges": "components/SendGraphChanges.coffee" } } -} +} \ No newline at end of file diff --git a/components/SendEdges.coffee b/components/SendEdges.coffee new file mode 100644 index 0000000..4c0fa6f --- /dev/null +++ b/components/SendEdges.coffee @@ -0,0 +1,32 @@ +noflo = require 'noflo' + +exports.getComponent = -> + c = new noflo.Component + c.description = 'Send edges selected by user to runtime' + c.inPorts.add 'edges', + datatype: 'array' + required: yes + c.inPorts.add 'runtime', + datatype: 'object' + required: yes + c.outPorts.add 'out', + datatype: 'array' + c.outPorts.add 'error', + datatype: 'object' + + noflo.helpers.WirePattern c, + in: 'edges' + params: 'runtime' + out: 'out' + async: true + , (data, groups, out, callback) -> + unless c.params.runtime.canDo + return callback new Error 'Incorrect runtime instance' + unless c.params.runtime.isConnected() + # Pass-through since there is no connection + out.send data + do callback + return + c.params.runtime.sendNetwork 'edges', data + out.send edges + do callback diff --git a/package.json b/package.json index 0476cd2..1a1d0be 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,9 @@ "ListGraphs": "components/ListGraphs.coffee", "ListNetworks": "components/ListNetworks.coffee", "SendComponent": "components/SendComponent.coffee", + "SendEdges": "components/SendEdges.coffee", "SendGraph": "components/SendGraph.coffee", "SendGraphChanges": "components/SendGraphChanges.coffee" } } -} +} \ No newline at end of file