Skip to content

[change] Reuse django-leaflet for dashboard map #709 - #794

Draft
kunalverma2512 wants to merge 11 commits into
openwisp:masterfrom
kunalverma2512:bugfix/709-reuse-django-leaflet
Draft

[change] Reuse django-leaflet for dashboard map #709#794
kunalverma2512 wants to merge 11 commits into
openwisp:masterfrom
kunalverma2512:bugfix/709-reuse-django-leaflet

Conversation

@kunalverma2512

@kunalverma2512 kunalverma2512 commented May 18, 2026

Copy link
Copy Markdown

Removed bundled netjsongraph files and updated device map templates to load unbundled ECharts and django-leaflet directly, preventing redundant Leaflet loading.

Fixes #709

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #709.
Closes #710.

Description of Changes

To achieve the "Ideal Situation" described in #709 and avoid loading Leaflet twice, this PR makes the following changes:

  • Deletes the heavily bundled netjsongraph.min.js and its associated CSS from the monitoring/static/ folder.
  • Updates MapPageAdmin in device/admin.py to point to the new, unbundled ECharts assets from openwisp-utils.
  • Injects {% leaflet_js %} and {% leaflet_css %} into map_page.html so the dashboard map correctly reuses the Leaflet assets directly from django-leaflet.

This PR depends on the shared static files introduced in my openwisp-utils PR .

Screenshot

5DB6A74D-5BC0-4A92-9D10-B214DA2A3AB9 56D3EA7F-1ED8-4CFF-9B9D-77BA4932E9ED image

Removed bundled netjsongraph files and updated device map templates to load unbundled ECharts and django-leaflet directly, preventing redundant Leaflet loading.

Fixes openwisp#709
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates the admin map page to load Leaflet via django-leaflet and switches MapPageAdmin.Media to use ECharts plus the netjsongraph.echarts bundle and lib/netjsongraph CSS. Admin tests were updated to expect the new JS files. Separately, setup.py now appends a CI-specific openwisp-utils Git dependency into install_requires.

Sequence Diagram(s)

