mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 03:27:21 -06:00
Fixes #2365: Toggle for showing available prefixes/ip addresses
This commit is contained in:
parent
8a4293a4cc
commit
37bc17d3a2
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Enhancements
|
## Enhancements
|
||||||
|
|
||||||
|
* [#2365](https://github.com/netbox-community/netbox/issues/2365) - Toggle for showing available prefixes/ip addresses
|
||||||
* [#3705](https://github.com/netbox-community/netbox/issues/3705) - Provide request context when executing custom scripts
|
* [#3705](https://github.com/netbox-community/netbox/issues/3705) - Provide request context when executing custom scripts
|
||||||
* [#3762](https://github.com/netbox-community/netbox/issues/3762) - Add date/time picker widgets
|
* [#3762](https://github.com/netbox-community/netbox/issues/3762) - Add date/time picker widgets
|
||||||
* [#3788](https://github.com/netbox-community/netbox/issues/3788) - Enable partial search for inventory items
|
* [#3788](https://github.com/netbox-community/netbox/issues/3788) - Enable partial search for inventory items
|
||||||
|
@ -333,6 +333,13 @@ class AggregateView(PermissionRequiredMixin, View):
|
|||||||
).annotate_depth(
|
).annotate_depth(
|
||||||
limit=0
|
limit=0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Update the ipam_show_available cookie if request specifies it
|
||||||
|
if request.GET.get('show_available') is not None:
|
||||||
|
request.session['ipam_show_available'] = request.GET.get('show_available') == 'true'
|
||||||
|
|
||||||
|
# Add available prefixes to the table if the cookie requested it
|
||||||
|
if request.session.get('ipam_show_available'):
|
||||||
child_prefixes = add_available_prefixes(aggregate.prefix, child_prefixes)
|
child_prefixes = add_available_prefixes(aggregate.prefix, child_prefixes)
|
||||||
|
|
||||||
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
||||||
@ -356,6 +363,7 @@ class AggregateView(PermissionRequiredMixin, View):
|
|||||||
'aggregate': aggregate,
|
'aggregate': aggregate,
|
||||||
'prefix_table': prefix_table,
|
'prefix_table': prefix_table,
|
||||||
'permissions': permissions,
|
'permissions': permissions,
|
||||||
|
'show_available': request.session.get('ipam_show_available'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -511,8 +519,12 @@ class PrefixPrefixesView(PermissionRequiredMixin, View):
|
|||||||
'site', 'vlan', 'role',
|
'site', 'vlan', 'role',
|
||||||
).annotate_depth(limit=0)
|
).annotate_depth(limit=0)
|
||||||
|
|
||||||
# Annotate available prefixes
|
# Update the ipam_show_available cookie if request specifies it
|
||||||
if child_prefixes:
|
if request.GET.get('show_available') is not None:
|
||||||
|
request.session['ipam_show_available'] = request.GET.get('show_available') == 'true'
|
||||||
|
|
||||||
|
# Add available prefixes to the table if the cookie requested it
|
||||||
|
if child_prefixes and request.session.get('ipam_show_available'):
|
||||||
child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)
|
child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes)
|
||||||
|
|
||||||
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
prefix_table = tables.PrefixDetailTable(child_prefixes)
|
||||||
@ -539,6 +551,7 @@ class PrefixPrefixesView(PermissionRequiredMixin, View):
|
|||||||
'permissions': permissions,
|
'permissions': permissions,
|
||||||
'bulk_querystring': 'vrf_id={}&within={}'.format(prefix.vrf.pk if prefix.vrf else '0', prefix.prefix),
|
'bulk_querystring': 'vrf_id={}&within={}'.format(prefix.vrf.pk if prefix.vrf else '0', prefix.prefix),
|
||||||
'active_tab': 'prefixes',
|
'active_tab': 'prefixes',
|
||||||
|
'show_available': request.session.get('ipam_show_available'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -553,6 +566,13 @@ class PrefixIPAddressesView(PermissionRequiredMixin, View):
|
|||||||
ipaddresses = prefix.get_child_ips().prefetch_related(
|
ipaddresses = prefix.get_child_ips().prefetch_related(
|
||||||
'vrf', 'interface__device', 'primary_ip4_for', 'primary_ip6_for'
|
'vrf', 'interface__device', 'primary_ip4_for', 'primary_ip6_for'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Update the ipam_show_available cookie if request specifies it
|
||||||
|
if request.GET.get('show_available') is not None:
|
||||||
|
request.session['ipam_show_available'] = request.GET.get('show_available') == 'true'
|
||||||
|
|
||||||
|
# Add available IP addresses to the table if the cookie requested it
|
||||||
|
if request.session.get('ipam_show_available'):
|
||||||
ipaddresses = add_available_ipaddresses(prefix.prefix, ipaddresses, prefix.is_pool)
|
ipaddresses = add_available_ipaddresses(prefix.prefix, ipaddresses, prefix.is_pool)
|
||||||
|
|
||||||
ip_table = tables.IPAddressTable(ipaddresses)
|
ip_table = tables.IPAddressTable(ipaddresses)
|
||||||
@ -579,6 +599,7 @@ class PrefixIPAddressesView(PermissionRequiredMixin, View):
|
|||||||
'permissions': permissions,
|
'permissions': permissions,
|
||||||
'bulk_querystring': 'vrf_id={}&parent={}'.format(prefix.vrf.pk if prefix.vrf else '0', prefix.prefix),
|
'bulk_querystring': 'vrf_id={}&parent={}'.format(prefix.vrf.pk if prefix.vrf else '0', prefix.prefix),
|
||||||
'active_tab': 'ip-addresses',
|
'active_tab': 'ip-addresses',
|
||||||
|
'show_available': request.session.get('ipam_show_available'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +40,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ aggregate }}{% endblock %}</h1>
|
<h1>{% block title %}{{ aggregate }}{% endblock %}</h1>
|
||||||
{% include 'inc/created_updated.html' with obj=aggregate %}
|
{% include 'inc/created_updated.html' with obj=aggregate %}
|
||||||
|
{% if show_available is not None %}
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available='true' %}" class="btn btn-default{% if show_available %} active disabled{% endif %}">Show available</a>
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available='false' %}" class="btn btn-default{% if not show_available %} active disabled{% endif %}">Hide available</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% custom_links aggregate %}
|
{% custom_links aggregate %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,6 +53,14 @@
|
|||||||
</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 %}
|
||||||
|
{% if show_available is not None %}
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available='true' %}" class="btn btn-default{% if show_available %} active disabled{% endif %}">Show available</a>
|
||||||
|
<a href="{{ request.path }}{% querystring request show_available='false' %}" class="btn btn-default{% if not show_available %} active disabled{% endif %}">Hide available</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% custom_links prefix %}
|
{% custom_links prefix %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user