Update base template with user menu and auth support

This commit is contained in:
2025-12-10 10:42:15 +11:00
parent c4556adc37
commit b648eef93e

View File

@@ -20,6 +20,7 @@
<span class="tagline">{% block tagline %}Track your work hours{% endblock %}</span>
</div>
</div>
{% if current_user.is_authenticated %}
<nav class="nav-links">
<a href="{{ url_for('index') }}" class="nav-link {% if request.endpoint == 'index' %}active{% endif %}">
<span class="nav-icon">📝</span>
@@ -27,20 +28,53 @@
</a>
<a href="{{ url_for('settings') }}" class="nav-link {% if request.endpoint == 'settings' %}active{% endif %}">
<span class="nav-icon">⚙️</span>
Settings
Tasks
</a>
{% if current_user.is_admin %}
<a href="{{ url_for('admin_users') }}" class="nav-link {% if request.endpoint == 'admin_users' %}active{% endif %}">
<span class="nav-icon">👥</span>
Users
</a>
{% endif %}
<div class="user-menu">
<button class="user-menu-btn" onclick="toggleUserMenu()">
<span class="user-avatar">{{ current_user.display_name[0]|upper if current_user.display_name else current_user.username[0]|upper }}</span>
<span class="user-name">{{ current_user.display_name or current_user.username }}</span>
<span class="dropdown-arrow"></span>
</button>
<div class="user-dropdown" id="userDropdown">
<a href="{{ url_for('change_password') }}">🔑 Change Password</a>
<hr>
<a href="{{ url_for('logout') }}">🚪 Logout</a>
</div>
</div>
</nav>
{% endif %}
</div>
</header>
<!-- Flash Messages -->
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="flash-messages">
{% for category, message in messages %}
<div class="flash-message flash-{{ category }}">
{{ message }}
<button class="flash-close" onclick="this.parentElement.remove()">×</button>
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<!-- Main Content -->
<main class="main-content">
{% block content %}{% endblock %}
</main>
</div>
<!-- Toast Notifications -->
<div id="toast-container"></div>
<!-- Toast Container -->
<div id="toastContainer" class="toast-container"></div>
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
{% block extra_js %}{% endblock %}