Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format default user preferences (and other) JSON when populating the config editor #14690

Closed
markkuleinio opened this issue Jan 4, 2024 · 2 comments · Fixed by #15623
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@markkuleinio
Copy link
Contributor

NetBox version

v3.7.0

Feature type

Change to existing functionality

Proposed functionality

When editing Default user preferences in Current Config - Edit, the JSON is shown just dumped, like this (very short example):

{"tables": {"ASNTable": {"columns": ["asn", "tags"]}, "RackTable": {"columns": ["name", "site", "get_utilization", "get_power_utilization"]}}}

I propose that the JSON data would be formatted using the same formatter as in the Current Config screen (before editing, showing JSON nicely structured and indented) before showing it in the edit box, instead of just dumping the compressed JSON data there.

If there are other similar JSON-based configuration items, this same principle can probably be used in them all.

Use case

When fine-tuning the typically very long JSON data in the config editor it is hard to locate and understand particular keys and values in the unformatted JSON dump. Formatting the JSON data nicely will help editing the data and preventing errors when modifying and saving the configuration.

Even if the editor shows the data structured and indented, it is nevertheless saved in the optimal compressed format, so there is no loss of efficiency in the database.

Database changes

None

External dependencies

None (json module from Python standard library can be used unless some other method is already preferred in NetBox)

@markkuleinio markkuleinio added the type: feature Introduction of new functionality to the application label Jan 4, 2024
@markkuleinio
Copy link
Contributor Author

I have tested code for this, so I'm willing to submit a PR if this FR is accepted.

markkuleinio added a commit to markkuleinio/netbox that referenced this issue Jan 20, 2024
@jeremystretch jeremystretch added the status: needs triage This issue is awaiting triage by a maintainer label Mar 26, 2024
@jeffgdotorg jeffgdotorg added status: accepted This issue has been accepted for implementation and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 3, 2024
@jeffgdotorg
Copy link
Contributor

Thanks for opening this FR, and for your patience. Please get that PR going and we'll see if there are any issues with the approach you chose.

For the benefit of future GitHub archaeologists, and to placate my inner pedant, I'm going to describe as "minified" the JSON formatting that you describe as "compressed".

markkuleinio added a commit to markkuleinio/netbox that referenced this issue Apr 4, 2024
jeremystretch pushed a commit that referenced this issue Apr 22, 2024
* Closes #14690: Pretty-format JSON fields in the config form

* Revert changes

* Use our own JSONField for config parameters for pretty editor outputs

* Compare identity instead of equality
JCWasmx86 pushed a commit to JCWasmx86/netbox that referenced this issue Apr 23, 2024
…g form (netbox-community#15623)

* Closes netbox-community#14690: Pretty-format JSON fields in the config form

* Revert changes

* Use our own JSONField for config parameters for pretty editor outputs

* Compare identity instead of equality
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants