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