Files
jormun-admin/templates/base.html.twig
2026-03-08 04:16:14 -04:00

629 lines
21 KiB
Twig

<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Jormun Admin{% endblock %}</title>
{# Bootstrap 5 - modern, light/dark built-in #}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
{# Bootstrap Icons #}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
{# Google Fonts: Syne (display) + DM Mono (data) #}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:wght@300;400;500&display=swap" rel="stylesheet">
<style>
:root {
--jormun-teal: #0d9488;
--jormun-teal-mid: #14b8a6;
--jormun-teal-light: #ccfbf1;
--jormun-teal-xlight: #f0fdfa;
--jormun-dark: #0f2027;
--jormun-accent: #059669;
--sidebar-width: 230px;
--topbar-height: 52px;
}
/* ── Typography ── */
body {
font-family: 'DM Mono', monospace;
font-size: 0.82rem;
background: #f8fafb;
}
.font-display { font-family: 'Syne', sans-serif; }
/* ── Topbar ── */
.jormun-topbar {
height: var(--topbar-height);
background: #fff;
border-bottom: 1px solid #e2e8f0;
position: fixed;
top: 0; left: 0; right: 0;
z-index: 1030;
display: flex;
align-items: center;
padding: 0 1rem;
gap: 1rem;
}
.jormun-logo {
font-family: 'Syne', sans-serif;
font-weight: 800;
font-size: 1.1rem;
color: var(--jormun-teal);
letter-spacing: -0.02em;
text-decoration: none;
display: flex;
align-items: center;
gap: 0.4rem;
white-space: nowrap;
}
.jormun-logo .logo-serpent {
width: 26px;
height: 26px;
flex-shrink: 0;
}
.jormun-logo span.sub {
font-weight: 400;
font-size: 0.7rem;
color: #94a3b8;
font-family: 'DM Mono', monospace;
}
/* ── Breadcrumbs ── */
.jormun-breadcrumb {
display: flex;
align-items: center;
gap: 0.3rem;
font-size: 0.75rem;
color: #64748b;
flex: 1;
}
.jormun-breadcrumb a {
color: var(--jormun-teal);
text-decoration: none;
}
.jormun-breadcrumb a:hover { text-decoration: underline; }
.jormun-breadcrumb .sep { color: #cbd5e1; }
.jormun-breadcrumb .current {
color: #1e293b;
font-weight: 500;
}
/* ── Sidebar ── */
.jormun-sidebar {
width: var(--sidebar-width);
background: #fff;
border-right: 1px solid #e2e8f0;
position: fixed;
top: var(--topbar-height);
left: 0;
bottom: 0;
overflow-y: auto;
z-index: 900;
transition: transform 0.2s ease;
display: flex;
flex-direction: column;
}
.jormun-sidebar.collapsed {
transform: translateX(calc(-1 * var(--sidebar-width)));
}
.sidebar-section-label {
font-family: 'Syne', sans-serif;
font-size: 0.65rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #94a3b8;
padding: 0.75rem 1rem 0.3rem;
}
.sidebar-table-link {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.38rem 1rem;
color: #374151;
text-decoration: none;
font-size: 0.78rem;
border-left: 3px solid transparent;
transition: all 0.12s;
}
.sidebar-table-link:hover {
background: var(--jormun-teal-xlight);
color: var(--jormun-teal);
border-left-color: var(--jormun-teal-mid);
}
.sidebar-table-link.active {
background: var(--jormun-teal-light);
color: var(--jormun-teal);
border-left-color: var(--jormun-teal);
font-weight: 500;
}
.sidebar-table-link i { font-size: 0.75rem; opacity: 0.6; }
.sidebar-new-table {
margin: 0.5rem 0.75rem;
}
.sidebar-search {
padding: 0.5rem 0.75rem 0.3rem;
}
/* ── Main content ── */
.jormun-main {
margin-left: var(--sidebar-width);
margin-top: var(--topbar-height);
padding: 1.25rem 1.5rem;
min-height: calc(100vh - var(--topbar-height));
transition: margin-left 0.2s ease;
}
.jormun-main.sidebar-collapsed {
margin-left: 0;
}
/* ── Operation Tabs ── */
.op-tabs {
display: flex;
gap: 0.15rem;
margin-bottom: 1rem;
border-bottom: 2px solid #e2e8f0;
padding-bottom: 0;
}
.op-tab {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.45rem 0.85rem;
font-size: 0.78rem;
font-family: 'DM Mono', monospace;
color: #64748b;
text-decoration: none;
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: all 0.12s;
}
.op-tab:hover {
color: var(--jormun-teal);
background: var(--jormun-teal-xlight);
}
.op-tab.active {
color: var(--jormun-teal);
border-bottom-color: var(--jormun-teal);
font-weight: 500;
}
.op-tab i { font-size: 0.8rem; }
/* ── Toasts ── */
.toast-zone {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 0.5rem;
pointer-events: none;
}
.jormun-toast {
pointer-events: all;
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.6rem 1rem;
border-radius: 6px;
font-size: 0.78rem;
box-shadow: 0 4px 16px rgba(0,0,0,0.10);
border-left: 4px solid;
background: #fff;
min-width: 260px;
max-width: 400px;
animation: toast-in 0.22s ease;
}
@keyframes toast-in {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.jormun-toast.success { border-color: var(--jormun-teal); }
.jormun-toast.success i { color: var(--jormun-teal); }
.jormun-toast.error { border-color: #ef4444; }
.jormun-toast.error i { color: #ef4444; }
.jormun-toast.info { border-color: #3b82f6; }
.jormun-toast.info i { color: #3b82f6; }
/* ── Content card ── */
.content-card {
background: #fff;
border: 1px solid #e2e8f0;
border-radius: 8px;
overflow: hidden;
}
.content-card-header {
padding: 0.75rem 1rem;
border-bottom: 1px solid #f1f5f9;
background: #f8fafc;
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
}
.content-card-header h6 {
font-family: 'Syne', sans-serif;
font-size: 0.78rem;
font-weight: 700;
color: #374151;
margin: 0;
}
/* ── Data table ── */
.data-table {
width: 100%;
border-collapse: collapse;
font-size: 0.78rem;
}
.data-table th {
background: #f8fafc;
padding: 0.5rem 0.75rem;
text-align: left;
font-family: 'Syne', sans-serif;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
color: #64748b;
border-bottom: 1px solid #e2e8f0;
white-space: nowrap;
}
.data-table td {
padding: 0.45rem 0.75rem;
border-bottom: 1px solid #f1f5f9;
vertical-align: top;
max-width: 240px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.data-table tr:hover td { background: var(--jormun-teal-xlight); }
.data-table .pk-cell {
color: var(--jormun-teal);
font-weight: 500;
}
.data-table .null-val { color: #cbd5e1; font-style: italic; }
.data-table .action-cell { white-space: nowrap; }
/* ── Badges / pills ── */
.status-badge {
display: inline-block;
padding: 0.15rem 0.5rem;
border-radius: 999px;
font-size: 0.65rem;
font-weight: 600;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.creating { background: #fef9c3; color: #854d0e; }
.status-badge.deleting { background: #fee2e2; color: #991b1b; }
.status-badge.error { background: #fee2e2; color: #991b1b; }
.status-badge.unknown { background: #f1f5f9; color: #64748b; }
.type-badge {
display: inline-block;
padding: 0.1rem 0.35rem;
border-radius: 3px;
font-size: 0.65rem;
font-weight: 600;
background: var(--jormun-teal-light);
color: var(--jormun-teal);
}
/* ── Buttons ── */
.btn-jormun {
background: var(--jormun-teal);
color: #fff;
border: none;
padding: 0.38rem 0.9rem;
border-radius: 5px;
font-size: 0.78rem;
font-family: 'DM Mono', monospace;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.4rem;
transition: background 0.12s;
}
.btn-jormun:hover { background: var(--jormun-accent); color: #fff; }
.btn-jormun-outline {
background: transparent;
color: var(--jormun-teal);
border: 1px solid var(--jormun-teal);
padding: 0.35rem 0.85rem;
border-radius: 5px;
font-size: 0.78rem;
font-family: 'DM Mono', monospace;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.4rem;
text-decoration: none;
transition: all 0.12s;
}
.btn-jormun-outline:hover {
background: var(--jormun-teal);
color: #fff;
}
.btn-danger-sm {
background: transparent;
color: #ef4444;
border: 1px solid #fca5a5;
padding: 0.2rem 0.55rem;
border-radius: 4px;
font-size: 0.72rem;
cursor: pointer;
font-family: 'DM Mono', monospace;
transition: all 0.12s;
}
.btn-danger-sm:hover { background: #ef4444; color: #fff; }
.btn-sm-edit {
background: transparent;
color: #3b82f6;
border: 1px solid #bfdbfe;
padding: 0.2rem 0.55rem;
border-radius: 4px;
font-size: 0.72rem;
cursor: pointer;
font-family: 'DM Mono', monospace;
text-decoration: none;
transition: all 0.12s;
}
.btn-sm-edit:hover { background: #3b82f6; color: #fff; }
/* ── Form elements ── */
.jormun-input {
width: 100%;
padding: 0.4rem 0.65rem;
border: 1px solid #e2e8f0;
border-radius: 5px;
font-family: 'DM Mono', monospace;
font-size: 0.78rem;
color: #1e293b;
background: #fff;
transition: border-color 0.12s;
}
.jormun-input:focus {
outline: none;
border-color: var(--jormun-teal);
box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.jormun-select {
padding: 0.4rem 0.65rem;
border: 1px solid #e2e8f0;
border-radius: 5px;
font-family: 'DM Mono', monospace;
font-size: 0.78rem;
color: #1e293b;
background: #fff;
}
/* ── JSON editor ── */
.json-editor {
width: 100%;
min-height: 280px;
padding: 0.65rem;
border: 1px solid #e2e8f0;
border-radius: 5px;
font-family: 'DM Mono', monospace;
font-size: 0.78rem;
color: #1e293b;
resize: vertical;
line-height: 1.6;
}
.json-editor:focus {
outline: none;
border-color: var(--jormun-teal);
box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
/* ── Dark mode overrides ── */
[data-bs-theme="dark"] body { background: #0f172a; }
[data-bs-theme="dark"] .jormun-topbar,
[data-bs-theme="dark"] .jormun-sidebar {
background: #1e293b;
border-color: #334155;
}
[data-bs-theme="dark"] .content-card {
background: #1e293b;
border-color: #334155;
}
[data-bs-theme="dark"] .content-card-header {
background: #0f172a;
border-color: #334155;
}
[data-bs-theme="dark"] .data-table th {
background: #0f172a;
color: #94a3b8;
}
[data-bs-theme="dark"] .data-table td { border-color: #1e293b; }
[data-bs-theme="dark"] .sidebar-table-link { color: #94a3b8; }
[data-bs-theme="dark"] .jormun-input,
[data-bs-theme="dark"] .jormun-select,
[data-bs-theme="dark"] .json-editor {
background: #0f172a;
border-color: #334155;
color: #e2e8f0;
}
[data-bs-theme="dark"] .jormun-toast { background: #1e293b; }
/* ── Misc ── */
.cell-value { font-family: 'DM Mono', monospace; }
.empty-state {
text-align: center;
padding: 3rem 1rem;
color: #94a3b8;
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; color: #cbd5e1; }
.stat-pill {
display: inline-flex;
align-items: center;
gap: 0.3rem;
padding: 0.2rem 0.6rem;
background: #f1f5f9;
border-radius: 999px;
font-size: 0.7rem;
color: #64748b;
}
/* Sidebar toggle btn */
.sidebar-toggle {
background: none;
border: none;
color: #64748b;
cursor: pointer;
padding: 0.2rem 0.4rem;
border-radius: 4px;
}
.sidebar-toggle:hover { background: #f1f5f9; color: var(--jormun-teal); }
</style>
{% block head %}{% endblock %}
</head>
<body x-data="jormunApp()" :data-bs-theme="darkMode ? 'dark' : 'light'">
{# ── Topbar ── #}
<header class="jormun-topbar">
<button class="sidebar-toggle" @click="sidebarOpen = !sidebarOpen" title="Toggle sidebar">
<i class="bi bi-layout-sidebar"></i>
</button>
<a href="{{ path('dashboard') }}" class="jormun-logo">
{# Serpent SVG icon — stylized ouroboros/coil #}
<svg class="logo-serpent" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 3C9.373 3 4 8.373 4 15c0 4.5 2.3 8.46 5.78 10.8" stroke="#0d9488" stroke-width="2.5" stroke-linecap="round"/>
<path d="M16 29c6.627 0 12-5.373 12-12 0-4.5-2.3-8.46-5.78-10.8" stroke="#14b8a6" stroke-width="2.5" stroke-linecap="round"/>
<path d="M9.78 25.8C11.5 27.2 13.65 28 16 28" stroke="#0d9488" stroke-width="2" stroke-linecap="round"/>
<path d="M22.22 6.2C20.5 4.8 18.35 4 16 4" stroke="#14b8a6" stroke-width="2" stroke-linecap="round"/>
<circle cx="9" cy="26" r="2" fill="#0d9488"/>
<circle cx="23" cy="6" r="2" fill="#14b8a6"/>
</svg>
Jormun<span style="color:var(--jormun-teal-mid)">Admin</span>
<span class="sub">JormunDB</span>
</a>
{# Breadcrumbs #}
<nav class="jormun-breadcrumb">
{% block breadcrumbs %}
<a href="{{ path('dashboard') }}"><i class="bi bi-house"></i> Home</a>
{% endblock %}
</nav>
{# Right side controls #}
<div class="d-flex align-items-center gap-2 ms-auto">
<button class="sidebar-toggle" @click="toggleDark()" :title="darkMode ? 'Light mode' : 'Dark mode'">
<i :class="darkMode ? 'bi bi-sun' : 'bi bi-moon'"></i>
</button>
<a href="{{ path('logout') }}" class="sidebar-toggle" title="Logout">
<i class="bi bi-box-arrow-right"></i>
</a>
</div>
</header>
{# ── Sidebar ── #}
<aside class="jormun-sidebar" :class="{ 'collapsed': !sidebarOpen }">
<div class="sidebar-search">
<input
type="text"
class="jormun-input"
placeholder="&#xF52A; Filter tables…"
x-model="tableFilter"
style="font-family: 'DM Mono', monospace; font-size:0.75rem;"
>
</div>
<div class="sidebar-section-label">Tables</div>
{% block sidebar_tables %}{% endblock %}
<div style="padding: 0.5rem 0.75rem; margin-top: auto; border-top: 1px solid #f1f5f9;">
<a href="{{ path('table_create') }}" class="btn-jormun-outline w-100" style="justify-content:center;">
<i class="bi bi-plus-lg"></i> New Table
</a>
</div>
</aside>
{# ── Main ── #}
<main class="jormun-main" :class="{ 'sidebar-collapsed': !sidebarOpen }">
{% block content %}{% endblock %}
</main>
{# ── Toast Zone ── #}
<div class="toast-zone" x-data>
<template x-for="(t, i) in $store.toasts.list" :key="t.id">
<div class="jormun-toast" :class="t.type" x-show="t.visible" x-transition.opacity>
<i :class="{
'bi bi-check-circle-fill': t.type === 'success',
'bi bi-exclamation-triangle-fill': t.type === 'error',
'bi bi-info-circle-fill': t.type === 'info'
}"></i>
<span x-text="t.msg" style="flex:1;"></span>
<button @click="$store.toasts.dismiss(t.id)" style="background:none;border:none;cursor:pointer;color:#94a3b8;padding:0 0.2rem;">
<i class="bi bi-x"></i>
</button>
</div>
</template>
</div>
{# ── Server-side toast injection ── #}
{% if app.session.get('toast') %}
<script>
document.addEventListener('alpine:init', () => {
const t = {{ app.session.get('toast')|json_encode|raw }};
Alpine.store('toasts').add(t.type, t.msg);
});
</script>
{% endif %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script>
document.addEventListener('alpine:init', () => {
// ── Toast store ──
Alpine.store('toasts', {
list: [],
_id: 0,
add(type, msg, duration = 4000) {
const id = ++this._id;
this.list.push({ id, type, msg, visible: true });
setTimeout(() => this.dismiss(id), duration);
},
dismiss(id) {
const t = this.list.find(x => x.id === id);
if (t) t.visible = false;
setTimeout(() => { this.list = this.list.filter(x => x.id !== id); }, 300);
}
});
});
function jormunApp() {
return {
sidebarOpen: true,
tableFilter: '',
darkMode: localStorage.getItem('jormun-dark') === '1',
toggleDark() {
this.darkMode = !this.darkMode;
localStorage.setItem('jormun-dark', this.darkMode ? '1' : '0');
},
filterMatches(name) {
if (!this.tableFilter) return true;
return name.toLowerCase().includes(this.tableFilter.toLowerCase());
}
};
}
</script>
{% block scripts %}{% endblock %}
</body>
</html>