feat: ip address history

This commit is contained in:
2025-12-27 01:45:37 +00:00
parent e028f9610c
commit 21042b7fd7
4 changed files with 279 additions and 3 deletions
+39
View File
@@ -75,6 +75,45 @@
</ul>
</div>
<!-- IP History Section -->
{% if ip_history %}
<div class="ip-history mb-6">
<h3 class="text-lg font-bold mb-2">IP Assignment History:</h3>
<div class="bg-gray-200 dark:bg-zinc-700 rounded-lg p-4 max-h-96 overflow-y-auto">
<div class="space-y-3">
{% for entry in ip_history %}
<div class="flex items-start gap-3 pb-3 {% if not loop.last %}border-b border-gray-400 dark:border-zinc-600{% endif %}">
<div class="flex-shrink-0 mt-1">
{% if entry.action == 'assigned' %}
<i class="fas fa-plus-circle text-green-500"></i>
{% else %}
<i class="fas fa-minus-circle text-red-500"></i>
{% endif %}
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2 flex-wrap">
<span class="font-mono font-semibold">{{ entry.ip }}</span>
<span class="text-sm text-gray-600 dark:text-gray-400">
{% if entry.action == 'assigned' %}Assigned{% else %}Removed{% endif %}
</span>
<span class="text-sm text-gray-600 dark:text-gray-400">
to {{ entry.device_name }}
</span>
</div>
<div class="text-sm text-gray-600 dark:text-gray-400 mt-1">
{{ entry.subnet_name }} ({{ entry.subnet_cidr }})
</div>
<div class="text-xs text-gray-500 dark:text-gray-500 mt-1">
by {{ entry.user_name }} • {{ entry.timestamp.strftime('%Y-%m-%d %H:%M:%S') if entry.timestamp else 'Unknown' }}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
<!-- Tags Section -->
<div class="tags-section mb-6">
<h3 class="text-lg font-bold mb-2">Tags:</h3>
+20 -1
View File
@@ -50,7 +50,11 @@
<tbody class="divide-y divide-gray-700">
{% for ip in ip_addresses %}
<tr id="ip-{{ ip[0] }}">
<td class="font-bold text-center">{{ ip[1] }}</td>
<td class="font-bold text-center">
<button type="button" class="ip-history-btn hover:text-blue-400 cursor-pointer" data-ip="{{ ip[1] }}" title="View IP history">
{{ ip[1] }}
</button>
</td>
<td class="text-center">
{% if ip[2] == 'DHCP' %}
<span class="font-semibold">DHCP</span>
@@ -72,7 +76,22 @@
</form>
</div>
</div>
<!-- IP History Modal -->
<div id="ip-history-modal" class="hidden fixed inset-0 bg-black/30 backdrop-blur-md flex items-center justify-center z-50">
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg p-6 max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto shadow-2xl border border-gray-300 dark:border-zinc-700">
<div class="flex justify-between items-center mb-4">
<h2 class="text-2xl font-bold">IP History: <span id="modal-ip-address" class="font-mono"></span></h2>
<button type="button" id="close-ip-history-modal" class="text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:cursor-pointer text-2xl">&times;</button>
</div>
<div id="ip-history-content" class="space-y-3">
<div class="text-center text-gray-600 dark:text-gray-400">Loading...</div>
</div>
</div>
</div>
<script src="/static/js/export_csv.js"></script>
<script src="/static/js/subnet.js"></script>
<script src="/static/js/ip_history.js"></script>
</body>
</html>