1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into dev

This commit is contained in:
Nick O'Leary 2021-05-12 16:00:36 +01:00
commit 5dbaaae68e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
14 changed files with 120 additions and 72 deletions

View File

@ -17,9 +17,8 @@ module.exports = {
})
} else {
opts.lang = apiUtils.determineLangFromHeaders(req.acceptsLanguages());
if (/[^a-z\-\*]/i.test(opts.lang)) {
res.json({});
return;
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
opts.lang = "en-US";
}
runtimeAPI.plugins.getPluginConfigs(opts).then(function(configs) {
res.send(configs);
@ -32,9 +31,8 @@ module.exports = {
lang: req.query.lng,
req: apiUtils.getRequestLogObject(req)
}
if (/[^a-z\-\*]/i.test(opts.lang)) {
res.json({});
return;
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
opts.lang = "en-US";
}
runtimeAPI.plugins.getPluginCatalogs(opts).then(function(result) {
res.json(result);

View File

@ -1260,22 +1260,27 @@ RED.clipboard = (function() {
hideDropTarget();
})
.on("drop",function(event) {
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
var data = event.originalEvent.dataTransfer.getData("text/plain");
data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
importNodes(data);
} else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
var files = event.originalEvent.dataTransfer.files;
if (files.length === 1) {
var file = files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
importNodes(e.target.result);
};
})(file);
reader.readAsText(file);
try {
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
var data = event.originalEvent.dataTransfer.getData("text/plain");
data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
importNodes(data);
} else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
var files = event.originalEvent.dataTransfer.files;
if (files.length === 1) {
var file = files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
importNodes(e.target.result);
};
})(file);
reader.readAsText(file);
}
}
} catch(err) {
// Ensure any errors throw above doesn't stop the drop target from
// being hidden.
}
hideDropTarget();
event.preventDefault();

View File

