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

Implement dynamic object lists using HTMX #8057

Closed
jeremystretch opened this issue Dec 13, 2021 · 0 comments · Fixed by #8073
Closed

Implement dynamic object lists using HTMX #8057

jeremystretch opened this issue Dec 13, 2021 · 0 comments · Fixed by #8073
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@jeremystretch
Copy link
Member

NetBox version

v3.1.1

Feature type

New functionality

Proposed functionality

Currently, moving to the next page of an object table or reordering by a different column requires a complete page refresh. This issue proposes employing HTMX in an opportunistic manner so that only the table itself needs to be returned.

For example, navigating to /dcim/sites/ will render a complete page, including the first page of the sites table, as NetBox does today. However, selecting the next page or a column header will re-render only the <table> element within the page. Using HTMX, the table is rendered entirely on the backend; no additional Javascript is required on the frontend. This concept can be extended to include the "quick find" search box as well.

I've experimented with a proof of concept, and implementing this seems to require shockingly little adjustment, and no additional Javascript. I believe this can be done in a way that's completely backward-compatible: All existing links (e.g. to filtered results) will continue to work.

The key parts of this implementation include:

  • Extending the object list view to detect HTMX requests and return only the relevant HTML (i.e. rendered tables)
  • Extending the table and paginator templates to add HTMX attributes to the the relevant links
  • Some general cleanup of the table template structure

Use case

Rendering only the necessary page components, as opposed to the entire page, reduces overhead and load time, and makes for a more seamless user experience.

Database changes

No response

External dependencies

No response

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Dec 13, 2021
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Dec 14, 2021
@jeremystretch jeremystretch self-assigned this Dec 14, 2021
jeremystretch added a commit that referenced this issue Dec 15, 2021
Closes #8057: Dynamic object tables using HTMX
jeremystretch added a commit that referenced this issue Dec 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2022
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.

1 participant