feat: ✨ global search
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<body class="bg-gray-300 text-gray-900 dark:bg-zinc-900 dark:text-gray-100 min-h-screen flex flex-col">
|
||||
{% include 'header.html' %}
|
||||
<div class="flex-1 flex items-center justify-center mx-4">
|
||||
<div class="container py-8 w-auto min-w-2xl pt-20">
|
||||
<div class="container py-8 max-w-2xl pt-20">
|
||||
<div class="flex items-center mb-8 relative justify-between gap-4">
|
||||
<a href="/devices" class="hidden sm:flex bg-gray-200 hover:bg-gray-400 dark:bg-zinc-700 dark:hover:bg-zinc-600 flex items-center justify-center rounded-full w-11 h-11 shrink-0"><i class="fas fa-arrow-left"></i></a>
|
||||
<h1 class="text-3xl font-bold text-center flex-1 min-w-0 truncate">{{ device.name }}</h1>
|
||||
|
||||
+23
-6
@@ -1,15 +1,22 @@
|
||||
<header class="bg-zinc-800 shadow-md py-3 px-6 flex items-center justify-between relative">
|
||||
<div class="flex items-center space-x-3">
|
||||
<div class="flex items-center space-x-3 flex-shrink-0">
|
||||
<a href="/" class="flex items-center space-x-3">
|
||||
<img src="{{ LOGO_PNG }}" alt="Logo" class="h-8 rounded">
|
||||
<span class="text-2xl font-bold text-white whitespace-nowrap">{{ NAME }} IPAM</span>
|
||||
</a>
|
||||
<a href="https://github.com/JDB-NET/ipam/releases" target="_blank" rel="noopener noreferrer" class="text-sm font-normal text-gray-300 hover:text-gray-100 -ml-1 mt-3">v{{ VERSION }}</a>
|
||||
</div>
|
||||
<div class="hidden 2xl:block absolute left-1/2 transform -translate-x-1/2 text-white text-lg font-medium whitespace-nowrap">
|
||||
{% if current_user_name %}Hello, {{ current_user_name }}{% endif %}
|
||||
<div class="hidden lg:flex items-center justify-center absolute left-1/2 transform -translate-x-1/2">
|
||||
<form action="/search" method="GET" class="flex items-center space-x-2">
|
||||
<input type="text" name="q" id="search-input" placeholder="Search..."
|
||||
class="bg-zinc-700 text-white placeholder-gray-400 px-4 py-2 rounded-md text-base focus:outline-none focus:ring-2 focus:ring-gray-500 w-100"
|
||||
value="{{ request.args.get('q', '') }}">
|
||||
<button type="submit" class="text-gray-200 hover:text-gray-400 hover:cursor-pointer flex-shrink-0">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<nav class="hidden md:flex items-center space-x-6" id="main-nav">
|
||||
<nav class="hidden lg:flex items-center space-x-6 flex-shrink-0" id="main-nav">
|
||||
{% if has_permission('view_index') %}
|
||||
<a href="/" class="text-gray-200 hover:text-gray-400 font-medium">Home</a>
|
||||
{% endif %}
|
||||
@@ -29,12 +36,22 @@
|
||||
<a href="/logout" class="text-gray-200 hover:text-gray-400 font-medium">Logout</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<button class="md:hidden flex items-center text-gray-200 hover:cursor-pointer focus:outline-none" id="nav-toggle" aria-label="Open navigation menu">
|
||||
<button class="lg:hidden flex items-center text-gray-200 hover:cursor-pointer focus:outline-none flex-shrink-0" id="nav-toggle" aria-label="Open navigation menu">
|
||||
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="md:hidden absolute top-16 right-6 bg-zinc-800 rounded-lg shadow-lg z-50 w-48 hidden flex-col py-2" id="mobile-nav">
|
||||
<div class="lg:hidden fixed top-13 left-0 right-0 bg-zinc-800 shadow-lg z-50 w-full hidden flex-col py-2" id="mobile-nav">
|
||||
<form action="/search" method="GET" class="px-4 py-2 border-b border-zinc-700">
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="text" name="q" placeholder="Search..."
|
||||
class="bg-zinc-700 text-white placeholder-gray-400 px-3 py-2.5 rounded text-base focus:outline-none focus:ring-2 focus:ring-gray-500 flex-1"
|
||||
value="{{ request.args.get('q', '') }}">
|
||||
<button type="submit" class="text-gray-200 hover:text-gray-400 hover:cursor-pointer flex-shrink-0">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% if has_permission('view_index') %}
|
||||
<a href="/" class="block px-6 py-2 text-gray-200 hover:text-gray-400 font-medium">Home</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Search - {{ NAME }} IPAM</title>
|
||||
<link rel="icon" type="image/png" href="{{ LOGO_PNG }}">
|
||||
<link href="/static/css/output.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="bg-gray-300 text-gray-900 dark:bg-zinc-900 dark:text-gray-100 min-h-screen flex flex-col">
|
||||
{% include 'header.html' %}
|
||||
<div class="flex-1 container mx-auto px-4 py-8 pt-20">
|
||||
<div class="max-w-6xl mx-auto">
|
||||
<h1 class="text-3xl font-bold mb-6">Search Results</h1>
|
||||
|
||||
{% if query %}
|
||||
<p class="text-lg mb-6">Search results for: <span class="font-semibold">"{{ query }}"</span></p>
|
||||
{% else %}
|
||||
<p class="text-lg mb-6 text-gray-600 dark:text-gray-400">Enter a search query to find IPs, devices, subnets, tags, racks, and sites.</p>
|
||||
{% endif %}
|
||||
|
||||
{% if query %}
|
||||
{% set total_results = results.subnets|length + results.ips|length + results.devices|length + results.tags|length + results.racks|length + results.sites|length %}
|
||||
|
||||
{% if total_results == 0 %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-8 text-center">
|
||||
<i class="fas fa-search text-4xl text-gray-400 mb-4"></i>
|
||||
<p class="text-xl font-semibold mb-2">No results found</p>
|
||||
<p class="text-gray-600 dark:text-gray-400">Try a different search term or check your spelling.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="space-y-6">
|
||||
<!-- Subnets -->
|
||||
{% if results.subnets %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-network-wired mr-2"></i>
|
||||
Subnets ({{ results.subnets|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for subnet in results.subnets %}
|
||||
<a href="/subnet/{{ subnet.id }}" class="block p-3 bg-gray-300 dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded-lg transition-colors">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="font-semibold text-lg">{{ subnet.name }}</p>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ subnet.cidr }}</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ subnet.site }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- IP Addresses -->
|
||||
{% if results.ips %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-map-marker-alt mr-2"></i>
|
||||
IP Addresses ({{ results.ips|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for ip in results.ips %}
|
||||
<a href="/subnet/{{ ip.subnet_id }}#ip-{{ ip.id }}" class="block p-3 bg-gray-300 dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded-lg transition-colors">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="font-semibold text-lg">{{ ip.ip }}</p>
|
||||
{% if ip.hostname %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ ip.hostname }}</p>
|
||||
{% endif %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ ip.subnet_name }} ({{ ip.subnet_cidr }})</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ ip.site }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Devices -->
|
||||
{% if results.devices %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-server mr-2"></i>
|
||||
Devices ({{ results.devices|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for device in results.devices %}
|
||||
<a href="/device/{{ device.id }}" class="block p-3 bg-gray-300 dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded-lg transition-colors">
|
||||
<div>
|
||||
<p class="font-semibold text-lg">{{ device.name }}</p>
|
||||
{% if device.description %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ device.description }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Tags -->
|
||||
{% if results.tags %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-tags mr-2"></i>
|
||||
Tags ({{ results.tags|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for tag in results.tags %}
|
||||
<a href="/tags" class="block p-3 bg-gray-300 dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded-lg transition-colors">
|
||||
<div>
|
||||
<p class="font-semibold text-lg">{{ tag.name }}</p>
|
||||
{% if tag.description %}
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ tag.description }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Racks -->
|
||||
{% if results.racks %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-th mr-2"></i>
|
||||
Racks ({{ results.racks|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for rack in results.racks %}
|
||||
<a href="/rack/{{ rack.id }}" class="block p-3 bg-gray-300 dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded-lg transition-colors">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="font-semibold text-lg">{{ rack.name }}</p>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ rack.height_u }}U</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{{ rack.site }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Sites -->
|
||||
{% if results.sites %}
|
||||
<div class="bg-gray-200 dark:bg-zinc-800 rounded-lg shadow-md p-6">
|
||||
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
||||
<i class="fas fa-map-marker-alt mr-2"></i>
|
||||
Sites ({{ results.sites|length }})
|
||||
</h2>
|
||||
<div class="space-y-2">
|
||||
{% for site in results.sites %}
|
||||
<div class="p-3 bg-gray-300 dark:bg-zinc-900 rounded-lg">
|
||||
<p class="font-semibold text-lg">{{ site }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-700">
|
||||
{% for ip in ip_addresses %}
|
||||
<tr>
|
||||
<tr id="ip-{{ ip[0] }}">
|
||||
<td class="font-bold text-center">{{ ip[1] }}</td>
|
||||
<td class="text-center">
|
||||
{% if ip[2] == 'DHCP' %}
|
||||
|
||||
Reference in New Issue
Block a user