netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.77k stars 2.54k forks source link

Unable to deselect columns in listing view #6288

Closed candlerb closed 3 years ago

candlerb commented 3 years ago

NetBox version

v2.11.1

Python version

3.6

Steps to Reproduce

I am currently seeing the following behaviour:

  1. Go to /ipam/ip-addresses/
  2. Click the "Configure" button
  3. Remove one of the columns (e.g. "Role"), by clicking on it in the bottom selection box, and clicking the red "Remove columns button", then click the blue Save

(ipam/ip-addresses is just an example; I see this with others e.g. ipam/prefixes)

Expected Behavior

When the page redraws, the column should no longer be shown.

Observed Behavior

The removed column is still shown. In fact, it displays the same set of columns as if I had selected "Reset".

The columns which are not displayed by default, and hence are in the "Available columns" list, are:

I can successfully add these columns to the display, individually or all at once. However if I remove any one of them, it removes them all - again, as if I'd selected Reset.

(Aside: beta.netbox.dev is down, and netboxdemo.com is still running v2.10.1, which makes it harder to reproduce "clean")

candlerb commented 3 years ago

Looking at tcpdump I see the following when I click "Save" after removing a column:

PATCH /api/users/config/ HTTP/1.1
...

{"tables":{"IPAddressDetailTable":{"available_columns":[],"columns":[]}}}

So it looks like the Javascript is sending an empty list of columns, presumably treated as reset. (Aside: browser is Chrome 90.0.4430.85 under macOS 10.14.6. I don't see any errors in Javascript console)

If I click "Save" after adding a column (in this case "Tags"):

PATCH /api/users/config/ HTTP/1.1
...

{"tables":{"IPAddressDetailTable":{"available_columns":[],"columns":["address","vrf","status","role","tenant","assigned","dns_name","description","tags"]}}}

Here it has correctly listed the columns to display, but available_columns is empty.

Note: I do have one custom field defined in my database. It is on IPAM > Prefixes, name "dhcp_pool", label "DHCP Pool", type text. However, there are no others, and in particular not on IPAM > IPAddresses.

EDIT: I have removed the custom field, it makes no difference.

candlerb commented 3 years ago

Also, the response to the PATCH looks like this:

{"tables":{"SiteTable":{"columns":["name","status","region","asn","description","tags"]},"DeviceTable":{"columns":[],"available_columns":[]},"InterfaceTable":{"columns":["device","name","label","enabled","type","mgmt_only","description"]},"VMInterfaceTable":{"columns":["virtual_machine","name","enabled","mac_address","description"]},"PrefixDetailTable":{"columns":[],"available_columns":[]},"DeviceInterfaceTable":{"columns":["name","label","enabled","type","lag","mode","mac_address","description","cable","connection","ip_addresses","parent"],"available_columns":[]},"IPAddressDetailTable":{"columns":[],"available_columns":[]},"VirtualMachineDetailTable":{"columns":["name","status","cluster","role","primary_ip","tags"]}},"pagination":{"per_page":25}}

Note the empty column sets for DeviceTable, PrefixDetailTable, IPAddressDetailTable.

This matches select * from users_userconfig:

 id |                                                                                                                                                                                                                                                                                                                                                                                                                          data                                                                                                                                                                                                                                                                                                                                                                                                                           | user_id
----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------
  1 | {"tables": {"SiteTable": {"columns": ["name", "status", "region", "asn", "description", "tags"]}, "DeviceTable": {"columns": [], "available_columns": []}, "InterfaceTable": {"columns": ["device", "name", "label", "enabled", "type", "mgmt_only", "description"]}, "VMInterfaceTable": {"columns": ["virtual_machine", "name", "enabled", "mac_address", "description"]}, "PrefixDetailTable": {"columns": [], "available_columns": []}, "DeviceInterfaceTable": {"columns": ["name", "label", "enabled", "type", "lag", "mode", "mac_address", "description", "cable", "connection", "ip_addresses", "parent"], "available_columns": []}, "IPAddressDetailTable": {"columns": [], "available_columns": []}, "VirtualMachineDetailTable": {"columns": ["name", "status", "cluster", "role", "primary_ip", "tags"]}}, "pagination": {"per_page": 25}} |       1
(1 row)
candlerb commented 3 years ago

Another note: if I click "Reset" in the IPAM > IPAddresses view, then the exchange is:

>>>
{"tables":{"IPAddressDetailTable":{"available_columns":[],"columns":[]}}}

<<<
…,"IPAddressDetailTable":{"columns":[],"available_columns":[]},…

That is: the Reset button also sends empty column lists.

jeremystretch commented 3 years ago

Duplicate of #6248