Replies: 3 comments 1 reply
-
|
Hi @stop5, thanks for this feature suggestion! In fact I had the matter of zone hierarchies on my list for a while now, albeit for other purposes (such as checking delegation records etc.). This is related to it, or at least part of it is, as your suggestion actually involves two parts:
Implementing item 1 is probably not too difficult, although it involves a bit more work that just selecting the appropriate sorting algorithm. Whether it does what the user expects is another question, as for some users it might me prefrerable to sort instead of so it has to be optional in any case. How to get that incorporated into the Django table code is another question, but I guess it can be done and I hope it can be done without resorting to JavaScript, which I hate pretty much :-) The other issue is the depth indicators, and although they are very easy to implement it could get messy here. For an example, just go to the "prefixes" list and sort, for example, by "Description". You'll get something like this:
... which is pretty wierd. And plain wrong (and that's NetBox, they had plenty of time to sort this out :-)) The obvious solution would be to disable depth indicators if any other than the hierarchical sorting mode is enabled, but in that case I already see the issues coming in ... "My depth indicators are missing, please fix it" (this is what happens with the display of free IP addresses in NetBox all the time - an ever-recurring question). There should be a good way to implement it, but I haven't thought too much about it as there are more pressing issues on the roadmap and I'm pretty much out of play-time for the imminent future. But it is a nice idea anyway. |
Beta Was this translation helpful? Give feedback.
-
|
I had a look at it, but I'm afraid it can't be done that easily. The problem is that with IPAM The second issue is the depth indicator - again, with prefixes you can rely on native PostgreSQL functionality, and even so it reqiures an annotation with And then we still have the sorting vs. depth indicators issue I mentioned above, which even the NetBox core project hasn't solved in a satisfactory way. So, for the time being, I won't try to implement it (even more so as I don't have too much time and there are more useful features that need to be implemented). Sorry, I really like the idea, but I don't see how it can be done without an amount of work that doesn't seem justified. I'll move this over to a discussion, maybe you want to try yourself at it or someone comes up with a better idea how to do it. |
Beta Was this translation helpful? Give feedback.
-
|
Here's my first approach at sorting the zones by "DNS hierarchy": from functools import cmp_to_key
...
class ZoneManager(models.Manager.from_queryset(RestrictedQuerySet)):
...
def in_dns_order(self, *args, **kwargs):
qs = self.get_queryset().filter(*args, **kwargs)
return sorted(
qs,
key=cmp_to_key(
lambda x, y: (x.view.name > y.view.name)
or (dns_name.from_text(x.name).fullcompare(dns_name.from_text(y.name)))[
1
]
),
)This actually works quite well, but it returns a list, not a queryset, and |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
Its not an direct problem
Describe the solution you'd like
In the current Netbox version there is this nice Depth indication for IP-Prefixes.
I would like to see something similar if it is possible for the zones table.
This would be useful if you split zones to make management easier, since the deep subdomains are separated.
Describe alternatives you've considered
currently Netbox orders them like this
But it would make more sense to order them like this:
Beta Was this translation helpful? Give feedback.
All reactions