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 2022-04-20 10:56:55 +01:00
commit 12a25c37aa
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
9 changed files with 230 additions and 217 deletions

View File

@ -474,7 +474,7 @@ var RED = (function() {
var parts = topic.split("/"); var parts = topic.split("/");
var node = RED.nodes.node(parts[1]); var node = RED.nodes.node(parts[1]);
if (node) { if (node) {
if (msg.hasOwnProperty("text") && msg.text !== null && /^[a-zA-Z]/.test(msg.text)) { if (msg.hasOwnProperty("text") && msg.text !== null && /^[@a-zA-Z]/.test(msg.text)) {
msg.text = node._(msg.text.toString(),{defaultValue:msg.text.toString()}); msg.text = node._(msg.text.toString(),{defaultValue:msg.text.toString()});
} }
node.status = msg; node.status = msg;

View File

@ -319,21 +319,25 @@ RED.deploy = (function() {
},delta); },delta);
}); });
} }
function save(skipValidation,force) { function save(skipValidation, force) {
if (!$("#red-ui-header-button-deploy").hasClass("disabled")) { if ($("#red-ui-header-button-deploy").hasClass("disabled")) {
return; //deploy is disabled
}
if ($("#red-ui-header-shade").is(":visible")) {
return; //deploy is shaded
}
if (!RED.user.hasPermission("flows.write")) { if (!RED.user.hasPermission("flows.write")) {
RED.notify(RED._("user.errors.deploy"),"error"); RED.notify(RED._("user.errors.deploy"), "error");
return; return;
} }
let hasUnusedConfig = false;
if (!skipValidation) { if (!skipValidation) {
var hasUnknown = false; let hasUnknown = false;
var hasInvalid = false; let hasInvalid = false;
var hasUnusedConfig = false; const unknownNodes = [];
const invalidNodes = [];
var unknownNodes = []; RED.nodes.eachConfig(function (node) {
var invalidNodes = [];
RED.nodes.eachConfig(function(node) {
if (node.valid === undefined) { if (node.valid === undefined) {
RED.editor.validateNode(node); RED.editor.validateNode(node);
} }
@ -346,7 +350,7 @@ RED.deploy = (function() {
} }
} }
}); });
RED.nodes.eachNode(function(node) { RED.nodes.eachNode(function (node) {
if (!node.valid && !node.d) { if (!node.valid && !node.d) {
invalidNodes.push(getNodeInfo(node)); invalidNodes.push(getNodeInfo(node));
} }
@ -359,31 +363,31 @@ RED.deploy = (function() {
hasUnknown = unknownNodes.length > 0; hasUnknown = unknownNodes.length > 0;
hasInvalid = invalidNodes.length > 0; hasInvalid = invalidNodes.length > 0;
var unusedConfigNodes = []; const unusedConfigNodes = [];
RED.nodes.eachConfig(function(node) { RED.nodes.eachConfig(function (node) {
if ((node._def.hasUsers !== false) && (node.users.length === 0)) { if ((node._def.hasUsers !== false) && (node.users.length === 0)) {
unusedConfigNodes.push(getNodeInfo(node)); unusedConfigNodes.push(getNodeInfo(node));
hasUnusedConfig = true; hasUnusedConfig = true;
} }
}); });
var showWarning = false; let showWarning = false;
var notificationMessage; let notificationMessage;
var notificationButtons = []; let notificationButtons = [];
var notification; let notification;
if (hasUnknown && !ignoreDeployWarnings.unknown) { if (hasUnknown && !ignoreDeployWarnings.unknown) {
showWarning = true; showWarning = true;
notificationMessage = "<p>"+RED._('deploy.confirm.unknown')+"</p>"+ notificationMessage = "<p>" + RED._('deploy.confirm.unknown') + "</p>" +
'<ul class="red-ui-deploy-dialog-confirm-list"><li>'+cropList(unknownNodes).map(function(n) { return sanitize(n) }).join("</li><li>")+"</li></ul><p>"+ '<ul class="red-ui-deploy-dialog-confirm-list"><li>' + cropList(unknownNodes).map(function (n) { return sanitize(n) }).join("</li><li>") + "</li></ul><p>" +
RED._('deploy.confirm.confirm')+ RED._('deploy.confirm.confirm') +
"</p>"; "</p>";
notificationButtons= [ notificationButtons = [
{ {
id: "red-ui-deploy-dialog-confirm-deploy-deploy", id: "red-ui-deploy-dialog-confirm-deploy-deploy",
text: RED._("deploy.confirm.button.confirm"), text: RED._("deploy.confirm.button.confirm"),
class: "primary", class: "primary",
click: function() { click: function () {
save(true); save(true);
notification.close(); notification.close();
} }
@ -393,16 +397,16 @@ RED.deploy = (function() {
showWarning = true; showWarning = true;
invalidNodes.sort(sortNodeInfo); invalidNodes.sort(sortNodeInfo);
notificationMessage = "<p>"+RED._('deploy.confirm.improperlyConfigured')+"</p>"+ notificationMessage = "<p>" + RED._('deploy.confirm.improperlyConfigured') + "</p>" +
'<ul class="red-ui-deploy-dialog-confirm-list"><li>'+cropList(invalidNodes.map(function(A) { return sanitize( (A.tab?"["+A.tab+"] ":"")+A.label+" ("+A.type+")")})).join("</li><li>")+"</li></ul><p>"+ '<ul class="red-ui-deploy-dialog-confirm-list"><li>' + cropList(invalidNodes.map(function (A) { return sanitize((A.tab ? "[" + A.tab + "] " : "") + A.label + " (" + A.type + ")") })).join("</li><li>") + "</li></ul><p>" +
RED._('deploy.confirm.confirm')+ RED._('deploy.confirm.confirm') +
"</p>"; "</p>";
notificationButtons= [ notificationButtons = [
{ {
id: "red-ui-deploy-dialog-confirm-deploy-deploy", id: "red-ui-deploy-dialog-confirm-deploy-deploy",
text: RED._("deploy.confirm.button.confirm"), text: RED._("deploy.confirm.button.confirm"),
class: "primary", class: "primary",
click: function() { click: function () {
save(true); save(true);
notification.close(); notification.close();
} }
@ -413,28 +417,28 @@ RED.deploy = (function() {
notificationButtons.unshift( notificationButtons.unshift(
{ {
text: RED._("common.label.cancel"), text: RED._("common.label.cancel"),
click: function() { click: function () {
notification.close(); notification.close();
} }
} }
); );
notification = RED.notify(notificationMessage,{ notification = RED.notify(notificationMessage, {
modal: true, modal: true,
fixed: true, fixed: true,
buttons:notificationButtons buttons: notificationButtons
}); });
return; return;
} }
} }
var nns = RED.nodes.createCompleteNodeSet(); const nns = RED.nodes.createCompleteNodeSet();
const startTime = Date.now();
var startTime = Date.now(); $(".red-ui-deploy-button-content").css('opacity', 0);
$(".red-ui-deploy-button-content").css('opacity',0);
$(".red-ui-deploy-button-spinner").show(); $(".red-ui-deploy-button-spinner").show();
$("#red-ui-header-button-deploy").addClass("disabled"); $("#red-ui-header-button-deploy").addClass("disabled");
var data = {flows:nns}; const data = { flows: nns };
if (!force) { if (!force) {
data.rev = RED.nodes.version(); data.rev = RED.nodes.version();
@ -446,25 +450,25 @@ RED.deploy = (function() {
$("#red-ui-palette-shade").show(); $("#red-ui-palette-shade").show();
$("#red-ui-sidebar-shade").show(); $("#red-ui-sidebar-shade").show();
$.ajax({ $.ajax({
url:"flows", url: "flows",
type: "POST", type: "POST",
data: JSON.stringify(data), data: JSON.stringify(data),
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
headers: { headers: {
"Node-RED-Deployment-Type":deploymentType "Node-RED-Deployment-Type": deploymentType
} }
}).done(function(data,textStatus,xhr) { }).done(function (data, textStatus, xhr) {
RED.nodes.dirty(false); RED.nodes.dirty(false);
RED.nodes.version(data.rev); RED.nodes.version(data.rev);
RED.nodes.originalFlow(nns); RED.nodes.originalFlow(nns);
if (hasUnusedConfig) { if (hasUnusedConfig) {
RED.notify( RED.notify(
'<p>'+RED._("deploy.successfulDeploy")+'</p>'+ '<p>' + RED._("deploy.successfulDeploy") + '</p>' +
'<p>'+RED._("deploy.unusedConfigNodes")+' <a href="#" onclick="RED.sidebar.config.show(true); return false;">'+RED._("deploy.unusedConfigNodesLink")+'</a></p>',"success",false,6000); '<p>' + RED._("deploy.unusedConfigNodes") + ' <a href="#" onclick="RED.sidebar.config.show(true); return false;">' + RED._("deploy.unusedConfigNodesLink") + '</a></p>', "success", false, 6000);
} else { } else {
RED.notify('<p>'+RED._("deploy.successfulDeploy")+'</p>',"success"); RED.notify('<p>' + RED._("deploy.successfulDeploy") + '</p>', "success");
} }
RED.nodes.eachNode(function(node) { RED.nodes.eachNode(function (node) {
if (node.changed) { if (node.changed) {
node.dirty = true; node.dirty = true;
node.changed = false; node.changed = false;
@ -473,7 +477,7 @@ RED.deploy = (function() {
node.dirty = true; node.dirty = true;
node.moved = false; node.moved = false;
} }
if(node.credentials) { if (node.credentials) {
delete node.credentials; delete node.credentials;
} }
}); });
@ -483,42 +487,41 @@ RED.deploy = (function() {
delete confNode.credentials; delete confNode.credentials;
} }
}); });
RED.nodes.eachSubflow(function(subflow) { RED.nodes.eachSubflow(function (subflow) {
subflow.changed = false; subflow.changed = false;
}); });
RED.nodes.eachWorkspace(function(ws) { RED.nodes.eachWorkspace(function (ws) {
ws.changed = false; ws.changed = false;
}); });
// Once deployed, cannot undo back to a clean state // Once deployed, cannot undo back to a clean state
RED.history.markAllDirty(); RED.history.markAllDirty();
RED.view.redraw(); RED.view.redraw();
RED.events.emit("deploy"); RED.events.emit("deploy");
}).fail(function(xhr,textStatus,err) { }).fail(function (xhr, textStatus, err) {
RED.nodes.dirty(true); RED.nodes.dirty(true);
$("#red-ui-header-button-deploy").removeClass("disabled"); $("#red-ui-header-button-deploy").removeClass("disabled");
if (xhr.status === 401) { if (xhr.status === 401) {
RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error"); RED.notify(RED._("deploy.deployFailed", { message: RED._("user.notAuthorized") }), "error");
} else if (xhr.status === 409) { } else if (xhr.status === 409) {
resolveConflict(nns, true); resolveConflict(nns, true);
} else if (xhr.responseText) { } else if (xhr.responseText) {
RED.notify(RED._("deploy.deployFailed",{message:xhr.responseText}),"error"); RED.notify(RED._("deploy.deployFailed", { message: xhr.responseText }), "error");
} else { } else {
RED.notify(RED._("deploy.deployFailed",{message:RED._("deploy.errors.noResponse")}),"error"); RED.notify(RED._("deploy.deployFailed", { message: RED._("deploy.errors.noResponse") }), "error");
} }
}).always(function() { }).always(function () {
deployInflight = false; deployInflight = false;
var delta = Math.max(0,300-(Date.now()-startTime)); const delta = Math.max(0, 300 - (Date.now() - startTime));
setTimeout(function() { setTimeout(function () {
$(".red-ui-deploy-button-content").css('opacity',1); $(".red-ui-deploy-button-content").css('opacity', 1);
$(".red-ui-deploy-button-spinner").hide(); $(".red-ui-deploy-button-spinner").hide();
$("#red-ui-header-shade").hide(); $("#red-ui-header-shade").hide();
$("#red-ui-editor-shade").hide(); $("#red-ui-editor-shade").hide();
$("#red-ui-palette-shade").hide(); $("#red-ui-palette-shade").hide();
$("#red-ui-sidebar-shade").hide(); $("#red-ui-sidebar-shade").hide();
},delta); }, delta);
}); });
} }
}
return { return {
init: init, init: init,
setDeployInflight: function(state) { setDeployInflight: function(state) {

View File

@ -168,7 +168,7 @@
'b': { before:"**", after: "**", tooltip: RED._("markdownEditor.bold")}, 'b': { before:"**", after: "**", tooltip: RED._("markdownEditor.bold")},
'i': { before:"_", after: "_", tooltip: RED._("markdownEditor.italic")}, 'i': { before:"_", after: "_", tooltip: RED._("markdownEditor.italic")},
'code': { before:"`", after: "`", tooltip: RED._("markdownEditor.code")}, 'code': { before:"`", after: "`", tooltip: RED._("markdownEditor.code")},
'ol': { before:" * ", newline: true, tooltip: RED._("markdownEditor.ordered-list")}, 'ol': { before:" 1. ", newline: true, tooltip: RED._("markdownEditor.ordered-list")},
'ul': { before:" - ", newline: true, tooltip: RED._("markdownEditor.unordered-list")}, 'ul': { before:" - ", newline: true, tooltip: RED._("markdownEditor.unordered-list")},
'bq': { before:"> ", newline: true, tooltip: RED._("markdownEditor.quote")}, 'bq': { before:"> ", newline: true, tooltip: RED._("markdownEditor.quote")},
'link': { before:"[", after: "]()", tooltip: RED._("markdownEditor.link")}, 'link': { before:"[", after: "]()", tooltip: RED._("markdownEditor.link")},

View File

@ -150,7 +150,6 @@ $popover-button-border-color-hover: #666;
$diff-text-header-color: $secondary-text-color; $diff-text-header-color: $secondary-text-color;
$diff-text-header-background: #ffd; $diff-text-header-background: #ffd;
$diff-text-header-background-hover: #ffc;
$diff-state-color: $primary-text-color; $diff-state-color: $primary-text-color;
$diff-state-prefix-color: $secondary-text-color; $diff-state-prefix-color: $secondary-text-color;
$diff-state-added: #009900; $diff-state-added: #009900;
@ -195,7 +194,6 @@ $view-lasso-stroke: #ff7f0e;
$view-lasso-fill: rgba(20,125,255,0.1); $view-lasso-fill: rgba(20,125,255,0.1);
$view-background: $secondary-background; $view-background: $secondary-background;
$view-select-mode-background: $secondary-background-selected;
$view-grid-color: #eee; $view-grid-color: #eee;
$node-label-color: #333; $node-label-color: #333;

View File

@ -26,6 +26,13 @@
box-shadow: none; box-shadow: none;
} }
.ui-widget.ui-widget-content {
border: 1px solid $tertiary-border-color;
}
.ui-widget-content {
border: 1px solid $secondary-border-color;
}
.ui-widget-header { .ui-widget-header {
color: $header-text-color; color: $header-text-color;
} }

View File

@ -58,7 +58,6 @@
.red-ui-workspace-select-mode { .red-ui-workspace-select-mode {
.red-ui-workspace-chart-background { .red-ui-workspace-chart-background {
opacity: 0.7; opacity: 0.7;
// fill: $view-select-mode-background;
} }
.red-ui-workspace-chart-grid line { .red-ui-workspace-chart-grid line {
opacity: 0.8; opacity: 0.8;

View File

@ -108,7 +108,9 @@ module.exports = function(RED) {
} }
}) })
this.on("input", function(msg, send, done) { this.on("input", function(msg, send, done) {
if (hasOwnProperty.call(msg, "status") && hasOwnProperty.call(msg.status, "source") && hasOwnProperty.call(msg.status.source, "id") && (msg.status.source.id === node.id)) { if (hasOwnProperty.call(msg, "status") && msg.status &&
hasOwnProperty.call(msg.status, "source") && msg.status.source &&
hasOwnProperty.call(msg.status.source, "id") && (msg.status.source.id === node.id)) {
done(); done();
return; return;
} }
@ -129,7 +131,8 @@ module.exports = function(RED) {
fill = "red"; fill = "red";
st = msg.error.message; st = msg.error.message;
} }
if (hasOwnProperty.call(msg, "status")) { if (hasOwnProperty.call(msg, "status") &&
msg.status) {
fill = msg.status.fill || "grey"; fill = msg.status.fill || "grey";
shape = msg.status.shape || "ring"; shape = msg.status.shape || "ring";
st = msg.status.text || ""; st = msg.status.text || "";

View File

@ -35,8 +35,6 @@ module.exports = function(RED) {
} }
} }
var listenerNodes = {}; var listenerNodes = {};
var activeListenerNodes = 0;
// A node red node that sets up a local websocket server // A node red node that sets up a local websocket server
function WebSocketListenerNode(n) { function WebSocketListenerNode(n) {
@ -166,7 +164,6 @@ module.exports = function(RED) {
} }
if (node.isServer) { if (node.isServer) {
activeListenerNodes++;
if (!serverUpgradeAdded) { if (!serverUpgradeAdded) {
RED.server.on('upgrade', handleServerUpgrade); RED.server.on('upgrade', handleServerUpgrade);
serverUpgradeAdded = true serverUpgradeAdded = true
@ -210,7 +207,7 @@ module.exports = function(RED) {
startconn(); // start outbound connection startconn(); // start outbound connection
} }
node.on("close", function() { node.on("close", function(done) {
if (node.heartbeatInterval) { if (node.heartbeatInterval) {
clearInterval(node.heartbeatInterval); clearInterval(node.heartbeatInterval);
} }
@ -218,19 +215,25 @@ module.exports = function(RED) {
delete listenerNodes[node.fullPath]; delete listenerNodes[node.fullPath];
node.server.close(); node.server.close();
node._inputNodes = []; node._inputNodes = [];
activeListenerNodes--;
// if (activeListenerNodes === 0 && serverUpgradeAdded) {
// RED.server.removeListener('upgrade', handleServerUpgrade);
// serverUpgradeAdded = false;
// }
} }
else { else {
node.closing = true; node.closing = true;
node.server.close(); node.server.close();
//wait 20*50 (1000ms max) for ws to close.
//call done when readyState === ws.CLOSED (or 1000ms, whichever comes fist)
const closeMonitorInterval = 20;
let closeMonitorCount = 50;
let si = setInterval(() => {
if(node.server.readyState === ws.CLOSED || closeMonitorCount <= 0) {
if (node.tout) { if (node.tout) {
clearTimeout(node.tout); clearTimeout(node.tout);
node.tout = null; node.tout = null;
} }
clearInterval(si);
return done();
}
closeMonitorCount--;
}, closeMonitorInterval);
} }
}); });
} }

View File

@ -582,7 +582,7 @@ class Flow {
reportingNode = node; reportingNode = node;
} }
if (!muteStatusEvent) { if (!muteStatusEvent) {
if (statusMessage.hasOwnProperty("text") && typeof(statusMessage.text !== "string")) { if (statusMessage.hasOwnProperty("text") && typeof statusMessage.text !== "string") {
try { try {
statusMessage.text = statusMessage.text.toString(); statusMessage.text = statusMessage.text.toString();
} }