mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 02:58:17 -06:00
Added buttons and filtering of available IP Addresses and child prefixes in prefix view
- Add 2 new buttons, Hide available and Show available to Prefix view. - Add in logic into the prefix view to only include IP Addresses if we want to show available addresses - This changes the default mode to NOT show available IPAddresses in the prefix view.
This commit is contained in:
parent
d4a9318826
commit
95ce232076
@ -504,8 +504,9 @@ class PrefixPrefixesView(View):
|
|||||||
).annotate_depth(limit=0)
|
).annotate_depth(limit=0)
|
||||||
|
|
||||||
# Annotate available prefixes
|
# Annotate available prefixes
|
||||||
if child_prefixes:
|
if request.GET.get('show_available', None):
|
||||||
child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)
|
if child_prefixes:
|
||||||
|
child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)
|
||||||
|
|
||||||
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
||||||
if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'):
|
if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'):
|
||||||
@ -544,7 +545,8 @@ class PrefixIPAddressesView(View):
|
|||||||
ipaddresses = prefix.get_child_ips().select_related(
|
ipaddresses = prefix.get_child_ips().select_related(
|
||||||
'vrf', 'interface__device', 'primary_ip4_for', 'primary_ip6_for'
|
'vrf', 'interface__device', 'primary_ip4_for', 'primary_ip6_for'
|
||||||
)
|
)
|
||||||
ipaddresses = add_available_ipaddresses(prefix.prefix, ipaddresses, prefix.is_pool)
|
if request.GET.get('show_available', None):
|
||||||
|
ipaddresses = add_available_ipaddresses(prefix.prefix, ipaddresses, prefix.is_pool)
|
||||||
|
|
||||||
ip_table = tables.IPAddressTable(ipaddresses)
|
ip_table = tables.IPAddressTable(ipaddresses)
|
||||||
if request.user.has_perm('ipam.change_ipaddress') or request.user.has_perm('ipam.delete_ipaddress'):
|
if request.user.has_perm('ipam.change_ipaddress') or request.user.has_perm('ipam.delete_ipaddress'):
|
||||||
|
@ -52,6 +52,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ prefix }}{% endblock %}</h1>
|
<h1>{% block title %}{{ prefix }}{% endblock %}</h1>
|
||||||
{% include 'inc/created_updated.html' with obj=prefix %}
|
{% include 'inc/created_updated.html' with obj=prefix %}
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available=None %}" class="btn btn-default{% if not request.GET.show_available %} active{% endif %}">Hide available</a>
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available='on' %}" class="btn btn-default{% if request.GET.show_available %} active{% endif %}">Show available</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<ul class="nav nav-tabs" style="margin-bottom: 20px">
|
<ul class="nav nav-tabs" style="margin-bottom: 20px">
|
||||||
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
|
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
|
||||||
<a href="{% url 'ipam:prefix' pk=prefix.pk %}">Prefix</a>
|
<a href="{% url 'ipam:prefix' pk=prefix.pk %}">Prefix</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user