mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Tidy up debug message status count
This commit is contained in:
parent
a63dfc4650
commit
973b31521e
@ -456,7 +456,7 @@
|
|||||||
|
|
||||||
var counter = {
|
var counter = {
|
||||||
value: "counter",
|
value: "counter",
|
||||||
label: "message count",
|
label: RED._("node-red:debug.messageCount"),
|
||||||
hasValue: false
|
hasValue: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ module.exports = function(RED) {
|
|||||||
var statExpression = hasStatExpression ? n.statusVal : null;
|
var statExpression = hasStatExpression ? n.statusVal : null;
|
||||||
|
|
||||||
var node = this;
|
var node = this;
|
||||||
if ( node.statusType === "counter" ){
|
if ( node.statusType === "counter" ){
|
||||||
node.status({fill:"blue", shape:"ring", text: node.counter});
|
node.status({fill:"blue", shape:"ring", text: node.counter});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.status({fill:"", shape:"", text: ""});
|
node.status({fill:"", shape:"", text: ""});
|
||||||
}
|
}
|
||||||
var preparedEditExpression = null;
|
var preparedEditExpression = null;
|
||||||
var preparedStatExpression = null;
|
var preparedStatExpression = null;
|
||||||
if (editExpression) {
|
if (editExpression) {
|
||||||
@ -115,6 +115,9 @@ module.exports = function(RED) {
|
|||||||
if (this.oldState) {
|
if (this.oldState) {
|
||||||
this.status({});
|
this.status({});
|
||||||
}
|
}
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
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") && hasOwnProperty.call(msg.status, "source") && hasOwnProperty.call(msg.status.source, "id") && (msg.status.source.id === node.id)) {
|
||||||
@ -122,57 +125,54 @@ module.exports = function(RED) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (node.tostatus === true) {
|
if (node.tostatus === true) {
|
||||||
prepareStatus(msg, function(err,debugMsg) {
|
if ( node.statusType === "counter" ){
|
||||||
if (err) { node.error(err); return; }
|
const differenceOfTime = (new Date().getTime() - node.lastTime);
|
||||||
|
node.lastTime = new Date().getTime();
|
||||||
if ( node.statusType === "counter" ){
|
node.counter++;
|
||||||
const differenceOfTime = (new Date().getTime() - node.lastTime);
|
if ( differenceOfTime > 100 ){
|
||||||
node.lastTime = new Date().getTime();
|
node.status({fill:"blue", shape:"ring", text: node.counter});
|
||||||
node.counter++;
|
}
|
||||||
if ( differenceOfTime > 100 ){
|
|
||||||
node.status({fill:"blue", shape:"ring", text: node.counter});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (node.timeout) {
|
|
||||||
clearTimeout(node.timeout)
|
|
||||||
}
|
|
||||||
node.timeout = setTimeout(() => {
|
|
||||||
node.status({fill:"blue", shape:"ring", text: node.counter})
|
|
||||||
}, 200)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
var output = debugMsg.msg;
|
if (node.timeout) {
|
||||||
var st = (typeof output === 'string') ? output : util.inspect(output);
|
clearTimeout(node.timeout)
|
||||||
var fill = "grey";
|
}
|
||||||
var shape = "dot";
|
node.timeout = setTimeout(() => {
|
||||||
if (typeof output === 'object' && hasOwnProperty.call(output, "fill") && hasOwnProperty.call(output, "shape") && hasOwnProperty.call(output, "text")) {
|
node.status({fill:"blue", shape:"ring", text: node.counter})
|
||||||
fill = output.fill;
|
}, 200)
|
||||||
shape = output.shape;
|
}
|
||||||
st = output.text;
|
} else {
|
||||||
}
|
prepareStatus(msg, function(err,debugMsg) {
|
||||||
if (node.statusType === "auto") {
|
if (err) { node.error(err); return; }
|
||||||
if (hasOwnProperty.call(msg, "error")) {
|
var output = debugMsg.msg;
|
||||||
fill = "red";
|
var st = (typeof output === 'string') ? output : util.inspect(output);
|
||||||
st = msg.error.message;
|
var fill = "grey";
|
||||||
}
|
var shape = "dot";
|
||||||
if (hasOwnProperty.call(msg, "status")) {
|
if (typeof output === 'object' && hasOwnProperty.call(output, "fill") && hasOwnProperty.call(output, "shape") && hasOwnProperty.call(output, "text")) {
|
||||||
fill = msg.status.fill || "grey";
|
fill = output.fill;
|
||||||
shape = msg.status.shape || "ring";
|
shape = output.shape;
|
||||||
st = msg.status.text || "";
|
st = output.text;
|
||||||
}
|
}
|
||||||
}
|
if (node.statusType === "auto") {
|
||||||
|
if (hasOwnProperty.call(msg, "error")) {
|
||||||
|
fill = "red";
|
||||||
|
st = msg.error.message;
|
||||||
|
}
|
||||||
|
if (hasOwnProperty.call(msg, "status")) {
|
||||||
|
fill = msg.status.fill || "grey";
|
||||||
|
shape = msg.status.shape || "ring";
|
||||||
|
st = msg.status.text || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (st.length > 32) { st = st.substr(0,32) + "..."; }
|
if (st.length > 32) { st = st.substr(0,32) + "..."; }
|
||||||
|
|
||||||
var newStatus = {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
|
if (JSON.stringify(newStatus) !== node.oldState) { // only send if we have to
|
||||||
node.status(newStatus);
|
node.status(newStatus);
|
||||||
node.oldState = JSON.stringify(newStatus);
|
node.oldState = JSON.stringify(newStatus);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.complete === "true") {
|
if (this.complete === "true") {
|
||||||
@ -315,7 +315,7 @@ module.exports = function(RED) {
|
|||||||
res.sendFile(
|
res.sendFile(
|
||||||
req.params[0],
|
req.params[0],
|
||||||
options,
|
options,
|
||||||
err => {
|
err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
"msgprop": "message property",
|
"msgprop": "message property",
|
||||||
"msgobj": "complete msg object",
|
"msgobj": "complete msg object",
|
||||||
"autostatus": "same as debug output",
|
"autostatus": "same as debug output",
|
||||||
|
"messageCount": "message count",
|
||||||
"to": "To",
|
"to": "To",
|
||||||
"debtab": "debug tab",
|
"debtab": "debug tab",
|
||||||
"tabcon": "debug tab and console",
|
"tabcon": "debug tab and console",
|
||||||
|
Loading…
Reference in New Issue
Block a user