mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'master' into tabs
This commit is contained in:
commit
a16c0835fd
@ -19,7 +19,7 @@
|
||||
// Sample Node-RED node file
|
||||
|
||||
// Require main module
|
||||
var RED = require("../../red/red");
|
||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||
|
||||
// The main node definition - most things happen in here
|
||||
function SampleNode(n) {
|
||||
@ -41,10 +41,10 @@ function SampleNode(n) {
|
||||
this.send(msg);
|
||||
|
||||
this.on("close", function() {
|
||||
// Called when the node is shutdown - eg on redeploy.
|
||||
// Allows ports to be closed, connections dropped etc.
|
||||
// eg: this.client.disconnect();
|
||||
});
|
||||
// Called when the node is shutdown - eg on redeploy.
|
||||
// Allows ports to be closed, connections dropped etc.
|
||||
// eg: this.client.disconnect();
|
||||
});
|
||||
}
|
||||
|
||||
// Register the node by name. This must be called before overriding any of the
|
||||
|
@ -29,14 +29,14 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="debug">
|
||||
<p>The Debug node can be connected to the output of any node. It will display the timestamp, <b>msg.topic</b> and <b>msg.payload</b> fields of any messages it receives in the debug tab of the sidebar.
|
||||
<br/>The sidebar can be accessed under the options drop-down in the top right corner.</p>
|
||||
<p>The button to the right of the node will toggle it's output on and off so you can de-clutter the debug window.</p>
|
||||
<p>If the payload is an object it will be stringified first for display and indicate that by saying "(Object) ".</p>
|
||||
<p>If the payload is a buffer it will be stringified first for display and indicate that by saying "(Buffer) ".</p>
|
||||
<p>Selecting any particular message will highlight (in red) the debug node that reported it. This is useful if you wire up multiple debug nodes.</p>
|
||||
<p>Optionally can show the complete msg object - but the screen can get messy.</p>
|
||||
<p>In addition any calls to node.warn or node.error will appear here.</p>
|
||||
<p>The Debug node can be connected to the output of any node. It will display the timestamp, <b>msg.topic</b> and <b>msg.payload</b> fields of any messages it receives in the debug tab of the sidebar.
|
||||
<br/>The sidebar can be accessed under the options drop-down in the top right corner.</p>
|
||||
<p>The button to the right of the node will toggle it's output on and off so you can de-clutter the debug window.</p>
|
||||
<p>If the payload is an object it will be stringified first for display and indicate that by saying "(Object) ".</p>
|
||||
<p>If the payload is a buffer it will be stringified first for display and indicate that by saying "(Buffer) ".</p>
|
||||
<p>Selecting any particular message will highlight (in red) the debug node that reported it. This is useful if you wire up multiple debug nodes.</p>
|
||||
<p>Optionally can show the complete msg object - but the screen can get messy.</p>
|
||||
<p>In addition any calls to node.warn or node.error will appear here.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -59,34 +59,25 @@
|
||||
icon: "debug.png",
|
||||
align: "right",
|
||||
button: {
|
||||
color: function() {
|
||||
return (typeof this.active === 'undefined') ? ("#87a980" ) : (this.active ? "#87a980" : "#b9b9b9");
|
||||
},
|
||||
toggle: "active",
|
||||
onclick: function() {
|
||||
var label = this.name||"debug";
|
||||
var node = this;
|
||||
d3.xhr("debug/"+this.id).post(function(err,resp) {
|
||||
if (err) {
|
||||
if (err.status == 404) {
|
||||
RED.notify("<strong>Error</strong>: debug node not deployed","error");
|
||||
} else if (err.status == 0) {
|
||||
RED.notify("<strong>Error</strong>: no response from server","error");
|
||||
} else {
|
||||
RED.notify("<strong>Error</strong>: unexpected error: ("+err.status+")"+err.response,"error");
|
||||
}
|
||||
} else if (resp.status == 200) {
|
||||
RED.notify("Successfully activated: "+label,"success");
|
||||
node.active = true;
|
||||
node.dirty = true;
|
||||
RED.view.redraw();
|
||||
} else if (resp.status == 201) {
|
||||
RED.notify("Successfully deactivated: "+label,"success");
|
||||
node.active = false;
|
||||
node.dirty = true;
|
||||
RED.view.redraw();
|
||||
d3.xhr("debug/"+this.id+"/"+(this.active?"enable":"disable")).post(function(err,resp) {
|
||||
if (err) {
|
||||
if (err.status == 404) {
|
||||
RED.notify("<strong>Error</strong>: debug node not deployed","error");
|
||||
} else if (err.status == 0) {
|
||||
RED.notify("<strong>Error</strong>: no response from server","error");
|
||||
} else {
|
||||
RED.notify("<strong>Error</strong>: unexpected response: ("+resp.status+") "+resp.response,"error");
|
||||
RED.notify("<strong>Error</strong>: unexpected error: ("+err.status+")"+err.response,"error");
|
||||
}
|
||||
} else if (resp.status == 200) {
|
||||
RED.notify("Successfully activated: "+label,"success");
|
||||
} else if (resp.status == 201) {
|
||||
RED.notify("Successfully deactivated: "+label,"success");
|
||||
} else {
|
||||
RED.notify("<strong>Error</strong>: unexpected response: ("+resp.status+") "+resp.response,"error");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -116,10 +107,10 @@
|
||||
var sbc = document.getElementById("debug-content");
|
||||
|
||||
var errornotification = null;
|
||||
|
||||
|
||||
var messageCount = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
function debugConnect() {
|
||||
//console.log("debug ws connecting");
|
||||
var ws = new WebSocket("ws://"+location.hostname+":"+location.port+document.location.pathname+"/debug");
|
||||
@ -165,7 +156,7 @@
|
||||
var atBottom = (sbc.scrollHeight-messages.offsetHeight-sbc.scrollTop) < 5;
|
||||
messageCount++;
|
||||
$(messages).append(msg);
|
||||
|
||||
|
||||
if (messageCount > 200) {
|
||||
$("#debug-content .debug-message:first").remove();
|
||||
messageCount--;
|
||||
|
@ -100,16 +100,19 @@ DebugNode.logHandler.on("log",function(msg) {
|
||||
});
|
||||
RED.nodes.addLogHandler(DebugNode.logHandler);
|
||||
|
||||
RED.app.post("/debug/:id", function(req,res) {
|
||||
RED.app.post("/debug/:id/:state", function(req,res) {
|
||||
var node = RED.nodes.getNode(req.params.id);
|
||||
var state = req.params.state;
|
||||
if (node != null) {
|
||||
if (node.active) {
|
||||
node.active = false;
|
||||
if (state === "enable") {
|
||||
node.active = true;
|
||||
res.send(201);
|
||||
} else {
|
||||
node.active = true;
|
||||
} else if (state === "disable") {
|
||||
node.active = false;
|
||||
res.send(200);
|
||||
}
|
||||
} else {
|
||||
res.send(404);
|
||||
}
|
||||
} else {
|
||||
res.send(404);
|
||||
}
|
||||
|
@ -19,106 +19,105 @@ var reconnectTime = RED.settings.socketReconnectTime||10000;
|
||||
var net = require('net');
|
||||
|
||||
function TcpOut(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.host = n.host;
|
||||
this.port = n.port * 1;
|
||||
this.base64 = n.base64;
|
||||
this.beserver = n.beserver;
|
||||
this.name = n.name;
|
||||
this.closing = false;
|
||||
var node = this;
|
||||
RED.nodes.createNode(this,n);
|
||||
this.host = n.host;
|
||||
this.port = n.port * 1;
|
||||
this.base64 = n.base64;
|
||||
this.beserver = n.beserver;
|
||||
this.name = n.name;
|
||||
this.closing = false;
|
||||
var node = this;
|
||||
|
||||
if (!node.beserver||node.beserver=="client") {
|
||||
var reconnectTimeout;
|
||||
var client = null;
|
||||
var connected = false;
|
||||
|
||||
function setupTcpClient() {
|
||||
node.log("connecting to "+node.host+":"+node.port);
|
||||
client = net.connect(node.port, node.host, function() {
|
||||
connected = true;
|
||||
node.log("connected to "+node.host+":"+node.port);
|
||||
});
|
||||
|
||||
client.on('error', function (err) {
|
||||
node.log('error : '+err);
|
||||
});
|
||||
|
||||
client.on('end', function (err) {
|
||||
});
|
||||
|
||||
client.on('close', function() {
|
||||
node.log("connection lost to "+node.host+":"+node.port);
|
||||
connected = false;
|
||||
client.destroy();
|
||||
if (!node.closing) {
|
||||
reconnectTimeout = setTimeout(setupTcpClient,reconnectTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
setupTcpClient();
|
||||
|
||||
|
||||
node.on("input", function(msg) {
|
||||
if (connected && msg.payload != null) {
|
||||
if (Buffer.isBuffer(msg.payload)) {
|
||||
client.write(msg.payload);
|
||||
} else if (typeof msg.payload === "string" && node.base64) {
|
||||
client.write(new Buffer(msg.payload,'base64'));
|
||||
} else {
|
||||
client.write(new Buffer(""+msg.payload));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this._close = function() {
|
||||
this.closing = true;
|
||||
client.end();
|
||||
clearTimeout(reconnectTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
var connectedSockets = [];
|
||||
var server = net.createServer(function (socket) {
|
||||
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
||||
node.log("connection from "+remoteDetails);
|
||||
connectedSockets.push(socket);
|
||||
socket.on('close',function() {
|
||||
node.log("connection closed from "+remoteDetails);
|
||||
if (!node.beserver||node.beserver=="client") {
|
||||
var reconnectTimeout;
|
||||
var client = null;
|
||||
var connected = false;
|
||||
|
||||
function setupTcpClient() {
|
||||
node.log("connecting to "+node.host+":"+node.port);
|
||||
client = net.connect(node.port, node.host, function() {
|
||||
connected = true;
|
||||
node.log("connected to "+node.host+":"+node.port);
|
||||
});
|
||||
|
||||
client.on('error', function (err) {
|
||||
node.log('error : '+err);
|
||||
});
|
||||
|
||||
client.on('end', function (err) {
|
||||
});
|
||||
|
||||
client.on('close', function() {
|
||||
node.log("connection lost to "+node.host+":"+node.port);
|
||||
connected = false;
|
||||
client.destroy();
|
||||
if (!node.closing) {
|
||||
reconnectTimeout = setTimeout(setupTcpClient,reconnectTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
setupTcpClient();
|
||||
|
||||
|
||||
node.on("input", function(msg) {
|
||||
if (connected && msg.payload != null) {
|
||||
if (Buffer.isBuffer(msg.payload)) {
|
||||
client.write(msg.payload);
|
||||
} else if (typeof msg.payload === "string" && node.base64) {
|
||||
client.write(new Buffer(msg.payload,'base64'));
|
||||
} else {
|
||||
client.write(new Buffer(""+msg.payload));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
node.on("close", function() {
|
||||
this.closing = true;
|
||||
client.end();
|
||||
clearTimeout(reconnectTimeout);
|
||||
});
|
||||
|
||||
} else {
|
||||
var connectedSockets = [];
|
||||
var server = net.createServer(function (socket) {
|
||||
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
||||
node.log("connection from "+remoteDetails);
|
||||
connectedSockets.push(socket);
|
||||
socket.on('close',function() {
|
||||
node.log("connection closed from "+remoteDetails);
|
||||
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
||||
});
|
||||
socket.on('error',function() {
|
||||
node.log("socket error from "+remoteDetails);
|
||||
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
||||
});
|
||||
});
|
||||
node.on("input", function(msg) {
|
||||
if (msg.payload != null) {
|
||||
var buffer;
|
||||
if (Buffer.isBuffer(msg.payload)) {
|
||||
buffer = msg.payload;
|
||||
} else if (typeof msg.payload === "string" && node.base64) {
|
||||
buffer = new Buffer(msg.payload,'base64');
|
||||
} else {
|
||||
buffer = new Buffer(""+msg.payload);
|
||||
}
|
||||
for (var i = 0; i<connectedSockets.length;i+=1) {
|
||||
connectedSockets[i].write(buffer);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(node.port);
|
||||
node.log('listening on port '+node.port);
|
||||
});
|
||||
node.on("input", function(msg) {
|
||||
if (msg.payload != null) {
|
||||
var buffer;
|
||||
if (Buffer.isBuffer(msg.payload)) {
|
||||
buffer = msg.payload;
|
||||
} else if (typeof msg.payload === "string" && node.base64) {
|
||||
buffer = new Buffer(msg.payload,'base64');
|
||||
} else {
|
||||
buffer = new Buffer(""+msg.payload);
|
||||
}
|
||||
for (var i = 0; i<connectedSockets.length;i+=1) {
|
||||
connectedSockets[i].write(buffer);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this._close = function() {
|
||||
server.close();
|
||||
node.log('stopped listening on port '+node.port);
|
||||
}
|
||||
}
|
||||
server.listen(node.port);
|
||||
node.log('listening on port '+node.port);
|
||||
|
||||
node.on('close', function() {
|
||||
server.close();
|
||||
node.log('stopped listening on port '+node.port);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RED.nodes.registerType("tcp out",TcpOut);
|
||||
|
||||
TcpOut.prototype.close = function() {
|
||||
this._close();
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,9 @@
|
||||
<div class="form-row">
|
||||
<label for="node-input-operation"><i class="icon-wrench"></i> Operation</label>
|
||||
<select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;">
|
||||
<option value=store>Store</option>
|
||||
<option value=delete>Delete</option>
|
||||
<option value=store>save</option>
|
||||
<option value=insert>insert</option>
|
||||
<option value=delete>remove</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row node-input-payonly">
|
||||
@ -83,13 +84,13 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="mongodb out">
|
||||
<p>A simple MongoDB output node. Stores the <b>msg</b> object in a chosen collection.</p>
|
||||
<p>By default MongoDB creates an <i>_id</i> property as the primary key - so repeated injections of the same <b>msg</b> will result in many database entries.</p>
|
||||
<p>If this is NOT the desired behaviour - ie you want repeated entries to overwrite, then you must set the <b>msg._id</b> property to be a constant by the use of a previous function node.</p>
|
||||
<p>This could be a unique constant or you could create one based on some other msg property.</p>
|
||||
<p>Currently we do not limit or cap the collection size at all... this may well change.</p>
|
||||
<p>You can also choose to <b>remove</b> items. To do so the <b>msg.payload</b> <i>MUST</i> contain an object that will select the items(s) to remove.
|
||||
A blank object will delete <i>all of the objects</i> in the collection. You have been warned...</p>
|
||||
<p>A simple MongoDB output node. Stores the <b>msg</b> object in a chosen collection.</p>
|
||||
<p>By default MongoDB creates an <i>_id</i> property as the primary key - so repeated injections of the same <b>msg</b> will result in many database entries.</p>
|
||||
<p>If this is NOT the desired behaviour - ie you want repeated entries to overwrite, then you must set the <b>msg._id</b> property to be a constant by the use of a previous function node.</p>
|
||||
<p>This could be a unique constant or you could create one based on some other msg property.</p>
|
||||
<p>Currently we do not limit or cap the collection size at all... this may well change.</p>
|
||||
<p>You can also choose to <b>remove</b> items. To do so the <b>msg.payload</b> <i>MUST</i> contain an object that will select the items(s) to remove.
|
||||
A blank object will delete <i>all of the objects</i> in the collection. You have been warned...</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -134,9 +135,9 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="mongodb in">
|
||||
<p>Queries a MongoDB collection by using the <b>msg.payload</b> to be a MongoDB query statement as per the .find() function.</p>
|
||||
<p>You may also (via a function) set a <b>msg.projection</b> object to constrain the returned fields, a <b>msg.sort</b> object and a <b>msg.limit</b> object.</p>
|
||||
<p>All are optional - see the <a href="http://docs.mongodb.org/manual/reference/method/db.collection.find/" target="new"><i>MongoDB find docs</i></a> for examples.</p>
|
||||
<p>Queries a MongoDB collection by using the <b>msg.payload</b> to be a MongoDB query statement as per the .find() function.</p>
|
||||
<p>You may also (via a function) set a <b>msg.projection</b> object to constrain the returned fields, a <b>msg.sort</b> object and a <b>msg.limit</b> object.</p>
|
||||
<p>All are optional - see the <a href="http://docs.mongodb.org/manual/reference/method/db.collection.find/" target="new"><i>MongoDB find docs</i></a> for examples.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -42,19 +42,24 @@ function MongoOutNode(n) {
|
||||
if (err) { node.error(err); }
|
||||
else {
|
||||
node.clientDb.collection(node.collection,function(err,coll) {
|
||||
if (err) { node.error(err); }
|
||||
else {
|
||||
node.on("input",function(msg) {
|
||||
if (node.operation == "store") {
|
||||
delete msg._topic;
|
||||
if (node.payonly) coll.save(msg.payload,function(err,item){ if (err){node.error(err);} });
|
||||
else coll.save(msg,function(err,item){if (err){node.error(err);}});
|
||||
}
|
||||
if (node.operation == "delete") {
|
||||
coll.remove(msg.payload, {w:1}, function(err, items){ if (err) node.error(err); });
|
||||
}
|
||||
});
|
||||
}
|
||||
if (err) { node.error(err); }
|
||||
else {
|
||||
node.on("input",function(msg) {
|
||||
if (node.operation == "store") {
|
||||
delete msg._topic;
|
||||
if (node.payonly) coll.save(msg.payload,function(err,item){ if (err){node.error(err);} });
|
||||
else coll.save(msg,function(err,item){if (err){node.error(err);}});
|
||||
}
|
||||
else if (node.operation == "insert") {
|
||||
delete msg._topic;
|
||||
if (node.payonly) coll.insert(msg.payload,function(err,item){ if (err){node.error(err);} });
|
||||
else coll.insert(msg,function(err,item){if (err){node.error(err);}});
|
||||
}
|
||||
if (node.operation == "delete") {
|
||||
coll.remove(msg.payload, {w:1}, function(err, items){ if (err) node.error(err); });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -62,11 +67,11 @@ function MongoOutNode(n) {
|
||||
this.error("missing mongodb configuration");
|
||||
}
|
||||
|
||||
this.on("close", function() {
|
||||
if (this.clientDb) {
|
||||
this.clientDb.close();
|
||||
}
|
||||
});
|
||||
this.on("close", function() {
|
||||
if (this.clientDb) {
|
||||
this.clientDb.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("mongodb out",MongoOutNode);
|
||||
|
||||
@ -105,10 +110,10 @@ function MongoInNode(n) {
|
||||
this.error("missing mongodb configuration");
|
||||
}
|
||||
|
||||
this.on("close", function() {
|
||||
if (this.clientDb) {
|
||||
this.clientDb.close();
|
||||
}
|
||||
});
|
||||
this.on("close", function() {
|
||||
if (this.clientDb) {
|
||||
this.clientDb.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("mongodb in",MongoInNode);
|
||||
|
@ -160,7 +160,7 @@ RED.view = function() {
|
||||
.attr("height",0)
|
||||
.attr("class","lasso");
|
||||
d3.event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ RED.view = function() {
|
||||
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);
|
||||
}
|
||||
@ -226,7 +226,7 @@ RED.view = function() {
|
||||
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+scaleY*node_height)+" "+
|
||||
@ -624,7 +624,22 @@ RED.view = function() {
|
||||
redraw();
|
||||
d3.event.stopPropagation();
|
||||
}
|
||||
|
||||
|
||||
function nodeButtonClicked(d) {
|
||||
if (d._def.button.toggle) {
|
||||
d[d._def.button.toggle] = !d[d._def.button.toggle];
|
||||
d.dirty = true;
|
||||
}
|
||||
if (d._def.button.onclick) {
|
||||
d._def.button.onclick.call(d);
|
||||
}
|
||||
|
||||
if (d.dirty) {
|
||||
redraw();
|
||||
}
|
||||
d3.event.preventDefault();
|
||||
}
|
||||
|
||||
function redraw() {
|
||||
vis.attr("transform","scale("+scaleFactor+")");
|
||||
outer.attr("width", space_width*scaleFactor).attr("height", space_height*scaleFactor);
|
||||
@ -658,19 +673,18 @@ RED.view = function() {
|
||||
}
|
||||
|
||||
if (d._def.button) {
|
||||
node.append('rect')
|
||||
.attr("class",function(d) { return (d._def.align == "right") ? "node_right_button_group" : "node_left_button_group"; })
|
||||
.attr("x",function(d) { return (d._def.align == "right") ? 94 : -25; })
|
||||
.attr("y",2)
|
||||
var nodeButtonGroup = node.append('svg:g')
|
||||
.attr("transform",function(d) { return "translate("+((d._def.align == "right") ? 94 : -25)+",2)"; })
|
||||
.attr("class",function(d) { return "node_button "+((d._def.align == "right") ? "node_right_button" : "node_left_button"); });
|
||||
nodeButtonGroup.append('rect')
|
||||
.attr("rx",8)
|
||||
.attr("ry",8)
|
||||
.attr("width",32)
|
||||
.attr("height",node_height-4)
|
||||
.attr("fill","#eee");//function(d) { return d._def.color;})
|
||||
node.append('rect')
|
||||
.attr("class",function(d) { return (d._def.align == "right") ? "node_right_button" : "node_left_button"; })
|
||||
.attr("x",function(d) { return (d._def.align == "right") ? 104 : -20; })
|
||||
.attr("y",6)
|
||||
nodeButtonGroup.append('rect')
|
||||
.attr("x",function(d) { return d._def.align == "right"? 10:5})
|
||||
.attr("y",4)
|
||||
.attr("rx",5)
|
||||
.attr("ry",5)
|
||||
.attr("width",16)
|
||||
@ -680,9 +694,15 @@ RED.view = function() {
|
||||
.on("mousedown",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.2);d3.event.preventDefault(); d3.event.stopPropagation();}})
|
||||
.on("mouseup",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);d3.event.preventDefault();d3.event.stopPropagation();}})
|
||||
.on("mouseover",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",0.4);}})
|
||||
.on("mouseout",function(d) {if (!lasso) { d3.select(this).attr("fill-opacity",1);}})
|
||||
.on("click",function(d) { d._def.button.onclick.call(d); d3.event.preventDefault(); })
|
||||
.on("touchstart",function(d) { d._def.button.onclick.call(d); d3.event.preventDefault(); })
|
||||
.on("mouseout",function(d) {if (!lasso) {
|
||||
var op = 1;
|
||||
if (d._def.button.toggle) {
|
||||
op = d[d._def.button.toggle]?1:0.2;
|
||||
}
|
||||
d3.select(this).attr("fill-opacity",op);
|
||||
}})
|
||||
.on("click",nodeButtonClicked)
|
||||
.on("touchstart",nodeButtonClicked)
|
||||
}
|
||||
|
||||
var mainRect = node.append("rect")
|
||||
@ -718,7 +738,7 @@ RED.view = function() {
|
||||
.attr("x",0).attr("y",function(d){return (d.h-Math.min(50,d.h))/2;})
|
||||
.attr("width","15")
|
||||
.attr("height", function(d){return Math.min(50,d.h);});
|
||||
|
||||
|
||||
if (d._def.align) {
|
||||
icon.attr('class','node_icon node_icon_'+d._def.align);
|
||||
}
|
||||
@ -818,10 +838,24 @@ RED.view = function() {
|
||||
});
|
||||
thisNode.selectAll(".node_icon").attr("height",function(d){return Math.min(50,d.h);}).attr("y",function(d){return (d.h-Math.min(50,d.h))/2;});
|
||||
|
||||
thisNode.selectAll('.node_right_button_group').attr("transform",function(d){return "translate("+(d.w-100)+","+0+")";});
|
||||
thisNode.selectAll('.node_right_button').attr("transform",function(d){return "translate("+(d.w-100)+","+0+")";}).attr("fill",function(d) {
|
||||
return typeof d._def.button.color === "function" ? d._def.button.color.call(d):(d._def.button.color != null ? d._def.button.color : d._def.color)
|
||||
thisNode.selectAll('.node_right_button').attr("transform",function(d){
|
||||
var x = d.w-6;
|
||||
if (d._def.button.toggle && !d[d._def.button.toggle]) {
|
||||
x = x - 8;
|
||||
}
|
||||
return "translate("+x+",2)";
|
||||
});
|
||||
thisNode.selectAll('.node_right_button rect').attr("fill-opacity",function(d){
|
||||
if (d._def.button.toggle) {
|
||||
return d[d._def.button.toggle]?1:0.2;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
//thisNode.selectAll('.node_right_button').attr("transform",function(d){return "translate("+(d.w - d._def.button.width.call(d))+","+0+")";}).attr("fill",function(d) {
|
||||
// return typeof d._def.button.color === "function" ? d._def.button.color.call(d):(d._def.button.color != null ? d._def.button.color : d._def.color)
|
||||
//});
|
||||
|
||||
thisNode.selectAll('.node_badge_group').attr("transform",function(d){return "translate("+(d.w-40)+","+(d.h+3)+")";});
|
||||
thisNode.selectAll('text.node_badge_label').text(function(d,i) {
|
||||
@ -877,14 +911,14 @@ RED.view = function() {
|
||||
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;
|
||||
@ -941,11 +975,11 @@ RED.view = function() {
|
||||
var root_node = new_ms[0].n;
|
||||
var dx = root_node.x;
|
||||
var dy = root_node.y;
|
||||
|
||||
|
||||
if (mouse_position == null) {
|
||||
mouse_position = [0,0];
|
||||
}
|
||||
|
||||
|
||||
for (var i in new_ms) {
|
||||
new_ms[i].n.selected = true;
|
||||
new_ms[i].n.x -= dx - mouse_position[0];
|
||||
|
@ -329,10 +329,11 @@ a.brand img {
|
||||
stroke: #ff7f0e;
|
||||
}
|
||||
.node_highlighted {
|
||||
stroke: #ff0000;
|
||||
stroke: #dd1616;
|
||||
stroke-width: 2;
|
||||
stroke-dasharray: 10, 4;
|
||||
}
|
||||
.node_hovered {
|
||||
dstroke: #ff7f0e;
|
||||
}
|
||||
|
||||
.port_hovered {
|
||||
@ -425,11 +426,11 @@ button.input-append-right {
|
||||
}
|
||||
|
||||
.form-tips {
|
||||
background: lightgoldenrodyellow;
|
||||
font-size: 12px;
|
||||
padding: 8px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #999;
|
||||
background: lightgoldenrodyellow;
|
||||
font-size: 12px;
|
||||
padding: 8px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
.form-tips code {
|
||||
border: none;
|
||||
@ -563,7 +564,6 @@ div.node-info {
|
||||
#node-select-library li.list-hover {
|
||||
background: #ffffd0;
|
||||
}
|
||||
|
||||
.node-text-editor {
|
||||
border:1px solid #ccc;
|
||||
border-radius:5px;
|
||||
|
Loading…
Reference in New Issue
Block a user