feat: search modal #41

Merged
jamie merged 1 commits from v1.9.7 into main 2026-02-19 20:25:29 +00:00
9 changed files with 139 additions and 197 deletions
Showing only changes of commit 84d024f4c6 - Show all commits
+2 -18
View File
@@ -14,21 +14,5 @@ jobs:
- name: Build and push Docker image - name: Build and push Docker image
run: | run: |
docker build -t cr.jdbnet.co.uk/public/ipam:dev \ docker build -t cr.jdbnet.co.uk/public/ipam:dev --build-arg VERSION=dev .
--build-arg VERSION=dev \ docker push cr.jdbnet.co.uk/public/ipam:dev
.
docker push cr.jdbnet.co.uk/public/ipam:dev
deploy:
name: Deploy to Kubernetes
needs: release
runs-on: k3s-internal-htz-01
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to Kubernetes
run: |
sudo kubectl replace -f deployment-dev.yml --grace-period=60 --force
+1 -15
View File
@@ -43,18 +43,4 @@ jobs:
name: ${{ steps.get_version.outputs.VERSION }} name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }} body: ${{ steps.changelog.outputs.changelog }}
draft: false draft: false
prerelease: false prerelease: false
deploy:
name: Deploy to Kubernetes
needs: release
runs-on: k3s-internal-htz-01
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy to Kubernetes
run: |
sudo kubectl replace -f deployment-prod.yml --grace-period=60 --force
+1 -1
View File
@@ -1,5 +1,5 @@
<div align="center"> <div align="center">
<img src="https://projects.jdbnet.co.uk/ipam/img/favicon.png" alt="IPAM" width="200" /> <img src="https://assets.jdbnet.co.uk/projects/ipam.png" alt="IPAM" width="200" />
# IP Address Management # IP Address Management
</div> </div>
+1 -1
View File
@@ -34,7 +34,7 @@ def inject_env_vars():
return { return {
'NAME': os.environ.get('NAME', 'JDB-NET'), 'NAME': os.environ.get('NAME', 'JDB-NET'),
'LOGO_PNG': os.environ.get('LOGO_PNG', 'https://assets.s3.jdbnet.co.uk/logo/128x128.png'), 'LOGO_PNG': os.environ.get('LOGO_PNG', 'https://assets.jdbnet.co.uk/logo/128x128.png'),
'VERSION': version, 'VERSION': version,
'has_permission': has_permission, 'has_permission': has_permission,
'is_feature_enabled': is_feature_enabled 'is_feature_enabled': is_feature_enabled
-64
View File
@@ -1,64 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ipam
namespace: ipam
spec:
replicas: 1
selector:
matchLabels:
app: ipam
template:
metadata:
labels:
app: ipam
spec:
containers:
- name: ipam
image: cr.jdbnet.co.uk/public/ipam:dev
imagePullPolicy: Always
ports:
- containerPort: 5000
name: "ipam"
env:
- name: SECRET_KEY
value: "41TbN7v5peFLZPrdwSCc64J3mjmiUk5fkVWsmb2m"
- name: MYSQL_HOST
value: "10.10.25.4"
- name: MYSQL_USER
value: "ipam"
- name: MYSQL_PASSWORD
value: "WXPmo05sGCfjGe"
- name: MYSQL_DATABASE
value: "ipam"
---
apiVersion: v1
kind: Service
metadata:
name: ipam-ingress-service
namespace: ipam
spec:
selector:
app: ipam
ports:
- protocol: TCP
port: 80
targetPort: 5000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ipam-ingress
namespace: ipam
spec:
rules:
- host: ipam.jdb143.uk
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: ipam-ingress-service
port:
number: 80
-64
View File
@@ -1,64 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ipam
namespace: ipam
spec:
replicas: 1
selector:
matchLabels:
app: ipam
template:
metadata:
labels:
app: ipam
spec:
containers:
- name: ipam
image: cr.jdbnet.co.uk/public/ipam:latest
imagePullPolicy: Always
ports:
- containerPort: 5000
name: "ipam"
env:
- name: SECRET_KEY
value: "41TbN7v5peFLZPrdwSCc64J3mjmiUk5fkVWsmb2m"
- name: MYSQL_HOST
value: "10.10.25.4"
- name: MYSQL_USER
value: "ipam"
- name: MYSQL_PASSWORD
value: "WXPmo05sGCfjGe"
- name: MYSQL_DATABASE
value: "ipam"
---
apiVersion: v1
kind: Service
metadata:
name: ipam-ingress-service
namespace: ipam
spec:
selector:
app: ipam
ports:
- protocol: TCP
port: 80
targetPort: 5000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ipam-ingress
namespace: ipam
spec:
rules:
- host: ipam.jdb143.uk
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: ipam-ingress-service
port:
number: 80
+88 -4
View File
@@ -1,12 +1,96 @@
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
const navToggle = document.getElementById('nav-toggle'); const navToggle = document.getElementById('nav-toggle');
const mobileNav = document.getElementById('mobile-nav'); const mobileNav = document.getElementById('mobile-nav');
navToggle.addEventListener('click', function() { const searchModal = document.getElementById('search-modal');
mobileNav.classList.toggle('hidden'); const searchModalOpen = document.getElementById('search-modal-open');
}); const searchModalOpenMobile = document.getElementById('search-modal-open-mobile');
const searchModalClose = document.getElementById('search-modal-close');
const searchModalBackdrop = document.getElementById('search-modal-backdrop');
const searchModalInput = document.getElementById('search-modal-input');
if (navToggle && mobileNav) {
navToggle.addEventListener('click', function() {
mobileNav.classList.toggle('hidden');
});
}
function openSearchModal() {
if (!searchModal) {
return;
}
searchModal.classList.remove('hidden');
searchModal.classList.add('flex');
document.body.classList.add('overflow-hidden');
if (mobileNav) {
mobileNav.classList.add('hidden');
}
setTimeout(function() {
if (searchModalInput) {
searchModalInput.focus();
searchModalInput.select();
}
}, 0);
}
function closeSearchModal() {
if (!searchModal) {
return;
}
searchModal.classList.add('hidden');
searchModal.classList.remove('flex');
document.body.classList.remove('overflow-hidden');
}
if (searchModalOpen) {
searchModalOpen.addEventListener('click', openSearchModal);
}
if (searchModalOpenMobile) {
searchModalOpenMobile.addEventListener('click', openSearchModal);
}
if (searchModalClose) {
searchModalClose.addEventListener('click', closeSearchModal);
}
if (searchModalBackdrop) {
searchModalBackdrop.addEventListener('click', closeSearchModal);
}
document.addEventListener('click', function(e) { document.addEventListener('click', function(e) {
if (!mobileNav.contains(e.target) && !navToggle.contains(e.target)) { if (mobileNav && navToggle && !mobileNav.contains(e.target) && !navToggle.contains(e.target)) {
mobileNav.classList.add('hidden'); mobileNav.classList.add('hidden');
} }
}); });
document.addEventListener('keydown', function(e) {
const target = e.target;
const isEditableTarget = target && (
target.tagName === 'INPUT' ||
target.tagName === 'TEXTAREA' ||
target.tagName === 'SELECT' ||
target.isContentEditable
);
if (
e.key === '/' &&
!e.ctrlKey &&
!e.metaKey &&
!e.altKey &&
searchModal &&
!isEditableTarget
) {
e.preventDefault();
openSearchModal();
return;
}
if (e.key === 'Escape') {
closeSearchModal();
}
});
}); });
+1 -1
View File
@@ -1 +1 @@
document.addEventListener("DOMContentLoaded",function(){let t=document.getElementById("nav-toggle"),e=document.getElementById("mobile-nav");t.addEventListener("click",function(){e.classList.toggle("hidden")}),document.addEventListener("click",function(n){e.contains(n.target)||t.contains(n.target)||e.classList.add("hidden")})}); document.addEventListener("DOMContentLoaded",function(){let e=document.getElementById("nav-toggle"),t=document.getElementById("mobile-nav"),o=document.getElementById("search-modal"),n=document.getElementById("search-modal-open"),d=document.getElementById("search-modal-open-mobile"),c=document.getElementById("search-modal-close"),l=document.getElementById("search-modal-backdrop"),a=document.getElementById("search-modal-input");function s(){o&&(o.classList.remove("hidden"),o.classList.add("flex"),document.body.classList.add("overflow-hidden"),t&&t.classList.add("hidden"),setTimeout(function(){a&&(a.focus(),a.select())},0))}function i(){o&&(o.classList.add("hidden"),o.classList.remove("flex"),document.body.classList.remove("overflow-hidden"))}e&&t&&e.addEventListener("click",function(){t.classList.toggle("hidden")}),n&&n.addEventListener("click",s),d&&d.addEventListener("click",s),c&&c.addEventListener("click",i),l&&l.addEventListener("click",i),document.addEventListener("click",function(o){t&&e&&!t.contains(o.target)&&!e.contains(o.target)&&t.classList.add("hidden")}),document.addEventListener("keydown",function(e){let t=e.target,n=t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||t.isContentEditable);if("/"===e.key&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&o&&!n)return e.preventDefault(),void s();"Escape"===e.key&&i()})});
+45 -29
View File
@@ -1,4 +1,4 @@
<header class="bg-zinc-800 shadow-md py-3 px-6 relative flex items-center justify-between lg:grid lg:grid-cols-[auto_minmax(18rem,1fr)_auto] lg:gap-6"> <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 flex-shrink-0"> <div class="flex items-center space-x-3 flex-shrink-0">
<a href="/" class="flex items-center space-x-3"> <a href="/" class="flex items-center space-x-3">
<img src="{{ LOGO_PNG }}" alt="Logo" class="h-8 rounded"> <img src="{{ LOGO_PNG }}" alt="Logo" class="h-8 rounded">
@@ -6,19 +6,13 @@
</a> </a>
<a href="https://git.jdbnet.co.uk/jamie/ipam/releases" target="_blank" rel="noopener noreferrer" class="text-sm font-normal text-gray-300 hover:text-gray-100 -ml-1 mt-3">{{ VERSION }}</a> <a href="https://git.jdbnet.co.uk/jamie/ipam/releases" target="_blank" rel="noopener noreferrer" class="text-sm font-normal text-gray-300 hover:text-gray-100 -ml-1 mt-3">{{ VERSION }}</a>
</div> </div>
<nav class="hidden lg:flex items-center space-x-6 flex-shrink-0" id="main-nav">
<div class="hidden lg:flex items-center min-w-0"> {% if current_user_name %}
<form action="/search" method="GET" class="flex items-center space-x-2 w-full max-w-2xl mx-auto"> <button type="button" class="text-gray-200 hover:text-gray-400 font-medium flex items-center gap-2 hover:cursor-pointer" id="search-modal-open" aria-label="Open search modal">
<input type="text" name="q" id="search-input" placeholder="Search..." <i class="fas fa-search"></i>
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-full min-w-0" <span>Search</span>
value="{{ request.args.get('q', '') }}"> </button>
<button type="submit" class="text-gray-200 hover:text-gray-400 hover:cursor-pointer flex-shrink-0"> {% endif %}
<i class="fas fa-search"></i>
</button>
</form>
</div>
<nav class="hidden lg:flex items-center space-x-6 flex-shrink-0 whitespace-nowrap justify-self-end" id="main-nav">
{% if has_permission('view_index') %} {% if has_permission('view_index') %}
<a href="/" class="text-gray-200 hover:text-gray-400 font-medium flex items-center gap-2"> <a href="/" class="text-gray-200 hover:text-gray-400 font-medium flex items-center gap-2">
<i class="fas fa-home"></i> <i class="fas fa-home"></i>
@@ -60,22 +54,19 @@
</a> </a>
{% endif %} {% endif %}
</nav> </nav>
<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"> <div class="lg:hidden flex items-center gap-3 flex-shrink-0">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> {% if current_user_name %}
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path> <button class="flex items-center text-gray-200 hover:cursor-pointer focus:outline-none" id="search-modal-open-mobile" aria-label="Open search modal">
</svg> <i class="fas fa-search text-xl"></i>
</button> </button>
{% endif %}
<button class="flex items-center text-gray-200 hover:cursor-pointer focus:outline-none" 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>
<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"> <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') %} {% if has_permission('view_index') %}
<a href="/" class="block px-6 py-2 text-gray-200 hover:text-gray-400 font-medium flex items-center gap-2"> <a href="/" class="block px-6 py-2 text-gray-200 hover:text-gray-400 font-medium flex items-center gap-2">
<i class="fas fa-home"></i> <i class="fas fa-home"></i>
@@ -117,6 +108,31 @@
</a> </a>
{% endif %} {% endif %}
</div> </div>
{% if current_user_name %}
<div id="search-modal" class="hidden fixed inset-0 z-50 items-center justify-center p-4">
<div id="search-modal-backdrop" class="absolute inset-0 bg-black/60"></div>
<div class="relative w-full max-w-2xl rounded-lg bg-zinc-800 border border-zinc-700 shadow-xl">
<div class="flex items-center justify-between px-4 py-3 border-b border-zinc-700">
<h3 class="text-white font-semibold text-lg">Search</h3>
<button type="button" id="search-modal-close" class="text-gray-300 hover:text-white hover:cursor-pointer" aria-label="Close search modal">
<i class="fas fa-times"></i>
</button>
</div>
<form action="/search" method="GET" class="p-4">
<div class="flex items-center gap-2">
<input type="text" name="q" id="search-modal-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-full"
value="{{ request.args.get('q', '') }}">
<button type="submit" class="text-gray-200 hover:text-gray-400 hover:cursor-pointer flex-shrink-0" aria-label="Submit search">
<i class="fas fa-search"></i>
</button>
</div>
</form>
</div>
</div>
{% endif %}
<script src="/static/js/header.min.js"></script> <script src="/static/js/header.min.js"></script>
<!-- Update Available Toast --> <!-- Update Available Toast -->