mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
merge master
This commit is contained in:
commit
f82a779817
@ -1035,8 +1035,8 @@ RED.nodes = (function() {
|
|||||||
node.outputs = n.outputs||node._def.outputs;
|
node.outputs = n.outputs||node._def.outputs;
|
||||||
// If 'wires' is longer than outputs, clip wires
|
// If 'wires' is longer than outputs, clip wires
|
||||||
if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) {
|
if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) {
|
||||||
|
console.log("Warning: node.wires longer than node.outputs - trimming wires:",node.id," wires:",node.wires.length," outputs:",node.outputs);
|
||||||
node.wires = node.wires.slice(0,node.outputs);
|
node.wires = node.wires.slice(0,node.outputs);
|
||||||
wireClippedNodes.push(node);
|
|
||||||
}
|
}
|
||||||
for (d in node._def.defaults) {
|
for (d in node._def.defaults) {
|
||||||
if (node._def.defaults.hasOwnProperty(d)) {
|
if (node._def.defaults.hasOwnProperty(d)) {
|
||||||
|
@ -15,6 +15,25 @@
|
|||||||
**/
|
**/
|
||||||
var RED = (function() {
|
var RED = (function() {
|
||||||
|
|
||||||
|
function appendNodeConfig(nodeConfig) {
|
||||||
|
var m = /<!-- --- \[red-module:(\S+)\] --- -->/.exec(nodeConfig.trim());
|
||||||
|
var moduleId;
|
||||||
|
if (m) {
|
||||||
|
moduleId = m[1];
|
||||||
|
} else {
|
||||||
|
moduleId = "unknown";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$("body").append(nodeConfig);
|
||||||
|
} catch(err) {
|
||||||
|
RED.notify(RED._("notification.errors.failedToAppendNode",{module:moduleId, error:err.toString()}),{
|
||||||
|
type: "error",
|
||||||
|
timeout: 10000
|
||||||
|
});
|
||||||
|
console.log("["+moduleId+"] "+err.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadNodeList() {
|
function loadNodeList() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers: {
|
headers: {
|
||||||
@ -55,7 +74,11 @@ var RED = (function() {
|
|||||||
cache: false,
|
cache: false,
|
||||||
url: 'nodes',
|
url: 'nodes',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$("body").append(data);
|
var configs = data.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/);
|
||||||
|
configs.forEach(function(data) {
|
||||||
|
appendNodeConfig(data);
|
||||||
|
});
|
||||||
|
|
||||||
$("body").i18n();
|
$("body").i18n();
|
||||||
$("#palette > .palette-spinner").hide();
|
$("#palette > .palette-spinner").hide();
|
||||||
$(".palette-scroll").removeClass("hide");
|
$(".palette-scroll").removeClass("hide");
|
||||||
@ -296,7 +319,7 @@ var RED = (function() {
|
|||||||
addedTypes = addedTypes.concat(m.types);
|
addedTypes = addedTypes.concat(m.types);
|
||||||
RED.i18n.loadNodeCatalog(id, function() {
|
RED.i18n.loadNodeCatalog(id, function() {
|
||||||
$.get('nodes/'+id, function(data) {
|
$.get('nodes/'+id, function(data) {
|
||||||
$("body").append(data);
|
appendNodeConfig(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -324,7 +347,7 @@ var RED = (function() {
|
|||||||
RED.notify(RED._("palette.event.nodeEnabled", {count:msg.types.length})+typeList,"success");
|
RED.notify(RED._("palette.event.nodeEnabled", {count:msg.types.length})+typeList,"success");
|
||||||
} else {
|
} else {
|
||||||
$.get('nodes/'+msg.id, function(data) {
|
$.get('nodes/'+msg.id, function(data) {
|
||||||
$("body").append(data);
|
appendNodeConfig(data);
|
||||||
typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
|
typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
|
||||||
RED.notify(RED._("palette.event.nodeAdded", {count:msg.types.length})+typeList,"success");
|
RED.notify(RED._("palette.event.nodeAdded", {count:msg.types.length})+typeList,"success");
|
||||||
});
|
});
|
||||||
|
@ -106,7 +106,8 @@
|
|||||||
"lostConnectionTry": "Try now",
|
"lostConnectionTry": "Try now",
|
||||||
"cannotAddSubflowToItself": "Cannot add subflow to itself",
|
"cannotAddSubflowToItself": "Cannot add subflow to itself",
|
||||||
"cannotAddCircularReference": "Cannot add subflow - circular reference detected",
|
"cannotAddCircularReference": "Cannot add subflow - circular reference detected",
|
||||||
"unsupportedVersion": "Using an unsupported version of Node.js<br/>You should upgrade to the latest Node.js LTS release"
|
"unsupportedVersion": "<p>Using an unsupported version of Node.js</p><p>You should upgrade to the latest Node.js LTS release</p>",
|
||||||
|
"failedToAppendNode": "<p>Failed to load '__module__'</p><p>__error__</p>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"clipboard": {
|
"clipboard": {
|
||||||
|
@ -395,6 +395,7 @@ function getAllNodeConfigs(lang) {
|
|||||||
var id = nodeList[i];
|
var id = nodeList[i];
|
||||||
var config = moduleConfigs[getModule(id)].nodes[getNode(id)];
|
var config = moduleConfigs[getModule(id)].nodes[getNode(id)];
|
||||||
if (config.enabled && !config.err) {
|
if (config.enabled && !config.err) {
|
||||||
|
result += "\n<!-- --- [red-module:"+id+"] --- -->\n";
|
||||||
result += config.config;
|
result += config.config;
|
||||||
result += loader.getNodeHelp(config,lang||"en-US")||"";
|
result += loader.getNodeHelp(config,lang||"en-US")||"";
|
||||||
//script += config.script;
|
//script += config.script;
|
||||||
@ -417,7 +418,7 @@ function getNodeConfig(id,lang) {
|
|||||||
}
|
}
|
||||||
config = config.nodes[getNode(id)];
|
config = config.nodes[getNode(id)];
|
||||||
if (config) {
|
if (config) {
|
||||||
var result = config.config;
|
var result = "<!-- --- [red-module:"+id+"] --- -->\n"+config.config;
|
||||||
result += loader.getNodeHelp(config,lang||"en-US")
|
result += loader.getNodeHelp(config,lang||"en-US")
|
||||||
|
|
||||||
//if (config.script) {
|
//if (config.script) {
|
||||||
|
@ -381,9 +381,9 @@ describe("red/nodes/registry/registry",function() {
|
|||||||
types: [ "test-c","test-d"]
|
types: [ "test-c","test-d"]
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
typeRegistry.getNodeConfig("test-module/test-name").should.eql('configAHEtest-nameLP');
|
typeRegistry.getNodeConfig("test-module/test-name").should.eql('<!-- --- [red-module:test-module/test-name] --- -->\nconfigAHEtest-nameLP');
|
||||||
typeRegistry.getNodeConfig("test-module/test-name-2").should.eql('configBHEtest-name-2LP');
|
typeRegistry.getNodeConfig("test-module/test-name-2").should.eql('<!-- --- [red-module:test-module/test-name-2] --- -->\nconfigBHEtest-name-2LP');
|
||||||
typeRegistry.getAllNodeConfigs().should.eql('configAHEtest-nameLPconfigBHEtest-name-2LP');
|
typeRegistry.getAllNodeConfigs().should.eql('\n<!-- --- [red-module:test-module/test-name] --- -->\nconfigAHEtest-nameLP\n<!-- --- [red-module:test-module/test-name-2] --- -->\nconfigBHEtest-name-2LP');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getModuleInfo', function() {
|
describe('#getModuleInfo', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user