Skip to content

Use HTMX for check connectivity functionality#3568

Merged
Simrayz merged 9 commits intomasterfrom
feat/3560-use-htmx-for-check-connectivity
Oct 30, 2025
Merged

Use HTMX for check connectivity functionality#3568
Simrayz merged 9 commits intomasterfrom
feat/3560-use-htmx-for-check-connectivity

Conversation

@Simrayz
Copy link
Copy Markdown
Contributor

@Simrayz Simrayz commented Oct 1, 2025

Scope and purpose

Resolves #3560.

This PR replaces a complicated flow to check if an IP Device can connect to a given management profile. The javascript flow has been completely replaced with htmx templates and views, with a two step process:

  1. A check is made to ensure that a valid IP address is provided, and that management profiles exist. This can result in either:
    • If neither an address or profile is sent, an error message is returned.
    • If the provided address is an invalid IP, but resolves to a hostname, a prompt to select an address is shown.
    • If the IP is valid, the view returns a loader which triggers connectivity checks.
  2. With a valid IP address and selected profiles, connectivity checks are run for each provided profile.
    • The view returns a list of successful and failed connections.
    • "Collected info" is updated with the resolved sysname and netbox type.

This pull request

  • Replaces javascript flow for checking connectivity with HTMX views and templates
  • Adds test coverage for check connectivity flow
  • Improves error messages returned by the connectivity tests

Screenshots

Form is disabled while running connectivity test. A loading spinner is shown .

Before
image

After. Uses an .htmx-indicator with a spinner gif instead of Spinner(...) class in JS
image

Connectivity check responses

Before After Comment
IP and profile validation
image image Text was made slightly smaller to match other alerts in the form
image image A select is shown if an invalid IP address is resolved to a hostname
image image Selecting an address updates the IP address input
Connectivity tests
image image A successful connection shows a success alert
image image Adjusted error list items to take up less height, and removed superfluous words.
image image Checks with multiple profiles shows both successful and erroneous connections
image image Collected info is updated after a connectivity test completes, regardless of success or failure

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@Simrayz Simrayz self-assigned this Oct 1, 2025
@Simrayz Simrayz force-pushed the feat/3560-use-htmx-for-check-connectivity branch from 3a1a0cd to 584c694 Compare October 1, 2025 07:49
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 1, 2025

Test results

    27 files      27 suites   45m 41s ⏱️
 2 652 tests  2 652 ✅ 0 💤 0 ❌
19 606 runs  19 606 ✅ 0 💤 0 ❌

Results for commit 372e2db.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 89.13043% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.81%. Comparing base (bb1a777) to head (78f8274).
⚠️ Report is 210 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/web/seeddb/page/netbox/edit.py 89.13% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3568      +/-   ##
==========================================
+ Coverage   62.66%   62.81%   +0.15%     
==========================================
  Files         611      611              
  Lines       45107    45125      +18     
  Branches       43       43              
==========================================
+ Hits        28267    28346      +79     
+ Misses      16830    16769      -61     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Simrayz Simrayz force-pushed the feat/3560-use-htmx-for-check-connectivity branch 3 times, most recently from 71fd92a to 8db0ab6 Compare October 1, 2025 14:49
@Simrayz Simrayz marked this pull request as ready for review October 2, 2025 09:24
@Simrayz Simrayz requested a review from a team October 2, 2025 09:25
Copy link
Copy Markdown
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality is great! Just nitpicks to tests

@Simrayz Simrayz force-pushed the feat/3560-use-htmx-for-check-connectivity branch from f4b13e6 to 46ff1d9 Compare October 8, 2025 09:08
@Simrayz Simrayz requested a review from johannaengland October 8, 2025 09:09
@Simrayz Simrayz force-pushed the feat/3560-use-htmx-for-check-connectivity branch from 46ff1d9 to e527049 Compare October 10, 2025 11:51
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Oct 15, 2025

@lunkwill42 Let me know when you have taken a look at this, and I can merge it :)

Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole PR just gives me warm, fuzzy feelings 🫶

e527049 has a slight typo in the commit log 😉

Actually, while you're at it, can we also fix one slight thing that wasn't there before? Only profiles that fail are hyperlinked to their SeedDB page. Successful profiles are not hyperlinked. Why shouldn't they also be hyperlinked?

(A minor annoyance on my part has also always been that one can select any profile, but there is no way to go directly to see the profile details when you're unsure if you're selecting the right profile. You have to make multiple clicks to find the same profile by name in the Management Profile tab. Not sure what the UI could look like to make profile both selectable and also somehow hyperlinked so I can check their details. Feel free to make an issue out of this annoyance 😆)

@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Oct 16, 2025

This whole PR just gives me warm, fuzzy feelings 🫶

:D

e527049 has a slight typo in the commit log 😉

NPM sNPM spnm snmp. (All jokes aside, I can fix it when rebasing the fixups before merging)

Actually, while you're at it, can we also fix one slight thing that wasn't there before? Only profiles that fail are hyperlinked to their SeedDB page. Successful profiles are not hyperlinked. Why shouldn't they also be hyperlinked?

Added it :)

(A minor annoyance on my part has also always been that one can select any profile, but there is no way to go directly to see the profile details when you're unsure if you're selecting the right profile. You have to make multiple clicks to find the same profile by name in the Management Profile tab. Not sure what the UI could look like to make profile both selectable and also somehow hyperlinked so I can check their details. Feel free to make an issue out of this annoyance 😆)

I can look into it after merging this PR :) I'm not sure what kind of UX would be a good fit, but maybe selecting a profile adds it to a list, instead of using the select 2 labels.

@Simrayz Simrayz requested a review from lunkwill42 October 21, 2025 08:58
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, just a nitpick on one error message!

Comment on lines +156 to 157
if not is_valid_ip(ip_address, strict=True):
return _handle_invalid_ip(request, ip_address)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like it made much of a difference though... since your error handling routine tries to look up the string in DNS, and the resolver will actually be as lenient as to convert integer input values into something resembling an IP address. 52 still becomes 0.0.0.52 😆

@lunkwill42
Copy link
Copy Markdown
Member

lunkwill42 commented Oct 30, 2025

I can look into it after merging this PR :) I'm not sure what kind of UX would be a good fit, but maybe selecting a profile adds it to a list, instead of using the select 2 labels.

Some experimentation to find a good UX would be nice. Not high priority, but make an issue out of it :)

@Simrayz Simrayz force-pushed the feat/3560-use-htmx-for-check-connectivity branch from 372e2db to 78f8274 Compare October 30, 2025 11:53
@Simrayz Simrayz requested a review from lunkwill42 October 30, 2025 11:53
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Oct 30, 2025

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@Simrayz Simrayz merged commit 5eaae6b into master Oct 30, 2025
16 checks passed
@Simrayz Simrayz deleted the feat/3560-use-htmx-for-check-connectivity branch October 30, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace SeedDB "Check Connectivity" JavaScript-based functionality with back-end code and HTMX

3 participants