mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #667: Added stats to RIR list view
This commit is contained in:
@ -127,11 +127,16 @@ class RIRTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = tables.LinkColumn(verbose_name='Name')
|
||||
aggregate_count = tables.Column(verbose_name='Aggregates')
|
||||
stats_total = tables.Column(accessor='stats.total', verbose_name='Total')
|
||||
stats_active = tables.Column(accessor='stats.active', verbose_name='Active')
|
||||
stats_reserved = tables.Column(accessor='stats.reserved', verbose_name='Reserved')
|
||||
stats_deprecated = tables.Column(accessor='stats.deprecated', verbose_name='Deprecated')
|
||||
stats_available = tables.Column(accessor='stats.available', verbose_name='Available')
|
||||
stats_total = tables.Column(accessor='stats.total', verbose_name='Total',
|
||||
footer=lambda table: sum(r.stats['total'] for r in table.data))
|
||||
stats_active = tables.Column(accessor='stats.active', verbose_name='Active',
|
||||
footer=lambda table: sum(r.stats['active'] for r in table.data))
|
||||
stats_reserved = tables.Column(accessor='stats.reserved', verbose_name='Reserved',
|
||||
footer=lambda table: sum(r.stats['reserved'] for r in table.data))
|
||||
stats_deprecated = tables.Column(accessor='stats.deprecated', verbose_name='Deprecated',
|
||||
footer=lambda table: sum(r.stats['deprecated'] for r in table.data))
|
||||
stats_available = tables.Column(accessor='stats.available', verbose_name='Available',
|
||||
footer=lambda table: sum(r.stats['available'] for r in table.data))
|
||||
utilization = tables.TemplateColumn(template_code=RIR_UTILIZATION, verbose_name='Utilization')
|
||||
actions = tables.TemplateColumn(template_code=RIR_ACTIONS, attrs={'td': {'class': 'text-right'}}, verbose_name='')
|
||||
|
||||
|
@ -160,9 +160,12 @@ class RIRListView(ObjectListView):
|
||||
|
||||
def alter_queryset(self, request):
|
||||
|
||||
# Count /64s for IPv6 rather than individual IPs
|
||||
family = 4
|
||||
denominator = 2 ** 64 if family == 6 else 1
|
||||
if request.GET.get('family') == '6':
|
||||
family = 6
|
||||
denominator = 2 ** 64 # Count /64s for IPv6 rather than individual IPs
|
||||
else:
|
||||
family = 4
|
||||
denominator = 1
|
||||
|
||||
rirs = []
|
||||
for rir in self.queryset:
|
||||
|
@ -85,6 +85,9 @@ label.required {
|
||||
th.pk, td.pk {
|
||||
width: 30px;
|
||||
}
|
||||
tfoot td {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Paginator */
|
||||
nav ul.pagination {
|
||||
|
@ -6,6 +6,17 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="pull-right">
|
||||
{% if request.GET.family == '6' %}
|
||||
<a href="{% url 'ipam:rir_list' %}" class="btn btn-default">
|
||||
<span class="fa fa-table" aria-hidden="true"></span>
|
||||
IPv4 Stats
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'ipam:rir_list' %}?family=6" class="btn btn-default">
|
||||
<span class="fa fa-table" aria-hidden="true"></span>
|
||||
IPv6 Stats
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if perms.ipam.add_rir %}
|
||||
<a href="{% url 'ipam:rir_add' %}" class="btn btn-primary">
|
||||
<span class="fa fa-plus" aria-hidden="true"></span>
|
||||
@ -19,29 +30,7 @@
|
||||
{% include 'utilities/obj_table.html' with bulk_delete_url='ipam:rir_bulk_delete' %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<h3>Totals</h3>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<h3>{{ totals.total|intcomma }}</h3>
|
||||
All IPv4 space
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<h3>{{ totals.active|intcomma }}</h3>
|
||||
Active
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<h3>{{ totals.reserved|intcomma }}</h3>
|
||||
Reserved
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<h3>{{ totals.deprecated|intcomma }}</h3>
|
||||
Deprecated
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<h3>{{ totals.available|intcomma }}</h3>
|
||||
Available
|
||||
</div>
|
||||
</div>
|
||||
{% if request.GET.family == '6' %}
|
||||
<div class="pull-right text-muted"><strong>Note:</strong> Numbers shown indicate /64 prefixes.</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user