Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember sort order #54

Open
TheFatherMind opened this issue Sep 20, 2017 · 4 comments
Open

Remember sort order #54

TheFatherMind opened this issue Sep 20, 2017 · 4 comments

Comments

@TheFatherMind
Copy link

TheFatherMind commented Sep 20, 2017

First of all I would like to thank you for sharing this great app and tell you that it is the best one I have seen so far for pdns.

Why is the default sort order by ID? That would make sense for a computer but not for a human. A human is going to look down a list for a username or domain name in alphabetical order. To me.. it all just looks scrambled and random. Is there a way to make this sort alpha by default? I am perfectly fine with hacking the code if you direct me to the right spots and give me a clue as to how to change it.

Note: I know I can click the top of the column and make it sort there. But that setting is not remembered when I return to the page and I am having to click that obsessively. This is counter to the general function/purpose of a computer.

Thank you again!!

@loewexy
Copy link
Owner

loewexy commented Sep 20, 2017

I think we can change that in v2.0 so that it remembers you last sort order.

For a temporary workaround:
I think that the sorting by ID is just the default from the database. If you do not sort explicitly by something no ORDER BY is added to the query and the database is free to return whichever it likes.
In api/domains.php in line 84 is the logic for the sorting. So you could add an else here, and append ORDER BY name ASC to the query.

Same in api/edit-master.php line 64 for the records.

Hope that helps you in the meantime.

@loewexy loewexy changed the title Default sort order... Remember sort order Sep 20, 2017
@SpaceJelly
Copy link

SpaceJelly commented Sep 20, 2017

What would be nice would be to sort by Type, then Name. That way records would be grouped logically by Type. My code for domains.php (Though only really need name on this but doesn't hurt to sort by type too if you have multiples.)

Line 101. replace:
}
with:

    } else {
            $sql .= "ORDER BY type ASC, name ASC";
    }

for edit-master.php
Line 82. replace:
}
with:

    } else {
            $sql .= "ORDER BY type ASC, name ASC, priority ASC";
    }

Added priority into edit-master.php for the MX records :)

Those are my tweaks, thanks for the tips on where to find the search bits!

@TheFatherMind
Copy link
Author

@loewexy and @SpaceJelly thank you for the tips! Good directions! I did exactly as instructed and have the exact results I was hoping for.

For anyone reading this thread I would like to add to that with one more edit I made. To make the users list sort in alpha by default do the following...

edit api/users.php
line 52. replace:
}
with

      } else {
        $sql .= "ORDER BY name ASC";
      }

Unless you want to group your admins then you should do this...

edit api/users.php
line 52. replace:
}
with

      } else {
        $sql .= "ORDER BY type ASC, name ASC"";
      }

@morremeyer morremeyer modified the milestones: 2.1, 2.0 Sep 24, 2017
@loewexy loewexy removed this from the 2.0 milestone Apr 12, 2018
@DesktopMasters
Copy link

Greetings! I would like to do this. However the above information does not seem to apply to the existing code. What do I hack to make it remember the sort order for the domains in the list, as well as the records and users?

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

No branches or pull requests

5 participants