Skip to content

Commit

Permalink
allow filtering of debug node output within subflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroyasuNishiyama committed Feb 10, 2021
1 parent f5da2eb commit 5a6568e
Showing 1 changed file with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ RED.debug = (function() {
filteredNodes[node.id] = !$(this).prop('checked');
$(".red-ui-debug-msg-node-"+node.id.replace(/\./g,"_")).toggleClass('hide',filteredNodes[node.id]);
});
if (!node.active || RED.nodes.workspace(node.z).disabled) {
if ((node.hasOwnProperty("active") && !node.active) || RED.nodes.workspace(node.z).disabled) {
container.addClass('disabled');
muteControl.checkboxSet('disable');
}
Expand Down Expand Up @@ -233,6 +233,35 @@ RED.debug = (function() {

}

function containsDebug(sid, map) {
if (sid in map) {
return true;
}
var nodes = RED.nodes.filterNodes({z: sid});
var contain = false;
nodes.forEach(function (n) {
if (contain) {
return;
}
var nt = n.type;
if (nt === "debug") {
contain = true;
return;
}
if (nt.substring(0, 8) === "subflow:") {
var id = nt.substring(8);
if (containsDebug(id, map)) {
contain = true;
return;
}
}
});
if (contain) {
map[sid] = true;
}
return contain;
}

function refreshDebugNodeList() {
debugNodeList.editableList('empty');
var candidateNodes = RED.nodes.filterNodes({type:'debug'});
Expand All @@ -243,7 +272,18 @@ RED.debug = (function() {
});
candidateNodes = candidateNodes.filter(function(node) {
return workspaceOrderMap.hasOwnProperty(node.z);
})
});
var map = {};
RED.nodes.eachNode(function (n) {
var nt = n.type;
if ((n.z in workspaceOrderMap) &&
(nt.substring(0, 8) === "subflow:")) {
var sid = nt.substring(8);
if (containsDebug(sid, map)) {
candidateNodes.push(n);
}
}
});
candidateNodes.sort(function(A,B) {
var wsA = workspaceOrderMap[A.z];
var wsB = workspaceOrderMap[B.z];
Expand All @@ -253,7 +293,7 @@ RED.debug = (function() {
var labelA = RED.utils.getNodeLabel(A,A.id);
var labelB = RED.utils.getNodeLabel(B,B.id);
return labelA.localeCompare(labelB);
})
});
var currentWs = null;
var nodeList = [];
candidateNodes.forEach(function(node) {
Expand All @@ -262,10 +302,8 @@ RED.debug = (function() {
nodeList.push(RED.nodes.workspace(node.z));
}
nodeList.push(node);
})


debugNodeList.editableList('addItems',nodeList)
});
debugNodeList.editableList('addItems',nodeList);
}

function getTimestamp() {
Expand Down

0 comments on commit 5a6568e

Please sign in to comment.