Skip to content

Commit 0c1a08a

Browse files
committed
[admin] Add search in subnet
Closes #39
1 parent b034f1e commit 0c1a08a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

openwisp_ipam/static/openwisp-ipam/js/subnet.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ function initHostsInfiniteScroll($, current_subnet, address_add_url, address_cha
5858
});
5959
return div;
6060
}
61+
$(document).ready(function () {
62+
$("#subnet-search").on("keyup", function () {
63+
var searchQuery = $(this).val().toLowerCase();
64+
$("#subnet-visual div a").filter(function () {
65+
$(this).toggle($(this).text().toLowerCase().indexOf(searchQuery) > -1)
66+
});
67+
});
68+
});
6169
function appendPage() {
6270
$('.subnet-visual').append(pageContainer(fetchedPages[lastRenderedPage]));
6371
if (lastRenderedPage >= renderedPages) {

openwisp_ipam/templates/admin/openwisp-ipam/subnet/change_form.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ <h2>{% trans 'Network Hierarchical View' %}</h2>
2828
<div id="graph"></div>
2929

3030
<h3>{% trans 'Subnet Visual Display' %}</h3>
31-
<section class="subnet-visual{% if original.subnet.version == 6 %} ipv6{% endif %}">
32-
</section>
31+
<input id="subnet-search" placeholder="Search">
32+
<section id="subnet-visual" class="subnet-visual{% if original.subnet.version == 6 %} ipv6{% endif %}">
33+
</section>
34+
</input>
3335
{% endif %}
3436
{% endblock %}
3537

0 commit comments

Comments
 (0)