sequenceDiagram
  participant AdminTemplate as map_page.html
  participant DjangoLeaflet as django-leaflet
  participant AdminMedia as MapPageAdmin.Media
  AdminTemplate->>DjangoLeaflet: render `{% leaflet_js %}` + `{% leaflet_css %}`
  AdminTemplate->>AdminMedia: render `{{ media }}` (echarts.min.js + netjsongraph.echarts.min.js + lib/netjsongraph css)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nemesifier

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Bug Fixes ❌ Error Test updates check asset paths but don't reproduce the bug scenario (Leaflet loading twice). No new regression test verifies Leaflet loads only from django-leaflet, not bundled with netjsongraph. Add test verifying Leaflet loads from django-leaflet only and netjsongraph is unbundled from it, confirming the fix prevents redundant Leaflet loading.
Out of Scope Changes check ❓ Inconclusive The setup.py change adding an unconditional CI-specific openwisp-utils dependency via Git URL is potentially out of scope or temporary in nature and warrants clarification. Clarify whether the setup.py modification is intentional and permanent, or if it was meant to be reverted as part of cleanup.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title '[change] Reuse django-leaflet for dashboard map #709' follows the required format with [change] prefix, is descriptive, references the linked issue, and clearly summarizes the main change.
Linked Issues check ✅ Passed Changes align with #709 objectives: removes bundled netjsongraph files, updates MapPageAdmin to use unbundled ECharts assets, and injects django-leaflet CSS/JS to reuse Leaflet from django-leaflet instead of bundling it.
Description check ✅ Passed Pull request description is comprehensive, includes all required checklist items, references related issues, and provides clear explanation of changes with supporting screenshots.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label May 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openwisp_monitoring/device/admin.py`:
- Around line 591-599: The Media asset paths in the device admin (Media class in
openwisp_monitoring/device/admin.py) were changed to lib/netjsongraph/... but
apps.py (AppConfig in openwisp_monitoring/device/apps.py) and tests still
reference monitoring/js/lib/netjsongraph.* and the new files
(lib/netjsongraph/js/netjsongraph.echarts.min.js and
lib/netjsongraph/css/netjsongraph*.css) do not exist; fix this by making asset
references consistent across the codebase: either (A) restore the old paths in
the Media class to monitoring/js/lib/netjsongraph.* and
monitoring/css/netjsongraph.css everywhere (admin.py, apps.py, tests) or (B) add
the missing static files under static/lib/netjsongraph/js and
static/lib/netjsongraph/css and update apps.py and all tests to reference
lib/netjsongraph/...; ensure the chosen approach updates admin.py Media, the
AppConfig asset references, and any unit tests so all three components point to
the same existing asset filenames and that staticfiles collection will include
them.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1e21d724-ac4e-4965-80d4-fa93e12d8175

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0d312 and ad5e8e6.

⛔ Files ignored due to path filters (1)
  • openwisp_monitoring/device/static/monitoring/js/lib/netjsongraph.min.js is excluded by !**/*.min.js
📒 Files selected for processing (3)
  • openwisp_monitoring/device/admin.py
  • openwisp_monitoring/device/static/monitoring/css/netjsongraph.css
  • openwisp_monitoring/device/templates/admin/map/map_page.html
💤 Files with no reviewable changes (1)
  • openwisp_monitoring/device/static/monitoring/css/netjsongraph.css
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
{**/*.sh,**/*.{js,ts,tsx,jsx},**/*.py,**/*.rb,**/*.go,**/*.java,**/*.cs,**/*.cpp,**/*.c}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • openwisp_monitoring/device/admin.py
🧠 Learnings (3)
📚 Learning: 2026-02-21T18:44:28.852Z
Learnt from: dee077
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/device/api/views.py:263-281
Timestamp: 2026-02-21T18:44:28.852Z
Learning: In openwisp-monitoring, MonitoringIndoorCoordinatesList inherits organization scoping from the parent IndoorCoordinatesList (from openwisp-controller), which uses FilterByParentManaged mixin and filters by location_id in get_queryset(). The child class only overrides the queryset attribute to add monitoring-specific select_related fields; this pattern is safe as long as get_queryset() from the parent is not bypassed. During reviews, verify that MonitoringIndoorCoordinatesList continues to rely on the parent's get_queryset() and that any added select_related fields in the child do not alter the parent's filtering logic.

Applied to files:

  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In this repository (openwisp/openwisp-monitoring), the project targets Python 3.10–3.13 as defined by CI. Do not flag backports.zoneinfo as a missing dependency; zoneinfo is a built-in module in all supported Python versions. When reviewing Python code, assume zoneinfo is available and avoid suggesting installation of backports.zoneinfo. If a file imports zoneinfo or uses it for time zone handling, treat it as standard library usage compatible with the supported CI matrix.

Applied to files:

  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In the openwisp-monitoring project, targets are Linux-based environments. Do not flag a Windows-specific tzdata package as a missing dependency in code reviews for Python files (e.g., openwisp_monitoring/utils.py). If a platform-specific dependency is truly required, document the exception in review guidelines and ensure CI/packaging checks enforce platform constraints rather than manual review.

Applied to files:

  • openwisp_monitoring/device/admin.py
🔇 Additional comments (2)
openwisp_monitoring/device/templates/admin/map/map_page.html (1)

17-19: LGTM!

openwisp_monitoring/device/admin.py (1)

592-592: ⚡ Quick win

No action required—fullscreen plugin compatibility verified.

The leaflet.fullscreen.min.js plugin is confirmed compatible with Leaflet loaded from django-leaflet. The plugin uses standard Leaflet APIs (L.Control, L.Map.include, L.DomUtil, L.DomEvent) that remain stable across versions, and existing tests (test_floorplan_fullscreen, test_admin.py) actively verify fullscreen functionality works correctly.

Comment on lines +591 to +599
"lib/netjsongraph/js/netjsongraph.echarts.min.js",
"monitoring/js/lib/leaflet.fullscreen.min.js",
]
css = {
"all": [
"monitoring/css/device-map.css",
"leaflet/leaflet.css",
"monitoring/css/leaflet.fullscreen.css",
"monitoring/css/netjsongraph.css",
"lib/netjsongraph/css/netjsongraph.css",
"lib/netjsongraph/css/netjsongraph-theme.css",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining references to old netjsongraph bundle paths

# Check for old JS path references
echo "=== Checking for old netjsongraph.min.js references ==="
rg -n "netjsongraph\.min\.js" --type py --type html --type js -g '!*.min.js'

# Check for old CSS path references  
echo -e "\n=== Checking for old monitoring/css/netjsongraph.css references ==="
rg -n "monitoring/css/netjsongraph\.css" --type py --type html

# Verify new paths exist or are documented
echo -e "\n=== Checking for new lib/netjsongraph path references ==="
fd -t f "netjsongraph.echarts.min.js"
fd -t f -p "lib/netjsongraph/css/netjsongraph.css"

Repository: openwisp/openwisp-monitoring

Length of output: 1070


🏁 Script executed:

# Check the context around apps.py lines 378-381 to understand the scope
sed -n '375,385p' openwisp_monitoring/device/apps.py

# Check if admin.py is the only file with new paths, or if there are other updated files
echo "=== Searching for lib/netjsongraph references in .py files ==="
rg -n "lib/netjsongraph" --type py

# Verify the exact state in admin.py around the modified lines
echo -e "\n=== Admin.py context around lines 591-599 ==="
sed -n '589,601p' openwisp_monitoring/device/admin.py

Repository: openwisp/openwisp-monitoring

Length of output: 1941


Critical: Asset migration is incomplete and will cause runtime failures.

The admin.py Media class has been updated to reference assets from lib/netjsongraph/ (lines 591, 598-599), but:

  1. Other files still use old paths: apps.py (lines 378, 381) and test files continue to reference monitoring/js/lib/netjsongraph.min.js and monitoring/css/netjsongraph.css
  2. New assets do not exist: The files lib/netjsongraph/js/netjsongraph.echarts.min.js and lib/netjsongraph/css/netjsongraph*.css are not present in the repository
  3. Conflicting references: Two different Media configurations in the same codebase now use incompatible asset paths

Either migrate all asset references across apps.py, test files, and admin.py consistently, or verify that openwisp-utils has been integrated and the new assets are available. This PR cannot merge in its current state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openwisp_monitoring/device/admin.py` around lines 591 - 599, The Media asset
paths in the device admin (Media class in openwisp_monitoring/device/admin.py)
were changed to lib/netjsongraph/... but apps.py (AppConfig in
openwisp_monitoring/device/apps.py) and tests still reference
monitoring/js/lib/netjsongraph.* and the new files
(lib/netjsongraph/js/netjsongraph.echarts.min.js and
lib/netjsongraph/css/netjsongraph*.css) do not exist; fix this by making asset
references consistent across the codebase: either (A) restore the old paths in
the Media class to monitoring/js/lib/netjsongraph.* and
monitoring/css/netjsongraph.css everywhere (admin.py, apps.py, tests) or (B) add
the missing static files under static/lib/netjsongraph/js and
static/lib/netjsongraph/css and update apps.py and all tests to reference
lib/netjsongraph/...; ensure the chosen approach updates admin.py Media, the
AppConfig asset references, and any unit tests so all three components point to
the same existing asset filenames and that staticfiles collection will include
them.

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (2/3).

