Added more frontend and some more login logic

This commit is contained in:
2026-06-05 21:58:10 +02:00
parent 6543149dab
commit 52d551ab39
22 changed files with 1043 additions and 173 deletions

View File

@@ -1,27 +1,82 @@
<!DOCTYPE html>
<html lang="de">
{{ define "base.html" }}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .Title }}</title>
<title>{{ .Title }} | MiauInv</title>
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<link rel="stylesheet" href="/assets/css/theme.css">
<link rel="stylesheet" href="/assets/css/dashboard.css">
</head>
<body>
<nav>
<a href="/dashboard">Dashboard</a>
<a href="/items">Inventar</a>
<a href="/projects">Projekte</a>
<a href="/locations">Orte</a>
</nav>
<header>
<div class="nav-container">
<div class="nav-left">
<div class="brand">Miau<span>Inv</span></div>
<nav id="main-nav">
<a href="/dashboard">Dashboard</a>
<a href="/inventory">Inventory</a>
<a href="/projects">Projects</a>
<a href="/locations">Locations</a>
</nav>
</div>
<div class="profile-dropdown">
<button class="profile-trigger" id="profile-btn">
<div class="avatar">M</div>
<span class="username">Profile</span>
</button>
<div class="dropdown-menu" id="dropdown-menu">
<a href="/profile/settings">Account Settings</a>
<a href="/profile/activity">Activity Log</a>
<hr class="dropdown-divider">
<button class="logout-btn"
hx-post="/api/logout"
hx-trigger="click"
hx-on::after-request="
if (event.detail.successful) {
localStorage.removeItem('access_token');
localStorage.removeItem('refresh_token');
document.cookie = 'access_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;';
document.cookie = 'refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;';
window.location.href = '/login';
} else {
alert('Logout failed. Please try again.');
}
">
Log Out
</button>
</div>
</div>
</div>
</header>
<main>
{{ template "content" . }}
</main>
<script>
document.querySelectorAll('#main-nav a').forEach(link => {
if (link.getAttribute('href') === window.location.pathname) {
link.classList.add('active');
}
});
const profileBtn = document.getElementById('profile-btn');
const dropdownMenu = document.getElementById('dropdown-menu');
profileBtn.addEventListener('click', (e) => {
e.stopPropagation();
dropdownMenu.classList.toggle('show');
});
document.addEventListener('click', () => {
if (dropdownMenu.classList.contains('show')) {
dropdownMenu.classList.remove('show');
}
});
</script>
</body>
</html>
</html>
{{ end }}