feat: vertical/horizontal nav layout toggle with grouped dropdowns, mobile auto-sidebar

This commit is contained in:
Reditus committed 2026-06-14 22:54:55 +01:00
1 parent 3486f3b2cb
commit 306ebcc871
6 files changed
+263 -8

No files matched your search

+1
View File
@@ -30,6 +30,7 @@ chmod +x start.sh
- **Director Tools** (battlegroups, world state, transfers)
- **SSH File Browser** + **in-browser shell**
- **Pod Management** (list, logs, describe, delete with safe-mode for DB backup pods)
- **Nav Layout** — switch between horizontal and vertical sidebar; persists preference; auto-enables sidebar on mobile
- **Firewall Hardening** via iptables
- **Auto‑Update** with safe file replacement
- **HTTPS + Remote Access** (self‑signed or Let’s Encrypt)
+2 -1
View File
@@ -4,7 +4,7 @@ import json
import logging
from flask import Blueprint, render_template, request, jsonify
from flask_login import login_required, current_user
from app.utils.constants import NAV_PAGES, GUILD_ROLES
from app.utils.constants import NAV_PAGES, NAV_GROUPS, GUILD_ROLES
from app.utils.debug_logging import sanitize_for_log
from app.services.player import LIKE_PC
@@ -49,6 +49,7 @@ def register_routes(app, services, settings):
)
return dict(
nav_pages=NAV_PAGES,
nav_groups=NAV_GROUPS,
current_path=request.path if request else '/',
fmt_role=fmt_role,
conn_ok=conn_ok,
+25
View File
@@ -84,3 +84,28 @@ NAV_PAGES = [
('/admin-experimental', 'Experimental'),
('/backup', 'Backup'),
]
NAV_GROUPS = [
('/', 'Overview'),
('Server', [
('/server', 'Server'),
('/director', 'Director'),
('/shell', 'Shell'),
('/files', 'Files'),
]),
('Players', [
('/players', 'Players'),
('/vehicles', 'Vehicles'),
('/guilds', 'Guilds'),
('/buildings', 'Buildings'),
]),
('World', [
('/events', 'Events'),
('/chat', 'Chat'),
('/map', 'Map'),
]),
('System', [
('/admin-experimental', 'Experimental'),
('/backup', 'Backup'),
]),
]
+171
View File
@@ -71,6 +71,50 @@ nav a.active {
nav .spacer { flex: 1; }
/* Horizontal vs vertical nav link visibility */
.nav-links-h { display: flex; align-items: center; gap: 2px; }
.nav-links-v { display: none; }
body[data-nav-layout="vertical"] .nav-links-h { display: none; }
body[data-nav-layout="vertical"] .nav-links-v { display: flex; flex-direction: column; width: 100%; flex: 1; overflow-y: auto; }
/* Horizontal nav dropdowns */
.nav-dropdown {
position: relative;
display: inline-block;
}
.nav-dropdown-toggle {
cursor: default;
padding: 0 10px;
}
.nav-dropdown-content {
display: none;
position: absolute;
top: 100%;
left: 0;
background: var(--nav-bg);
min-width: 140px;
box-shadow: 0 4px 16px rgba(0,0,0,0.4);
border-radius: 6px;
z-index: 1000;
padding: 4px 0;
border: 1px solid rgba(255,255,255,0.1);
}
.nav-dropdown-content a {
color: var(--nav-text);
padding: 8px 16px;
height: auto;
border-bottom: none;
font-size: 12px;
display: block;
}
.nav-dropdown-content a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-dropdown-content a.active {
color: var(--nav-active);
border-left: 3px solid var(--nav-active);
}
.nav-dropdown:hover .nav-dropdown-content { display: block; }
.conn-dot {
width: 8px;
height: 8px;
@@ -1170,3 +1214,130 @@ td a:hover { text-decoration: underline; }
font-family: monospace;
white-space: nowrap;
}
/* Nav Layout Toggle */
.nav-toggle {
position: fixed;
top: 56px;
left: 6px;
z-index: 101;
background: var(--nav-bg);
color: var(--nav-text);
border: 1px solid rgba(255,255,255,0.15);
border-radius: 4px;
padding: 3px 7px;
font-size: 15px;
cursor: pointer;
line-height: 1;
opacity: 0.5;
transition: opacity 0.15s;
}
.nav-toggle:hover { opacity: 1; color: #fff; }
/* Vertical sidebar layout */
body[data-nav-layout="vertical"] {
padding-left: 216px;
}
body[data-nav-layout="vertical"] .nav-toggle {
left: 204px;
top: 6px;
}
body[data-nav-layout="vertical"] nav {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: 200px;
flex-direction: column;
height: 100vh;
padding: 0;
align-items: stretch;
box-shadow: 1px 0 4px rgba(0,0,0,0.2);
}
body[data-nav-layout="vertical"] nav .brand {
padding: 20px 16px 12px;
margin-right: 0;
font-size: 13px;
text-align: center;
border-bottom: 1px solid rgba(255,255,255,0.08);
}
body[data-nav-layout="vertical"] nav a {
padding: 10px 16px;
height: auto;
border-bottom: none;
border-left: 3px solid transparent;
font-size: 12px;
}
body[data-nav-layout="vertical"] nav a:hover {
background: rgba(255,255,255,0.05);
}
body[data-nav-layout="vertical"] nav a.active {
border-bottom-color: transparent;
border-left-color: var(--nav-active);
}
body[data-nav-layout="vertical"] nav .spacer {
display: none;
}
body[data-nav-layout="vertical"] nav .theme-dropdown {
padding: 8px 16px;
border-top: 1px solid rgba(255,255,255,0.08);
}
body[data-nav-layout="vertical"] nav .theme-dropdown .theme-dropdown-content {
bottom: 100%;
top: auto;
left: 0;
right: auto;
margin-bottom: 4px;
}
body[data-nav-layout="vertical"] nav .theme-dropdown .theme-btn {
width: 100%;
justify-content: center;
}
body[data-nav-layout="vertical"] nav .nav-conn,
body[data-nav-layout="vertical"] nav .nav-logout {
padding: 10px 16px;
justify-content: center;
border-top: 1px solid rgba(255,255,255,0.08);
}
body[data-nav-layout="vertical"] .container {
max-width: none;
padding: 24px;
}
body[data-nav-layout="vertical"] .site-footer {
margin-left: 216px;
}
@media (max-width: 768px) {
body[data-nav-layout="vertical"] {
padding-left: 0;
}
body[data-nav-layout="vertical"] .nav-toggle {
top: 8px;
left: 8px;
}
body[data-nav-layout="vertical"] nav {
display: none;
}
body[data-nav-layout="vertical"] nav.nav-open {
display: flex;
}
body[data-nav-layout="vertical"] .container {
padding: 24px;
}
body[data-nav-layout="vertical"] .site-footer {
margin-left: 0;
}
}
+2 -2
View File
@@ -367,7 +367,7 @@
display: none;
position: absolute;
right: 0;
background: #252530;
background: var(--nav-bg);
min-width: 290px;
max-height: 80vh;
overflow-y: auto;
@@ -375,7 +375,7 @@
border-radius: 8px;
z-index: 1000;
padding: 12px;
border: 1px solid #404050;
border: 1px solid rgba(255,255,255,0.1);
}
.theme-grid {
+62 -5
View File
@@ -18,11 +18,34 @@
{% block head_extra %}{% endblock %}
</head>
<body>
<button class="nav-toggle" id="navToggle" title="Toggle nav layout" onclick="toggleNavLayout()">☰</button>
<nav>
<div class="brand">DUNE DASHBOARD</div>
{% for href, label in nav_pages %}
<a href="{{ href }}" class="{% if current_path == href %}active{% endif %}">{{ label }}</a>
{% endfor %}
<!-- Horizontal: use grouped nav -->
<div class="nav-links-h">
{% for item in nav_groups %}
{% if item|length == 2 and item[1] is string %}
{# Simple link #}
<a href="{{ item[0] }}" class="{% if current_path == item[0] %}active{% endif %}">{{ item[1] }}</a>
{% else %}
{# Dropdown group: item[0] is label, item[1] is list of (href, label) #}
<div class="nav-dropdown">
<a class="nav-dropdown-toggle {% for ih, il in item[1] %}{% if current_path == ih %}active{% endif %}{% endfor %}">{{ item[0] }} ▾</a>
<div class="nav-dropdown-content">
{% for ih, il in item[1] %}
<a href="{{ ih }}" class="{% if current_path == ih %}active{% endif %}">{{ il }}</a>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
<!-- Vertical nav links (flat list) -->
<div class="nav-links-v">
{% for href, label in nav_pages %}
<a href="{{ href }}" class="{% if current_path == href %}active{% endif %}">{{ label }}</a>
{% endfor %}
</div>
<div class="spacer"></div>
<div class="theme-dropdown">
<button class="theme-btn" title="Theme">🎨</button>
@@ -101,12 +124,12 @@
</div>
</div>
</div>
<span style="font-size:12px;color:var(--nav-text);display:flex;align-items:center;">
<span class="nav-conn">
<span class="conn-dot {% if conn_ok %}online{% else %}offline{% endif %}"></span>
{{ 'Connected' if conn_ok else 'Disconnected' }}
</span>
{% if current_user and current_user.is_authenticated %}
<a href="/logout" style="font-size:12px;color:var(--nav-text);">Logout</a>
<a href="/logout" class="nav-logout">Logout</a>
{% endif %}
</nav>
<main class="container">
@@ -135,7 +158,41 @@
updateThemeUI(savedTheme);
}
// Nav Layout System (experimental vertical toggle)
function toggleNavLayout() {
const body = document.body;
const isMobile = window.innerWidth <= 768;
if (isMobile) {
document.querySelector('nav').classList.toggle('nav-open');
return;
}
const current = body.getAttribute('data-nav-layout') || 'horizontal';
const next = current === 'horizontal' ? 'vertical' : 'horizontal';
body.setAttribute('data-nav-layout', next);
localStorage.setItem('dune-nav-layout', next);
}
function initNavLayout() {
const isMobile = window.innerWidth <= 768;
if (isMobile) {
document.body.setAttribute('data-nav-layout', 'vertical');
localStorage.removeItem('dune-nav-layout');
} else {
const saved = localStorage.getItem('dune-nav-layout') || 'horizontal';
document.body.setAttribute('data-nav-layout', saved);
}
}
window.addEventListener('resize', function() {
const isMobile = window.innerWidth <= 768;
const current = document.body.getAttribute('data-nav-layout');
if (isMobile && current !== 'vertical') {
document.body.setAttribute('data-nav-layout', 'vertical');
}
});
initTheme();
initNavLayout();
</script>
{% block scripts %}{% endblock %}
<style>