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

Merge pull request #2638 from node-red/Clean-up-debug-status-/-remove-loops

fix debug status to not loop, make migration more seamless, detect status type objects
This commit is contained in:
Nick O'Leary 2020-07-07 13:37:05 +01:00 committed by GitHub
commit dc541444ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View File

@ -25,7 +25,7 @@
</label> </label>
</div> </div>
<div class="form-row" id="node-tostatus-line"> <div class="form-row" id="node-tostatus-line">
<label for="node-input-typed-status"><i class="fa fa-ellipsis-h"></i> <span data-i18n="debug.status"></span></label> <label for="node-input-typed-status"></label>
<input id="node-input-typed-status" type="text" style="width: 70%"> <input id="node-input-typed-status" type="text" style="width: 70%">
<input id="node-input-statusVal" type="hidden"> <input id="node-input-statusVal" type="hidden">
<input id="node-input-statusType" type="hidden"> <input id="node-input-statusType" type="hidden">
@ -435,7 +435,7 @@
$("#node-input-typed-status").typedInput('value',this.statusVal || ""); $("#node-input-typed-status").typedInput('value',this.statusVal || "");
} }
if (this.statusType === undefined) { if (this.statusType === undefined) {
this.statusType = this.targetType; this.statusType = "auto";
$("#node-input-typed-status").typedInput('type',this.statusType || "auto"); $("#node-input-typed-status").typedInput('type',this.statusType || "auto");
} }
if (typeof this.console === "string") { if (typeof this.console === "string") {

View File

@ -99,6 +99,10 @@ module.exports = function(RED) {
} }
this.on("input", function(msg, send, done) { 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) { if (node.tostatus === true) {
prepareStatus(msg, function(err,debugMsg) { prepareStatus(msg, function(err,debugMsg) {
if (err) { node.error(err); return; } if (err) { node.error(err); return; }
@ -106,19 +110,29 @@ module.exports = function(RED) {
var st = (typeof output === 'string') ? output : util.inspect(output); var st = (typeof output === 'string') ? output : util.inspect(output);
var fill = "grey"; var fill = "grey";
var shape = "dot"; 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 (node.statusType === "auto") {
if (msg.hasOwnProperty("error")) { if (msg.hasOwnProperty("error")) {
fill = "red"; fill = "red";
st = msg.error.message; st = msg.error.message;
} }
if (msg.hasOwnProperty("status")) { if (msg.hasOwnProperty("status")) {
if (msg.status.hasOwnProperty("fill")) { fill = msg.status.fill; } fill = msg.status.fill || "grey";
if (msg.status.hasOwnProperty("shape")) { shape = msg.status.shape; } shape = msg.status.shape || "ring";
if (msg.status.hasOwnProperty("text")) { st = msg.status.text; } st = msg.status.text || "";
} }
} }
if (st.length > 32) { st = st.substr(0,32) + "..."; } 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);
}
}); });
} }

View File

@ -123,7 +123,7 @@
"invalid-exp": "Invalid JSONata expression: __error__", "invalid-exp": "Invalid JSONata expression: __error__",
"msgprop": "message property", "msgprop": "message property",
"msgobj": "complete msg object", "msgobj": "complete msg object",
"autostatus": "automatic", "autostatus": "show Output",
"to": "To", "to": "To",
"debtab": "debug tab", "debtab": "debug tab",
"tabcon": "debug tab and console", "tabcon": "debug tab and console",