add IP count

This commit is contained in:
lijiejie
2024-06-09 22:54:01 +08:00
parent 80083e67ab
commit 71c6aae27c
4 changed files with 60 additions and 8 deletions
+18 -5
View File
@@ -2,33 +2,46 @@
<nav>
<ul class="pagination">
{% if logs.has_previous %}
<li class="page-item"><a class="page-link" href="?page={{ logs.previous_page_number }}">
{% if numpages > 5 %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page=1">
<span aria-hidden="true">&laquo;</span></a></li>
{% endif %}
{% if logs.has_previous %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ logs.previous_page_number }}">
<span aria-hidden="true">Previous</span></a></li>
{% else %}
<li class="page-item disabled"><span class="page-link" aria-hidden="true">&laquo;</span></li>
<li class="page-item disabled"><span class="page-link" aria-hidden="true">Previous</span></li>
{% endif %}
{% if logs.number|add:'-4' > 1 %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ logs.number|add:'-5' }}">&hellip;</a></li>
{% endif %}
{% spaceless %}
{% for i in logs.paginator.page_range %}
{% if logs.number == i %}
<li class="page-item active"><span class="page-link">{{ i }} <span class="sr-only">(current)</span></span></li>
{% elif i > logs.number|add:'-5' and i < logs.number|add:'5' %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ i }}">{{ i }}</a></li>
{% endif %}
{% endfor %}
{% endspaceless %}
{% if logs.paginator.num_pages > logs.number|add:'4' %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ logs.number|add:'5' }}">&hellip;</a></li>
{% endif %}
{% if logs.has_next %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ logs.next_page_number }}"><span aria-hidden="true">&raquo;</span></a></li>
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ logs.next_page_number }}"><span aria-hidden="true">Next</span></a></li>
{% else %}
<li class="page-item disabled"><span class="page-link" aria-hidden="true">&raquo;</span></li>
<li class="page-item disabled"><span class="page-link" aria-hidden="true">Next</span></li>
{% endif %}
{% if numpages > 5 %}
<li class="page-item"><a class="page-link" href="?{{ query_prefix }}page={{ numpages }}">
<span aria-hidden="true">&raquo;</span></a></li>
{% endif %}
<span class="page-link ml-4" style="border: none">{% blocktranslate %}第{{ page }}页 / 共{{ numpages }}页, 共{{ total }}条记录{% endblocktranslate %}</span>
+25 -3
View File
@@ -60,7 +60,8 @@
</div>
{% include 'auto_reload.html' %}
</form>
<div id="ip_count" class="d-flex flex-wrap">
</div>
<div data-example-id="hoverable-table">
<table class="table table-hover">
<thead>
@@ -68,7 +69,7 @@
<th>ID</th>
<th>{% translate '域名' %}</th>
<th>Type</th>
<th>IP</th>
<th>IP<button id="btnCountIPs" class="btn btn-sm btn-info py-0 ml-2" onclick="count_ips('dns')">Count</button></th>
<th>{% translate '位置' %}
<div class="spinner-grow spinner-grow-sm" role="status" id="spinner_location">
</div>
@@ -109,13 +110,15 @@
</div>
{% include 'auto_reload.html' %}
</form>
<div id="ip_count" class="d-flex flex-wrap">
</div>
<div data-example-id="hoverable-table">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th style="width: 350px;">URL</th>
<th>IP</th>
<th>IP<button id="btnCountIPs" class="btn btn-sm btn-info py-0 ml-2" onclick="count_ips('web')">Count</button></th>
<th>{% translate '位置' %}
<div class="spinner-grow spinner-grow-sm" role="status" id="spinner_location">
</div>
@@ -543,6 +546,25 @@
}
});
function count_ips(type){
$('#btnCountIPs').attr("disabled", true);
$.get("/ip_count/" + type, function(result){
$('#ip_count').html('');
for (let i = 0; i < result['data'].length - 1; i++) {
html = `
<a href="?ip=${result['data'][i]['ip']}" target="_blank">
<div class="card rounded-1 bg-light mr-4 my-1" style="width: 110px;" >
<div class="card-body p-0 justify-content-between d-flex">
<span class="badge bg-light" >${result['data'][i]['ip']}</span> <span class="badge bg-warning float-end rounded-1">${result['data'][i]['total']}</span>
</div>
</div>
</a>`;
$('#ip_count').append(html);
}
$('#btnCountIPs').attr("disabled", false);
});
}
</script>
</body>