@kunalverma2512

Copy link
Copy Markdown
Author

Hi @nemesifier, I am completely done with the changes for this issue!

Just a heads-up that the CI tests are currently failing with NetJSONGraph is not defined and Leaflet errors. This is expected because the CI environment is pulling the master branch of openwisp-utils, which doesn't contain the new unbundled static files from my other PR (openwisp-utils#675) yet.

The script loading order is correctly set up to load django-leaflet first. Once the openwisp-utils PR is merged, the 404 errors here will resolve and the CI will automatically pass.

Please let me know what the next steps are for further working on this project, and if any more guidance will help me get things finalized as nicely as possible!

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (2/3).

@nemesifier nemesifier left a comment

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.

The failing selenium test indicates there's a problem.

- Added missing echarts.min.js to MapPageAdmin to fix NetJSONGraph initialization.
- Temporarily pointed setup.py to custom openwisp-utils branch for CI testing.
- Resolved flake8 trailing whitespace and black line-length limits in setup.py.

Fixes openwisp#709

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@setup.py`:
- Around line 22-26: The temporary git dependency is being appended inside the
requirements parsing loop (the requirements.append(...) call), causing
duplication and always including the fork; move that requirements.append call
out of the loop so it runs once after the requirements list is built, and wrap
it with an environment check (e.g., if os.getenv("ADD_OPENWISP_UTILS_FORK") or
similar) so the git dependency is only added when the env var is set; also add
an import for os if not present and ensure the logic references the same
requirements list variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1eefea9c-c4cf-4615-8c0a-0c78397e0860

📥 Commits

Reviewing files that changed from the base of the PR and between ad5e8e6 and 6d600ec.

📒 Files selected for processing (2)
  • openwisp_monitoring/device/admin.py
  • setup.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
{**/*.sh,**/*.{js,ts,tsx,jsx},**/*.py,**/*.rb,**/*.go,**/*.java,**/*.cs,**/*.cpp,**/*.c}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • setup.py
  • openwisp_monitoring/device/admin.py
🧠 Learnings (3)
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In this repository (openwisp/openwisp-monitoring), the project targets Python 3.10–3.13 as defined by CI. Do not flag backports.zoneinfo as a missing dependency; zoneinfo is a built-in module in all supported Python versions. When reviewing Python code, assume zoneinfo is available and avoid suggesting installation of backports.zoneinfo. If a file imports zoneinfo or uses it for time zone handling, treat it as standard library usage compatible with the supported CI matrix.

Applied to files:

  • setup.py
  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In the openwisp-monitoring project, targets are Linux-based environments. Do not flag a Windows-specific tzdata package as a missing dependency in code reviews for Python files (e.g., openwisp_monitoring/utils.py). If a platform-specific dependency is truly required, document the exception in review guidelines and ensure CI/packaging checks enforce platform constraints rather than manual review.

Applied to files:

  • setup.py
  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-02-21T18:44:28.852Z
Learnt from: dee077
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/device/api/views.py:263-281
Timestamp: 2026-02-21T18:44:28.852Z
Learning: In openwisp-monitoring, MonitoringIndoorCoordinatesList inherits organization scoping from the parent IndoorCoordinatesList (from openwisp-controller), which uses FilterByParentManaged mixin and filters by location_id in get_queryset(). The child class only overrides the queryset attribute to add monitoring-specific select_related fields; this pattern is safe as long as get_queryset() from the parent is not bypassed. During reviews, verify that MonitoringIndoorCoordinatesList continues to rely on the parent's get_queryset() and that any added select_related fields in the child do not alter the parent's filtering logic.

Applied to files:

  • openwisp_monitoring/device/admin.py
🔇 Additional comments (1)
openwisp_monitoring/device/admin.py (1)

591-593: LGTM!

Comment thread setup.py Outdated
Moved the temporary openwisp-utils CI requirement outside the requirements.txt parsing loop to prevent duplicate appending and pip ResolutionImpossible errors.

Fixes openwisp#709

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
setup.py (1)

22-26: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Gate the temporary git dependency to CI only.

On Line 22–26, this temporary fork is still added unconditionally, so all installs (not just CI) can pull a feature-branch dependency. Please guard it behind an environment variable before appending.

#!/bin/bash
# Verify whether setup.py gates the temporary openwisp-utils git dependency by env var.
# Expected: an `os.environ.get(...)` / `os.getenv(...)` check controls this append.
nl -ba setup.py | sed -n '1,80p'
rg -n 'openwisp-utils @ git\+https://github.com/kunalverma2512/openwisp-utils.git@feature/517-add-netjsongraph-static|os\.environ|getenv' setup.py
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@setup.py` around lines 22 - 26, The temporary git dependency appended via
requirements.append("openwisp-utils @
git+https://github.com/kunalverma2512/...@feature/517-add-netjsongraph-static")
must be gated to CI only; modify the block so it only runs when an environment
variable (e.g., CI or INCLUDE_TEMP_GIT_DEP) is set by checking
os.environ.get(...) or os.getenv(...), and only then call requirements.append
for that openwisp-utils entry; update or add a short comment indicating this is
CI-only and ensure you reference the existing requirements.append call when
making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@setup.py`:
- Around line 22-26: The temporary git dependency appended via
requirements.append("openwisp-utils @
git+https://github.com/kunalverma2512/...@feature/517-add-netjsongraph-static")
must be gated to CI only; modify the block so it only runs when an environment
variable (e.g., CI or INCLUDE_TEMP_GIT_DEP) is set by checking
os.environ.get(...) or os.getenv(...), and only then call requirements.append
for that openwisp-utils entry; update or add a short comment indicating this is
CI-only and ensure you reference the existing requirements.append call when
making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0a5cce28-7b94-4885-a923-bd064b292bb7

📥 Commits

Reviewing files that changed from the base of the PR and between 6d600ec and 75a0753.

📒 Files selected for processing (1)
  • setup.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
🧰 Additional context used
📓 Path-based instructions (1)
{**/*.sh,**/*.{js,ts,tsx,jsx},**/*.py,**/*.rb,**/*.go,**/*.java,**/*.cs,**/*.cpp,**/*.c}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • setup.py
🧠 Learnings (2)
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In this repository (openwisp/openwisp-monitoring), the project targets Python 3.10–3.13 as defined by CI. Do not flag backports.zoneinfo as a missing dependency; zoneinfo is a built-in module in all supported Python versions. When reviewing Python code, assume zoneinfo is available and avoid suggesting installation of backports.zoneinfo. If a file imports zoneinfo or uses it for time zone handling, treat it as standard library usage compatible with the supported CI matrix.

Applied to files:

  • setup.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In the openwisp-monitoring project, targets are Linux-based environments. Do not flag a Windows-specific tzdata package as a missing dependency in code reviews for Python files (e.g., openwisp_monitoring/utils.py). If a platform-specific dependency is truly required, document the exception in review guidelines and ensure CI/packaging checks enforce platform constraints rather than manual review.

Applied to files:

  • setup.py

Removed the temporary openwisp-utils git requirement from setup.py as it conflicts with upstream dependencies like openwisp-controller during pip resolution. The missing echarts.min.js file added to MapPageAdmin previously should be sufficient to pass initialization.

Fixes openwisp#709
@kunalverma2512

Copy link
Copy Markdown
Author

Hi @nemesifier, you were completely right about the Selenium tests indicating a problem. Thank you for pointing that out!

I dug into the logs and realized exactly what went wrong. Here is a summary of what I just updated:

  1. The Root Cause: I realized I missed including echarts.min.js in the Media class of MapPageAdmin. This caused the NetJSONGraph is not defined error, which completely crashed the map during the automated browser tests. I have now explicitly added echarts.min.js to fix this.
  2. The CI Experiment: To prove the map works, I temporarily tried pointing setup.py to my custom openwisp-utils PR branch so the CI could fetch the unbundled files. However, this caused a pip ResolutionImpossible conflict with openwisp-controller (which strictly expects the upstream utils version).
  3. The Revert & Current State: I reverted the setup.py hack to keep the dependencies clean. All code is currently passing the run-qa-checks formatting strictly.

Current Status:
The CI tests will likely still show red with 404 errors during the Selenium tests because the CI is pulling the master branch of openwisp-utils (which lacks the unbundled static files until my other PR is merged). However, the actual code missing the ECharts initialization has been corrected!

Please let me know if this looks good to you now, or if there is anything else I should adjust!

@CodingWithSaksham

Copy link
Copy Markdown
Contributor

I encountered GDAL/GeoDjango system dependency issues while trying to spin up the local test server on my Mac. Because these changes are strictly related to frontend static file paths, I am submitting this PR to allow the CI pipeline to run its automated tests on the map integration

You can use docker to build a test environment via the given Dockerfile and docker-compose.yml. There can still be some minor issues but most of the dependencies should be solved.

@CodingWithSaksham

CodingWithSaksham commented May 20, 2026

Copy link
Copy Markdown
Contributor

@kunalverma2512 I ran your code locally and it seems like you have a few issues, these issues are also there in the CI

Error 1:- 
  File "/opt/openwisp/openwisp_monitoring/device/tests/test_admin.py", line 1263, in test_mappage_admin_media_files
    self.assertContains(response, static_file)
AssertionError: False is not true : Couldn't find 'monitoring/js/lib/netjsongraph.min.js' in the following response
----------------------------------------------------------------------------
Error 2:-
Traceback (most recent call last):
  File "/opt/openwisp/openwisp_monitoring/tests/test_selenium.py", line 77, in setUpClass
    super().setUpClass()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 96, in setUpClass
    cls.web_driver = cls.get_webdriver()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 101, in get_webdriver
    return cls.get_firefox_webdriver()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 139, in get_firefox_webdriver
    web_driver = webdriver.Firefox(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 69, in __init__
    super().__init__(command_executor=executor, options=self.options)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/common/webdriver.py", line 25, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 274, in __init__
    self.start_session(capabilities)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 370, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 450, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 255
--------------------------------------------------------------

Error 3:-
django.core.exceptions.ImproperlyConfigured: test_metric is an already registered Metric Configuration.

These test cases are making your test suit fail, most importantly the 1st one. I haven't dig into this PR/issue much but you either

  • Need to change the test case to point to the relevant file.
  • Change your code to so that this test case passes

@CodingWithSaksham

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openwisp_monitoring/device/admin.py`:
- Around line 591-592: The MapPageAdmin.Media asset paths changed to use the
netjsongraph distribution from openwisp-utils, but tests and production
requirements weren't updated: add openwisp-utils to requirements.txt with the
minimum version that contains the netjsongraph assets (use the version from the
openwisp-utils PR that introduced lib/netjsongraph), and update the
test_mappage_admin_media_files() expectations in test_admin.py (references:
MapPageAdmin.Media and test_mappage_admin_media_files) to remove the old
monitoring/js/lib/netjsongraph.min.js entry and assert the new paths (e.g.
"lib/netjsongraph/js/echarts.min.js" and
"lib/netjsongraph/js/netjsongraph.echarts.min.js") are present. Ensure the
requirements change is included in production requirements and run the test to
confirm the new asset list matches MapPageAdmin.Media.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 346ee5b9-6e11-42ce-88f1-890abb07a51b

📥 Commits

Reviewing files that changed from the base of the PR and between ac683ed and 04ea4ff.

⛔ Files ignored due to path filters (1)
  • openwisp_monitoring/device/static/monitoring/js/lib/netjsongraph.min.js is excluded by !**/*.min.js
📒 Files selected for processing (4)
  • openwisp_monitoring/device/admin.py
  • openwisp_monitoring/device/static/monitoring/css/netjsongraph.css
  • openwisp_monitoring/device/templates/admin/map/map_page.html
  • setup.py
💤 Files with no reviewable changes (1)
  • openwisp_monitoring/device/static/monitoring/css/netjsongraph.css
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
{**/*.sh,**/*.{js,ts,tsx,jsx},**/*.py,**/*.rb,**/*.go,**/*.java,**/*.cs,**/*.cpp,**/*.c}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • setup.py
  • openwisp_monitoring/device/admin.py
