I inserted a Junction in a flow, but the crafty beggar was nowhere to be found. I did find it eventually but there must be an easier way to find one than searching every mm of the editor. That (hopefully) being the case - how do I find them?
Not sure how much help this is but here is a flow to find which tabs contain junctions. You have to specify the name of your flows file. It includes, free of charge, a junction.
[{"id":"c49df6e16a547839","type":"tab","label":"Find Junctions","disabled":false,"info":"","env":[]},{"id":"e883c99617400e92","type":"junction","z":"c49df6e16a547839","x":560,"y":80,"wires":[[]]},{"id":"4cf40830ba8fe0a6","type":"file in","z":"c49df6e16a547839","name":"","filename":"/home/pi/.node-red/flows.json","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":300,"y":100,"wires":[["350662d71f70af2f"]]},{"id":"350662d71f70af2f","type":"json","z":"c49df6e16a547839","name":"","property":"payload","action":"","pretty":false,"x":150,"y":160,"wires":[["253619dd52d5e7c2"]]},{"id":"9e2c8711f4b584b0","type":"inject","z":"c49df6e16a547839","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":100,"wires":[["4cf40830ba8fe0a6"]]},{"id":"92bd6c51687e5b5f","type":"debug","z":"c49df6e16a547839","name":"Junctions with outgoing wires","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":140,"wires":[]},{"id":"92f88dd682af2d65","type":"function","z":"c49df6e16a547839","name":"function 29","func":"let tablist = flow.get(\"tablist\")\nfor (let i in msg.payload) {\n let newmsg = {}\n if (msg.payload[i].type == \"junction\") {\n newmsg.payload = {\"id\": msg.payload[i].id, \"Tab\": tablist[msg.payload[i].z]}\n if (msg.payload[i].wires[0].length == 0) {\n node.send([null, newmsg])\n }\n else {\n node.send([newmsg, null])\n }\n }\n}\n\n","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":160,"wires":[["92bd6c51687e5b5f"],["5ca5b2d76cf25068"]]},{"id":"5ca5b2d76cf25068","type":"debug","z":"c49df6e16a547839","name":"Junctions with no outgoing wires","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":180,"wires":[]},{"id":"253619dd52d5e7c2","type":"function","z":"c49df6e16a547839","name":"Find tab names","func":"let tablist = {}\nfor (let i in msg.payload) {\n let newmsg = {}\n if (msg.payload[i].type == \"tab\") {\n tablist[msg.payload[i].id] = msg.payload[i].label\n }\n}\nflow.set(\"tablist\", tablist)\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":160,"wires":[["92f88dd682af2d65"]]}]
So I started to reply with You can search by type:junction. You can also view all nodes in the info sidebar.
But then thought better and checked - but neither of those statements are true
Issue raised.
One of the reasons we didn't add this is because Junctions don't have properties such as a name - so it didn't feel useful to show search results where you cannot actually distinguish the results. This is also why they don't get listed in the info sidebar.
We can revisit the search aspect.
Yeah, agree, but with my hindsight glasses on, I can see a benefit to searching by type.
Yes I already tried those options before asking the question. I think, for me, the issue is the fact that the junction does not appear at the insert point. If I knew WHERE it was going to end up I would be a happy bunny.
Of course having a way to find them after the even would also be useful
Yes that's frustrating!
You can make them stand out in the editor with an editor CSS file
.red-ui-flow-junction-background {
fill: yellow;
}
I will try that. I also have a copy of your 'find a node' flow is the 'find a junction' an offshoot of that?
I don't know!
I just logged in to my experimental Node-red machine and searched for "junction" thinking it would find all the junctions.
It didn't, instead it found the flow "Find junctions"
Aside from the search question, it would be helpful to understand what is happening when you insert the junction for it not to appear where you are inserting it.
- How are you inserting the junction?
- Once you found the junction, how far off was it?
I alos have this problem from time to time
When you right click on a wire and insert junction, it seems to be inserted half-way along the wire and not at the insertion point
This can often be behind existing nodes which is why the problem occurs
You most often want to insert junctions when the desktop is pretty congested.
I'd like to insert a junction in the wires leading from the triggers to the function so I highlight the wires, place the cursor where I want the junction, right click and insert.
It gets inserted in all those wires, good.
But it's not where the cursor is. Instead it's near the middle of the wires and of course the wires are all redrawn.
Junctions getting created beneath other nodes can occur, but I find it unusual. This
Results in this
The joined/redrawn wires are deselected.
- It would be better if the junction is inserted at [the grid point closest to] the cursor.
- Selecting the redrawn wires and new junction would make it's location clearer. cf a moved/modified/inserted node is highlighted by the blue dot.
- Actually the selected appearance of a junction is pretty subliminal. Maybe a fill rather than an outline would be better?
ps Sometimes wires are too close together to easily select the right ones.
If you instead drag to select a bunch of nodes and their wires then insert a junction, it does a good job of not messing up what links where, but inserts a junction in each wire.
Gives
the selected appearance of a junction is pretty subliminal. Maybe a fill rather than an outline would be better?
Personally I would prefer it to be a little larger, sometimes I find it tricky to select the input or output rather than the body, making connecting up a problem sometimes.
Right click, insert Junction. Above and to the left. About 24 squares above and 10 squares to the left (Grid squares)
@knolleary there appears to be a problem with right click > insert when zoomed. If I zoom out three times and then try, it inserts at the wrong point.
So I think there are two separate issues here:
- inserting a link into a wire defaults to placing the junction at the mid-point of the wire, rather than where the user clicked.
- if the workspace is zoomed, the insert position is not calculated correctly
If anyone wants to get an issue raised, that would be appreciated.
Done, under 'Inserting a Junction Issues'. Hope it is OK as this is the first time I have raised an issue on Github
Done, under 'Inserting a Junction Issues'
Could you post a link to it here please, so we can easily find it.
Here it is - Inserting A Junction Issues · Issue #4969 · node-red/node-red · GitHub
Thanks @Buckskin - good first issue!