From b96d5627006c6de371de30a1d911554fe0b02339 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sat, 4 Jul 2020 15:26:02 +0100 Subject: [PATCH] fix debug status to not loop, make migration more seamless, detect status type objects --- .../@node-red/nodes/core/common/21-debug.html | 4 ++-- .../@node-red/nodes/core/common/21-debug.js | 22 +++++++++++++++---- .../nodes/locales/en-US/messages.json | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/21-debug.html b/packages/node_modules/@node-red/nodes/core/common/21-debug.html index d12279c74..7f9c621e4 100644 --- a/packages/node_modules/@node-red/nodes/core/common/21-debug.html +++ b/packages/node_modules/@node-red/nodes/core/common/21-debug.html @@ -25,7 +25,7 @@
- + @@ -435,7 +435,7 @@ $("#node-input-typed-status").typedInput('value',this.statusVal || ""); } if (this.statusType === undefined) { - this.statusType = this.targetType; + this.statusType = "auto"; $("#node-input-typed-status").typedInput('type',this.statusType || "auto"); } if (typeof this.console === "string") { diff --git a/packages/node_modules/@node-red/nodes/core/common/21-debug.js b/packages/node_modules/@node-red/nodes/core/common/21-debug.js index c77a50c22..272f48016 100644 --- a/packages/node_modules/@node-red/nodes/core/common/21-debug.js +++ b/packages/node_modules/@node-red/nodes/core/common/21-debug.js @@ -99,6 +99,10 @@ module.exports = function(RED) { } this.on("input", function(msg, send, done) { + if (msg.hasOwnProperty("status") && msg.status.hasOwnProperty("source") && msg.status.source.hasOwnProperty("id") && (msg.status.source.id === node.id)) { + done(); + return; + } if (node.tostatus === true) { prepareStatus(msg, function(err,debugMsg) { if (err) { node.error(err); return; } @@ -106,19 +110,29 @@ module.exports = function(RED) { var st = (typeof output === 'string') ? output : util.inspect(output); var fill = "grey"; var shape = "dot"; + if (typeof output === 'object' && output.hasOwnProperty("fill") && output.hasOwnProperty("shape") && output.hasOwnProperty("text")) { + fill = output.fill; + shape = output.shape; + st = output.text; + } if (node.statusType === "auto") { if (msg.hasOwnProperty("error")) { fill = "red"; st = msg.error.message; } if (msg.hasOwnProperty("status")) { - if (msg.status.hasOwnProperty("fill")) { fill = msg.status.fill; } - if (msg.status.hasOwnProperty("shape")) { shape = msg.status.shape; } - if (msg.status.hasOwnProperty("text")) { st = msg.status.text; } + fill = msg.status.fill || "grey"; + shape = msg.status.shape || "ring"; + st = msg.status.text || ""; } } + if (st.length > 32) { st = st.substr(0,32) + "..."; } - node.status({fill:fill, shape:shape, text:st}); + var newStatus = {fill:fill, shape:shape, text:st}; + if (JSON.stringify(newStatus) !== node.oldState) { // only send if we have to + node.status(newStatus); + node.oldState = JSON.stringify(newStatus); + } }); } diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index db3da0ff8..5eff7c42d 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -123,7 +123,7 @@ "invalid-exp": "Invalid JSONata expression: __error__", "msgprop": "message property", "msgobj": "complete msg object", - "autostatus": "automatic", + "autostatus": "show Output", "to": "To", "debtab": "debug tab", "tabcon": "debug tab and console",