Replace expand/collpase with max mask length for prefixes list

This commit is contained in:
Jeremy Stretch
2020-08-05 16:48:45 -04:00
parent e8df9be702
commit d384f25ec2
5 changed files with 29 additions and 12 deletions

View File

@@ -511,10 +511,6 @@ class PrefixFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm)
choices=BOOLEAN_WITH_BLANK_CHOICES
)
)
expand = forms.BooleanField(
required=False,
label='Expand prefix hierarchy'
)
tag = TagFilterField(model)

View File

@@ -39,10 +39,10 @@ ROLE_VLAN_COUNT = """
"""
PREFIX_LINK = """
{% if record.has_children %}
<span class="text-nowrap" style="padding-left: {{ record.depth }}0px "><i class="fa fa-caret-right"></i></a>
{% if record.children %}
<span class="text-nowrap" style="padding-left: {{ record.parents }}0px "><i class="fa fa-caret-right"></i></a>
{% else %}
<span class="text-nowrap" style="padding-left: {{ record.depth }}9px">
<span class="text-nowrap" style="padding-left: {{ record.parents }}9px">
{% endif %}
<a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if parent.vrf %}&vrf={{ parent.vrf.pk }}{% endif %}{% if parent.site %}&site={{ parent.site.pk }}{% endif %}{% if parent.tenant %}&tenant_group={{ parent.tenant.group.pk }}&tenant={{ parent.tenant.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a>
</span>
@@ -336,8 +336,10 @@ class PrefixTable(BaseTable):
class Meta(BaseTable.Meta):
model = Prefix
fields = ('pk', 'prefix', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'is_pool', 'description')
default_columns = ('pk', 'prefix', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'description')
fields = (
'pk', 'prefix', 'children', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'is_pool', 'description',
)
default_columns = ('pk', 'prefix', 'children', 'status', 'vrf', 'tenant', 'site', 'vlan', 'role', 'description')
row_attrs = {
'class': lambda record: 'success' if not record.pk else '',
}

View File

@@ -318,7 +318,7 @@ class RoleBulkDeleteView(BulkDeleteView):
#
class PrefixListView(ObjectListView):
queryset = Prefix.objects.prefetch_related('site', 'vrf__tenant', 'tenant', 'vlan', 'role')
queryset = Prefix.objects.prefetch_related('site', 'vrf__tenant', 'tenant', 'vlan', 'role').annotate_tree()
filterset = filters.PrefixFilterSet
filterset_form = forms.PrefixFilterForm
table = tables.PrefixDetailTable