From 306ebcc87106a2cc3a312211da9134b93b3ac9e9 Mon Sep 17 00:00:00 2001 From: Reditus <33814724+ReditusDraco@users.noreply.github.com> Date: Sun, 14 Jun 2026 22:54:55 +0100 Subject: [PATCH] feat: vertical/horizontal nav layout toggle with grouped dropdowns, mobile auto-sidebar --- README.md | 1 + app/routes/main.py | 3 +- app/utils/constants.py | 25 ++++++ static/style.css | 171 +++++++++++++++++++++++++++++++++++++++++ static/themes.css | 4 +- templates/base.html | 67 ++++++++++++++-- 6 files changed, 263 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 71fe8ab..925d5c3 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/app/routes/main.py b/app/routes/main.py index 8e238cb..f0b220f 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -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, diff --git a/app/utils/constants.py b/app/utils/constants.py index 7f53a4a..2f0cbf2 100644 --- a/app/utils/constants.py +++ b/app/utils/constants.py @@ -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'), + ]), +] diff --git a/static/style.css b/static/style.css index e80bb96..2f672de 100644 --- a/static/style.css +++ b/static/style.css @@ -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; + } +} diff --git a/static/themes.css b/static/themes.css index 7f87167..1f76a13 100644 --- a/static/themes.css +++ b/static/themes.css @@ -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 { diff --git a/templates/base.html b/templates/base.html index 47c1ce1..87d48fe 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,11 +18,34 @@ {% block head_extra %}{% endblock %}
+