🧠 Learnings (3)
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In this repository (openwisp/openwisp-monitoring), the project targets Python 3.10–3.13 as defined by CI. Do not flag backports.zoneinfo as a missing dependency; zoneinfo is a built-in module in all supported Python versions. When reviewing Python code, assume zoneinfo is available and avoid suggesting installation of backports.zoneinfo. If a file imports zoneinfo or uses it for time zone handling, treat it as standard library usage compatible with the supported CI matrix.

Applied to files:

  • setup.py
  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In the openwisp-monitoring project, targets are Linux-based environments. Do not flag a Windows-specific tzdata package as a missing dependency in code reviews for Python files (e.g., openwisp_monitoring/utils.py). If a platform-specific dependency is truly required, document the exception in review guidelines and ensure CI/packaging checks enforce platform constraints rather than manual review.

Applied to files:

  • setup.py
  • openwisp_monitoring/device/admin.py
📚 Learning: 2026-02-21T18:44:28.852Z
Learnt from: dee077
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/device/api/views.py:263-281
Timestamp: 2026-02-21T18:44:28.852Z
Learning: In openwisp-monitoring, MonitoringIndoorCoordinatesList inherits organization scoping from the parent IndoorCoordinatesList (from openwisp-controller), which uses FilterByParentManaged mixin and filters by location_id in get_queryset(). The child class only overrides the queryset attribute to add monitoring-specific select_related fields; this pattern is safe as long as get_queryset() from the parent is not bypassed. During reviews, verify that MonitoringIndoorCoordinatesList continues to rely on the parent's get_queryset() and that any added select_related fields in the child do not alter the parent's filtering logic.

