mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	update subflow finding algorithm
This commit is contained in:
		| @@ -224,66 +224,91 @@ RED.debug = (function() { | |||||||
|         }); |         }); | ||||||
|         RED.popover.tooltip(toolbar.find("#red-ui-sidebar-debug-clear"),RED._('node-red:debug.sidebar.clearLog'),"core:clear-debug-messages"); |         RED.popover.tooltip(toolbar.find("#red-ui-sidebar-debug-clear"),RED._('node-red:debug.sidebar.clearLog'),"core:clear-debug-messages"); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         return { |         return { | ||||||
|             content: content, |             content: content, | ||||||
|             footer: footerToolbar |             footer: footerToolbar | ||||||
|         } |         }; | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     function containsDebug(sid, map) { |     function containsDebug(sid, map) { | ||||||
|         if (sid in map) { |         var item = map[sid]; | ||||||
|             return true; |         if (item) { | ||||||
|         } |             if (item.debug === undefined) { | ||||||
|         var nodes = RED.nodes.filterNodes({z: sid}); |                 var sfs = Object.keys(item.subflows); | ||||||
|                 var contain = false; |                 var contain = false; | ||||||
|         nodes.forEach(function (n) { |                 for (var i = 0; i < sfs.length; i++) { | ||||||
|             if (contain) { |                     var sf = sfs[i]; | ||||||
|                 return; |                     if (containsDebug(sf, map)) { | ||||||
|             } |  | ||||||
|             var nt = n.type; |  | ||||||
|             if (nt === "debug") { |  | ||||||
|                         contain = true; |                         contain = true; | ||||||
|                 return; |                         break; | ||||||
|             } |  | ||||||
|             if (nt.substring(0, 8) === "subflow:") { |  | ||||||
|                 var id = nt.substring(8); |  | ||||||
|                 if (containsDebug(id, map)) { |  | ||||||
|                     contain = true; |  | ||||||
|                     return; |  | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|         }); |                 item.debug = contain; | ||||||
|         if (contain) { |  | ||||||
|             map[sid] = true; |  | ||||||
|             } |             } | ||||||
|         return contain; |             return item.debug; | ||||||
|         } |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     function refreshDebugNodeList() { |     function refreshDebugNodeList() { | ||||||
|         debugNodeList.editableList('empty'); |         debugNodeList.editableList('empty'); | ||||||
|         var candidateNodes = RED.nodes.filterNodes({type:'debug'}); |  | ||||||
|         var workspaceOrder = RED.nodes.getWorkspaceOrder(); |         var workspaceOrder = RED.nodes.getWorkspaceOrder(); | ||||||
|         var workspaceOrderMap = {}; |         var workspaceOrderMap = {}; | ||||||
|         workspaceOrder.forEach(function(ws,i) { |         workspaceOrder.forEach(function(ws,i) { | ||||||
|             workspaceOrderMap[ws] = i; |             workspaceOrderMap[ws] = i; | ||||||
|         }); |         }); | ||||||
|         candidateNodes = candidateNodes.filter(function(node) { |  | ||||||
|             return workspaceOrderMap.hasOwnProperty(node.z); |         var candidateNodes = []; | ||||||
|         }); |         var candidateSFs = []; | ||||||
|         var map = {}; |         var subflows = {}; | ||||||
|         RED.nodes.eachNode(function (n) { |         RED.nodes.eachNode(function (n) { | ||||||
|             var nt = n.type; |             var nt = n.type; | ||||||
|             if ((n.z in workspaceOrderMap) && |             if (nt === "debug") { | ||||||
|                 (nt.substring(0, 8) === "subflow:")) { |                 if (n.z in workspaceOrderMap) { | ||||||
|                 var sid = nt.substring(8); |  | ||||||
|                 if (containsDebug(sid, map)) { |  | ||||||
|                     candidateNodes.push(n); |                     candidateNodes.push(n); | ||||||
|                 } |                 } | ||||||
|  |                 else { | ||||||
|  |                     var sf = RED.nodes.subflow(n.z); | ||||||
|  |                     if (sf) { | ||||||
|  |                         subflows[sf.id] = { | ||||||
|  |                             debug: true, | ||||||
|  |                             subflows: {} | ||||||
|  |                         }; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else if(nt.substring(0, 8) === "subflow:") { | ||||||
|  |                 if (n.z in workspaceOrderMap) { | ||||||
|  |                     candidateSFs.push(n); | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     var psf = RED.nodes.subflow(n.z); | ||||||
|  |                     if (psf) { | ||||||
|  |                         var sid = nt.substring(8); | ||||||
|  |                         var item = subflows[psf.id]; | ||||||
|  |                         if (!item) { | ||||||
|  |                             item = { | ||||||
|  |                                 debug: undefined, | ||||||
|  |                                 subflows: {} | ||||||
|  |                             }; | ||||||
|  |                             subflows[psf.id] = item; | ||||||
|  |                         } | ||||||
|  |                         item.subflows[sid] = true; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |         candidateSFs.forEach(function (sf) { | ||||||
|  |             var sid = sf.type.substring(8); | ||||||
|  |             if (containsDebug(sid, subflows)) { | ||||||
|  |                 candidateNodes.push(sf); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|         candidateNodes.sort(function(A,B) { |         candidateNodes.sort(function(A,B) { | ||||||
|             var wsA = workspaceOrderMap[A.z]; |             var wsA = workspaceOrderMap[A.z]; | ||||||
|             var wsB = workspaceOrderMap[B.z]; |             var wsB = workspaceOrderMap[B.z]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user