From ed9c91c47d3f16719a7de1a072a65ba31e034211 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Fri, 7 Aug 2026 10:30:38 -0400 Subject: [PATCH] Give a network device somewhere to put its IP The network device form had no IP field, so the one thing people look up a switch for could not be entered. The API had accepted an ipaddress since the legacy import work - create, update and every read already carried it - but nothing in the UI ever sent one, which also left the device off the "Devices on this network" list, since that matches on the IP a device does not have. The field sits next to Hostname and round-trips through the Communication row the platform keeps IPs in, the same way the PC and printer forms do. Clearing it now clears the stored address. The upsert helper returned early on a blank value despite a docstring promising it cleared - harmless while no form could submit one, wrong the moment this field existed. --- plugins/network/api/routes.py | 8 +++-- .../frontend/views/NetworkDeviceForm.vue | 15 +++++++++ tests/test_plugins/test_network_ipaddress.py | 33 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/plugins/network/api/routes.py b/plugins/network/api/routes.py index 3dfdc87..a011fa8 100644 --- a/plugins/network/api/routes.py +++ b/plugins/network/api/routes.py @@ -24,9 +24,13 @@ def _upsert_primary_ip(asset, ip): """Create/update/clear the asset's primary IP Communication from an ipaddress string. No-op if the IP CommunicationType is not seeded.""" ip = (ip or '').strip() - if not ip: - return comm = Communication.query.filter_by(assetid=asset.assetid, isprimary=True).first() + if not ip: + # Clearing the field clears the row's IP - it used to return early, so + # an address could be typed but never taken back out. + if comm: + comm.ipaddress = None + return if comm: comm.ipaddress = ip return diff --git a/plugins/network/frontend/views/NetworkDeviceForm.vue b/plugins/network/frontend/views/NetworkDeviceForm.vue index a10fe55..dbaa4b3 100644 --- a/plugins/network/frontend/views/NetworkDeviceForm.vue +++ b/plugins/network/frontend/views/NetworkDeviceForm.vue @@ -112,6 +112,16 @@ placeholder="e.g., sw-bldg1-floor2" /> +
+ + +