mirror of https://github.com/node-red/node-red.git
Merge branch 'master' into dev
commit
5511b27855
|
@ -44,6 +44,51 @@ RED.nodes = (function() {
|
||||||
|
|
||||||
var dirty = false;
|
var dirty = false;
|
||||||
|
|
||||||
|
const internalProperties = [
|
||||||
|
"changed",
|
||||||
|
"dirty",
|
||||||
|
"id",
|
||||||
|
"inputLabels",
|
||||||
|
"moved",
|
||||||
|
"outputLabels",
|
||||||
|
"selected",
|
||||||
|
"type",
|
||||||
|
"users",
|
||||||
|
"valid",
|
||||||
|
"validationErrors",
|
||||||
|
"wires",
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"d",
|
||||||
|
"e",
|
||||||
|
"f",
|
||||||
|
"g",
|
||||||
|
"h",
|
||||||
|
"i",
|
||||||
|
"j",
|
||||||
|
"k",
|
||||||
|
"l",
|
||||||
|
"m",
|
||||||
|
"n",
|
||||||
|
"o",
|
||||||
|
"p",
|
||||||
|
"q",
|
||||||
|
"r",
|
||||||
|
"s",
|
||||||
|
"t",
|
||||||
|
"u",
|
||||||
|
"v",
|
||||||
|
"w",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"_",
|
||||||
|
"_config",
|
||||||
|
"_def",
|
||||||
|
"_orig"
|
||||||
|
];
|
||||||
|
|
||||||
function setDirty(d) {
|
function setDirty(d) {
|
||||||
dirty = d;
|
dirty = d;
|
||||||
if (!d) {
|
if (!d) {
|
||||||
|
@ -231,7 +276,6 @@ RED.nodes = (function() {
|
||||||
def.type = nt;
|
def.type = nt;
|
||||||
nodeDefinitions[nt] = def;
|
nodeDefinitions[nt] = def;
|
||||||
|
|
||||||
|
|
||||||
if (def.defaults) {
|
if (def.defaults) {
|
||||||
for (var d in def.defaults) {
|
for (var d in def.defaults) {
|
||||||
if (def.defaults.hasOwnProperty(d)) {
|
if (def.defaults.hasOwnProperty(d)) {
|
||||||
|
@ -242,6 +286,11 @@ RED.nodes = (function() {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (internalProperties.includes(d)) {
|
||||||
|
console.warn(`registerType: ${nt}: the property "${d}" is internal and cannot be used.`);
|
||||||
|
delete def.defaults[d];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,16 @@ module.exports = function(RED) {
|
||||||
function CompleteNode(n) {
|
function CompleteNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
var node = this;
|
var node = this;
|
||||||
this.scope = n.scope;
|
this.scope = n.scope || [];
|
||||||
|
|
||||||
|
// auto-filter out any directly connected nodes to avoid simple loopback
|
||||||
|
const w = this.wires.flat();
|
||||||
|
for (let i=0; i < this.scope.length; i++) {
|
||||||
|
if (w.includes(this.scope[i])) {
|
||||||
|
this.scope.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.on("input",function(msg, send, done) {
|
this.on("input",function(msg, send, done) {
|
||||||
send(msg);
|
send(msg);
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -20,7 +20,16 @@ module.exports = function(RED) {
|
||||||
function StatusNode(n) {
|
function StatusNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
var node = this;
|
var node = this;
|
||||||
this.scope = n.scope;
|
this.scope = n.scope || [];
|
||||||
|
|
||||||
|
// auto-filter out any directly connected nodes to avoid simple loopback
|
||||||
|
const w = this.wires.flat();
|
||||||
|
for (let i=0; i < this.scope.length; i++) {
|
||||||
|
if (w.includes(this.scope[i])) {
|
||||||
|
this.scope.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.on("input", function(msg, send, done) {
|
this.on("input", function(msg, send, done) {
|
||||||
send(msg);
|
send(msg);
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -675,7 +675,7 @@ module.exports = function(RED) {
|
||||||
node.options.password = node.password;
|
node.options.password = node.password;
|
||||||
node.options.keepalive = node.keepalive;
|
node.options.keepalive = node.keepalive;
|
||||||
node.options.clean = node.cleansession;
|
node.options.clean = node.cleansession;
|
||||||
node.options.clientId = node.clientid || 'nodered_' + RED.util.generateId();
|
node.options.clientId = node.clientid || 'nodered' + RED.util.generateId();
|
||||||
node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
||||||
delete node.options.protocolId; //V4+ default
|
delete node.options.protocolId; //V4+ default
|
||||||
delete node.options.protocolVersion; //V4 default
|
delete node.options.protocolVersion; //V4 default
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<p>Wenn <code>msg.payload</code> ein Objekt ist, setzt der Node automatisch den Inhaltstyp der Anforderung
|
<p>Wenn <code>msg.payload</code> ein Objekt ist, setzt der Node automatisch den Inhaltstyp der Anforderung
|
||||||
auf <code>application/json</code> und kodiert den Hauptteil als solchen.</p>
|
auf <code>application/json</code> und kodiert den Hauptteil als solchen.</p>
|
||||||
<p>Um die Anforderung als Formulardaten zu kodieren, sollte <code>msg.headers["content-type"]</code> auf
|
<p>Um die Anforderung als Formulardaten zu kodieren, sollte <code>msg.headers["content-type"]</code> auf
|
||||||
<code>application/x-wwww-form-urlencoded</code> gesetzt werden.</p>
|
<code>application/x-www-form-urlencoded</code> gesetzt werden.</p>
|
||||||
<h4><b>Datei-Upload</b></h4>
|
<h4><b>Datei-Upload</b></h4>
|
||||||
<p>Um einen Datei-Upload umzusetzen, sollte <code>msg.headers["content-type"]</code> auf <code>multipart/form-data</code>
|
<p>Um einen Datei-Upload umzusetzen, sollte <code>msg.headers["content-type"]</code> auf <code>multipart/form-data</code>
|
||||||
gesetzt werden und das an den Node zu sendende <code>msg.payload</code> muss ein Objekt mit folgender Struktur sein:</p>
|
gesetzt werden und das an den Node zu sendende <code>msg.payload</code> muss ein Objekt mit folgender Struktur sein:</p>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
var should = require("should");
|
||||||
|
var catchNode = require("nr-test-utils").require("@node-red/nodes/core/common/24-complete.js");
|
||||||
|
var helper = require("node-red-node-test-helper");
|
||||||
|
|
||||||
|
describe('complete Node', function() {
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
helper.unload();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should output a message when called', function(done) {
|
||||||
|
var flow = [ { id:"n1", type:"complete", name:"status", wires:[["n2"]], scope:[] },
|
||||||
|
{id:"n2", type:"helper"} ];
|
||||||
|
helper.load(catchNode, flow, function() {
|
||||||
|
var n1 = helper.getNode("n1");
|
||||||
|
var n2 = helper.getNode("n2");
|
||||||
|
n1.should.have.property('name', 'status');
|
||||||
|
n2.on("input", function(msg) {
|
||||||
|
msg.text.should.equal("Oh dear");
|
||||||
|
msg.should.have.property('source');
|
||||||
|
msg.source.should.have.property('id',"12345");
|
||||||
|
msg.source.should.have.property('type',"testnode");
|
||||||
|
msg.source.should.have.property('name',"fred");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
var mst = {
|
||||||
|
text: "Oh dear",
|
||||||
|
source: {
|
||||||
|
id: "12345",
|
||||||
|
type: "testnode",
|
||||||
|
name: "fred"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n1.emit("input", mst);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -25,7 +25,7 @@ describe('status Node', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should output a message when called', function(done) {
|
it('should output a message when called', function(done) {
|
||||||
var flow = [ { id:"n1", type:"status", name:"status", wires:[["n2"]] },
|
var flow = [ { id:"n1", type:"status", name:"status", wires:[["n2"]], scope:[] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(catchNode, flow, function() {
|
helper.load(catchNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
|
|
|
@ -58,7 +58,7 @@ describe('MQTT Nodes', function () {
|
||||||
mqttBroker.should.have.property('options');
|
mqttBroker.should.have.property('options');
|
||||||
mqttBroker.options.should.have.property('clean', true);
|
mqttBroker.options.should.have.property('clean', true);
|
||||||
mqttBroker.options.should.have.property('clientId');
|
mqttBroker.options.should.have.property('clientId');
|
||||||
mqttBroker.options.clientId.should.containEql('nodered_');
|
mqttBroker.options.clientId.should.containEql('nodered');
|
||||||
mqttBroker.options.should.have.property('keepalive').type("number");
|
mqttBroker.options.should.have.property('keepalive').type("number");
|
||||||
mqttBroker.options.should.have.property('reconnectPeriod').type("number");
|
mqttBroker.options.should.have.property('reconnectPeriod').type("number");
|
||||||
//as this is not a v5 connection, ensure v5 properties are not present
|
//as this is not a v5 connection, ensure v5 properties are not present
|
||||||
|
@ -894,4 +894,4 @@ function nextTopic(topic) {
|
||||||
return (base_topic + topic + String(topicNo));
|
return (base_topic + topic + String(topicNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion HELPERS
|
//#endregion HELPERS
|
||||||
|
|
Loading…
Reference in New Issue