Unify System Admin navigation and full-width header

This commit is contained in:
A R R R Associates
2026-07-11 07:15:16 +05:30
parent 4e158f9e96
commit 69dcd42d7b
3 changed files with 57 additions and 65 deletions
@@ -16,50 +16,7 @@
</div>
</div>
{% set tabs = [
('overview', 'Overview'),
('firms', 'Firms'),
('firm-setup-health', 'Setup Health'),
('catalogue', 'Service Catalogue'),
('smtp', 'Platform SMTP'),
('storage', 'Storage'),
('billing', 'Billing Readiness'),
('reports', 'Reports'),
('wizards', 'Wizards'),
('audit-logs', 'Audit Logs')
] %}
<div class="hidden rounded-3xl border border-slate-200 bg-white p-2 shadow-soft sm:block">
<div class="flex gap-2 overflow-x-auto" id="system-admin-dashboard-tabs">
{% for tab_key, tab_label in tabs %}
<button type="button"
data-dashboard-tab="{{ tab_key }}"
class="system-admin-tab whitespace-nowrap rounded-2xl px-4 py-2 text-sm font-semibold transition {% if active_tab == tab_key %}bg-brand-600 text-white{% else %}text-slate-600 hover:bg-slate-100{% endif %}">
{{ tab_label }}
</button>
{% endfor %}
</div>
</div>
<details id="system-admin-mobile-menu" class="group overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-soft sm:hidden">
<summary class="flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-slate-800">
<span class="inline-flex items-center gap-2">
<svg class="h-5 w-5 group-open:hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" d="M4 6h16M4 12h16M4 18h16" /></svg>
<svg class="hidden h-5 w-5 group-open:block" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" d="M6 6l12 12M18 6 6 18" /></svg>
<span>Dashboard Menu</span>
</span>
<span class="text-xs font-medium text-slate-500">Platform dashboard sections</span>
</summary>
<div class="space-y-1 border-t border-slate-100 bg-slate-50/80 p-3">
{% for tab_key, tab_label in tabs %}
<button type="button"
data-dashboard-tab="{{ tab_key }}"
class="system-admin-tab block w-full rounded-xl px-3 py-2.5 text-left text-sm font-semibold transition {% if active_tab == tab_key %}bg-brand-600 text-white{% else %}bg-white text-slate-700 hover:bg-slate-100{% endif %}">
{{ tab_label }}
</button>
{% endfor %}
</div>
</details>
{# Dashboard sections are now part of the unified System Admin Dashboard submenu. #}
<div id="system-admin-dashboard-panel"
data-initial-tab="{{ active_tab }}"
@@ -70,45 +27,68 @@
<script>
(function () {
"use strict";
const panel = document.getElementById('system-admin-dashboard-panel');
const tabs = Array.from(document.querySelectorAll('[data-dashboard-tab]'));
if (!panel || !tabs.length) return;
if (!panel) return;
const dashboardLinks = Array.from(document.querySelectorAll(
'[data-uiux-v2-pilot="system-admin"] a[href^="/system-admin/dashboard?tab="]'
));
function tabFromLink(link) {
try {
return new URL(link.href, window.location.origin).searchParams.get('tab') || 'overview';
} catch (error) {
return 'overview';
}
}
function setActive(tabName) {
tabs.forEach((tab) => {
const active = tab.dataset.dashboardTab === tabName;
tab.classList.toggle('bg-brand-600', active);
tab.classList.toggle('text-white', active);
tab.classList.toggle('text-slate-600', !active);
tab.classList.toggle('bg-white', !active && tab.closest('#system-admin-mobile-menu'));
tab.classList.toggle('hover:bg-slate-100', !active);
dashboardLinks.forEach((link) => {
const active = tabFromLink(link) === tabName;
link.classList.toggle('bg-brand-50', active);
link.classList.toggle('text-brand-700', active);
link.classList.toggle('text-slate-700', !active);
if (active) {
link.setAttribute('aria-current', 'page');
} else {
link.removeAttribute('aria-current');
}
});
}
async function loadTab(tabName, pushState) {
setActive(tabName);
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
try {
const response = await fetch('/system-admin/dashboard/tab/' + encodeURIComponent(tabName), {
headers: { 'X-Requested-With': 'fetch' }
});
if (!response.ok) throw new Error('Tab load failed');
panel.innerHTML = await response.text();
if (pushState) {
const url = new URL(window.location.href);
url.searchParams.set('tab', tabName);
history.pushState({ tab: tabName }, '', url.toString());
}
const mobileMenu = document.getElementById('system-admin-mobile-menu');
if (mobileMenu) mobileMenu.open = false;
} catch (err) {
panel.innerHTML = '<div class="rounded-3xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 shadow-soft">Unable to load this tab. Please refresh the page.</div>';
document.querySelectorAll('[data-uiux-v2-pilot="system-admin"] details[open]').forEach((details) => {
details.open = false;
});
} catch (error) {
panel.innerHTML = '<div class="rounded-3xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 shadow-soft">Unable to load this dashboard section. Please refresh the page.</div>';
}
}
tabs.forEach((tab) => {
tab.addEventListener('click', function () {
loadTab(tab.dataset.dashboardTab, true);
dashboardLinks.forEach((link) => {
link.addEventListener('click', function (event) {
if (window.location.pathname !== '/system-admin/dashboard') return;
event.preventDefault();
loadTab(tabFromLink(link), true);
});
});