Replaced the flat 1000-entry select with optgroup grouping by device.
Each device gets its own optgroup label, making it possible to find
the target port even with hundreds of ports in the system.
The edit handler was fetching the connection twice but never using the
result, then constructing a new Connection struct without PortID1/PortID2
fields. The DB update would write NULL into both port columns, severing
the cable from both ends. Now the handler fetches the existing row once
and updates only the submitted metadata fields in place.