diff --git a/nodes/core/90-comment.html b/nodes/core/90-comment.html index 463711c32..86b8922cb 100644 --- a/nodes/core/90-comment.html +++ b/nodes/core/90-comment.html @@ -20,7 +20,7 @@
- +
diff --git a/nodes/io/21-httpin.html b/nodes/io/21-httpin.html index 9ec5fed50..3e438f6ec 100644 --- a/nodes/io/21-httpin.html +++ b/nodes/io/21-httpin.html @@ -50,14 +50,15 @@
foo=bar&this=that

- To send JSON encoded data, the content-type header of the request must be set to + To send JSON encoded data to the node, the content-type header of the request must be set to application/json.

- Note: This node does not send any response to the http request. This must be done within - a subsequent Function node. The Express response documentation - describes how this should be done. -

msg.res.send(200, 'Thanks for the request ');
return msg;
+ Note: This node does not send any response to the http request. This should be done with + a subsequent HTTP Response node, or Function node. + In the case of a Function node, the Express response documentation + describes how this should be done. For example: +
msg.res.send(200, 'Thanks for the request ');
return msg;

@@ -81,5 +82,37 @@ return this.name?"node_label_italic":""; } }); - + + + + + + + diff --git a/nodes/io/21-httpin.js b/nodes/io/21-httpin.js index c6234990f..95a57b5cd 100644 --- a/nodes/io/21-httpin.js +++ b/nodes/io/21-httpin.js @@ -35,17 +35,33 @@ function HTTPIn(n) { } else if (this.method == "delete") { RED.app.delete(this.url,this.callback); } + + this.on("close",function() { + var routes = RED.app.routes[this.method]; + for (var i in routes) { + if (routes[i].path == this.url) { + routes.splice(i,1); + break; + } + } + }); } RED.nodes.registerType("http in",HTTPIn); -HTTPIn.prototype.close = function() { - var routes = RED.app.routes[this.method]; - for (var i in routes) { - if (routes[i].path == this.url) { - routes.splice(i,1); - break; - } - } + +function HTTPOut(n) { + RED.nodes.createNode(this,n); + + this.on("input",function(msg) { + if (msg.res) { + if (msg.headers) { + res.set(msg.headers); + } + var rc = msg.rc || 200; + msg.res.send(rc,msg.payload); + } + }); } +RED.nodes.registerType("http response",HTTPOut); diff --git a/nodes/storage/67-leveldb.html b/nodes/storage/67-leveldb.html new file mode 100644 index 000000000..bca7afb03 --- /dev/null +++ b/nodes/storage/67-leveldb.html @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + diff --git a/nodes/storage/67-leveldb.js b/nodes/storage/67-leveldb.js new file mode 100644 index 000000000..050d456be --- /dev/null +++ b/nodes/storage/67-leveldb.js @@ -0,0 +1,93 @@ +/** + * Copyright 2013 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var RED = require("../../red/red"); +var lvldb = require('level'); + +function LevelNode(n) { + RED.nodes.createNode(this,n); + this.dbname = n.db; + var node = this; + lvldb(this.dbname, function(err, db) { + if (err) node.error(err); + node.db = db; + }); +} +RED.nodes.registerType("leveldbase",LevelNode); +LevelNode.prototype.close = function() { + this.db.close(); +} + +function LevelDBNodeIn(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.levelConfig = RED.nodes.getNode(this.level); + + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + node.levelConfig.db.get(msg.topic, function(err, value) { + if (err) { + //node.warn(err); + // for some reason they treat nothing found as an error... + msg.payload = null; // so we should return null + } + else { msg.payload = value; } + node.send(msg); + }); + } + else { + if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); + } + }); + } + else { + this.error("LevelDB database name not configured"); + } +} +RED.nodes.registerType("leveldb in",LevelDBNodeIn); + + +function LevelDBNodeOut(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.operation = n.operation; + this.levelConfig = RED.nodes.getNode(this.level); + + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + if (node.operation === "delete") { + node.levelConfig.db.del(msg.topic); + } + else { + node.levelConfig.db.put(msg.topic, msg.payload, function(err) { + if (err) node.error(err); + }); + } + } + else { + if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); + } + }); + } + else { + this.error("LevelDB database name not configured"); + } +} +RED.nodes.registerType("leveldb out",LevelDBNodeOut); diff --git a/public/red/ui/view.js b/public/red/ui/view.js index cddbb4a0a..d8fe0bdeb 100644 --- a/public/red/ui/view.js +++ b/public/red/ui/view.js @@ -154,14 +154,22 @@ RED.view = function() { var dx = mousePos[0]-(mousedown_node.x+sc*mousedown_node.w/2); var delta = Math.sqrt(dy*dy+dx*dx); var scale = lineCurveScale; - + var scaleY = 0; + if (delta < node_width) { scale = 0.75-0.75*((node_width-delta)/node_width); } + if (dx*sc < 0) { + scale += 2*(Math.min(5*node_width,Math.abs(dx))/(5*node_width)); + if (Math.abs(dy) < 3*node_height) { + scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_width,Math.abs(dx))/(node_width)) ; + } + } + drag_line.attr("d", "M "+(mousedown_node.x+sc*mousedown_node.w/2)+" "+(mousedown_node.y+y)+ - " C "+(mousedown_node.x+sc*(mousedown_node.w/2+node_width*scale))+" "+(mousedown_node.y+y)+" "+ - (mousePos[0]-sc*(scale)*node_width)+" "+mousePos[1]+" "+ + " C "+(mousedown_node.x+sc*(mousedown_node.w/2+node_width*scale))+" "+(mousedown_node.y+y+scaleY*node_height)+" "+ + (mousePos[0]-sc*(scale)*node_width)+" "+(mousePos[1]-scaleY*node_height)+" "+ mousePos[0]+" "+mousePos[1] ); @@ -796,19 +804,26 @@ RED.view = function() { var dx = (d.target.x-d.target.w/2)-(d.source.x+d.source.w/2); var delta = Math.sqrt(dy*dy+dx*dx); var scale = lineCurveScale; - + var scaleY = 0; if (delta < node_width) { scale = 0.75-0.75*((node_width-delta)/node_width); } - + + if (dx < 0) { + scale += 2*(Math.min(5*node_width,Math.abs(dx))/(5*node_width)); + if (Math.abs(dy) < 3*node_height) { + scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_width,Math.abs(dx))/(node_width)) ; + } + } + d.x1 = d.source.x+d.source.w/2; d.y1 = d.source.y+y; d.x2 = d.target.x-d.target.w/2; d.y2 = d.target.y; return "M "+(d.source.x+d.source.w/2)+" "+(d.source.y+y)+ - " C "+(d.source.x+d.source.w/2+scale*node_width)+" "+(d.source.y+y)+" "+ - (d.target.x-d.target.w/2-scale*node_width)+" "+d.target.y+" "+ + " C "+(d.source.x+d.source.w/2+scale*node_width)+" "+(d.source.y+y+scaleY*node_height)+" "+ + (d.target.x-d.target.w/2-scale*node_width)+" "+(d.target.y-scaleY*node_height)+" "+ (d.target.x-d.target.w/2)+" "+d.target.y; }) diff --git a/public/style.css b/public/style.css index a4ed3d521..5a27d7099 100644 --- a/public/style.css +++ b/public/style.css @@ -142,7 +142,6 @@ a.brand img { background-color: #eee; } - #sidebar { background: #fff; } @@ -315,19 +314,16 @@ a.brand img { .node_invalid { stroke: #ff0000; } - .node_selected { stroke: #ff7f0e; } - .node_highlighted { stroke: #ff0000; } - - .node_hovered { dstroke: #ff7f0e; } + .port_hovered { stroke: #ff7f0e; fill: #ff7f0e; @@ -368,15 +364,16 @@ a.brand img { text-align: center; display: none; } + #dialog { } + .container { } .notification { position: absolute; } - #notifications { z-index: 10000; width: 500px; @@ -389,6 +386,7 @@ a.brand img { box-shadow: 0 0 1px 1px; margin-bottom: 5px; } + .form-row { clear: both; margin-bottom: 7px; @@ -415,7 +413,6 @@ button.input-append-right { padding-right: 4px !important; } - .form-tips { background: lightgoldenrodyellow; font-size: 12px; @@ -472,16 +469,25 @@ div.node-info { .dropdown-menu * a.active > .icon-ok { display: inline-block; } +.dropdown-menu>li.disabled>a:hover>[class^="icon-"] { + background-image: url("bootstrap/img/glyphicons-halflings.png") !important; +} +/** Fix for unreachable dropdown menu **/ +.dropdown-menu { + width: 200px !important; +} +.dropdown-menu > li > a { + padding-left: 28px ; + text-indent: -8px ; + white-space: normal !important; +} + .navbar-fixed-top, .navbar-fixed-bottom { z-index: 1000; } .popover-title { display: none; } - -.dropdown-menu>li.disabled>a:hover>[class^="icon-"] { - background-image: url("bootstrap/img/glyphicons-halflings.png") !important; -} .ui-autocomplete { max-height: 250px; overflow-x: hidden; @@ -552,8 +558,3 @@ div.node-info { border-radius:5px; overflow: hidden; } - -/** Fix for unreachable dropdown menu **/ -div.pull-right > ul.dropdown-menu > li.dropdown-submenu > ul { - margin-left: 20px; -}