Closes #160: feature save filters (#227)

* initial saved filter support

* add filter field

* fixed model

* changed margin
This commit is contained in:
mattieserver
2022-12-26 12:07:01 +01:00
committed by GitHub
parent 683a980858
commit e0bd1d4e86
5 changed files with 11 additions and 2 deletions
+1
View File
@@ -31,6 +31,7 @@ class DeviceFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
None,
(
"q",
"filter_id",
"hide_unconnected",
"save_coords",
"show_circuit",
@@ -1 +1 @@
#visgraph{height:70vh}html[data-netbox-color-mode=dark] #visgraph{background-color:#212529}.image-dropdown img{width:64px;height:64px}.image-dropdown-content{display:flex;flex-wrap:wrap;gap:.5rem;padding-inline:.5rem;width:50vw;max-width:32rem}.image-dropdown-content>img{cursor:pointer}
#visgraph{height:64vh}html[data-netbox-color-mode=dark] #visgraph{background-color:#212529}.image-dropdown img{width:64px;height:64px}.image-dropdown-content{display:flex;flex-wrap:wrap;gap:.5rem;padding-inline:.5rem;width:50vw;max-width:32rem}.image-dropdown-content>img{cursor:pointer}
@@ -1,5 +1,5 @@
#visgraph {
height: 70vh;
height: 64vh;
}
html[data-netbox-color-mode=dark] #visgraph {
@@ -48,6 +48,12 @@
{% with config=settings.PLUGINS_CONFIG.netbox_topology_views %}
<div class="tab-content">
{# Applied filters #}
{% if filter_form %}
{% applied_filters model filter_form request.GET %}
<hr style="margin-top: 0px;">
{% endif %}
<div class="tab-pane show active" id="networks" role="tabpanel" aria-labelledby="network-tab">
<div class="panel-body">
<div id="visgraph"></div>
+2
View File
@@ -540,6 +540,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
"device_type", "device_role"
)
self.queryset = self.filterset(request.GET, self.queryset).qs
self.model = self.queryset.model
topo_data = None
if request.GET:
@@ -630,6 +631,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
"filter_form": DeviceFilterForm(request.GET, label_suffix=""),
"topology_data": json.dumps(topo_data),
"broken_image": find_image_url("role-unknown"),
"model": self.model,
},
)