@ -100,7 +100,22 @@ RED.tabs = (function() {
if (options.scrollable) {
wrapper.addClass("red-ui-tabs-scrollable");
scrollContainer.addClass("red-ui-tabs-scroll-container");
scrollContainer.on("scroll",updateScroll);
scrollContainer.on("scroll",function(evt) {
// Generated by trackpads - not mousewheel
updateScroll(evt);
});
scrollContainer.on("wheel", function(evt) {
if (evt.originalEvent.deltaX === 0) {
// Prevent the scroll event from firing
evt.preventDefault();
// Assume this is wheel event which might not trigger
// the scroll event, so do things manually
var sl = scrollContainer.scrollLeft();
sl -= evt.originalEvent.deltaY;
scrollContainer.scrollLeft(sl);
}
})
scrollLeft = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-left"><a href="#" style="display:none;"><i class="fa fa-caret-left"></i></a></div>').appendTo(wrapper).find("a");
scrollLeft.on('mousedown',function(evt) { scrollEventHandler(evt,'-=150') }).on('click',function(evt){ evt.preventDefault();});
scrollRight = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-right"><a href="#" style="display:none;"><i class="fa fa-caret-right"></i></a></div>').appendTo(wrapper).find("a");

View File

@ -320,12 +320,12 @@ RED.palette = (function() {
var paletteNode = getPaletteNode(nt);
ui.originalPosition.left = paletteNode.offset().left;
mouseX = ui.position.left - paletteWidth + (ui.helper.width()/2) + chart.scrollLeft();
mouseY = ui.position.top - paletteTop + (ui.helper.height()/2) + chart.scrollTop();
mouseY = ui.position.top - paletteTop + (ui.helper.height()/2) + chart.scrollTop() + 10;
if (!groupTimer) {
groupTimer = setTimeout(function() {
mouseX /= RED.view.scale();
mouseY /= RED.view.scale();
var group = RED.view.getGroupAtPoint(mouseX,mouseY);
var mx = mouseX / RED.view.scale();
var my = mouseY / RED.view.scale();
var group = RED.view.getGroupAtPoint(mx,my);
if (group !== hoverGroup) {
if (hoverGroup) {
document.getElementById("group_select_"+hoverGroup.id).classList.remove("red-ui-flow-group-hovered");
@ -357,23 +357,20 @@ RED.palette = (function() {
svgRect.width = 1;
svgRect.height = 1;
nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
mouseX /= RED.view.scale();
mouseY /= RED.view.scale();
} else {
// Firefox doesn't do getIntersectionList and that
// makes us sad
mouseX /= RED.view.scale();
mouseY /= RED.view.scale();
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
}
var mx = mouseX / RED.view.scale();
var my = mouseY / RED.view.scale();
for (var i=0;i<nodes.length;i++) {
var node = d3.select(nodes[i]);
if (node.classed('red-ui-flow-link-background') && !node.classed('red-ui-flow-link-link')) {
var length = nodes[i].getTotalLength();
for (var j=0;j<length;j+=10) {
var p = nodes[i].getPointAtLength(j);
var d2 = ((p.x-mouseX)*(p.x-mouseX))+((p.y-mouseY)*(p.y-mouseY));
var d2 = ((p.x-mx)*(p.x-mx))+((p.y-my)*(p.y-my));
if (d2 < 200 && d2 < bestDistance) {
bestDistance = d2;
bestLink = nodes[i];

View File

@ -199,7 +199,7 @@ RED.sidebar = (function() {
id = RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0]
}
if (id) {
if (!containsTab(id)) {
if (!containsTab(id) && knownTabs[id]) {
sidebar_tabs.addTab(knownTabs[id]);
}
sidebar_tabs.activateTab(id);

View File

@ -477,7 +477,7 @@ RED.sidebar.info = (function() {
return;
}
}
while ((m=/(\[(.*?)\])/.exec(tip))) {
while ((m=/(\[([a-z]*?)\])/.exec(tip))) {
tip = tip.replace(m[1],RED.keyboard.formatKey(m[2]));
}
tipBox.html(tip).fadeIn(200);

View File

@ -1476,15 +1476,15 @@ RED.view = (function() {
var mouseY = node.n.y;
if (outer[0][0].getIntersectionList) {
var svgRect = outer[0][0].createSVGRect();
svgRect.x = mouseX;
svgRect.y = mouseY;
svgRect.x = mouseX*scaleFactor;
svgRect.y = mouseY*scaleFactor;
svgRect.width = 1;
svgRect.height = 1;
nodes = outer[0][0].getIntersectionList(svgRect, outer[0][0]);
} else {
// Firefox doesn"t do getIntersectionList and that
// makes us sad
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
nodes = RED.view.getLinksAtPoint(mouseX*scaleFactor,mouseY*scaleFactor);
}
for (var i=0;i<nodes.length;i++) {
if (d3.select(nodes[i]).classed("red-ui-flow-link-background")) {
@ -3445,6 +3445,7 @@ RED.view = (function() {
}
}
function getGroupAt(x,y) {
// x,y expected to be in node-co-ordinate space
var candidateGroups = {};
for (var i=0;i<activeGroups.length;i++) {
var g = activeGroups[i];
@ -5081,6 +5082,9 @@ RED.view = (function() {
return scaleFactor;
},
getLinksAtPoint: function(x,y) {
// x,y must be in SVG co-ordinate space
// if they come from a node.x/y, they will need to be scaled using
// scaleFactor first.
var result = [];
var links = outer.selectAll(".red-ui-flow-link-background")[0];
for (var i=0;i<links.length;i++) {

View File

@ -25,7 +25,7 @@
.red-ui-notification {
box-sizing: border-box;
position: relative;
padding: 14px 18px;
padding: 8px 18px 0px;
margin-bottom: 4px;
box-shadow: 0 1px 1px 1px $shadow;
background-color: $secondary-background;
@ -35,6 +35,7 @@
overflow: hidden;
.ui-dialog-buttonset {
margin-top: 20px;
margin-bottom: 10px;
}
}
.red-ui-notification p:first-child {

View File

@ -636,7 +636,7 @@
url: "inject/"+this.id,
type:"POST",
success: function(resp) {
RED.notify(node._("inject.success",{label:label}),{type:"success",id:"inject"});
RED.notify(node._("inject.success",{label:label}),{type:"success",id:"inject", timeout: 2000});
},
error: function(jqXHR,textStatus,errorThrown) {
if (jqXHR.status == 404) {

View File

@ -129,9 +129,9 @@
RED.history.push(historyEvent);
RED.view.redraw();
if (xhr.status == 200) {
RED.notify(node._("debug.notification.activated",{label:label}),"success");
RED.notify(node._("debug.notification.activated",{label:label}),{type: "success", timeout: 2000});
} else if (xhr.status == 201) {
RED.notify(node._("debug.notification.deactivated",{label:label}),"success");
RED.notify(node._("debug.notification.deactivated",{label:label}),{type: "success", timeout: 2000});
}
});
}

View File

@ -1,18 +1,18 @@
[
{
"id": "2ebdd51e.c5d17a",
"id": "b05816ab.7f2b08",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert array of JavaScript objects to CSV with column name header",
"info": "CSV node can convert an array of JavaScript objects to multi-line CSV text with column name header at first line.",
"x": 390,
"y": 1200,
"z": "c6ffdacd.d887e8",
"name": "Specify column names in input message",
"info": "Column names can be specified by `columns` property of incoming message.\n",
"x": 240,
"y": 200,
"wires": []
},
{
"id": "2b4d538d.ada07c",
"id": "39205b5c.690684",
"type": "inject",
"z": "4b63452d.672afc",
"z": "c6ffdacd.d887e8",
"name": "",
"props": [
{
@ -30,41 +30,41 @@
"topic": "",
"payload": "",
"payloadType": "date",
"x": 260,
"y": 1260,
"x": 200,
"y": 260,
"wires": [
[
"3e5c9e8.5065b62"
"526b59ba.2fa068"
]
]
},
{
"id": "db02c7be.0984e8",
"id": "b78a407e.2d083",
"type": "csv",
"z": "4b63452d.672afc",
"z": "c6ffdacd.d887e8",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "all",
"multi": "one",
"ret": "\\n",
"temp": "kind,price",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 600,
"y": 1260,
"x": 750,
"y": 260,
"wires": [
[
"61f8b772.ddb1f8"
"8b7084dd.986f68"
]
]
},
{
"id": "3e5c9e8.5065b62",
"id": "526b59ba.2fa068",
"type": "template",
"z": "4b63452d.672afc",
"z": "c6ffdacd.d887e8",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
@ -72,18 +72,18 @@
"syntax": "plain",
"template": "[\n {\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n },\n {\n \"kind\": \"Orange\",\n \"price\": 120,\n \"origin\": \"USA\"\n },\n {\n \"kind\": \"Banana\",\n \"price\": 80,\n \"origin\": \"Philippines\"\n }\n]",
"output": "json",
"x": 430,
"y": 1260,
"x": 370,
"y": 260,
"wires": [
[
"db02c7be.0984e8"
"b204077a.227778"
]
]
},
{
"id": "61f8b772.ddb1f8",
"id": "8b7084dd.986f68",
"type": "debug",
"z": "4b63452d.672afc",
"z": "c6ffdacd.d887e8",
"name": "",
"active": true,
"tosidebar": true,
@ -92,8 +92,35 @@
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 1260,
"x": 930,
"y": 260,
"wires": []
},
{
"id": "b204077a.227778",
"type": "change",
"z": "c6ffdacd.d887e8",
"name": "",
"rules": [
{
"t": "set",
"p": "columns",
"pt": "msg",
"to": "kind,price",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 260,
"wires": [
[
"b78a407e.2d083"
]
]
}
]

View File

@ -21,9 +21,10 @@
the body of the message.</p>
<p>The function is expected to return a message object (or multiple message objects), but can choose
to return nothing in order to halt a flow.</p>
<p>The <b>Setup</b> tab contains code that will be run whenever the node is started.
The <b>Close</b> tab contains code that will be run when the node is stopped.</p>
<p>If an promise object is returned from the setup code, input message processing starts after its completion.</p>
<p>The <b>On Start</b> tab contains code that will be run whenever the node is started.
The <b>On Stop</b> tab contains code that will be run when the node is stopped.</p>
<p>If the On Start code returns a Promise object, the node will not start handling messages
until the promise is resolved.</p>
<h3>Details</h3>
<p>See the <a target="_blank" href="http://nodered.org/docs/writing-functions.html">online documentation</a>
for more information on writing functions.</p>

View File

@ -58,7 +58,7 @@ var api = module.exports = {
* @memberof @node-red/runtime_plugins
*/
getPluginConfigs: async function(opts) {
if (/[^a-z\-]/i.test(opts.lang)) {
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
throw new Error("Invalid language: "+opts.lang)
return;
}

View File

@ -220,7 +220,7 @@ var reinstallTimeout;
function reinstallModules(moduleList) {
const promises = [];
const reinstallList = [];
const installRetry = 30000;
var installRetry = 30000;
if (settings.hasOwnProperty('autoInstallModulesRetry')) {
log.warn(log._("server.deprecatedOption",{old:"autoInstallModulesRetry", new:"externalModules.autoInstallRetry"}));
installRetry = settings.autoInstallModulesRetry;