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
|
// Sample Node-RED node file
|
||||||
|
|
||||||
// Require main module
|
// 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
|
// The main node definition - most things happen in here
|
||||||
function SampleNode(n) {
|
function SampleNode(n) {
|
||||||
@ -41,10 +41,10 @@ function SampleNode(n) {
|
|||||||
this.send(msg);
|
this.send(msg);
|
||||||
|
|
||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
// Called when the node is shutdown - eg on redeploy.
|
// Called when the node is shutdown - eg on redeploy.
|
||||||
// Allows ports to be closed, connections dropped etc.
|
// Allows ports to be closed, connections dropped etc.
|
||||||
// eg: this.client.disconnect();
|
// eg: this.client.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the node by name. This must be called before overriding any of the
|
// Register the node by name. This must be called before overriding any of the
|
||||||
|
@ -29,14 +29,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="debug">
|
<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.
|
<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>
|
<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>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 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>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>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>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>In addition any calls to node.warn or node.error will appear here.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -59,34 +59,25 @@
|
|||||||
icon: "debug.png",
|
icon: "debug.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
button: {
|
button: {
|
||||||
color: function() {
|
toggle: "active",
|
||||||
return (typeof this.active === 'undefined') ? ("#87a980" ) : (this.active ? "#87a980" : "#b9b9b9");
|
|
||||||
},
|
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
var label = this.name||"debug";
|
var label = this.name||"debug";
|
||||||
var node = this;
|
d3.xhr("debug/"+this.id+"/"+(this.active?"enable":"disable")).post(function(err,resp) {
|
||||||
d3.xhr("debug/"+this.id).post(function(err,resp) {
|
if (err) {
|
||||||
if (err) {
|
if (err.status == 404) {
|
||||||
if (err.status == 404) {
|
RED.notify("<strong>Error</strong>: debug node not deployed","error");
|
||||||
RED.notify("<strong>Error</strong>: debug node not deployed","error");
|
} else if (err.status == 0) {
|
||||||
} else if (err.status == 0) {
|
RED.notify("<strong>Error</strong>: no response from server","error");
|
||||||
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();
|
|
||||||
} else {
|
} 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");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,16 +100,19 @@ DebugNode.logHandler.on("log",function(msg) {
|
|||||||
});
|
});
|
||||||
RED.nodes.addLogHandler(DebugNode.logHandler);
|
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 node = RED.nodes.getNode(req.params.id);
|
||||||
|
var state = req.params.state;
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
if (node.active) {
|
if (state === "enable") {
|
||||||
node.active = false;
|
node.active = true;
|
||||||
res.send(201);
|
res.send(201);
|
||||||
} else {
|
} else if (state === "disable") {
|
||||||
node.active = true;
|
node.active = false;
|
||||||
res.send(200);
|
res.send(200);
|
||||||
}
|
} else {
|
||||||
|
res.send(404);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.send(404);
|
res.send(404);
|
||||||
}
|
}
|
||||||
|
@ -19,106 +19,105 @@ var reconnectTime = RED.settings.socketReconnectTime||10000;
|
|||||||
var net = require('net');
|
var net = require('net');
|
||||||
|
|
||||||
function TcpOut(n) {
|
function TcpOut(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.host = n.host;
|
this.host = n.host;
|
||||||
this.port = n.port * 1;
|
this.port = n.port * 1;
|
||||||
this.base64 = n.base64;
|
this.base64 = n.base64;
|
||||||
this.beserver = n.beserver;
|
this.beserver = n.beserver;
|
||||||
this.name = n.name;
|
this.name = n.name;
|
||||||
this.closing = false;
|
this.closing = false;
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
if (!node.beserver||node.beserver=="client") {
|
if (!node.beserver||node.beserver=="client") {
|
||||||
var reconnectTimeout;
|
var reconnectTimeout;
|
||||||
var client = null;
|
var client = null;
|
||||||
var connected = false;
|
var connected = false;
|
||||||
|
|
||||||
function setupTcpClient() {
|
function setupTcpClient() {
|
||||||
node.log("connecting to "+node.host+":"+node.port);
|
node.log("connecting to "+node.host+":"+node.port);
|
||||||
client = net.connect(node.port, node.host, function() {
|
client = net.connect(node.port, node.host, function() {
|
||||||
connected = true;
|
connected = true;
|
||||||
node.log("connected to "+node.host+":"+node.port);
|
node.log("connected to "+node.host+":"+node.port);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('error', function (err) {
|
client.on('error', function (err) {
|
||||||
node.log('error : '+err);
|
node.log('error : '+err);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('end', function (err) {
|
client.on('end', function (err) {
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', function() {
|
client.on('close', function() {
|
||||||
node.log("connection lost to "+node.host+":"+node.port);
|
node.log("connection lost to "+node.host+":"+node.port);
|
||||||
connected = false;
|
connected = false;
|
||||||
client.destroy();
|
client.destroy();
|
||||||
if (!node.closing) {
|
if (!node.closing) {
|
||||||
reconnectTimeout = setTimeout(setupTcpClient,reconnectTime);
|
reconnectTimeout = setTimeout(setupTcpClient,reconnectTime);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setupTcpClient();
|
setupTcpClient();
|
||||||
|
|
||||||
|
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
if (connected && msg.payload != null) {
|
if (connected && msg.payload != null) {
|
||||||
if (Buffer.isBuffer(msg.payload)) {
|
if (Buffer.isBuffer(msg.payload)) {
|
||||||
client.write(msg.payload);
|
client.write(msg.payload);
|
||||||
} else if (typeof msg.payload === "string" && node.base64) {
|
} else if (typeof msg.payload === "string" && node.base64) {
|
||||||
client.write(new Buffer(msg.payload,'base64'));
|
client.write(new Buffer(msg.payload,'base64'));
|
||||||
} else {
|
} else {
|
||||||
client.write(new Buffer(""+msg.payload));
|
client.write(new Buffer(""+msg.payload));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
node.on("close", function() {
|
||||||
|
this.closing = true;
|
||||||
|
client.end();
|
||||||
|
clearTimeout(reconnectTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
this._close = function() {
|
} else {
|
||||||
this.closing = true;
|
var connectedSockets = [];
|
||||||
client.end();
|
var server = net.createServer(function (socket) {
|
||||||
clearTimeout(reconnectTimeout);
|
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
||||||
}
|
node.log("connection from "+remoteDetails);
|
||||||
}
|
connectedSockets.push(socket);
|
||||||
|
socket.on('close',function() {
|
||||||
else {
|
node.log("connection closed from "+remoteDetails);
|
||||||
var connectedSockets = [];
|
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
||||||
var server = net.createServer(function (socket) {
|
});
|
||||||
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
socket.on('error',function() {
|
||||||
node.log("connection from "+remoteDetails);
|
node.log("socket error from "+remoteDetails);
|
||||||
connectedSockets.push(socket);
|
|
||||||
socket.on('close',function() {
|
|
||||||
node.log("connection closed from "+remoteDetails);
|
|
||||||
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
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.listen(node.port);
|
||||||
server.close();
|
node.log('listening on port '+node.port);
|
||||||
node.log('stopped 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);
|
RED.nodes.registerType("tcp out",TcpOut);
|
||||||
|
|
||||||
TcpOut.prototype.close = function() {
|
|
||||||
this._close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -60,8 +60,9 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-operation"><i class="icon-wrench"></i> Operation</label>
|
<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;">
|
<select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;">
|
||||||
<option value=store>Store</option>
|
<option value=store>save</option>
|
||||||
<option value=delete>Delete</option>
|
<option value=insert>insert</option>
|
||||||
|
<option value=delete>remove</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row node-input-payonly">
|
<div class="form-row node-input-payonly">
|
||||||
@ -83,13 +84,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="mongodb out">
|
<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>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>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>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>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>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.
|
<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>
|
A blank object will delete <i>all of the objects</i> in the collection. You have been warned...</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -134,9 +135,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="mongodb in">
|
<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>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>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>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>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -42,19 +42,24 @@ function MongoOutNode(n) {
|
|||||||
if (err) { node.error(err); }
|
if (err) { node.error(err); }
|
||||||
else {
|
else {
|
||||||
node.clientDb.collection(node.collection,function(err,coll) {
|
node.clientDb.collection(node.collection,function(err,coll) {
|
||||||
if (err) { node.error(err); }
|
if (err) { node.error(err); }
|
||||||
else {
|
else {
|
||||||
node.on("input",function(msg) {
|
node.on("input",function(msg) {
|
||||||
if (node.operation == "store") {
|
if (node.operation == "store") {
|
||||||
delete msg._topic;
|
delete msg._topic;
|
||||||
if (node.payonly) coll.save(msg.payload,function(err,item){ if (err){node.error(err);} });
|
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 coll.save(msg,function(err,item){if (err){node.error(err);}});
|
||||||
}
|
}
|
||||||
if (node.operation == "delete") {
|
else if (node.operation == "insert") {
|
||||||
coll.remove(msg.payload, {w:1}, function(err, items){ if (err) node.error(err); });
|
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.error("missing mongodb configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
if (this.clientDb) {
|
if (this.clientDb) {
|
||||||
this.clientDb.close();
|
this.clientDb.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("mongodb out",MongoOutNode);
|
RED.nodes.registerType("mongodb out",MongoOutNode);
|
||||||
|
|
||||||
@ -105,10 +110,10 @@ function MongoInNode(n) {
|
|||||||
this.error("missing mongodb configuration");
|
this.error("missing mongodb configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
if (this.clientDb) {
|
if (this.clientDb) {
|
||||||
this.clientDb.close();
|
this.clientDb.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("mongodb in",MongoInNode);
|
RED.nodes.registerType("mongodb in",MongoInNode);
|
||||||
|
@ -160,7 +160,7 @@ RED.view = function() {
|
|||||||
.attr("height",0)
|
.attr("height",0)
|
||||||
.attr("class","lasso");
|
.attr("class","lasso");
|
||||||
d3.event.preventDefault();
|
d3.event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,6 +625,21 @@ RED.view = function() {
|
|||||||
d3.event.stopPropagation();
|
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() {
|
function redraw() {
|
||||||
vis.attr("transform","scale("+scaleFactor+")");
|
vis.attr("transform","scale("+scaleFactor+")");
|
||||||
outer.attr("width", space_width*scaleFactor).attr("height", space_height*scaleFactor);
|
outer.attr("width", space_width*scaleFactor).attr("height", space_height*scaleFactor);
|
||||||
@ -658,19 +673,18 @@ RED.view = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d._def.button) {
|
if (d._def.button) {
|
||||||
node.append('rect')
|
var nodeButtonGroup = node.append('svg:g')
|
||||||
.attr("class",function(d) { return (d._def.align == "right") ? "node_right_button_group" : "node_left_button_group"; })
|
.attr("transform",function(d) { return "translate("+((d._def.align == "right") ? 94 : -25)+",2)"; })
|
||||||
.attr("x",function(d) { return (d._def.align == "right") ? 94 : -25; })
|
.attr("class",function(d) { return "node_button "+((d._def.align == "right") ? "node_right_button" : "node_left_button"); });
|
||||||
.attr("y",2)
|
nodeButtonGroup.append('rect')
|
||||||
.attr("rx",8)
|
.attr("rx",8)
|
||||||
.attr("ry",8)
|
.attr("ry",8)
|
||||||
.attr("width",32)
|
.attr("width",32)
|
||||||
.attr("height",node_height-4)
|
.attr("height",node_height-4)
|
||||||
.attr("fill","#eee");//function(d) { return d._def.color;})
|
.attr("fill","#eee");//function(d) { return d._def.color;})
|
||||||
node.append('rect')
|
nodeButtonGroup.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"? 10:5})
|
||||||
.attr("x",function(d) { return (d._def.align == "right") ? 104 : -20; })
|
.attr("y",4)
|
||||||
.attr("y",6)
|
|
||||||
.attr("rx",5)
|
.attr("rx",5)
|
||||||
.attr("ry",5)
|
.attr("ry",5)
|
||||||
.attr("width",16)
|
.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("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("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("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("mouseout",function(d) {if (!lasso) {
|
||||||
.on("click",function(d) { d._def.button.onclick.call(d); d3.event.preventDefault(); })
|
var op = 1;
|
||||||
.on("touchstart",function(d) { d._def.button.onclick.call(d); d3.event.preventDefault(); })
|
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")
|
var mainRect = node.append("rect")
|
||||||
@ -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_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){
|
||||||
thisNode.selectAll('.node_right_button').attr("transform",function(d){return "translate("+(d.w-100)+","+0+")";}).attr("fill",function(d) {
|
var x = d.w-6;
|
||||||
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)
|
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('.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) {
|
thisNode.selectAll('text.node_badge_label').text(function(d,i) {
|
||||||
|
@ -329,10 +329,11 @@ a.brand img {
|
|||||||
stroke: #ff7f0e;
|
stroke: #ff7f0e;
|
||||||
}
|
}
|
||||||
.node_highlighted {
|
.node_highlighted {
|
||||||
stroke: #ff0000;
|
stroke: #dd1616;
|
||||||
|
stroke-width: 2;
|
||||||
|
stroke-dasharray: 10, 4;
|
||||||
}
|
}
|
||||||
.node_hovered {
|
.node_hovered {
|
||||||
dstroke: #ff7f0e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.port_hovered {
|
.port_hovered {
|
||||||
@ -425,11 +426,11 @@ button.input-append-right {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-tips {
|
.form-tips {
|
||||||
background: lightgoldenrodyellow;
|
background: lightgoldenrodyellow;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid #999;
|
border: 1px solid #999;
|
||||||
}
|
}
|
||||||
.form-tips code {
|
.form-tips code {
|
||||||
border: none;
|
border: none;
|
||||||
@ -563,7 +564,6 @@ div.node-info {
|
|||||||
#node-select-library li.list-hover {
|
#node-select-library li.list-hover {
|
||||||
background: #ffffd0;
|
background: #ffffd0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.node-text-editor {
|
.node-text-editor {
|
||||||
border:1px solid #ccc;
|
border:1px solid #ccc;
|
||||||
border-radius:5px;
|
border-radius:5px;
|
||||||
|
Loading…
Reference in New Issue
Block a user