Applied to files:

  • openwisp_monitoring/device/admin.py
🔇 Additional comments (2)
setup.py (1)

21-21: No actionable change here (formatting-only newline).

openwisp_monitoring/device/templates/admin/map/map_page.html (1)

17-18: LGTM!

Comment thread openwisp_monitoring/device/admin.py
Updated the static_files lists in test_mappage_admin_media_files and test_dashboard to assert the presence of the new unbundled echarts and netjsongraph files loaded directly from openwisp-utils, replacing the outdated local asset paths.

Fixes openwisp#709

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openwisp_monitoring/device/tests/test_admin.py (1)

902-914: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Update CSS path to match admin.py configuration in both test methods.

The test assertions on lines 905 and 1259 use monitoring/css/netjsongraph.css, but the admin configuration (admin.py line 599) serves lib/netjsongraph/css/netjsongraph.css. Update both occurrences to lib/netjsongraph/css/netjsongraph.css to match the actual served assets and maintain test consistency.

The JS paths have been correctly updated to the unbundled versions (lib/netjsongraph/js/echarts.min.js and lib/netjsongraph/js/netjsongraph.echarts.min.js), but the CSS path was not aligned with the corresponding admin configuration change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openwisp_monitoring/device/tests/test_admin.py` around lines 902 - 914, The
test asserts are checking for the wrong CSS asset path; update the occurrences
of "monitoring/css/netjsongraph.css" in the test(s) to
"lib/netjsongraph/css/netjsongraph.css" so the static_files list and the
self.assertContains checks match the admin.py asset configuration (update both
places where that CSS path appears in this test module).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@openwisp_monitoring/device/tests/test_admin.py`:
- Around line 902-914: The test asserts are checking for the wrong CSS asset
path; update the occurrences of "monitoring/css/netjsongraph.css" in the test(s)
to "lib/netjsongraph/css/netjsongraph.css" so the static_files list and the
self.assertContains checks match the admin.py asset configuration (update both
places where that CSS path appears in this test module).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8823da24-4612-4b5c-93c4-5d14fa0500c9

📥 Commits

Reviewing files that changed from the base of the PR and between 04ea4ff and 003bb9a.

📒 Files selected for processing (1)
  • openwisp_monitoring/device/tests/test_admin.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
🧰 Additional context used
📓 Path-based instructions (1)
{**/*.sh,**/*.{js,ts,tsx,jsx},**/*.py,**/*.rb,**/*.go,**/*.java,**/*.cs,**/*.cpp,**/*.c}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • openwisp_monitoring/device/tests/test_admin.py
🧠 Learnings (5)
📚 Learning: 2026-02-21T01:03:37.822Z
Learnt from: nemesifier
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/tests/test_selenium.py:827-859
Timestamp: 2026-02-21T01:03:37.822Z
Learning: In Selenium tests (e.g., in openwisp_monitoring/tests/test_selenium.py and similar test files), when testing JS animations on dashboards or elements driven by JavaScript (such as real-time location updates), insert a short sleep (e.g., sleep(0.3)) before WebDriverWait assertions to allow animations to complete and reduce flakiness. Note: use this as a targeted workaround and prefer explicit waits or animation-end checks where possible to avoid relying on fixed delays.

Applied to files:

  • openwisp_monitoring/device/tests/test_admin.py
📚 Learning: 2026-02-21T18:44:28.852Z
Learnt from: dee077
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/device/api/views.py:263-281
Timestamp: 2026-02-21T18:44:28.852Z
Learning: In openwisp-monitoring, MonitoringIndoorCoordinatesList inherits organization scoping from the parent IndoorCoordinatesList (from openwisp-controller), which uses FilterByParentManaged mixin and filters by location_id in get_queryset(). The child class only overrides the queryset attribute to add monitoring-specific select_related fields; this pattern is safe as long as get_queryset() from the parent is not bypassed. During reviews, verify that MonitoringIndoorCoordinatesList continues to rely on the parent's get_queryset() and that any added select_related fields in the child do not alter the parent's filtering logic.

Applied to files:

  • openwisp_monitoring/device/tests/test_admin.py
📚 Learning: 2026-02-25T18:42:08.825Z
Learnt from: dee077
Repo: openwisp/openwisp-monitoring PR: 738
File: openwisp_monitoring/tests/test_selenium.py:309-317
Timestamp: 2026-02-25T18:42:08.825Z
Learning: In Selenium tests that use ChannelsLiveServerTestCase (e.g., openwisp_monitoring/tests/test_selenium.py), override settings to configure CHANNEL_LAYERS with channels_redis.core.RedisChannelLayer instead of InMemoryChannelLayer. This is required because the live server runs in a separate process from the test process, and InMemoryChannelLayer is per-process only and cannot handle cross-process WebSocket broadcasting needed for real-time location update tests.

Applied to files:

  • openwisp_monitoring/device/tests/test_admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In this repository (openwisp/openwisp-monitoring), the project targets Python 3.10–3.13 as defined by CI. Do not flag backports.zoneinfo as a missing dependency; zoneinfo is a built-in module in all supported Python versions. When reviewing Python code, assume zoneinfo is available and avoid suggesting installation of backports.zoneinfo. If a file imports zoneinfo or uses it for time zone handling, treat it as standard library usage compatible with the supported CI matrix.

Applied to files:

  • openwisp_monitoring/device/tests/test_admin.py
📚 Learning: 2026-03-14T18:39:04.626Z
Learnt from: UltraBot05
Repo: openwisp/openwisp-monitoring PR: 766
File: openwisp_monitoring/utils.py:59-68
Timestamp: 2026-03-14T18:39:04.626Z
Learning: In the openwisp-monitoring project, targets are Linux-based environments. Do not flag a Windows-specific tzdata package as a missing dependency in code reviews for Python files (e.g., openwisp_monitoring/utils.py). If a platform-specific dependency is truly required, document the exception in review guidelines and ensure CI/packaging checks enforce platform constraints rather than manual review.

Applied to files:

  • openwisp_monitoring/device/tests/test_admin.py
🔇 Additional comments (1)
openwisp_monitoring/device/tests/test_admin.py (1)

1248-1266: ⚡ Quick win

Consistent with dashboard test—same CSS verification needed.

The media file expectations match the changes in test_dashboard (lines 907-908), which is correct. However, the same CSS path question applies: line 1260 still expects monitoring/css/netjsongraph.css rather than lib/netjsongraph/css/netjsongraph.css. Please verify this is intentional or update both test methods together if the CSS path should also move to lib/netjsongraph.

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

@kunalverma2512

Copy link
Copy Markdown
Author

@kunalverma2512 I ran your code locally and it seems like you have a few issues, these issues are also there in the CI

Error 1:- 
  File "/opt/openwisp/openwisp_monitoring/device/tests/test_admin.py", line 1263, in test_mappage_admin_media_files
    self.assertContains(response, static_file)
AssertionError: False is not true : Couldn't find 'monitoring/js/lib/netjsongraph.min.js' in the following response
----------------------------------------------------------------------------
Error 2:-
Traceback (most recent call last):
  File "/opt/openwisp/openwisp_monitoring/tests/test_selenium.py", line 77, in setUpClass
    super().setUpClass()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 96, in setUpClass
    cls.web_driver = cls.get_webdriver()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 101, in get_webdriver
    return cls.get_firefox_webdriver()
  File "/usr/local/lib/python3.10/site-packages/openwisp_utils/tests/selenium.py", line 139, in get_firefox_webdriver
    web_driver = webdriver.Firefox(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 69, in __init__
    super().__init__(command_executor=executor, options=self.options)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/common/webdriver.py", line 25, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 274, in __init__
    self.start_session(capabilities)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 370, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 450, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 255
--------------------------------------------------------------

Error 3:-
django.core.exceptions.ImproperlyConfigured: test_metric is an already registered Metric Configuration.

These test cases are making your test suit fail, most importantly the 1st one. I haven't dig into this PR/issue much but you either

  • Need to change the test case to point to the relevant file.
  • Change your code to so that this test case passes

Hi! Thanks for taking the time to run this locally and share the logs.

Here is a breakdown of what's happening with those errors:

Error 1 (test_mappage_admin_media_files):
You are completely right on this one. I updated the Media class in admin.py to load the unbundled echarts files from openwisp-utils, but I missed updating the corresponding test! The test is still explicitly looking for the old netjsongraph.min.js path. I will push a quick commit to update this test so it asserts the presence of the new ECharts files instead.

Error 2 (Selenium Status 255):
This looks like an environment-specific crash with Firefox/Geckodriver on initialization. Since my PR only updates static file paths and HTML templates, it doesn't touch the openwisp_utils.tests.selenium configuration.

Error 3 (Metric Configuration already registered):
This appears to be test state leakage (the registry not clearing properly between test cases). Given that this PR is purely focused on frontend static files for the Map admin, it shouldn't be interfering with backend metric registration.

I'll push the fix for Error 1 shortly! Let me know if you'd like me to look into anything else.

@nemesifier nemesifier left a comment

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.

I think this would also close #710, wouldn't it? Please confirm, if so, update the PR description to reflect this.

Then, please force the CI workflow to install your fork (from openwisp/openwisp-utils#675), eg:

# add this to the github actions CI YAML setup step, as last command
pip install --force-reinstall --no-deps https://github.com/kunalverma2512/openwisp-utils/tarball/feature/517-add-netjsongraph-static

Then, update the PR description with a GIF which shows the browser network tab open showing the separate JS files for netjsongraph` and leaflet being loaded as expected AND the geographic map UI working.

Once everything is done correctly the CI will pass. Manual testing on your end is needed to accomplish this.

Comment thread setup.py Outdated
continue
# add line to requirements
requirements.append(line)

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.

Avoid unrelated changes.

Restored setup.py to remove unrelated formatting changes from a previous reverted commit. Added the maintainer-requested pip install command to ci.yml to fetch the unbundled netjsongraph assets from the openwisp-utils fork during automated testing.

Fixes openwisp#709

Fixes openwisp#710
@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (2/3).

Moved Leaflet core assets from the map_page.html template directly into the MapPageAdmin Media class to enforce the correct strictly-ordered loading sequence. This guarantees that leaflet.js loads before the fullscreen plugin and NetJSONGraph, resolving the Javascript ReferenceError that crashed the map during automated browser tests.

Fixes openwisp#709
Updated the static_files lists in test_mappage_admin_media_files and test_dashboard to match the new unbundled asset paths. Removed the obsolete local monitoring/css/netjsongraph.css reference and added the new lib/netjsongraph/ CSS and JS paths provided by openwisp-utils.

Fixes openwisp#709
@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

Updated the static file paths in apps.py for the dashboard map to use the new unbundled NetJSONGraph assets from openwisp-utils. Also explicitly added leaflet.js to the dashboard javascript configuration since it is no longer bundled within netjsongraph. This resolves the 404 errors and Javascript crashes on the dashboard page during Selenium tests.

Fixes openwisp#709
Updated the static file test assertions in test_apps.py and test_admin.py to accurately reflect the newly unbundled NetJSONGraph assets and the explicit leaflet.js core requirement. Removed obsolete local paths.

Fixes openwisp#709
@openwisp-companion

Copy link
Copy Markdown

Test Failures in test_url_fragment_actions_on_indoor_map

Hello @kunalverma2512,
(Analysis for commit 9862322)

There are two test failures in test_url_fragment_actions_on_indoor_map:

  1. TimeoutException: The test timed out while waiting for an element to become visible. This indicates that the expected element (.njg-tooltip-inner) did not appear within the specified timeout period.
  2. AssertionError: The assertion "URL fragment was not updated after opening indoor map node popup" failed. This is likely a consequence of the timeout, as the state the test was expecting to verify was not reached.

Fix:

The most probable cause is a change in the UI or the timing of element rendering. You should investigate the test's interaction with the indoor map and:

  • Increase the WebDriverWait timeout if the element is expected to take longer to appear.
  • Verify that the selector .njg-tooltip-inner is still correct and that the element is actually present in the DOM when the test runs.
  • If the UI has changed, adjust the test to wait for the correct element or to account for the new rendering logic.

@kunalverma2512
kunalverma2512 force-pushed the bugfix/709-reuse-django-leaflet branch from bf43932 to 9862322 Compare May 22, 2026 15:54
@kunalverma2512

Copy link
Copy Markdown
Author

@nemesifier Yes, I confirm this PR also solves #710, and I have updated the description to reflect that.

@kunalverma2512

kunalverma2512 commented May 24, 2026

Copy link
Copy Markdown
Author

Hi @nemesifier, I have completed the suggested changes and attached the requested screenshots and also updated the PR description to include Closes #710 . Please let me know if everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[change] Load netjsongraph.js from openwisp-utils [bug] Avoid redundant leaflet JS in netjsongraph.js bundle, reuse django-leaflet

3 participants