Skip to content

Wireless: add wifi info to dashboard and info button#2038

Merged
limetech merged 5 commits into
unraid:masterfrom
bergware:master
Feb 24, 2025
Merged

Wireless: add wifi info to dashboard and info button#2038
limetech merged 5 commits into
unraid:masterfrom
bergware:master

Conversation

@bergware

@bergware bergware commented Feb 23, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Enhanced network status reporting now displays detailed information for wireless connections—showing transmission and reception rates when active—and offers clear reporting for loopback and other interfaces.
  • Refactor

    • Streamlined the network interface logic to deliver more accurate and internationalized connectivity status messages.
  • Style

    • Updated background colors and added new border styles for the dashboard table header across multiple themes, improving visual separation and aesthetics.
    • Modified styling for text overflow in labels to include truncation with ellipsis.
  • Chores

    • Updated copyright information to reflect the current year.

@coderabbitai

coderabbitai Bot commented Feb 23, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request refactors the network interface status reporting logic. It replaces the previous if conditions with a switch statement to handle different interface types including bonded, wireless, loopback, and others. The update introduces specific support for wireless interfaces by checking link status and retrieving transmission rates using the iw command. Additionally, a helper function (port_get_contents) has been added to improve file content retrieval, and the copyright notice has been updated.

Changes

File(s) Summary of Changes
emhttp/plugins/dynamix/nchan/update_3 Replaced conditional if checks with a switch statement; added cases for wlan (with link status and Rx/Tx rate retrieval via iw), explicit lo case, and default.
emhttp/plugins/dynamix/scripts/system_information Updated copyright year, added port_get_contents helper function, modified regex patterns to include wlan, and refactored interface handling into a switch statement.
emhttp/plugins/dynamix/styles/default-azure.css Added CSS rule for table.dashboard thead.stopgap to define left and right borders with color #e4e2e4.
emhttp/plugins/dynamix/styles/default-black.css Added CSS rule for table.dashboard thead.stopgap to define left and right borders with color #1c1b1b.
emhttp/plugins/dynamix/styles/default-gray.css Added CSS rule for table.dashboard thead.stopgap to define left and right borders with color #1b1d1b.
emhttp/plugins/dynamix/styles/default-white.css Added CSS rule for table.dashboard thead.stopgap to define left and right borders with color #f2f2f2.
emhttp/plugins/dynamix/sheets/DashStats-azure.css Updated background color of div.pie::after from #d7dbdd to #dcdcdc.
emhttp/plugins/dynamix/sheets/DashStats-gray.css Updated background color of div.pie::after from #212f3d to #3d3c3a.
emhttp/plugins/dynamix.vm.manager/sheets/AddVM.css Updated span.label to include overflow:hidden and text-overflow:ellipsis; reintroduced div.wlan0 with text-align:left.
emhttp/plugins/dynamix.vm.manager/sheets/UpdateVM.css Modified span.label to add overflow:hidden and text-overflow:ellipsis for text truncation.

Possibly Related PRs

  • Wireless support - fine tuning #2002: The changes in the main PR enhance network interface status reporting with specific handling for wireless interfaces, which is directly related to the modifications in this PR that also include enhancements for handling wireless interfaces in network configurations.
  • VM: make reference to interface instead of vhost #2013: The changes in the main PR and this PR are related as both involve modifications to the handling of network interfaces, specifically adding support for wireless interfaces (wlan) and updating the logic for network interface detection and reporting.
  • Service management enhancements and other fixes #2025: The changes in the main PR, which enhance network interface status reporting with specific handling for wireless interfaces, are related to this PR, as both involve modifications to the handling of network interfaces and the introduction of a switch statement for improved logic.

Poem

Oh, how I hop in code so free,
Switching cases like a dancing spree,
Bond, wlan, and loopback join the show,
With helper functions making data flow,
I'm a rabbit, leaping through each line with glee! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (3)
emhttp/plugins/dynamix/nchan/update_3 (1)

113-127: Add error handling for the iw command.

While the wireless interface support is well-implemented, the exec call to iw should include error handling in case the command fails or is not available.

-        exec("iw $port link | awk '/^\s+[rt]x bitrate: /{print $1,$2,$3,$4}'",$speed);
+        $ret = 0;
+        exec("command -v iw >/dev/null 2>&1 && iw $port link | awk '/^\s+[rt]x bitrate: /{print $1,$2,$3,$4}'",$speed,$ret);
+        if ($ret !== 0) {
+          $echo['mode'][] = _('unable to get wireless info');
+          break;
+        }
emhttp/plugins/dynamix/scripts/system_information (2)

38-40: Consider moving shared functions to a common utility file.

The port_get_contents function is duplicated between this file and update_3. Consider moving it to a shared utility file to maintain DRY principles.


185-199: Add consistent error handling for the iw command.

Similar to the update_3 file, add error handling for the iw command to ensure robustness.

-      exec("iw $port link | awk '/^\s+[rt]x bitrate: /{print $1,$2,$3,$4}'",$speed);
+      $ret = 0;
+      exec("command -v iw >/dev/null 2>&1 && iw $port link | awk '/^\s+[rt]x bitrate: /{print $1,$2,$3,$4}'",$speed,$ret);
+      if ($ret !== 0) {
+        echo "<tr class='$more'><td>$name</td><td>$port: ",_('unable to get wireless info'),"</td></tr>";
+        break;
+      }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 010ad20 and c1ecb1b.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/nchan/update_3 (2 hunks)
  • emhttp/plugins/dynamix/scripts/system_information (3 hunks)
🔇 Additional comments (3)
emhttp/plugins/dynamix/nchan/update_3 (2)

58-60: Good addition of the helper function!

The port_get_contents function improves code maintainability by centralizing file reading logic and handling non-existent files gracefully.


104-140: Well-structured refactoring using switch statement!

The switch statement improves code organization and makes it easier to add support for new interface types in the future.

emhttp/plugins/dynamix/scripts/system_information (1)

167-167: LGTM: Network interface pattern correctly updated!

The grep pattern has been properly updated to include wireless interfaces alongside bonded and ethernet interfaces.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
emhttp/plugins/dynamix.vm.manager/sheets/AddVM.css (1)

49-49: Enhance Text Truncation in Labels

The update to the span.label class now includes overflow:hidden and text-overflow:ellipsis, ensuring that excessively long text is gracefully truncated. Consider, as a future enhancement, adding a tooltip to reveal the full label text on hover for better accessibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 994c8b1 and 99bb469.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix.vm.manager/sheets/AddVM.css (1 hunks)
  • emhttp/plugins/dynamix.vm.manager/sheets/UpdateVM.css (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • emhttp/plugins/dynamix.vm.manager/sheets/UpdateVM.css
🔇 Additional comments (1)
emhttp/plugins/dynamix.vm.manager/sheets/AddVM.css (1)

53-53: Reintroduce Alignment for Wireless Interface Info

Restoring the div.wlan0 style with text-align:left is consistent with similar adjustments in related CSS files (e.g., UpdateVM.css) and ensures that wireless interface details display with proper alignment. This is a welcome change given the PR’s focus on incorporating WiFi info.

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