From eb12419c84fd51180f269720d5b5c3a8add59249 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Sun, 22 Nov 2026 01:01:09 +0100 Subject: [PATCH] Improve hosting account navigation and mobile panel layout --- src/coulobre/hosting/access.py | 22 ++ .../static/hosting/panel-navigation.js | 32 +++ src/coulobre/hosting/static/hosting/panel.css | 201 +++++++++++++++--- .../templates/hosting/account_backups.html | 2 +- .../templates/hosting/account_detail.html | 36 +++- .../templates/hosting/account_list.html | 29 +-- .../hosting/account_service_access.html | 14 +- .../templates/hosting/account_status.html | 1 + .../hosting/templates/hosting/base.html | 19 +- .../hosting/resource_provisioning.html | 2 +- src/coulobre/hosting/views.py | 17 ++ 11 files changed, 309 insertions(+), 66 deletions(-) create mode 100644 src/coulobre/hosting/static/hosting/panel-navigation.js create mode 100644 src/coulobre/hosting/templates/hosting/account_status.html diff --git a/src/coulobre/hosting/access.py b/src/coulobre/hosting/access.py index f07e5e0..453bc22 100644 --- a/src/coulobre/hosting/access.py +++ b/src/coulobre/hosting/access.py @@ -1,3 +1,18 @@ +NAVIGATION_SECTIONS = { + "accounts": "accounts", + "retired-accounts": "accounts", + "databases": "accounts", + "dns-zones": "accounts", + "mailboxes": "accounts", + "mail-domains": "accounts", + "customers": "customers", + "resellers": "resellers", + "hosting-plans": "hosting_plans", + "plans": "plans", + "service-health": "service_health", +} + + def customer_for_user(user): if not user.is_authenticated or user.is_superuser: return None @@ -24,12 +39,19 @@ def is_tenant(user): def panel_access(request): customer = customer_for_user(request.user) is not None reseller = not customer and reseller_for_user(request.user) is not None + match = request.resolver_match + section = None + if match is not None and match.namespace == "panel": + section = NAVIGATION_SECTIONS.get( + match.route.split("/", 1)[0], match.url_name + ) return { "is_customer": customer, "is_reseller": reseller, "is_tenant": customer or reseller, "is_operator": request.user.is_authenticated and not (customer or reseller), + "panel_section": section, } diff --git a/src/coulobre/hosting/static/hosting/panel-navigation.js b/src/coulobre/hosting/static/hosting/panel-navigation.js new file mode 100644 index 0000000..806259a --- /dev/null +++ b/src/coulobre/hosting/static/hosting/panel-navigation.js @@ -0,0 +1,32 @@ +const menuToggle = document.querySelector(".menu-toggle"); +const navigation = document.getElementById("panel-navigation"); +const compactLayout = window.matchMedia("(max-width: 780px)"); + +function setMenuExpanded(expanded) { + menuToggle.setAttribute("aria-expanded", String(expanded)); + navigation.hidden = !expanded; +} + +function updateMenuLayout() { + const focusInNavigation = navigation.contains(document.activeElement); + if (!compactLayout.matches && document.activeElement === menuToggle) { + setMenuExpanded(true); + navigation.querySelector("a")?.focus(); + } + setMenuExpanded(!compactLayout.matches || focusInNavigation); + menuToggle.hidden = !compactLayout.matches; +} + +menuToggle.addEventListener("click", () => { + setMenuExpanded(menuToggle.getAttribute("aria-expanded") !== "true"); +}); + +navigation.addEventListener("keydown", (event) => { + if (event.key === "Escape" && compactLayout.matches) { + setMenuExpanded(false); + menuToggle.focus(); + } +}); + +compactLayout.addEventListener("change", updateMenuLayout); +updateMenuLayout(); diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css index 1ad058a..b48489a 100644 --- a/src/coulobre/hosting/static/hosting/panel.css +++ b/src/coulobre/hosting/static/hosting/panel.css @@ -1,16 +1,16 @@ :root { color-scheme: light; - --page: #f4f5ef; - --surface: #fffefa; - --ink: #182923; - --muted: #516258; - --line: #dce3d9; - --sidebar: #142b26; - --sidebar-text: #e7f0e9; - --accent: #235440; - --accent-hover: #174332; - --focus: #8c4d2b; - --radius: 12px; + --page: #f3f6f3; + --surface: #fff; + --ink: #162b25; + --muted: #4c635a; + --line: #d8e4dd; + --sidebar: #112c25; + --sidebar-text: #eef6ef; + --accent: #1b6049; + --accent-hover: #104834; + --focus: #93440f; + --radius: 14px; font: 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; } @@ -54,7 +54,7 @@ button, input, select, textarea { .skip-link:focus { position: fixed; - z-index: 1; + z-index: 2; top: 1rem; left: 1rem; padding: 0.6rem 1rem; @@ -64,7 +64,7 @@ button, input, select, textarea { .panel { display: grid; min-height: 100vh; - grid-template-columns: 242px minmax(0, 1fr); + grid-template-columns: 235px minmax(0, 1fr); } .sidebar { @@ -75,7 +75,7 @@ button, input, select, textarea { flex-direction: column; overflow-y: auto; padding: 1.65rem 1.1rem 1.1rem; - background: var(--sidebar); + background: linear-gradient(160deg, #163a30, var(--sidebar) 55%); color: var(--sidebar-text); } @@ -95,10 +95,11 @@ button, input, select, textarea { display: grid; width: 2.15rem; height: 2.15rem; + flex: 0 0 2.15rem; place-items: center; border-radius: 0.55rem; - background: #d8e7bb; - color: #18372c; + background: #c7e8ca; + color: #15392f; font-size: 1.12rem; font-weight: 800; } @@ -126,12 +127,43 @@ button, input, select, textarea { text-decoration: none; } -.navigation a:hover, .navigation a[aria-current="page"] { +.navigation a:hover, .navigation a[aria-current] { border-color: #527369; background: #28473e; color: #fff; } +.navigation a[aria-current] { + box-shadow: inset 3px 0 #9dd3a8; + font-weight: 650; +} + +.menu-toggle { + display: inline-flex; + align-items: center; + gap: 0.5rem; + min-height: 2.6rem; + padding: 0.35rem 0.7rem; + border: 1px solid #668e7f; + border-radius: 8px; + background: #28473e; + color: var(--sidebar-text); + cursor: pointer; + font-size: 0.85rem; + font-weight: 650; +} + +.menu-icon { + width: 0.85rem; + height: 0.65rem; + border-block: 1px solid currentColor; + background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat; +} + +.menu-toggle[hidden], .navigation[hidden] { + display: none; +} + .nav-icon { display: inline-block; width: 1rem; @@ -217,8 +249,8 @@ button, input, select, textarea { .main { width: 100%; - max-width: 1230px; - padding: clamp(1.25rem, 4.6vw, 4.5rem); + max-width: 1320px; + padding: clamp(1.25rem, 4vw, 4rem); } .page-heading { @@ -226,7 +258,7 @@ button, input, select, textarea { align-items: flex-start; justify-content: space-between; gap: 1rem; - margin-bottom: 1.45rem; + margin-bottom: 1.65rem; } .page-heading > div { @@ -244,14 +276,14 @@ h1, h2, p, dl { h1 { overflow-wrap: anywhere; - font-size: clamp(1.75rem, 4vw, 2.65rem); - font-weight: 750; + font-size: clamp(1.85rem, 4vw, 2.85rem); + font-weight: 760; letter-spacing: -0.045em; line-height: 1.12; } h2 { - font-size: 1.06rem; + font-size: 1.12rem; font-weight: 700; } @@ -266,7 +298,7 @@ h2 { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); - box-shadow: 0 2px 5px #1a2e2010; + box-shadow: 0 3px 9px #10291c0d; } .main > section.surface + section.surface { @@ -321,6 +353,70 @@ h2 { justify-content: space-between; } +.section-text { + margin: 0.85rem 1.2rem; + overflow-wrap: anywhere; +} + +.account-toolbar { + justify-content: space-between; +} + +.account-toolbar form { + min-width: 0; + flex: 1 1 25rem; +} + +.account-domain { + margin-top: 0.22rem; +} + +.account-heading-meta { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.5rem 0.8rem; + margin-top: 0.6rem; + color: var(--muted); +} + +.account-content { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 1.25rem; +} + +.account-content :target { + scroll-margin-top: 1rem; +} + +.account-navigation { + display: flex; + flex-wrap: wrap; + gap: 0.35rem 0.6rem; + border-bottom: 1px solid var(--line); + margin-bottom: 1.25rem; + padding-bottom: 0.6rem; +} + +.account-navigation:empty { + display: none; +} + +.account-navigation a { + min-height: 2.5rem; + padding: 0.5rem 0.75rem; + border-radius: 7px; + font-size: 0.9rem; + font-weight: 680; + text-decoration: none; +} + +.account-navigation a:hover { + background: #e2eee6; + text-decoration: underline; +} + .pagination { justify-content: flex-end; border-top: 1px solid var(--line); @@ -381,7 +477,7 @@ th, td { } th { - background: #edf1e9; + background: #edf4ef; color: #40594b; font-size: 0.78rem; font-weight: 700; @@ -484,12 +580,23 @@ dd { .status { display: inline-block; - padding: 0.18rem 0.55rem; + padding: 0.18rem 0.62rem; border-radius: 0.75rem; font-size: 0.78rem; font-weight: 680; } +.status::before { + display: inline-block; + width: 0.4rem; + height: 0.4rem; + border-radius: 50%; + margin-inline-end: 0.35rem; + vertical-align: 0.08em; + background: currentColor; + content: ""; +} + .status.ready, .status.active { background: #dcebdc; color: #205038; @@ -500,6 +607,11 @@ dd { color: #6b431b; } +.status.failed { + background: #f9e5e1; + color: #862f25; +} + .configuration { margin: 0; overflow-x: auto; @@ -598,7 +710,7 @@ dd { position: static; display: grid; height: auto; - grid-template-columns: minmax(0, 1fr) auto; + grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.65rem 0.3rem; padding: 0.65rem 0.75rem; } @@ -607,6 +719,12 @@ dd { font-size: 1rem; } + .brand-mark { + width: 1.95rem; + height: 1.95rem; + flex-basis: 1.95rem; + } + .navigation { display: flex; flex-wrap: wrap; @@ -616,10 +734,19 @@ dd { } .navigation a { - padding: 0.38rem 0.55rem; + min-height: 2.6rem; + padding: 0.38rem 0.65rem; + } + + .menu-toggle { + grid-column: 3; + grid-row: 1; + align-self: center; } .sidebar-account { + grid-column: 2; + grid-row: 1; max-width: 8.5rem; justify-items: end; margin: 0; @@ -629,6 +756,24 @@ dd { } } +@media (max-width: 375px) { + .sidebar { + grid-template-columns: minmax(0, 1fr) auto; + } + + .menu-toggle { + grid-column: 2; + } + + .sidebar-account { + grid-column: 1 / -1; + grid-row: 3; + display: flex; + max-width: none; + justify-content: space-between; + } +} + @media (max-width: 520px) { .page-heading { flex-direction: column; diff --git a/src/coulobre/hosting/templates/hosting/account_backups.html b/src/coulobre/hosting/templates/hosting/account_backups.html index 02e5f80..1ac1d91 100644 --- a/src/coulobre/hosting/templates/hosting/account_backups.html +++ b/src/coulobre/hosting/templates/hosting/account_backups.html @@ -1,7 +1,7 @@
-

Backups

+

Backups

Includes the website and its MariaDB databases.

{% if account_backup_schedule %}

diff --git a/src/coulobre/hosting/templates/hosting/account_detail.html b/src/coulobre/hosting/templates/hosting/account_detail.html index f1b1793..2ea8cf7 100644 --- a/src/coulobre/hosting/templates/hosting/account_detail.html +++ b/src/coulobre/hosting/templates/hosting/account_detail.html @@ -5,7 +5,10 @@

{{ account.name }}

-

{{ account.primary_domain }}

+
{% if manage_sftp or export_backup_manifest or is_operator and perms.hosting.change_hostingaccount or can_retire_account %}
@@ -28,7 +31,6 @@ {% endif %}
-
Primary domain
{{ account.primary_domain }}
{% if is_tenant or perms.hosting.view_hostingplan %}
Hosting plan
{% if account.hosting_plan %}{{ account.hosting_plan.name }}{% else %}Unassigned{% endif %}
{% endif %} @@ -40,10 +42,21 @@ {% endif %}
Added
{{ account.created_at|date:"j M Y, H:i" }} UTC
+ + -
+
{% if request.impersonation %}
@@ -83,6 +87,7 @@ {% block content %}{% endblock %}
+ {% else %} {% block public_content %}{% endblock %} {% endif %} diff --git a/src/coulobre/hosting/templates/hosting/resource_provisioning.html b/src/coulobre/hosting/templates/hosting/resource_provisioning.html index 0f286e5..a164f6f 100644 --- a/src/coulobre/hosting/templates/hosting/resource_provisioning.html +++ b/src/coulobre/hosting/templates/hosting/resource_provisioning.html @@ -1,7 +1,7 @@ {% if provisioning.state == "configured" %} Configured {% elif provisioning.state == "failed" %} - Provisioning failed + Provisioning failed {% elif provisioning.state == "running" %} Provisioning {% elif provisioning %} diff --git a/src/coulobre/hosting/views.py b/src/coulobre/hosting/views.py index c4ec823..99d6a84 100644 --- a/src/coulobre/hosting/views.py +++ b/src/coulobre/hosting/views.py @@ -511,6 +511,7 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView): if reseller is not None or ( customer is None and user.has_perm(VIEW_PLANS) ): + context["show_web_previews"] = True context["plans"] = self.object.webprovisioningplan_set.order_by( "-requested_at", "-pk" )[:10] @@ -577,6 +578,22 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView): if mailbox_can_open_webmail(mailbox) } context["mailboxes"] = mailboxes + context["show_website_storage"] = bool( + context["can_measure_site_storage"] + or context["can_change_site_storage_limit"] + or getattr(context.get("website_storage"), "measured_at", None) + or getattr(context.get("website_limit"), "applied_at", None) + ) + context["show_website"] = any( + context.get(name) + for name in ( + "show_website_storage", + "website_php_settings", + "website_aliases", + "can_add_website_alias", + "show_web_previews", + ) + ) return context