mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Compare commits
19 Commits
4479-ensur
...
4485-copy-
Author | SHA1 | Date | |
---|---|---|---|
|
8a8245b560 | ||
|
282bb6c414 | ||
|
ce5b6a8024 | ||
|
0773edcaff | ||
|
68dcf7bceb | ||
|
d876146ea5 | ||
|
50627cd697 | ||
|
6a4d293352 | ||
|
1ad4fe44e2 | ||
|
59ea7a4f70 | ||
|
6c64ba45c2 | ||
|
c68cc4ac19 | ||
|
84ed88c8dd | ||
|
d7345d5bc6 | ||
|
aaed9882b8 | ||
|
8f5ebfcede | ||
|
1828d8a279 | ||
|
70ea5c839a | ||
|
d287b8867b |
@@ -51,7 +51,7 @@ module.exports = {
|
||||
|
||||
var ui = require("./ui");
|
||||
|
||||
ui.init(runtimeAPI);
|
||||
ui.init(settings, runtimeAPI);
|
||||
|
||||
const editorApp = apiUtil.createExpressApp(settings)
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
const crypto = require('crypto')
|
||||
var express = require('express');
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
@@ -24,13 +25,16 @@ var apiUtils = require("../util");
|
||||
var theme = require("./theme");
|
||||
|
||||
var runtimeAPI;
|
||||
let settings;
|
||||
var editorClientDir = path.dirname(require.resolve("@node-red/editor-client"));
|
||||
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.svg");
|
||||
var editorTemplatePath = path.join(editorClientDir,"templates","index.mst");
|
||||
var editorTemplate;
|
||||
let cacheBuster
|
||||
|
||||
module.exports = {
|
||||
init: function(_runtimeAPI) {
|
||||
init: function(_settings, _runtimeAPI) {
|
||||
settings = _settings;
|
||||
runtimeAPI = _runtimeAPI;
|
||||
editorTemplate = fs.readFileSync(editorTemplatePath,"utf8");
|
||||
Mustache.parse(editorTemplate);
|
||||
@@ -91,6 +95,12 @@ module.exports = {
|
||||
},
|
||||
|
||||
editor: async function(req,res) {
|
||||
if (!cacheBuster) {
|
||||
// settings.instanceId is set asynchronously to the editor-api
|
||||
// being initiaised. So we defer calculating the cacheBuster hash
|
||||
// until the first load of the editor
|
||||
cacheBuster = crypto.createHash('md5').update(`${settings.version || 'version'}-${settings.instanceId || 'instanceId'}`).digest("hex").substring(0,12)
|
||||
}
|
||||
|
||||
let sessionMessages;
|
||||
if (req.session && req.session.messages) {
|
||||
@@ -99,6 +109,7 @@ module.exports = {
|
||||
}
|
||||
res.send(Mustache.render(editorTemplate,{
|
||||
sessionMessages,
|
||||
cacheBuster,
|
||||
...await theme.context()
|
||||
}));
|
||||
},
|
||||
|
@@ -1222,6 +1222,7 @@
|
||||
"invalid-expr": "Invalid JSONata expression: __error__",
|
||||
"invalid-prop": "Invalid property expression",
|
||||
"invalid-num": "Invalid number",
|
||||
"invalid-num-prop": "__prop__: invalid number",
|
||||
"invalid-regexp": "Invalid input pattern",
|
||||
"invalid-regex-prop": "__prop__: invalid input pattern",
|
||||
"missing-required-prop": "__prop__: property value missing",
|
||||
|
@@ -1217,6 +1217,7 @@
|
||||
"invalid-expr": "Expression JSONata invalide : __error__",
|
||||
"invalid-prop": "Expression de propriété invalide",
|
||||
"invalid-num": "Numéro invalide",
|
||||
"invalid-num-prop": "__prop__: numéro invalide",
|
||||
"invalid-regexp": "Modèle d'entrée non valide",
|
||||
"invalid-regex-prop": "__prop__: modèle d'entrée non valide",
|
||||
"missing-required-prop": "__prop__: valeur de la propriété manquante",
|
||||
|
@@ -129,6 +129,11 @@
|
||||
"editPalette": "パレットの管理",
|
||||
"other": "その他",
|
||||
"showTips": "ヒントを表示",
|
||||
"showNodeHelp": "ノードのヘルプを表示",
|
||||
"enableSelectedNodes": "選択したノードを有効化",
|
||||
"disableSelectedNodes": "選択したノードを無効化",
|
||||
"showSelectedNodeLabels": "選択したノードのラベル表示",
|
||||
"hideSelectedNodeLabels": "選択したノードのラベル非表示",
|
||||
"showWelcomeTours": "新バージョンのガイドツアーを表示",
|
||||
"help": "Node-REDウェブサイト",
|
||||
"projects": "プロジェクト",
|
||||
@@ -510,7 +515,7 @@
|
||||
"selectAllConnected": "接続されたノードを選択",
|
||||
"addRemoveNode": "ノードの選択、選択解除",
|
||||
"editSelected": "選択したノードを編集",
|
||||
"deleteSelected": "選択したノードや接続を削除",
|
||||
"deleteSelected": "選択部分を削除",
|
||||
"deleteReconnect": "削除と再接続",
|
||||
"importNode": "フローの読み込み",
|
||||
"exportNode": "フローの書き出し",
|
||||
@@ -1214,8 +1219,10 @@
|
||||
"validator": {
|
||||
"errors": {
|
||||
"invalid-json": "JSONデータが不正: __error__",
|
||||
"invalid-expr": "不正なJSONata式: __error__",
|
||||
"invalid-prop": "プロパティ式が不正",
|
||||
"invalid-num": "数値が不正",
|
||||
"invalid-num-prop": "__prop__: 数値が不正",
|
||||
"invalid-regexp": "入力パターンが不正",
|
||||
"invalid-regex-prop": "__prop__: 入力パターンが不正",
|
||||
"missing-required-prop": "__prop__: プロパティが未設定",
|
||||
@@ -1225,6 +1232,7 @@
|
||||
}
|
||||
},
|
||||
"contextMenu": {
|
||||
"showActionList": "動作一覧を表示",
|
||||
"insert": "挿入",
|
||||
"node": "ノード",
|
||||
"junction": "分岐点",
|
||||
|
@@ -1187,6 +1187,7 @@
|
||||
"invalid-json": "Dados JSON inválidos: __error__",
|
||||
"invalid-prop": "Expressão de propriedade inválida",
|
||||
"invalid-num": "Número inválido",
|
||||
"invalid-num-prop": "__prop__: número inválido",
|
||||
"invalid-regexp": "Padrão de entrada inválido",
|
||||
"invalid-regex-prop": "__prop__: Padrão de entrada inválido",
|
||||
"missing-required-prop": "__prop__: valor de propriedade ausente",
|
||||
|
@@ -1220,6 +1220,7 @@
|
||||
"invalid-expr": "无效的 JSONata 表达式: __error__",
|
||||
"invalid-prop": "无效的属性表达式",
|
||||
"invalid-num": "无效的数字",
|
||||
"invalid-num-prop": "__prop__: 无效的数字",
|
||||
"invalid-regexp": "输入格式无效",
|
||||
"invalid-regex-prop": "__prop__: 输入格式无效",
|
||||
"missing-required-prop": "__prop__: 缺少属性值",
|
||||
|
@@ -30,8 +30,26 @@ RED.contextMenu = (function () {
|
||||
const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group'
|
||||
const canEdit = !RED.workspaces.isLocked()
|
||||
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
||||
const isAllGroups = hasSelection && selection.nodes.filter(n => n.type !== 'group').length === 0
|
||||
const hasGroup = hasSelection && selection.nodes.filter(n => n.type === 'group' ).length > 0
|
||||
let hasGroup, isAllGroups = true, hasDisabledNode, hasEnabledNode, hasLabeledNode, hasUnlabeledNode;
|
||||
if (hasSelection) {
|
||||
selection.nodes.forEach(n => {
|
||||
if (n.type === 'group') {
|
||||
hasGroup = true;
|
||||
} else {
|
||||
isAllGroups = false;
|
||||
}
|
||||
if (n.d) {
|
||||
hasDisabledNode = true;
|
||||
} else {
|
||||
hasEnabledNode = true;
|
||||
}
|
||||
if (n.l === undefined || n.l) {
|
||||
hasLabeledNode = true;
|
||||
} else {
|
||||
hasUnlabeledNode = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
const offset = $("#red-ui-workspace-chart").offset()
|
||||
|
||||
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
|
||||
@@ -55,7 +73,7 @@ RED.contextMenu = (function () {
|
||||
onselect: function () {
|
||||
RED.view.showQuickAddDialog({
|
||||
position: [addX, addY],
|
||||
touchTrigger: true,
|
||||
touchTrigger: 'ontouchstart' in window,
|
||||
splice: isSingleLink ? selection.links[0] : undefined,
|
||||
// spliceMultiple: isMultipleLinks
|
||||
})
|
||||
@@ -113,11 +131,11 @@ RED.contextMenu = (function () {
|
||||
)
|
||||
}
|
||||
nodeOptions.push(
|
||||
{ onselect: 'core:enable-selected-nodes', label: RED._('menu.label.enableSelectedNodes') },
|
||||
{ onselect: 'core:disable-selected-nodes', label: RED._('menu.label.disableSelectedNodes') },
|
||||
{ onselect: 'core:enable-selected-nodes', label: RED._('menu.label.enableSelectedNodes'), disabled: !hasDisabledNode },
|
||||
{ onselect: 'core:disable-selected-nodes', label: RED._('menu.label.disableSelectedNodes'), disabled: !hasEnabledNode },
|
||||
null,
|
||||
{ onselect: 'core:show-selected-node-labels', label: RED._('menu.label.showSelectedNodeLabels') },
|
||||
{ onselect: 'core:hide-selected-node-labels', label: RED._('menu.label.hideSelectedNodeLabels') }
|
||||
{ onselect: 'core:show-selected-node-labels', label: RED._('menu.label.showSelectedNodeLabels'), disabled: !hasUnlabeledNode },
|
||||
{ onselect: 'core:hide-selected-node-labels', label: RED._('menu.label.hideSelectedNodeLabels'), disabled: !hasLabeledNode }
|
||||
)
|
||||
menuItems.push({
|
||||
label: RED._('sidebar.info.node'),
|
||||
|
@@ -232,7 +232,7 @@ RED.sidebar.context = (function() {
|
||||
typeHint: data.format,
|
||||
sourceId: id+"."+k,
|
||||
tools: tools,
|
||||
path: ""
|
||||
path: k
|
||||
}).appendTo(propRow.children()[1]);
|
||||
}
|
||||
})
|
||||
@@ -278,7 +278,7 @@ RED.sidebar.context = (function() {
|
||||
typeHint: data.format,
|
||||
sourceId: id+"."+k,
|
||||
tools: tools,
|
||||
path: ""
|
||||
path: k
|
||||
}).appendTo(propRow.children()[1]);
|
||||
}
|
||||
});
|
||||
@@ -299,7 +299,7 @@ RED.sidebar.context = (function() {
|
||||
typeHint: v.format,
|
||||
sourceId: id+"."+k,
|
||||
tools: tools,
|
||||
path: ""
|
||||
path: k
|
||||
}).appendTo(propRow.children()[1]);
|
||||
if (contextStores.length > 1) {
|
||||
$("<span>",{class:"red-ui-sidebar-context-property-storename"}).text(v.store).appendTo($(propRow.children()[0]))
|
||||
|
@@ -186,8 +186,15 @@ RED.typeSearch = (function() {
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
|
||||
RED.utils.createIconElement(icon_url, iconContainer, false);
|
||||
|
||||
|
||||
if (!/^_action_:/.test(object.type) && object.type !== "junction") {
|
||||
if (/^subflow:/.test(object.type)) {
|
||||
var sf = RED.nodes.subflow(object.type.substring(8));
|
||||
if (sf.in.length > 0) {
|
||||
$('<div/>',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv);
|
||||
}
|
||||
if (sf.out.length > 0) {
|
||||
$('<div/>',{class:"red-ui-search-result-node-port red-ui-search-result-node-output"}).appendTo(nodeDiv);
|
||||
}
|
||||
} else if (!/^_action_:/.test(object.type) && object.type !== "junction") {
|
||||
if (def.inputs > 0) {
|
||||
$('<div/>',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv);
|
||||
}
|
||||
|
@@ -24,24 +24,24 @@
|
||||
<title>{{ page.title }}</title>
|
||||
<link rel="icon" type="image/png" href="{{ page.favicon }}">
|
||||
<link rel="mask-icon" href="{{ page.tabicon.icon }}" color="{{ page.tabicon.colour }}">
|
||||
<link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v={{ page.version }}">
|
||||
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v={{ page.version }}">
|
||||
<link rel="stylesheet" href="red/style.min.css?v={{ page.version }}">
|
||||
<link rel="stylesheet" href="vendor/jquery/css/base/jquery-ui.min.css?v={{ cacheBuster }}">
|
||||
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css?v={{ cacheBuster }}">
|
||||
<link rel="stylesheet" href="red/style.min.css?v={{ cacheBuster }}">
|
||||
{{#page.css}}
|
||||
<link rel="stylesheet" href="{{.}}">
|
||||
{{/page.css}}
|
||||
{{#asset.vendorMonaco}}
|
||||
<link rel="stylesheet" href="vendor/monaco/style.css?v={{ page.version }}">
|
||||
<link rel="stylesheet" href="vendor/monaco/style.css?v={{ cacheBuster }}">
|
||||
{{/asset.vendorMonaco}}
|
||||
</head>
|
||||
<body spellcheck="false">
|
||||
<div id="red-ui-editor"></div>
|
||||
<script src="vendor/vendor.js?v={{ page.version }}"></script>
|
||||
<script src="vendor/vendor.js?v={{ cacheBuster }}"></script>
|
||||
{{#asset.vendorMonaco}}
|
||||
<script src="{{ asset.vendorMonaco }}?v={{ page.version }}"></script>
|
||||
<script src="{{ asset.vendorMonaco }}?v={{ cacheBuster }}"></script>
|
||||
{{/asset.vendorMonaco}}
|
||||
<script src="{{ asset.red }}?v={{ page.version }}"></script>
|
||||
<script src="{{ asset.main }}?v={{ page.version }}"></script>
|
||||
<script src="{{ asset.red }}?v={{ cacheBuster }}"></script>
|
||||
<script src="{{ asset.main }}?v={{ cacheBuster }}"></script>
|
||||
{{# page.scripts }}
|
||||
<script src="{{.}}"></script>
|
||||
{{/ page.scripts }}
|
||||
|
@@ -485,7 +485,7 @@ class Flow {
|
||||
}
|
||||
if (!key.startsWith("$parent.")) {
|
||||
if (this._env.hasOwnProperty(key)) {
|
||||
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||
return this._env[key]
|
||||
}
|
||||
} else {
|
||||
key = key.substring(8);
|
||||
|
@@ -41,7 +41,7 @@ class Group {
|
||||
}
|
||||
if (!key.startsWith("$parent.")) {
|
||||
if (this._env.hasOwnProperty(key)) {
|
||||
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||
return this._env[key]
|
||||
}
|
||||
} else {
|
||||
key = key.substring(8);
|
||||
|
@@ -375,7 +375,7 @@ class Subflow extends Flow {
|
||||
}
|
||||
if (!key.startsWith("$parent.")) {
|
||||
if (this._env.hasOwnProperty(key)) {
|
||||
return (Object.hasOwn(this._env[key], 'value') && this._env[key].__clone__) ? clone(this._env[key].value) : this._env[key]
|
||||
return this._env[key]
|
||||
}
|
||||
} else {
|
||||
key = key.substring(8);
|
||||
|
@@ -102,9 +102,6 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
||||
pendingEvaluations.push(new Promise((resolve, _) => {
|
||||
redUtil.evaluateNodeProperty(value, 'jsonata', {_flow: flow}, null, (err, result) => {
|
||||
if (!err) {
|
||||
if (typeof result === 'object') {
|
||||
result = { value: result, __clone__: true}
|
||||
}
|
||||
evaluatedEnv[name] = result
|
||||
}
|
||||
resolve()
|
||||
@@ -112,9 +109,6 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
||||
}))
|
||||
} else {
|
||||
value = redUtil.evaluateNodeProperty(value, type, {_flow: flow}, null, null);
|
||||
if (typeof value === 'object') {
|
||||
value = { value: value, __clone__: true}
|
||||
}
|
||||
}
|
||||
evaluatedEnv[name] = value
|
||||
}
|
||||
@@ -144,13 +138,8 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
||||
}
|
||||
}}, null, null);
|
||||
}
|
||||
if (typeof value === 'object' && !value.__clone__) {
|
||||
value = { value: value, __clone__: true}
|
||||
}
|
||||
evaluatedEnv[name] = value
|
||||
|
||||
}
|
||||
// console.log(evaluatedEnv)
|
||||
|
||||
return evaluatedEnv
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ var express = require("express");
|
||||
var path = require('path');
|
||||
var fs = require("fs");
|
||||
var os = require("os");
|
||||
const crypto = require("crypto")
|
||||
|
||||
const {log,i18n,events,exec,util,hooks} = require("@node-red/util");
|
||||
|
||||
@@ -51,7 +52,7 @@ var adminApi = {
|
||||
var nodeApp;
|
||||
var adminApp;
|
||||
var server;
|
||||
|
||||
let userSettings;
|
||||
|
||||
/**
|
||||
* Initialise the runtime module.
|
||||
@@ -61,8 +62,9 @@ var server;
|
||||
* better abstracted.
|
||||
* @memberof @node-red/runtime
|
||||
*/
|
||||
function init(userSettings,httpServer,_adminApi) {
|
||||
function init(_userSettings,httpServer,_adminApi) {
|
||||
server = httpServer;
|
||||
userSettings = _userSettings
|
||||
|
||||
if (server && server.on) {
|
||||
// Add a listener to the upgrade event so that we can properly timeout connection
|
||||
@@ -134,7 +136,12 @@ function start() {
|
||||
.then(function() { return settings.load(storage)})
|
||||
.then(function() { return library.init(runtime)})
|
||||
.then(function() {
|
||||
|
||||
if (settings.available()) {
|
||||
if (settings.get('instanceId') === undefined) {
|
||||
settings.set('instanceId', crypto.randomBytes(8).toString('hex'))
|
||||
}
|
||||
userSettings.instanceId = settings.get('instanceId') || ''
|
||||
}
|
||||
if (log.metric()) {
|
||||
runtimeMetricInterval = setInterval(function() {
|
||||
reportMetrics();
|
||||
|
@@ -29,7 +29,7 @@ describe("api/editor/ui", function() {
|
||||
var app;
|
||||
|
||||
before(function() {
|
||||
ui.init({
|
||||
ui.init({}, {
|
||||
nodes: {
|
||||
getIcon: function(opts) {
|
||||
return new Promise(function(resolve,reject) {
|
||||
|
Reference in New Issue
Block a user