Skip to content

[Bug] UI/UX: Sort ipv4 addresses by octet, not as a combined string, for a "natural sort" in tables such as the DCHP lease table #1645

@pranavmishra90

Description

@pranavmishra90

Hi Shreyas,

I have a minor UI/UX bug which I'd like to report. When sorting a table on the web UI by "IP" address, the entire IP is being sorted as a string rather than by octet. I have a screenshot from the DCHP lease table and further details below.

Example

Observed order:

  • 192.168.0.101
  • 192.168.0.61
  • 192.168.0.62

Expected order:

  • 192.168.0.61
  • 192.168.0.62
  • 192.168.0.101
Image

Image1: Screenshot from DCHP leases table. Redacted names of family/friends for privacy, but I think the point is clear

Potential error in the source code

I believe the problem is arising from:

if (dir == "asc") {
                if (x.innerText.toLowerCase() > y.innerText.toLowerCase()) {
                    // If so, mark as a switch and break the loop:
                    shouldSwitch = true;
                    break;
                }
            } else if (dir == "desc") {
                if (x.innerText.toLowerCase() < y.innerText.toLowerCase()) {
                    // If so, mark as a switch and break the loop:
                    shouldSwitch = true;
                    break;
                }
            }

which is a part of the function sortTable(tableId, n) in DnsServerCore/www/js/common.js

https://github.com/TechnitiumSoftware/DnsServer/blob/master/DnsServerCore/www/js/common.js


If you're open for a PR, I can try to improve this sort logic. Full disclosure, I have minimal experience with javascript. However, I feel like this is "easy enough" for me to dip my toes and submit something if you'd like

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions