mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Compare commits
31 Commits
v-flow
...
filein-clo
Author | SHA1 | Date | |
---|---|---|---|
|
7c4e782c60 | ||
|
c8b8beda6a | ||
|
6026da867b | ||
|
4d58902ba7 | ||
|
4dc1343445 | ||
|
080487cb33 | ||
|
0febcf4f9e | ||
|
cd23f711ed | ||
|
f9b147af42 | ||
|
775f1110d3 | ||
|
57649a9b81 | ||
|
72a268b70a | ||
|
f86a171dff | ||
|
e022b782a9 | ||
|
bd67731bb7 | ||
|
25de4e4782 | ||
|
c590247afa | ||
|
5d36539271 | ||
|
0d673486a3 | ||
|
29f1651a18 | ||
|
dd20a3e685 | ||
|
75a5b1354c | ||
|
dae9ac8173 | ||
|
78b735276b | ||
|
e10dd54e2b | ||
|
cb8deab1f9 | ||
|
e5c27d0236 | ||
|
873bdc6733 | ||
|
8a40b075b5 | ||
|
56c41374bf | ||
|
a08c2c6437 |
@@ -16,6 +16,7 @@
|
||||
|
||||
var path = require("path");
|
||||
var fs = require("fs-extra");
|
||||
var sass = require("node-sass");
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
@@ -220,6 +221,7 @@ module.exports = function(grunt) {
|
||||
sass: {
|
||||
build: {
|
||||
options: {
|
||||
implementation: sass,
|
||||
outputStyle: 'compressed'
|
||||
},
|
||||
files: [{
|
||||
|
13
package.json
13
package.json
@@ -41,13 +41,13 @@
|
||||
"fs-extra": "8.1.0",
|
||||
"fs.notify": "0.0.4",
|
||||
"hash-sum": "2.0.0",
|
||||
"https-proxy-agent": "2.2.2",
|
||||
"https-proxy-agent": "2.2.3",
|
||||
"i18next": "15.1.2",
|
||||
"iconv-lite": "0.5.0",
|
||||
"is-utf8": "0.2.1",
|
||||
"js-yaml": "3.13.1",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"jsonata": "1.6.5",
|
||||
"jsonata": "1.7.0",
|
||||
"media-typer": "1.1.0",
|
||||
"memorystore": "1.6.1",
|
||||
"mime": "2.4.4",
|
||||
@@ -93,19 +93,20 @@
|
||||
"grunt-mocha-istanbul": "5.0.2",
|
||||
"grunt-nodemon": "~0.4.2",
|
||||
"grunt-npm-command": "~0.1.2",
|
||||
"grunt-sass": "~2.0.0",
|
||||
"grunt-sass": "~3.1.0",
|
||||
"grunt-simple-mocha": "~0.4.1",
|
||||
"http-proxy": "^1.16.2",
|
||||
"istanbul": "0.4.5",
|
||||
"jsdoc-nr-template": "github:node-red/jsdoc-nr-template",
|
||||
"minami": "1.2.3",
|
||||
"mocha": "^5.2.0",
|
||||
"mosca": "^2.8.3",
|
||||
"node-red-node-test-helper": "^0.2.3",
|
||||
"node-sass": "^4.13.0",
|
||||
"should": "^8.4.0",
|
||||
"sinon": "1.17.7",
|
||||
"stoppable": "^1.1.0",
|
||||
"supertest": "3.4.2",
|
||||
"node-red-node-test-helper": "^0.2.3",
|
||||
"jsdoc-nr-template": "node-red/jsdoc-nr-template"
|
||||
"supertest": "3.4.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
|
@@ -15,7 +15,7 @@
|
||||
**/
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
//var apiUtil = require('../util');
|
||||
// var apiUtil = require('../util');
|
||||
|
||||
var i18n = require("@node-red/util").i18n; // TODO: separate module
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = {
|
||||
var namespace = req.params[0];
|
||||
var lngs = req.query.lng;
|
||||
namespace = namespace.replace(/\.json$/,"");
|
||||
var lang = req.query.lng; //apiUtil.determineLangFromHeaders(req.acceptsLanguages() || []);
|
||||
var lang = req.query.lng || i18n.defaultLang; //apiUtil.determineLangFromHeaders(req.acceptsLanguages() || []);
|
||||
var prevLang = i18n.i.language;
|
||||
// Trigger a load from disk of the language if it is not the default
|
||||
i18n.i.changeLanguage(lang, function(){
|
||||
|
@@ -42,7 +42,7 @@ var editor;
|
||||
/**
|
||||
* Initialise the module.
|
||||
* @param {Object} settings The runtime settings
|
||||
* @param {HTTPServer} server An instance of HTTP Server
|
||||
* @param {HTTPServer} _server An instance of HTTP Server
|
||||
* @param {Storage} storage An instance of Node-RED Storage
|
||||
* @param {Runtime} runtimeAPI An instance of Node-RED Runtime
|
||||
* @memberof @node-red/editor-api
|
||||
|
@@ -45,8 +45,7 @@
|
||||
"rtl": "Right-to-left",
|
||||
"auto": "Contextual",
|
||||
"language": "Language",
|
||||
"browserDefault": "Browser default",
|
||||
"flowVertical": "Vertical flow"
|
||||
"browserDefault": "Browser default"
|
||||
},
|
||||
"sidebar": {
|
||||
"show": "Show sidebar"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$string": {
|
||||
"args": "arg",
|
||||
"desc": "Casts the *arg* parameter to a string using the following casting rules:\n\n - Strings are unchanged\n - Functions are converted to an empty string\n - Numeric infinity and NaN throw an error because they cannot be represented as a JSON number\n - All other values are converted to a JSON string using the `JSON.stringify` function"
|
||||
"args": "arg[, prettify]",
|
||||
"desc": "Casts the `arg` parameter to a string using the following casting rules:\n\n - Strings are unchanged\n - Functions are converted to an empty string\n - Numeric infinity and NaN throw an error because they cannot be represented as a JSON number\n - All other values are converted to a JSON string using the `JSON.stringify` function. If `prettify` is true, then \"prettified\" JSON is produced. i.e One line per field and lines will be indented based on the field depth."
|
||||
},
|
||||
"$length": {
|
||||
"args": "str",
|
||||
@@ -185,7 +185,7 @@
|
||||
},
|
||||
"$reduce": {
|
||||
"args":"array, function [, init]",
|
||||
"desc":"Returns an aggregated value derived from applying the `function` parameter successively to each value in `array` in combination with the result of the previous application of the function.\n\nThe function must accept two arguments, and behaves like an infix operator between each value within the `array`.\n\nThe optional `init` parameter is used as the initial value in the aggregation."
|
||||
"desc":"Returns an aggregated value derived from applying the `function` parameter successively to each value in `array` in combination with the result of the previous application of the function.\n\nThe function must accept two arguments, and behaves like an infix operator between each value within the `array`. The signature of `function` must be of the form: `myfunc($accumulator, $value[, $index[, $array]])`\n\nThe optional `init` parameter is used as the initial value in the aggregation."
|
||||
},
|
||||
"$flowContext": {
|
||||
"args": "string[, string]",
|
||||
@@ -230,6 +230,37 @@
|
||||
"$parseInteger": {
|
||||
"args": "string, picture",
|
||||
"desc": "Parses the contents of the `string` parameter to an integer (as a JSON number) using the format specified by the `picture` string. The `picture` string parameter has the same format as `$formatInteger`."
|
||||
|
||||
},
|
||||
"$error": {
|
||||
"args": "[str]",
|
||||
"desc": "Throws an error with a message. The optional `str` will replace the default message of `$error() function evaluated`"
|
||||
},
|
||||
"$assert": {
|
||||
"args": "arg, str",
|
||||
"desc": "If `arg` is true the function returns undefined. If `arg` is false an exception is thrown with `str` as the message of the exception."
|
||||
},
|
||||
"$single": {
|
||||
"args": "array, function",
|
||||
"desc": "Returns the one and only value in the `array` parameter that satisfies the `function` predicate (i.e. the `function` returns Boolean `true` when passed the value). Throws an exception if the number of matching values is not exactly one.\n\nThe function should be supplied in the following signature: `function(value [, index [, array]])` where value is each input of the array, index is the position of that value and the whole array is passed as the third argument"
|
||||
},
|
||||
"$encodeUrl": {
|
||||
"args": "str",
|
||||
"desc": "Encodes a Uniform Resource Locator (URL) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.\n\nExample: `$encodeUrlComponent(\"?x=test\")` => `\"%3Fx%3Dtest\"`"
|
||||
},
|
||||
"$encodeUrlComponent": {
|
||||
"args": "str",
|
||||
"desc": "Encodes a Uniform Resource Locator (URL) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. \n\nExample: `$encodeUrl(\"https://mozilla.org/?x=шеллы\")` => `\"https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\"`"
|
||||
},
|
||||
"$decodeUrl": {
|
||||
"args": "str",
|
||||
"desc": "Decodes a Uniform Resource Locator (URL) component previously created by encodeUrlComponent. \n\nExample: `$decodeUrlComponent(\"%3Fx%3Dtest\")` => `\"?x=test\"`"
|
||||
},
|
||||
"$decodeUrlComponent": {
|
||||
"args": "str",
|
||||
"desc": "Decodes a Uniform Resource Locator (URL) previously created by encodeUrl. \n\nExample: `$decodeUrl(\"https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\")` => `\"https://mozilla.org/?x=шеллы\"`"
|
||||
},
|
||||
"$distinct": {
|
||||
"args": "array",
|
||||
"desc": "Returns an array with duplicate values removed from `array`"
|
||||
}
|
||||
}
|
||||
|
@@ -45,8 +45,7 @@
|
||||
"rtl": "右から左",
|
||||
"auto": "文脈",
|
||||
"language": "表示言語",
|
||||
"browserDefault": "ブラウザのデフォルト",
|
||||
"flowVertical": "縦フロー"
|
||||
"browserDefault": "ブラウザのデフォルト"
|
||||
},
|
||||
"sidebar": {
|
||||
"show": "サイドバーを表示"
|
||||
|
@@ -36,8 +36,7 @@
|
||||
"defaultDir": "默认方向",
|
||||
"ltr": "从左到右",
|
||||
"rtl": "从右到左",
|
||||
"auto": "上下文",
|
||||
"flowVertical": "Vertical flow"
|
||||
"auto": "上下文"
|
||||
},
|
||||
"sidebar": {
|
||||
"show": "显示侧边栏"
|
||||
|
@@ -2558,7 +2558,7 @@ RED.editor = (function() {
|
||||
/**
|
||||
* Register a type editor.
|
||||
* @param {string} type - the type name
|
||||
* @param {object} options - the editor definition
|
||||
* @param {object} definition - the editor definition
|
||||
* @function
|
||||
* @memberof RED.editor
|
||||
*/
|
||||
|
@@ -788,7 +788,7 @@ RED.palette.editor = (function() {
|
||||
initInstallTab();
|
||||
})
|
||||
|
||||
packageList = $('<ol>',{style:"position: absolute;top: 78px;bottom: 0;left: 0;right: 0px;"}).appendTo(installTab).editableList({
|
||||
packageList = $('<ol>',{style:"position: absolute;top: 79px;bottom: 0;left: 0;right: 0px;"}).appendTo(installTab).editableList({
|
||||
addButton: false,
|
||||
scrollOnAdd: false,
|
||||
addItem: function(container,i,object) {
|
||||
|
@@ -139,14 +139,7 @@ RED.palette = (function() {
|
||||
var labelElement = el.find(".red-ui-palette-label");
|
||||
labelElement.html(lines).attr('dir', RED.text.bidi.resolveBaseTextDir(lines));
|
||||
|
||||
if (RED.view.vertical()) {
|
||||
// el.find(".red-ui-palette-port").css({top:(multiLineNodeHeight/2-5)+"px", left: "55px"});
|
||||
// el.find(".red-ui-palette-port-output").css({top:(multiLineNodeHeight-5)+"px", right: "55px"});
|
||||
// el.find(".red-ui-palette-port-input").css({top: "-5px"});
|
||||
}else{
|
||||
el.find(".red-ui-palette-port").css({top:(multiLineNodeHeight/2-5)+"px"});
|
||||
// el.find(".palette_port_output").css({top:(multiLineNodeHeight/2-5)+"px", right: "-6px", left: "auto"});
|
||||
}
|
||||
el.find(".red-ui-palette-port").css({top:(multiLineNodeHeight/2-5)+"px"});
|
||||
|
||||
var popOverContent;
|
||||
try {
|
||||
@@ -235,19 +228,16 @@ RED.palette = (function() {
|
||||
|
||||
d.css("backgroundColor", RED.utils.getNodeColor(nt,def));
|
||||
|
||||
if (!RED.view.vertical()) {
|
||||
if (def.outputs > 0) {
|
||||
var portOut = document.createElement("div");
|
||||
portOut.className = "red-ui-palette-port red-ui-palette-port-output";
|
||||
d.append(portOut);
|
||||
}
|
||||
|
||||
if (def.outputs > 0) {
|
||||
var portOut = document.createElement("div");
|
||||
portOut.className = "red-ui-palette-port red-ui-palette-port-output";
|
||||
d.append(portOut);
|
||||
}
|
||||
|
||||
if (def.inputs > 0) {
|
||||
var portIn = document.createElement("div");
|
||||
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
|
||||
d.append(portIn);
|
||||
}
|
||||
if (def.inputs > 0) {
|
||||
var portIn = document.createElement("div");
|
||||
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
|
||||
d.append(portIn);
|
||||
}
|
||||
|
||||
createCategory(nodeCategory,rootCategory,category,(coreCategories.indexOf(rootCategory) !== -1)?"node-red":def.set.id);
|
||||
|
@@ -802,8 +802,8 @@ RED.subflow = (function() {
|
||||
}
|
||||
$("<option/>", opt).text(item.text).appendTo(locales);
|
||||
});
|
||||
currentLocale = RED.i18n.lang();
|
||||
locales.val(currentLocale);
|
||||
var locale = RED.i18n.lang();
|
||||
locales.val(locale);
|
||||
|
||||
locales.on("change", function() {
|
||||
currentLocale = $(this).val();
|
||||
@@ -1048,7 +1048,7 @@ RED.subflow = (function() {
|
||||
}
|
||||
langs.forEach(function(l) {
|
||||
var row = $('<div>').appendTo(content);
|
||||
$('<span>').css({display:"inline-block",width:"50px"}).text(l+(l===currentLocale?"*":"")).appendTo(row);
|
||||
$('<span>').css({display:"inline-block",width:"120px"}).text(RED._("languages."+l)+(l===currentLocale?"*":"")).appendTo(row);
|
||||
$('<span>').text(ui.label[l]||"").appendTo(row);
|
||||
});
|
||||
return content;
|
||||
@@ -1371,7 +1371,8 @@ RED.subflow = (function() {
|
||||
}
|
||||
|
||||
var labels = ui.label || {};
|
||||
var labelText = lookupLabel(labels, labels["en-US"]||tenv.name, currentLocale);
|
||||
var locale = RED.i18n.lang();
|
||||
var labelText = lookupLabel(labels, labels["en-US"]||tenv.name, locale);
|
||||
var label = $('<label>').appendTo(row);
|
||||
var labelContainer = $('<span></span>').appendTo(label);
|
||||
if (ui.icon) {
|
||||
@@ -1423,7 +1424,7 @@ RED.subflow = (function() {
|
||||
input = $('<select>').css('width','70%').appendTo(row);
|
||||
if (ui.opts.opts) {
|
||||
ui.opts.opts.forEach(function(o) {
|
||||
$('<option>').val(o.v).text(lookupLabel(o.l, o.l['en-US']||o.v, currentLocale)).appendTo(input);
|
||||
$('<option>').val(o.v).text(lookupLabel(o.l, o.l['en-US']||o.v, locale)).appendTo(input);
|
||||
})
|
||||
}
|
||||
input.val(val.value);
|
||||
|
@@ -384,17 +384,7 @@ RED.typeSearch = (function() {
|
||||
|
||||
return {
|
||||
show: show,
|
||||
refresh: function(opts) {
|
||||
if (opts.x && opts.y) {
|
||||
if ($("#red-ui-main-container").height() - opts.y - 150 < 0) {
|
||||
opts.y = opts.y - 235;
|
||||
}
|
||||
dialog.css({left:opts.x+"px",top:opts.y+"px"}).show();
|
||||
}
|
||||
if (opts.filter) {
|
||||
refreshTypeList(opts);
|
||||
}
|
||||
},
|
||||
refresh: refreshTypeList,
|
||||
hide: hide
|
||||
};
|
||||
|
||||
|
@@ -133,8 +133,7 @@ RED.userSettings = (function() {
|
||||
{
|
||||
title: "menu.label.other",
|
||||
options: [
|
||||
{setting:"view-show-tips",oldSettings:"menu-menu-item-show-tips",label:"menu.label.showTips",toggle:true,default:true,onchange:"core:toggle-show-tips"},
|
||||
{setting:"view-flow-vertical",label:"menu.label.view.flowVertical",toggle:true,default:false,onchange:RED.view.vertical}
|
||||
{setting:"view-show-tips",oldSettings:"menu-menu-item-show-tips",label:"menu.label.showTips",toggle:true,default:true,onchange:"core:toggle-show-tips"}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
373
packages/node_modules/@node-red/editor-client/src/js/ui/view.js
vendored
Normal file → Executable file
373
packages/node_modules/@node-red/editor-client/src/js/ui/view.js
vendored
Normal file → Executable file
@@ -44,7 +44,6 @@ RED.view = (function() {
|
||||
|
||||
var gridSize = 20;
|
||||
var snapGrid = false;
|
||||
var vertical = false;
|
||||
|
||||
var activeSpliceLink;
|
||||
var spliceActive = false;
|
||||
@@ -596,112 +595,6 @@ RED.view = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function generateLinkPathV(origX,origY, destX, destY, sc) {
|
||||
var dy = destY-origY;
|
||||
var dx = destX-origX;
|
||||
var delta = Math.sqrt(dy*dy+dx*dx);
|
||||
var scale = lineCurveScale*2;
|
||||
var fullScale = scale;
|
||||
|
||||
if (dy*sc > 0) {
|
||||
if (delta < node_height) {
|
||||
scale = scale-scale*((node_height-delta)/node_height);
|
||||
}
|
||||
} else {
|
||||
scale = 0.4-0.2*(Math.max(0,(node_height-Math.min(Math.abs(dx),Math.abs(dy)))/node_height));
|
||||
}
|
||||
|
||||
if (dy*sc > 0) {
|
||||
if (delta < (1.5*node_width)) {
|
||||
scale = fullScale-fullScale*(((1.5*node_width)-delta)/(1.5*node_width));
|
||||
}
|
||||
|
||||
return "M "+origX+" "+origY+
|
||||
" C "+origX+" "+(origY+sc*node_height*scale)+" "+
|
||||
destX+" "+(destY-sc*scale*node_height)+" "+
|
||||
destX+" "+destY
|
||||
// +drawCross(origX,(origY+sc*(node_height*scale)))
|
||||
// +drawCross(destX,(destY-sc*scale*node_height))
|
||||
|
||||
} else {
|
||||
var scx = dx>0?1:-1;
|
||||
|
||||
var midX = Math.floor(destX-dx/2);
|
||||
var midY = Math.floor(destY-dy/2);
|
||||
//
|
||||
if (Math.abs(dx) < node_width) {
|
||||
midX = destX - 1.3*scx*node_width;
|
||||
}
|
||||
var cp_width = node_width/2;
|
||||
var x1 = (destX + midX)/2
|
||||
var topY = origY + 2*sc*node_height*scale;
|
||||
var topX = dx>0?Math.min(x1 - dx/2 , origX+cp_width):Math.max(x1 - dx/2 , origX-cp_width);
|
||||
var bottomY = destY - 2*sc*node_height*scale;
|
||||
var bottomX = dx>0?Math.max(x1, destX-cp_width):Math.min(x1, destX+cp_width);
|
||||
var y1 = (origY+topY)/2;
|
||||
var cp = [
|
||||
// Orig -> Top
|
||||
[origX,y1],
|
||||
[dx>0?Math.max(origX, topX-cp_width):Math.min(origX, topX+cp_width),topY],
|
||||
// Top -> Mid
|
||||
// [Mirror previous cp]
|
||||
[dx>0?Math.min(midX, topX+cp_width):Math.max(midX, topX-cp_width),y1],
|
||||
// Mid -> Bottom
|
||||
// [Mirror previous cp]
|
||||
[dx>0?Math.max(midX, bottomX-cp_width):Math.min(midX, bottomX+cp_width), bottomY],
|
||||
// Bottom -> Dest
|
||||
// [Mirror previous cp]
|
||||
[destX, (destY+bottomY)/2]
|
||||
];
|
||||
// if (cp[2][0] === topX+scx*cp_width) {
|
||||
// if (Math.abs(dx) < cp_width*10) {
|
||||
// cp[1][0] = topX-scx*cp_width/2;
|
||||
// cp[3][0] = bottomX-scx*cp_width/2;
|
||||
// }
|
||||
// cp[2][1] = topY;
|
||||
// }
|
||||
return "M "+origX+" "+origY+
|
||||
" C "+
|
||||
cp[0][0]+" "+cp[0][1]+" "+
|
||||
cp[1][0]+" "+cp[1][1]+" "+
|
||||
topX+" "+topY+
|
||||
" S "+
|
||||
cp[2][0]+" "+cp[2][1]+" "+
|
||||
midX+" "+midY+
|
||||
" S "+
|
||||
cp[3][0]+" "+cp[3][1]+" "+
|
||||
bottomX+" "+bottomY+
|
||||
" S "+
|
||||
cp[4][0]+" "+cp[4][1]+" "+
|
||||
destX+" "+destY
|
||||
// +drawCross(cp[0][0],cp[0][1])
|
||||
// +drawCross(cp[1][0],cp[1][1])
|
||||
// +drawCross(cp[2][0],cp[2][1])
|
||||
// +drawCross(cp[3][0],cp[3][1])
|
||||
// +drawCross(cp[4][0],cp[4][1])
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function drawCross(x,y,i) {
|
||||
var res = " M "+(x-4)+" "+y+" h8 M "+x+" "+(y-4)+" v8 ";
|
||||
// res += " M "+(x-8)+" "+(y-8)+" h2 ";
|
||||
// if (i>0) res += " M "+(x+8)+" "+(y-8)+" h2 ";
|
||||
// if (i>1) res += " M "+(x+8)+" "+(y+8)+" h2 ";
|
||||
// if (i>2) res += " M "+(x-8)+" "+(y+8)+" h2 ";
|
||||
return res;
|
||||
}
|
||||
function drawCircle(x,y,w) {
|
||||
return " M "+x+" "+y+" m -"+w+" 0 "+
|
||||
"a "+w+","+w+" 0 1,0 "+(2*w)+",0 "+
|
||||
"a "+w+","+w+" 0 1,0 -"+(2*w)+",0 "
|
||||
}
|
||||
function drawLine(x1,y1,x2,y2) {
|
||||
return " M "+x1+","+y1+" L "+x2+","+y2+" "
|
||||
}
|
||||
|
||||
function addNode(type,x,y) {
|
||||
var m = /^subflow:(.+)$/.exec(type);
|
||||
|
||||
@@ -751,13 +644,8 @@ RED.view = (function() {
|
||||
nn.changed = true;
|
||||
nn.moved = true;
|
||||
|
||||
if (vertical) {
|
||||
nn.w = Math.max(node_width,(nn.outputs||0) * 15);
|
||||
nn.h = node_height;
|
||||
}else{
|
||||
nn.w = node_width;
|
||||
nn.h = Math.max(node_height,(nn.outputs||0) * 15);
|
||||
}
|
||||
nn.w = node_width;
|
||||
nn.h = Math.max(node_height,(nn.outputs||0) * 15);
|
||||
nn.resize = true;
|
||||
|
||||
var historyEvent = {
|
||||
@@ -898,32 +786,21 @@ RED.view = (function() {
|
||||
}
|
||||
var numOutputs = (quickAddLink.portType === PORT_TYPE_OUTPUT)?(quickAddLink.node.outputs || 1):1;
|
||||
var sourcePort = quickAddLink.port;
|
||||
|
||||
if (vertical) {
|
||||
var portX = -((numOutputs-1)/2)*15 +15*sourcePort;
|
||||
}else{
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
}
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
var sc = (quickAddLink.portType === PORT_TYPE_OUTPUT)?1:-1;
|
||||
if (vertical) {
|
||||
quickAddLink.el.attr("d",generateLinkPathV(quickAddLink.node.x+portX, quickAddLink.node.y+sc*quickAddLink.node.h/2,point[0],point[1]-(node_height/2),sc));
|
||||
}else{
|
||||
quickAddLink.el.attr("d",generateLinkPath(quickAddLink.node.x+sc*quickAddLink.node.w/2,quickAddLink.node.y+portY,point[0]-sc*node_width/2,point[1],sc));
|
||||
}
|
||||
quickAddLink.el.attr("d",generateLinkPath(quickAddLink.node.x+sc*quickAddLink.node.w/2,quickAddLink.node.y+portY,point[0]-sc*node_width/2,point[1],sc));
|
||||
}
|
||||
if (quickAddLink) {
|
||||
rebuildQuickAddLink();
|
||||
}
|
||||
|
||||
|
||||
var lastAddedPos;
|
||||
var lastAddedX;
|
||||
var lastAddedWidth;
|
||||
|
||||
var tsX = d3.event.clientX-mainPos.left-node_width/2 - (ox-point[0]);
|
||||
var tsY = d3.event.clientY-mainPos.top+ node_height/2 + 5 - (oy-point[1]);
|
||||
RED.typeSearch.show({
|
||||
x:tsX,
|
||||
y:tsY,
|
||||
x:d3.event.clientX-mainPos.left-node_width/2 - (ox-point[0]),
|
||||
y:d3.event.clientY-mainPos.top+ node_height/2 + 5 - (oy-point[1]),
|
||||
filter: filter,
|
||||
move: function(dx,dy) {
|
||||
if (ghostNode) {
|
||||
@@ -1099,46 +976,31 @@ RED.view = (function() {
|
||||
updateActiveNodes();
|
||||
updateSelection();
|
||||
redraw();
|
||||
if (!vertical) {
|
||||
// At this point the newly added node will have a real width,
|
||||
// so check if the position needs nudging
|
||||
if (lastAddedPos !== undefined) {
|
||||
var lastNodeRHEdge = lastAddedPos + lastAddedWidth/2;
|
||||
var thisNodeLHEdge = nn.x - nn.w/2;
|
||||
var gap = thisNodeLHEdge - lastNodeRHEdge;
|
||||
if (gap != gridSize *2) {
|
||||
nn.x = nn.x + gridSize * 2 - gap;
|
||||
nn.dirty = true;
|
||||
nn.x = Math.ceil(nn.x / gridSize) * gridSize;
|
||||
redraw();
|
||||
}
|
||||
// At this point the newly added node will have a real width,
|
||||
// so check if the position needs nudging
|
||||
if (lastAddedX !== undefined) {
|
||||
var lastNodeRHEdge = lastAddedX + lastAddedWidth/2;
|
||||
var thisNodeLHEdge = nn.x - nn.w/2;
|
||||
var gap = thisNodeLHEdge - lastNodeRHEdge;
|
||||
if (gap != gridSize *2) {
|
||||
nn.x = nn.x + gridSize * 2 - gap;
|
||||
nn.dirty = true;
|
||||
nn.x = Math.ceil(nn.x / gridSize) * gridSize;
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
if (keepAdding) {
|
||||
if (lastAddedPos === undefined) {
|
||||
if (lastAddedX === undefined) {
|
||||
// ghostLink.attr("opacity",1);
|
||||
setTimeout(function() {
|
||||
RED.typeSearch.refresh({filter:{input:true}});
|
||||
},100);
|
||||
}
|
||||
|
||||
if (vertical) {
|
||||
lastAddedPos = nn.y;
|
||||
if ($("#red-ui-main-container").height()-150 < tsY) {
|
||||
var delta = tsY - ($("#red-ui-main-container").height()-150);
|
||||
var st = $("#red-ui-workspace-chart").scrollTop();
|
||||
$("#red-ui-workspace-chart").scrollTop(st+delta);
|
||||
tsY -= delta;
|
||||
}
|
||||
point[1] = nn.y + nn.h + node_height+gridSize;
|
||||
tsY += nn.h + node_height+gridSize;
|
||||
RED.typeSearch.refresh({x:tsX,y:tsY});
|
||||
} else {
|
||||
lastAddedPos = nn.x;
|
||||
point[0] = nn.x + nn.w/2 + node_width/2 + gridSize * 2;
|
||||
}
|
||||
lastAddedX = nn.x;
|
||||
lastAddedWidth = nn.w;
|
||||
|
||||
point[0] = nn.x + nn.w/2 + node_width/2 + gridSize * 2;
|
||||
ghostNode.attr('transform','translate('+(point[0] - node_width/2)+','+(point[1] - node_height/2)+')');
|
||||
rebuildQuickAddLink();
|
||||
} else {
|
||||
@@ -1280,18 +1142,10 @@ RED.view = (function() {
|
||||
var drag_line = drag_lines[i];
|
||||
var numOutputs = (drag_line.portType === PORT_TYPE_OUTPUT)?(drag_line.node.outputs || 1):1;
|
||||
var sourcePort = drag_line.port;
|
||||
if (vertical) {
|
||||
var portX = -((numOutputs-1)/2)*15 +15*sourcePort;
|
||||
}else{
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
}
|
||||
var portY = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
|
||||
var sc = (drag_line.portType === PORT_TYPE_OUTPUT)?1:-1;
|
||||
if (vertical) {
|
||||
drag_line.el.attr("d",generateLinkPathV(drag_line.node.x+portX,drag_line.node.y+sc*drag_line.node.h/2,mousePos[0],mousePos[1],sc));
|
||||
}else{
|
||||
drag_line.el.attr("d",generateLinkPath(drag_line.node.x+sc*drag_line.node.w/2,drag_line.node.y+portY,mousePos[0],mousePos[1],sc));
|
||||
}
|
||||
drag_line.el.attr("d",generateLinkPath(drag_line.node.x+sc*drag_line.node.w/2,drag_line.node.y+portY,mousePos[0],mousePos[1],sc));
|
||||
}
|
||||
d3.event.preventDefault();
|
||||
} else if (mouse_mode == RED.state.MOVING) {
|
||||
@@ -1350,13 +1204,7 @@ RED.view = (function() {
|
||||
if (snapGrid != d3.event.shiftKey && moving_set.length > 0) {
|
||||
var gridOffset = [0,0];
|
||||
node = moving_set[0];
|
||||
if (vertical) {
|
||||
// Align to the centre point of the node
|
||||
gridOffset[0] = node.n.x-(gridSize*Math.floor(node.n.x/gridSize));
|
||||
} else {
|
||||
// Align to the left edge of the node
|
||||
gridOffset[0] = node.n.x-(gridSize*Math.floor((node.n.x-node.n.w/2)/gridSize)+node.n.w/2);
|
||||
}
|
||||
gridOffset[0] = node.n.x-(gridSize*Math.floor((node.n.x-node.n.w/2)/gridSize)+node.n.w/2);
|
||||
gridOffset[1] = node.n.y-(gridSize*Math.floor(node.n.y/gridSize));
|
||||
if (gridOffset[0] !== 0 || gridOffset[1] !== 0) {
|
||||
for (i = 0; i<moving_set.length; i++) {
|
||||
@@ -2715,8 +2563,8 @@ RED.view = (function() {
|
||||
}
|
||||
nodeMouseUp.call(this,d);
|
||||
});
|
||||
var attr_output_translate = (vertical) ? 'translate(15,-5)' : 'translate(-5,15)';
|
||||
outGroup.append("g").attr('transform',attr_output_translate).append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
|
||||
outGroup.append("g").attr('transform','translate(-5,15)').append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
.on("mousedown", function(d,i){portMouseDown(d,PORT_TYPE_INPUT,0);} )
|
||||
.on("touchstart", function(d,i){portMouseDown(d,PORT_TYPE_INPUT,0);} )
|
||||
.on("mouseup", function(d,i){portMouseUp(d,PORT_TYPE_INPUT,0);})
|
||||
@@ -2758,8 +2606,8 @@ RED.view = (function() {
|
||||
}
|
||||
nodeMouseUp.call(this,d);
|
||||
});
|
||||
var attr_input_translate = (vertical) ? 'translate(15,35)' : 'translate(35,15)';
|
||||
inGroup.append("g").attr('transform',attr_input_translate).append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
|
||||
inGroup.append("g").attr('transform','translate(35,15)').append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
.on("mousedown", function(d,i){portMouseDown(d,PORT_TYPE_OUTPUT,i);} )
|
||||
.on("touchstart", function(d,i){portMouseDown(d,PORT_TYPE_OUTPUT,i);} )
|
||||
.on("mouseup", function(d,i){portMouseUp(d,PORT_TYPE_OUTPUT,i);})
|
||||
@@ -2801,8 +2649,8 @@ RED.view = (function() {
|
||||
}
|
||||
nodeMouseUp.call(this,d);
|
||||
});
|
||||
var attr_status_translate = (vertical) ? 'translate(15,-5)' : 'translate(-5,15)';
|
||||
statusGroup.append("g").attr('transform', attr_status_translate).append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
|
||||
statusGroup.append("g").attr('transform','translate(-5,15)').append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
.on("mousedown", function(d,i){portMouseDown(d,PORT_TYPE_INPUT,0);} )
|
||||
.on("touchstart", function(d,i){portMouseDown(d,PORT_TYPE_INPUT,0);} )
|
||||
.on("mouseup", function(d,i){portMouseUp(d,PORT_TYPE_INPUT,0);})
|
||||
@@ -2862,23 +2710,14 @@ RED.view = (function() {
|
||||
var hideLabel = d.hasOwnProperty('l')?!d.l : isLink;
|
||||
node.attr("id",d.id);
|
||||
var l = RED.utils.getNodeLabel(d);
|
||||
|
||||
if (d.resize || d.w === undefined) {
|
||||
if (hideLabel) {
|
||||
d.w = node_height;
|
||||
} else {
|
||||
if (vertical) {
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)),(d.outputs||0) * 16 );
|
||||
}else{
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) );
|
||||
}
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) );
|
||||
}
|
||||
}
|
||||
if (vertical) {
|
||||
d.h = node_height;
|
||||
}else{
|
||||
d.h = Math.max(node_height,(d.outputs||0) * 15);
|
||||
}
|
||||
d.h = Math.max(node_height,(d.outputs||0) * 15);
|
||||
|
||||
// if (d._def.badge) {
|
||||
// var badge = node.append("svg:g").attr("class","node_badge_group");
|
||||
@@ -3087,7 +2926,7 @@ RED.view = (function() {
|
||||
.attr("class","red-ui-flow-node-status-label")
|
||||
.attr("x",20).attr("y",10);
|
||||
|
||||
node.append("g").attr("class","red-ui-flow-node-changed hide").attr("transform","translate(20, -2)").append("circle").attr("r",4);
|
||||
node.append("g").attr("class","red-ui-flow-node-changed hide").attr("transform","translate(20, -2)").append("circle").attr("r",5);
|
||||
var nodeErrorButton = node.append("g").attr("class","red-ui-flow-node-error hide").attr("transform","translate(0, -2)").append("path").attr("d","M -5,4 l 10,0 -5,-8 z");
|
||||
nodeErrorButton.on("mouseenter", function() {
|
||||
if (d.validationErrors && d.validationErrors.length > 0) {
|
||||
@@ -3121,21 +2960,13 @@ RED.view = (function() {
|
||||
if (d.resize) {
|
||||
var l = RED.utils.getNodeLabel(d);
|
||||
var ow = d.w;
|
||||
if (vertical) {
|
||||
if (hideLabel) {
|
||||
d.w = node_height
|
||||
} else {
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)),(d.outputs||0) * 16 );
|
||||
}
|
||||
d.h = node_height;
|
||||
}else{
|
||||
if (hideLabel) {
|
||||
d.w = node_height;
|
||||
} else {
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) );
|
||||
}
|
||||
d.h = Math.max(node_height,(d.outputs||0) * 15);
|
||||
if (hideLabel) {
|
||||
d.w = node_height;
|
||||
} else {
|
||||
d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) );
|
||||
}
|
||||
// d.w = Math.max(node_width,20*(Math.ceil((calculateTextWidth(l, "red-ui-flow-node-label", 50)+(d._def.inputs>0?7:0))/20)) );
|
||||
d.h = Math.max(node_height,(d.outputs||0) * 15);
|
||||
d.x += (d.w-ow)/2;
|
||||
d.resize = false;
|
||||
}
|
||||
@@ -3176,18 +3007,11 @@ RED.view = (function() {
|
||||
|
||||
if (d.type === "link in") {
|
||||
inputGroupPorts = inputGroup.append("circle")
|
||||
.attr("cx",vertical ? 5 : -1).attr("cy",vertical ? -1 : 5)
|
||||
.attr("cx",-1).attr("cy",5)
|
||||
.attr("r",5)
|
||||
.attr("class","red-ui-flow-port red-ui-flow-link-port")
|
||||
} else {
|
||||
if (vertical) {
|
||||
inputGroupPorts = inputGroup.append("path").attr("class","red-ui-flow-port").attr("d","M 0 4.5 v -6 q 0 -3 3 -3 h 4 q 3 0 3 3 v6");
|
||||
} else {
|
||||
inputGroupPorts = inputGroup.append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10);
|
||||
}
|
||||
|
||||
|
||||
//.attr("rx",3).attr("ry",3).attr("width",10).attr("height",10).attr("y",vertical?-4:0)
|
||||
inputGroupPorts = inputGroup.append("rect").attr("class","red-ui-flow-port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
|
||||
}
|
||||
inputGroupPorts.on("mousedown",function(d){portMouseDown(d,PORT_TYPE_INPUT,0);})
|
||||
.on("touchstart",function(d){portMouseDown(d,PORT_TYPE_INPUT,0);})
|
||||
@@ -3207,11 +3031,7 @@ RED.view = (function() {
|
||||
numOutputs = 0;
|
||||
}
|
||||
}
|
||||
if (vertical) {
|
||||
var x = (d.w/2)-((numOutputs-1)/2)*15;
|
||||
}else{
|
||||
var y = (d.h/2)-((numOutputs-1)/2)*13;
|
||||
}
|
||||
var y = (d.h/2)-((numOutputs-1)/2)*13;
|
||||
d.ports = d.ports || d3.range(numOutputs);
|
||||
d._ports = thisNode.selectAll(".red-ui-flow-port-output").data(d.ports);
|
||||
var output_group = d._ports.enter().append("g").attr("class","red-ui-flow-port-output");
|
||||
@@ -3219,19 +3039,15 @@ RED.view = (function() {
|
||||
|
||||
if (d.type === "link out") {
|
||||
output_group_ports = output_group.append("circle")
|
||||
.attr("cx",vertical ? 6 : 11).attr("cy", vertical ? 8 : 6)
|
||||
.attr("cx",11).attr("cy",5)
|
||||
.attr("r",5)
|
||||
.attr("class","red-ui-flow-port red-ui-flow-link-port")
|
||||
} else {
|
||||
if (vertical) {
|
||||
output_group_ports = output_group.append("path").attr("class","red-ui-flow-port").attr("d","M0 2.5 v 6 q 0 3 3 3 h 4 q 3 0 3 -3 v-6");
|
||||
} else {
|
||||
output_group_ports = output_group.append("rect")
|
||||
.attr("class","red-ui-flow-port")
|
||||
.attr("rx",3).attr("ry",3)
|
||||
.attr("width",10)
|
||||
.attr("height",10)
|
||||
}
|
||||
output_group_ports = output_group.append("rect")
|
||||
.attr("class","red-ui-flow-port")
|
||||
.attr("rx",3).attr("ry",3)
|
||||
.attr("width",10)
|
||||
.attr("height",10)
|
||||
}
|
||||
|
||||
output_group_ports.on("mousedown",(function(){var node = d; return function(d,i){portMouseDown(node,PORT_TYPE_OUTPUT,i);}})() )
|
||||
@@ -3244,21 +3060,11 @@ RED.view = (function() {
|
||||
d._ports.exit().remove();
|
||||
if (d._ports) {
|
||||
numOutputs = d.outputs || 1;
|
||||
if (vertical) {
|
||||
x = (d.w/2)-((numOutputs-1)/2)*15;
|
||||
var y = d.h-2;
|
||||
}else{
|
||||
y = (d.h/2)-((numOutputs-1)/2)*13;
|
||||
var x = d.w - 5;
|
||||
}
|
||||
y = (d.h/2)-((numOutputs-1)/2)*13;
|
||||
var x = d.w - 5;
|
||||
d._ports.each(function(d,i) {
|
||||
var port = d3.select(this);
|
||||
//port.attr("y",(y+13*i)-5).attr("x",x);
|
||||
if (vertical) {
|
||||
port.attr("transform", function(d) { return "translate("+((x+15*i)-5)+","+ y +")";});
|
||||
}else{
|
||||
port.attr("transform", function(d) { return "translate("+x+","+((y+13*i)-5)+")";});
|
||||
}
|
||||
port.attr("transform", function(d) { return "translate("+x+","+((y+13*i)-5)+")";});
|
||||
});
|
||||
}
|
||||
thisNode.selectAll("text.red-ui-flow-node-label").text(function(d,i){
|
||||
@@ -3311,32 +3117,17 @@ RED.view = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (vertical) {
|
||||
thisNode.selectAll(".red-ui-flow-node-changed")
|
||||
.attr("transform",function(d){return "translate(0, 4)"})
|
||||
.classed("hide",function(d) { return !(d.changed||d.moved); });
|
||||
|
||||
thisNode.selectAll(".red-ui-flow-node-error")
|
||||
.attr("transform",function(d){ return "translate( 0,"+((d.changed||d.moved)?16:4)+")"})
|
||||
.classed("hide",function(d) { return d.valid; });
|
||||
} else {
|
||||
thisNode.selectAll(".red-ui-flow-node-changed")
|
||||
.attr("transform",function(d){return "translate("+(d.w-10)+", -2)"})
|
||||
.classed("hide",function(d) { return !(d.changed||d.moved); });
|
||||
|
||||
thisNode.selectAll(".red-ui-flow-node-error")
|
||||
.attr("transform",function(d){ return "translate("+(d.w-10-((d.changed||d.moved)?14:0))+", -2)"})
|
||||
.classed("hide",function(d) { return d.valid; });
|
||||
}
|
||||
thisNode.selectAll(".red-ui-flow-node-changed")
|
||||
.attr("transform",function(d){return "translate("+(d.w-10)+", -2)"})
|
||||
.classed("hide",function(d) { return !(d.changed||d.moved); });
|
||||
|
||||
thisNode.selectAll(".red-ui-flow-node-error")
|
||||
.attr("transform",function(d){ return "translate("+(d.w-10-((d.changed||d.moved)?14:0))+", -2)"})
|
||||
.classed("hide",function(d) { return d.valid; });
|
||||
|
||||
thisNode.selectAll(".red-ui-flow-port-input").each(function(d,i) {
|
||||
var port = d3.select(this);
|
||||
if (vertical) {
|
||||
port.attr("transform",function(d){return "translate("+((d.w/2)-5)+", -5)";})
|
||||
}else{
|
||||
port.attr("transform",function(d){return "translate(-5,"+((d.h/2)-5)+")";})
|
||||
}
|
||||
var port = d3.select(this);
|
||||
port.attr("transform",function(d){return "translate(-5,"+((d.h/2)-5)+")";})
|
||||
});
|
||||
|
||||
thisNode.selectAll(".red-ui-flow-node-icon").attr("y",function(d){return (d.h-d3.select(this).attr("height"))/2;});
|
||||
@@ -3401,17 +3192,9 @@ RED.view = (function() {
|
||||
var fill = status_colours[d.status.fill]; // Only allow our colours for now
|
||||
if (d.status.shape == null && fill == null) {
|
||||
thisNode.selectAll(".red-ui-flow-node-status").style("display","none");
|
||||
if (vertical) {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(" + (-12+d.w/2) + ","+(-13)+")");
|
||||
} else {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(-14,"+(d.h+3)+")");
|
||||
}
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(-14,"+(d.h+3)+")");
|
||||
} else {
|
||||
if (vertical) {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(" + (5 + d.w/2) + ","+(-13)+")");
|
||||
} else {
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")");
|
||||
}
|
||||
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")");
|
||||
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
|
||||
thisNode.selectAll(".red-ui-flow-node-status").style("display","inline").attr("class","red-ui-flow-node-status "+statusClass);
|
||||
}
|
||||
@@ -3496,23 +3279,17 @@ RED.view = (function() {
|
||||
link.attr("d",function(d){
|
||||
var numOutputs = d.source.outputs || 1;
|
||||
var sourcePort = d.sourcePort || 0;
|
||||
var path;
|
||||
if (vertical) {
|
||||
var x = -((numOutputs-1)/2)*15 +15*sourcePort;
|
||||
d.x1 = d.source.x+x;
|
||||
d.y1 = d.source.y+d.source.h/2;
|
||||
d.x2 = d.target.x;
|
||||
d.y2 = d.target.y-d.target.h/2;
|
||||
path = generateLinkPathV(d.x1,d.y1,d.x2,d.y2,1);
|
||||
}else{
|
||||
var y = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
d.x1 = d.source.x+d.source.w/2;
|
||||
d.y1 = d.source.y+y;
|
||||
d.x2 = d.target.x-d.target.w/2;
|
||||
d.y2 = d.target.y;
|
||||
path = generateLinkPath(d.x1,d.y1,d.x2,d.y2,1);
|
||||
}
|
||||
var y = -((numOutputs-1)/2)*13 +13*sourcePort;
|
||||
d.x1 = d.source.x+d.source.w/2;
|
||||
d.y1 = d.source.y+y;
|
||||
d.x2 = d.target.x-d.target.w/2;
|
||||
d.y2 = d.target.y;
|
||||
|
||||
// return "M "+d.x1+" "+d.y1+
|
||||
// " C "+(d.x1+scale*node_width)+" "+(d.y1+scaleY*node_height)+" "+
|
||||
// (d.x2-scale*node_width)+" "+(d.y2-scaleY*node_height)+" "+
|
||||
// d.x2+" "+d.y2;
|
||||
var path = generateLinkPath(d.x1,d.y1,d.x2,d.y2,1);
|
||||
if (/NaN/.test(path)) {
|
||||
return ""
|
||||
}
|
||||
@@ -4003,14 +3780,6 @@ RED.view = (function() {
|
||||
updateGrid();
|
||||
}
|
||||
},
|
||||
vertical: function(v) {
|
||||
if (v === undefined) {
|
||||
return vertical;
|
||||
} else {
|
||||
vertical = v;
|
||||
RED.view.redraw();
|
||||
}
|
||||
},
|
||||
getActiveNodes: function() {
|
||||
return activeNodes;
|
||||
},
|
||||
|
@@ -109,6 +109,7 @@
|
||||
{
|
||||
'$abs':{ args:[ 'number' ]},
|
||||
'$append':{ args:[ 'array1', 'array2' ]},
|
||||
'$assert':{ args: [ 'arg', 'str' ]},
|
||||
'$average':{ args:[ 'array' ]},
|
||||
'$base64decode':{ args:[ ]},
|
||||
'$base64encode':{ args:[ ]},
|
||||
@@ -116,8 +117,14 @@
|
||||
'$ceil':{ args:[ 'number' ]},
|
||||
'$contains':{ args:[ 'str', 'pattern' ]},
|
||||
'$count':{ args:[ 'array' ]},
|
||||
'$decodeUrl':{ args:[ 'str' ]},
|
||||
'$decodeUrlComponent':{ args:[ 'str' ]},
|
||||
'$distinct':{ args:[ 'array' ]},
|
||||
'$each':{ args:[ 'object', 'function' ]},
|
||||
'$encodeUrl':{ args: ['str'] },
|
||||
'$encodeUrlComponent':{ args:[ 'str' ]},
|
||||
'$env': { args:[ 'arg' ]},
|
||||
'$error':{ args:[ 'str' ]},
|
||||
'$eval': { args: ['expr', 'context']},
|
||||
'$exists':{ args:[ 'arg' ]},
|
||||
'$filter':{ args:[ 'array', 'function' ]},
|
||||
@@ -151,12 +158,13 @@
|
||||
'$reverse':{ args:[ 'array' ]},
|
||||
'$round':{ args:[ 'number', 'precision' ]},
|
||||
'$shuffle':{ args:[ 'array' ]},
|
||||
'$sift':{ args:[ 'object', 'function' ]},
|
||||
'$sift':{ args: ['object', 'function'] },
|
||||
'$single':{ args: ['array', 'function'] },
|
||||
'$sort':{ args:[ 'array', 'function' ]},
|
||||
'$split':{ args:[ 'str', 'separator', 'limit' ]},
|
||||
'$spread':{ args:[ 'object' ]},
|
||||
'$sqrt':{ args:[ 'number' ]},
|
||||
'$string':{ args:[ 'arg' ]},
|
||||
'$string':{ args:[ 'arg', 'prettify' ]},
|
||||
'$substring':{ args:[ 'str', 'start', 'length' ]},
|
||||
'$substringAfter':{ args:[ 'str', 'chars' ]},
|
||||
'$substringBefore':{ args:[ 'str', 'chars' ]},
|
||||
|
@@ -170,6 +170,7 @@
|
||||
if (this.authType) {
|
||||
$('#node-input-useAuth').prop('checked', true);
|
||||
$("#node-input-authType-select").val(this.authType);
|
||||
$("#node-input-authType-select").change();
|
||||
} else {
|
||||
$('#node-input-useAuth').prop('checked', false);
|
||||
}
|
||||
|
@@ -371,7 +371,6 @@ module.exports = function(RED) {
|
||||
var server = net.createServer(function (socket) {
|
||||
socket.setKeepAlive(true,120000);
|
||||
if (socketTimeout !== null) { socket.setTimeout(socketTimeout); }
|
||||
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
||||
node.log(RED._("tcpin.status.connection-from",{host:socket.remoteAddress, port:socket.remotePort}));
|
||||
connectedSockets.push(socket);
|
||||
node.status({text:RED._("tcpin.status.connections",{count:connectedSockets.length})});
|
||||
|
@@ -230,17 +230,17 @@ module.exports = function(RED) {
|
||||
node.send(msg); // finally send the array
|
||||
}
|
||||
}
|
||||
else {
|
||||
var len = a.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
else {
|
||||
var len = a.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var newMessage = RED.util.cloneMessage(msg);
|
||||
newMessage.payload = a[i];
|
||||
if (!has_parts) {
|
||||
newMessage.parts = {
|
||||
id: msg._msgid,
|
||||
index: i,
|
||||
count: len
|
||||
};
|
||||
newMessage.parts = {
|
||||
id: msg._msgid,
|
||||
index: i,
|
||||
count: len
|
||||
};
|
||||
}
|
||||
else {
|
||||
newMessage.parts.index -= node.skip;
|
||||
@@ -251,8 +251,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
node.send(newMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node.linecount = 0;
|
||||
}
|
||||
catch(e) { node.error(e,msg); }
|
||||
|
@@ -140,8 +140,8 @@ module.exports = function(RED) {
|
||||
try {
|
||||
var stat = fs.statSync(filename);
|
||||
node.wstreamIno = stat.ino;
|
||||
} catch(err) {
|
||||
}
|
||||
}
|
||||
catch(err) { }
|
||||
});
|
||||
node.wstream.on("error", function(err) {
|
||||
node.error(RED._("file.errors.appendfail",{error:err.toString()}),msg);
|
||||
@@ -276,7 +276,6 @@ module.exports = function(RED) {
|
||||
ch = "\n";
|
||||
type = "string";
|
||||
}
|
||||
var hwm;
|
||||
var getout = false;
|
||||
|
||||
var rs = fs.createReadStream(filename)
|
||||
@@ -290,30 +289,24 @@ module.exports = function(RED) {
|
||||
spare += decode(chunk, node.encoding);
|
||||
var bits = spare.split("\n");
|
||||
for (var i=0; i < bits.length - 1; i++) {
|
||||
var m = {
|
||||
payload:bits[i],
|
||||
topic:msg.topic,
|
||||
filename:msg.filename,
|
||||
parts:{index:count, ch:ch, type:type, id:msg._msgid}
|
||||
}
|
||||
var sendMessage = RED.util.cloneMessage(msg);
|
||||
sendMessage.payload = bits[i];
|
||||
sendMessage.parts = {index:count, ch:ch, type:type, id:msg._msgid};
|
||||
count += 1;
|
||||
nodeSend(m);
|
||||
nodeSend(sendMessage);
|
||||
}
|
||||
spare = bits[i];
|
||||
}
|
||||
if (node.format === "stream") {
|
||||
var m = {
|
||||
payload:chunk,
|
||||
topic:msg.topic,
|
||||
filename:msg.filename,
|
||||
parts:{index:count, ch:ch, type:type, id:msg._msgid}
|
||||
}
|
||||
var sendMessage = RED.util.cloneMessage(msg);
|
||||
sendMessage.payload = chunk;
|
||||
sendMessage.parts = {index:count, ch:ch, type:type, id:msg._msgid};
|
||||
count += 1;
|
||||
if (chunk.length < hwm) { // last chunk is smaller that high water mark = eof
|
||||
getout = false;
|
||||
m.parts.count = count;
|
||||
sendMessage.parts.count = count;
|
||||
}
|
||||
nodeSend(m);
|
||||
nodeSend(sendMessage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -332,28 +325,23 @@ module.exports = function(RED) {
|
||||
nodeDone();
|
||||
})
|
||||
.on('end', function() {
|
||||
var sendMessage = RED.util.cloneMessage(msg);
|
||||
if (node.chunk === false) {
|
||||
if (node.format === "utf8") {
|
||||
msg.payload = decode(lines, node.encoding);
|
||||
sendMessage.payload = decode(lines, node.encoding);
|
||||
}
|
||||
else { msg.payload = lines; }
|
||||
nodeSend(msg);
|
||||
else { sendMessage.payload = lines; }
|
||||
nodeSend(sendMessage);
|
||||
}
|
||||
else if (node.format === "lines") {
|
||||
var m = { payload: spare,
|
||||
parts: {
|
||||
index: count,
|
||||
count: count+1,
|
||||
ch: ch,
|
||||
type: type,
|
||||
id: msg._msgid
|
||||
}
|
||||
};
|
||||
nodeSend(m);
|
||||
sendMessage.payload = spare;
|
||||
sendMessage.parts = { index:count, count:count+1, ch:ch, type:type, id:msg._msgid };
|
||||
nodeSend(sendMessage);
|
||||
}
|
||||
else if (getout) { // last chunk same size as high water mark - have to send empty extra packet.
|
||||
var m = { parts:{index:count, count:count, ch:ch, type:type, id:msg._msgid} };
|
||||
nodeSend(m);
|
||||
delete sendMessage.payload;
|
||||
sendMessage.parts = { parts:{index:count, count:count, ch:ch, type:type, id:msg._msgid} };
|
||||
nodeSend(sendMessage);
|
||||
}
|
||||
nodeDone();
|
||||
});
|
||||
|
@@ -36,7 +36,7 @@
|
||||
<dt class="optional">followRedirects</dt>
|
||||
<dd>If set to <code>false</code> prevent following Redirect (HTTP 301).<code>true</code> by default</dd>
|
||||
<dt class="optional">requestTimeout</dt>
|
||||
<dd>If set to a positive number, will override the globally set <code>httpRequestTimeout</code> parameter.</dd>
|
||||
<dd>If set to a positive number of milliseconds, will override the globally set <code>httpRequestTimeout</code> parameter.</dd>
|
||||
</dl>
|
||||
<h3>Outputs</h3>
|
||||
<dl class="message-properties">
|
||||
|
@@ -33,6 +33,8 @@
|
||||
<dd><code>false</code>をセットすると、自己署名証明書を使用するhttpsサイトへのリクエストを許可します。</dd>
|
||||
<dt class="optional">followRedirects</dt>
|
||||
<dd><code>false</code>をセットすると、リダイレクトを行いません。デフォルトは<code>true</code>です。</dd>
|
||||
<dt class="optional">requestTimeout</dt>
|
||||
<dd>正のミリ秒数をセットすると、 グローバルに設定された<code>httpRequestTimeout</code>パラメータを上書きします。</dd>
|
||||
</dl>
|
||||
<h3>出力</h3>
|
||||
<dl class="message-properties">
|
||||
|
@@ -27,7 +27,7 @@
|
||||
"fs-extra": "8.1.0",
|
||||
"fs.notify": "0.0.4",
|
||||
"hash-sum": "2.0.0",
|
||||
"https-proxy-agent": "2.2.2",
|
||||
"https-proxy-agent": "2.2.3",
|
||||
"is-utf8": "0.2.1",
|
||||
"js-yaml": "3.13.1",
|
||||
"media-typer": "1.1.0",
|
||||
|
@@ -224,7 +224,7 @@ Node.prototype._emitInput = function(arg) {
|
||||
}
|
||||
);
|
||||
} catch(err) {
|
||||
node.error(err,msg);
|
||||
node.error(err,arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
"clone": "2.1.2",
|
||||
"i18next": "15.1.2",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"jsonata": "1.6.5",
|
||||
"jsonata": "1.7.0",
|
||||
"when": "3.7.8"
|
||||
}
|
||||
}
|
||||
|
@@ -251,7 +251,8 @@ describe('delay Node', function() {
|
||||
var helperNode1 = helper.getNode("helperNode1");
|
||||
var receivedMessagesStack = [];
|
||||
|
||||
var rate = 1000/aLimit;
|
||||
// Add a small grace to the calculated delay
|
||||
var rate = 1000/aLimit + 10;
|
||||
|
||||
var receiveTimestamp;
|
||||
|
||||
|
@@ -1192,6 +1192,43 @@ describe('file Nodes', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should read in a file and output split lines with parts and preserve other properties', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", filename:fileToTest, format:"lines", wires:[["n2"]]},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
var n1 = helper.getNode("fileInNode1");
|
||||
var n2 = helper.getNode("n2");
|
||||
var c = 0;
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
msg.should.have.property('payload');
|
||||
msg.payload.should.be.a.String();
|
||||
msg.should.have.property('topic',"dujour");
|
||||
msg.should.have.property('foo',"bar");
|
||||
msg.should.have.property('parts');
|
||||
msg.parts.should.have.property('index',c);
|
||||
msg.parts.should.have.property('type','string');
|
||||
msg.parts.should.have.property('ch','\n');
|
||||
if (c === 0) {
|
||||
msg.payload.should.equal("File message line 1");
|
||||
}
|
||||
if (c === 1) {
|
||||
msg.payload.should.equal("File message line 2");
|
||||
}
|
||||
if (c === 2) {
|
||||
msg.payload.should.equal("");
|
||||
done();
|
||||
}
|
||||
c++;
|
||||
}
|
||||
catch(e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
n1.receive({payload:"",topic:"dujour",foo:"bar"});
|
||||
});
|
||||
});
|
||||
|
||||
it('should read in a file and output a buffer with parts', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", filename:fileToTest, format:"stream", wires:[["n2"]]},
|
||||
{id:"n2", type:"helper"}];
|
||||
@@ -1212,6 +1249,28 @@ describe('file Nodes', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should read in a file and output a buffer with parts and preserve other properties', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", filename:fileToTest, format:"stream", wires:[["n2"]]},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
var n1 = helper.getNode("fileInNode1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
msg.should.have.property('payload');
|
||||
msg.should.have.property('topic',"dujour");
|
||||
msg.should.have.property('foo',"bar");
|
||||
Buffer.isBuffer(msg.payload).should.be.true();
|
||||
msg.payload.should.have.length(40);
|
||||
msg.should.have.property('parts');
|
||||
msg.parts.should.have.property('count',1);
|
||||
msg.parts.should.have.property('type','buffer');
|
||||
msg.parts.should.have.property('ch','');
|
||||
done();
|
||||
});
|
||||
n1.receive({payload:"",topic:"dujour",foo:"bar"});
|
||||
});
|
||||
});
|
||||
|
||||
it('should warn if no filename set', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "format":""}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
|
Reference in New Issue
Block a user