Skip to content

Conversation

@luckylinux
Copy link
Contributor

@luckylinux luckylinux commented Jan 9, 2026

Use getApiBase() to get GraphQL Endpoint for front/systeminfoNetwork.php.

Note that you might want to check the Variable Names and see if baseUrl or apiBase is preferrable to you (it might not be fully consistent with the rest of the Code).

Summary by CodeRabbit

  • Refactor
    • Improved internal API endpoint configuration for better maintainability and consistency across the application.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Multiple frontend files were updated to replace hardcoded URL construction using protocol, host, and port variables with a centralized getApiBase() function, standardizing how API endpoints are built across the application.

Changes

Cohort / File(s) Summary
API Base URL Consolidation
front/appEventsCore.php, front/deviceDetailsTools.php, front/events.php, front/systeminfoNetwork.php
Replaced manual protocol/host/port composition with centralized getApiBase() function. Updated GraphQL and REST endpoint URLs to use ${apiBase}/... pattern. Removed direct references to window location properties and GRAPHQL_PORT. No changes to authentication, request methods, or error handling.

Poem

🐰 One base to rule them all, no more scattered ways,
Protocol, host, and port fade to better days,
getApiBase() hops in, clean and bright,
Our API endpoints unified just right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change: refactoring multiple files to use getApiBase() for constructing API endpoints instead of manual protocol/host/port assembly, with focus on network system information functionality.
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.

@jokob-sk jokob-sk merged commit 52135e8 into netalertx:main Jan 9, 2026
1 of 2 checks passed
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

Caution

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

⚠️ Outside diff range comments (1)
front/systeminfoNetwork.php (1)

34-101: Eliminate duplicate code blocks.

The same code block (External IP retrieval and network variable assignments) is repeated three times identically. This violates the DRY principle and makes maintenance difficult.

♻️ Proposed fix to remove duplication

Remove the duplicate blocks at lines 59-76 and 84-101. The first occurrence (lines 34-51) is sufficient since these variables are used in the HTML output that follows.

-// ----------------------------------------------------
-// Network Hardware Stats
-// ----------------------------------------------------
-
-
-// External IP
-$externalIp = getExternalIp();
-
-// Server Name
-$network_NAME = gethostname() ?: lang('Systeminfo_Network_Server_Name_String');
-
-// HTTPS Check
-$network_HTTPS = isset($_SERVER['HTTPS']) ? 'Yes (HTTPS)' : lang('Systeminfo_Network_Secure_Connection_String');
-
-// Query String
-$network_QueryString = !empty($_SERVER['QUERY_STRING'])
-    ? $_SERVER['QUERY_STRING']
-    : lang('Systeminfo_Network_Server_Query_String');
-
-// Referer
-$network_referer = !empty($_SERVER['HTTP_REFERER'])
-    ? $_SERVER['HTTP_REFERER']
-    : lang('Systeminfo_Network_HTTP_Referer_String');
-
-
-
-// ----------------------------------------------------
-// Network Stats (General)
-// ----------------------------------------------------
-
-// External IP
-$externalIp = getExternalIp();
-
-// Server Name
-$network_NAME = gethostname() ?: lang('Systeminfo_Network_Server_Name_String');
-
-// HTTPS Check
-$network_HTTPS = isset($_SERVER['HTTPS']) ? 'Yes (HTTPS)' : lang('Systeminfo_Network_Secure_Connection_String');
-
-// Query String
-$network_QueryString = !empty($_SERVER['QUERY_STRING'])
-    ? $_SERVER['QUERY_STRING']
-    : lang('Systeminfo_Network_Server_Query_String');
-
-// Referer
-$network_referer = !empty($_SERVER['HTTP_REFERER'])
-    ? $_SERVER['HTTP_REFERER']
-    : lang('Systeminfo_Network_HTTP_Referer_String');
-
🧹 Nitpick comments (1)
front/deviceDetailsTools.php (1)

221-222: Remove redundant apiBase declaration.

The apiBase constant is already declared globally at line 214. Re-declaring it here is unnecessary and creates a shadowed variable.

♻️ Proposed fix
-    // Build base URL dynamically
-    const apiBase = getApiBase();
-
     $.ajax({

The same issue exists in deleteDeviceEvents() at line 586 and resetDeviceProps() at line 638. Consider removing those redundant declarations as well.

📜 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 0727798 and 494f010.

📒 Files selected for processing (4)
  • front/appEventsCore.php
  • front/deviceDetailsTools.php
  • front/events.php
  • front/systeminfoNetwork.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/appEventsCore.php
  • front/events.php
  • front/systeminfoNetwork.php
  • front/deviceDetailsTools.php
🔇 Additional comments (5)
front/systeminfoNetwork.php (1)

339-344: LGTM: Centralized API base URL construction.

The change correctly uses getApiBase() to construct the endpoint URL, replacing the previous hardcoded approach. This improves maintainability and consistency across the application.

front/appEventsCore.php (1)

27-28: LGTM: Centralized GraphQL endpoint construction.

The change correctly replaces manual protocol/host/port assembly with the centralized getApiBase() function, improving consistency across the codebase.

front/events.php (2)

163-166: LGTM: Centralized API base for event totals endpoint.

The change correctly uses getApiBase() to construct the endpoint URL, aligning with the PR's objective to standardize API base URL handling.


209-211: LGTM: Centralized API base for session events endpoint.

The change correctly uses getApiBase() to construct the endpoint URL, maintaining consistency with the other updated functions in this file.

front/deviceDetailsTools.php (1)

213-215: LGTM: Global API configuration.

The global apiBase and apiToken declarations provide convenient access across multiple tool functions. This centralizes the API configuration effectively.

@luckylinux luckylinux deleted the fix-system-info-network branch January 10, 2026 12:59
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