Skip to content

Fix Saving Changes in Devices Page.#1395

Merged
jokob-sk merged 1 commit intonetalertx:mainfrom
luckylinux:fix-devices-edit
Jan 9, 2026
Merged

Fix Saving Changes in Devices Page.#1395
jokob-sk merged 1 commit intonetalertx:mainfrom
luckylinux:fix-devices-edit

Conversation

@luckylinux
Copy link
Contributor

@luckylinux luckylinux commented Jan 9, 2026

Addresses #1394.

Can now save Changes from Devices Page.

Summary by CodeRabbit

  • Refactor
    • Streamlined API base URL construction for device management functions to use a centralized accessor, improving consistency across multiple API calls.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

The PR refactors API URL construction across two frontend files by replacing inline dynamic protocol/host/port combinations with centralized getApiBase() function calls, improving consistency in API endpoint handling throughout the device details interface.

Changes

Cohort / File(s) Summary
API URL Construction Refactoring
front/deviceDetailsEdit.php, front/deviceDetailsTools.php
Replaced manual base URL construction (${protocol}//${host}:${port}) with centralized getApiBase() function calls. Changes applied in setDeviceData AJAX request and three functions (manualnmapscan, deleteDeviceEvents, resetDeviceProps) respectively. No behavioral changes; improves URL consistency and maintainability.

Poem

🐰 With carrots of code, I've tidied the way,
One function now builds what URLs display,
No more scattered fragments spread far and wide,
The API base calls now take us for a ride! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title is vague and generic. It states 'Fix Saving Changes in Devices Page' but the actual changes involve refactoring API URL construction from dynamic host/protocol/port to a centralized getApiBase() function across two files. The title does not accurately reflect the technical nature or scope of the changes. Consider a more specific title that reflects the actual implementation, such as 'Refactor API base URL construction using centralized getApiBase()' or 'Replace inline API URL construction with centralized getApiBase() helper'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
front/deviceDetailsTools.php (2)

224-225: Good refactoring, but note inconsistency.

The use of getApiBase() is correct, but this file now has mixed approaches to API URL construction across different functions.


268-268: Consider completing the API base URL refactoring for consistency and maintainability.

Six functions in this file still construct API URLs inline using hardcoded protocol/host/port variables, while three other functions use the centralized getApiBase() helper. This inconsistency violates the DRY principle and creates unnecessary maintenance burden across multiple functions.

Refactor these functions to use getApiBase():

  • speedtestcli() (line 268)
  • traceroute() (line 319)
  • nslookup() (line 369)
  • wakeonlan() (line 453)
  • copyFromDevice() (line 495)
  • internetinfo() (line 678)

This would consolidate the URL construction logic into a single, centralized location and align with the pattern already established in manualnmapscan() and other refactored functions.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 730e8b8 and 82041f3.

📒 Files selected for processing (2)
  • front/deviceDetailsEdit.php
  • front/deviceDetailsTools.php
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,php,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use environment variables (NETALERTX_DB, NETALERTX_LOG, etc.) everywhere instead of hardcoding /data/db or relative paths. Use /data for persistent config/db, /tmp for runtime logs/api/nginx state

Files:

  • front/deviceDetailsEdit.php
  • front/deviceDetailsTools.php
🔇 Additional comments (4)
front/deviceDetailsEdit.php (2)

357-357: LGTM! Centralized API base URL improves consistency.

The refactoring to use getApiBase() instead of inline URL construction is a solid improvement for maintainability.


405-405: Correct usage of centralized API base.

The URL construction properly leverages the apiBase variable defined earlier in the function.

front/deviceDetailsTools.php (2)

594-594: Correct implementation of centralized API base.

The refactoring properly replaces the inline URL construction.


644-644: Correct implementation of centralized API base.

The change is consistent with the other refactored functions in this PR.

@jokob-sk jokob-sk merged commit 44eba4c into netalertx:main Jan 9, 2026
6 checks passed
@luckylinux luckylinux deleted the fix-devices-edit branch January 10, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants