82 lines
2.7 KiB
HTML
82 lines
2.7 KiB
HTML
{{ define "base.html" }}
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<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>
|
|
|
|
<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>
|
|
{{ end }} |