Files
at-container-registry/pkg/hold/admin/templates/pages/admin.html
T

110 lines
3.5 KiB
HTML

{{define "page-header"}}{{end}}
{{define "page-content"}}
<!-- Dashboard (loads immediately) -->
<div id="tab-dashboard" class="admin-panel"
hx-get="/admin/api/tab/dashboard"
hx-trigger="load"
hx-swap="innerHTML">
<p class="text-base-content/50 italic">Loading...</p>
</div>
<!-- Crew (loads on first activation) -->
<div id="tab-crew" class="admin-panel hidden"
hx-get="/admin/api/tab/crew"
hx-trigger="tab:crew from:body once"
hx-swap="innerHTML">
</div>
<!-- Settings (loads on first activation) -->
<div id="tab-settings" class="admin-panel hidden"
hx-get="/admin/api/tab/settings"
hx-trigger="tab:settings from:body once"
hx-swap="innerHTML">
</div>
<!-- Relays (loads on first activation) -->
<div id="tab-relays" class="admin-panel hidden"
hx-get="/admin/api/tab/relays"
hx-trigger="tab:relays from:body once"
hx-swap="innerHTML">
</div>
<!-- Storage / GC (loads on first activation) -->
<div id="tab-storage" class="admin-panel hidden"
hx-get="/admin/api/tab/storage"
hx-trigger="tab:storage from:body once"
hx-swap="innerHTML">
</div>
<script>
(function() {
var validTabs = ['dashboard', 'crew', 'settings', 'relays', 'storage'];
function switchAdminTab(tabId) {
if (validTabs.indexOf(tabId) === -1) tabId = 'dashboard';
// Toggle panel visibility
document.querySelectorAll('.admin-panel').forEach(function(p) {
p.classList.add('hidden');
});
var panel = document.getElementById('tab-' + tabId);
if (panel) panel.classList.remove('hidden');
// Desktop sidebar: toggle menu-active
document.querySelectorAll('.menu li[data-tab]').forEach(function(li) {
if (li.dataset.tab === tabId) {
li.classList.add('menu-active');
} else {
li.classList.remove('menu-active');
}
});
// Mobile: toggle btn-secondary / btn-ghost
document.querySelectorAll('.admin-tab-mobile').forEach(function(a) {
if (a.dataset.tab === tabId) {
a.classList.remove('btn-ghost');
a.classList.add('btn-secondary');
} else {
a.classList.remove('btn-secondary');
a.classList.add('btn-ghost');
}
});
history.replaceState(null, '', '#' + tabId);
document.body.dispatchEvent(new CustomEvent('tab:' + tabId));
}
document.addEventListener('DOMContentLoaded', function() {
// Mobile tab click handlers
document.querySelectorAll('.admin-tab-mobile').forEach(function(a) {
a.addEventListener('click', function(e) {
e.preventDefault();
switchAdminTab(this.dataset.tab);
});
});
// Desktop sidebar click handlers
document.querySelectorAll('.menu li[data-tab] a').forEach(function(link) {
link.addEventListener('click', function(e) {
e.preventDefault();
switchAdminTab(this.parentElement.dataset.tab);
});
});
// Activate tab from hash (default: dashboard)
requestAnimationFrame(function() {
var hash = window.location.hash.replace('#', '') || 'dashboard';
switchAdminTab(hash);
});
});
// Handle browser back/forward
window.addEventListener('hashchange', function() {
var hash = window.location.hash.replace('#', '') || 'dashboard';
switchAdminTab(hash);
});
})();
</script>
{{end}}