This commit is contained in:
2025-12-08 01:54:31 +01:00
parent b170af3945
commit c931d79e32
12 changed files with 415 additions and 399 deletions

View File

@@ -0,0 +1,185 @@
<?php
$base = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') ?: '';
$assetVersion = defined('ASSET_VERSION') ? ASSET_VERSION : time();
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Email Template System Administration</title>
<script>document.documentElement.classList.add('auth-pending');</script>
<style>html.auth-pending body{visibility:hidden;}</style>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="<?= $base ?>/assets/css/admin.css?v=<?= htmlspecialchars($assetVersion, ENT_QUOTES) ?>">
<link rel="stylesheet" href="<?= $base ?>/assets/css/toast.css?v=<?= htmlspecialchars($assetVersion, ENT_QUOTES) ?>">
<style>
:root { color-scheme: light; }
.btn{display:inline-flex;align-items:center;gap:.5rem;padding:.35rem .7rem;border-radius:.7rem;border:1px solid #e5e7eb;background:#fff;font-size:.9rem;cursor:pointer;}
.btn:hover{background:#f8fafc}
.btn-avatar{padding:.35rem;border-radius:999px;width:42px;height:42px;justify-content:center;font-weight:600;background:#0ea5e9;color:#fff;border:none}
.btn-avatar:hover{background:#0284c7}
.section-card{background:#fff;border:1px solid #e2e8f0;border-radius:1rem;padding:1.25rem;margin-bottom:1.5rem}
.section-card h4{margin:0 0 1rem;font-size:1rem;font-weight:600;color:#0f172a}
.input{width:100%;border:1px solid #cbd5f5;border-radius:.5rem;padding:.5rem .75rem}
.team-table{width:100%;border-collapse:collapse;font-size:.9rem}
.team-table th,.team-table td{padding:.35rem .5rem;border-bottom:1px solid #e2e8f0;text-align:left}
.badge{display:inline-flex;align-items:center;padding:.1rem .5rem;border-radius:999px;font-size:.75rem;background:#e2e8f0;color:#0f172a}
.chip{display:inline-flex;align-items:center;padding:.15rem .55rem;border-radius:999px;background:#f1f5f9;color:#0f172a;border:1px solid #e2e8f0;font-size:.8rem}
.user-menu{position:absolute;top:calc(100% + .5rem);right:0;min-width:180px;background:#fff;border:1px solid #e2e8f0;border-radius:.75rem;box-shadow:0 20px 35px rgba(15,23,42,.15);padding:.35rem;z-index:40}
.user-menu-item{display:block;width:100%;text-align:left;padding:.45rem .75rem;border-radius:.6rem;font-size:.9rem;color:#0f172a}
.user-menu-item:hover{background:#f1f5f9}
</style>
</head>
<body class="bg-slate-50 text-slate-800" data-page="admin">
<header class="sticky top-0 z-30 bg-white/90 border-b backdrop-blur">
<div class="max-w-5xl mx-auto px-4 py-4 flex items-center gap-3">
<a href="<?= $base ?>/index.php" class="btn" title="Zurück zur Übersicht">← Übersicht</a>
<h1 class="font-semibold text-lg">Administration</h1>
<div class="ms-auto flex gap-2 items-center">
<div class="relative" id="userMenu">
<button id="btn-user" type="button" class="btn-avatar" aria-haspopup="true" aria-expanded="false">
<span id="userAvatar">U</span>
</button>
<div id="userMenuPanel" class="user-menu hidden" role="menu">
<a href="<?= $base ?>/admin/profile.php" class="user-menu-item" data-menu="profile">Profil</a>
<a href="<?= $base ?>/admin/dashboard.php" class="user-menu-item" data-role="admin">Dashboard</a>
<a href="<?= $base ?>/admin/settings.php" class="user-menu-item" data-role="admin">Administration</a>
<button id="btn-logout" type="button" class="user-menu-item text-red-600">Logout</button>
</div>
</div>
</div>
</div>
</header>
<main class="max-w-5xl mx-auto p-4 md:p-6 space-y-6">
<section class="section-card" data-role="owner">
<div class="flex items-center justify-between mb-3">
<h4>Team</h4>
<button type="button" id="btn-user-add" class="btn">+ Nutzer</button>
</div>
<div class="overflow-auto">
<table class="team-table" id="teamTable">
<thead>
<tr><th>Name</th><th>E-Mail</th><th>Rolle</th><th>Status</th><th class="text-right">Aktionen</th></tr>
</thead>
<tbody></tbody>
</table>
</div>
<form id="userForm" class="space-y-3 mt-4 hidden">
<input type="hidden" name="user_id">
<label class="block text-sm text-slate-600">Name
<input type="text" name="name" class="input mt-1" required>
</label>
<label class="block text-sm text-slate-600">E-Mail
<input type="email" name="email" class="input mt-1" required>
</label>
<label class="block text-sm text-slate-600">Rolle
<select name="role" class="input mt-1">
<option value="owner">Owner</option>
<option value="admin">Admin</option>
<option value="editor">Editor</option>
<option value="viewer">Viewer</option>
</select>
</label>
<label class="inline-flex items-center gap-2 text-sm text-slate-600">
<input type="checkbox" name="is_active" checked> Aktiv
</label>
<label class="inline-flex items-center gap-2 text-sm text-slate-600 reset-only hidden">
<input type="checkbox" name="reset_password"> Passwort zurücksetzen
</label>
<div class="flex justify-end gap-2">
<button type="button" id="userFormCancel" class="btn">Abbrechen</button>
<button type="submit" class="btn">Speichern</button>
</div>
</form>
</section>
<section class="section-card" data-role="admin">
<div class="flex items-center justify-between mb-3">
<h4>Absender für Testmails</h4>
<button type="button" id="btn-sender-add" class="btn">+ Absender</button>
</div>
<div class="overflow-auto">
<table class="team-table" id="senderTable">
<thead>
<tr><th>Bezeichnung</th><th>From-Name</th><th>E-Mail</th><th>Reply-To</th><th class="text-right">Aktionen</th></tr>
</thead>
<tbody></tbody>
</table>
</div>
<form id="senderForm" class="space-y-3 mt-4 hidden">
<input type="hidden" name="sender_id">
<label class="block text-sm text-slate-600">Bezeichnung
<input type="text" name="label" class="input mt-1" placeholder="Interner Name (optional)">
</label>
<label class="block text-sm text-slate-600">Absender-Name
<input type="text" name="from_name" class="input mt-1" placeholder="z.B. Newsletter Team">
</label>
<label class="block text-sm text-slate-600">Absender-E-Mail
<input type="email" name="from_email" class="input mt-1" required placeholder="news@example.com">
</label>
<label class="block text-sm text-slate-600">Reply-To (optional)
<input type="email" name="reply_to" class="input mt-1" placeholder="support@example.com">
</label>
<div class="flex justify-end gap-2">
<button type="button" id="senderFormCancel" class="btn">Abbrechen</button>
<button type="submit" class="btn">Speichern</button>
</div>
</form>
</section>
<section class="section-card" data-role="admin">
<h4>Integrationen, Downloads & Tokens</h4>
<p class="text-sm text-slate-600 mb-4">Die Dateien enthalten automatisch deine aktuellen Tokens. Nach dem Speichern neuer Tokens bitte die Dateien erneut herunterladen.</p>
<form id="settingsForm" class="space-y-3">
<label class="block text-sm text-slate-600">Bridge-URL
<input type="url" name="bridge_url" class="input mt-1" placeholder="https://domain.tld/emailtemplate_bridge.php">
</label>
<div>
<label class="block text-sm text-slate-600">Bridge Token</label>
<div class="flex gap-2 mt-1">
<input type="text" name="bridge_token" class="input" readonly>
<button type="button" class="btn" data-rotate="bridge">Neu erstellen</button>
</div>
</div>
<div>
<label class="block text-sm text-slate-600">Sender Token</label>
<div class="flex gap-2 mt-1">
<input type="text" name="sender_token" class="input" readonly>
<button type="button" class="btn" data-rotate="sender">Neu erstellen</button>
</div>
</div>
<div>
<label class="block text-sm text-slate-600">Externer API-Token</label>
<div class="flex gap-2 mt-1">
<input type="text" name="external_api_token" class="input" readonly>
<button type="button" class="btn" data-rotate="external">Neu erstellen</button>
</div>
</div>
<div>
<label class="block text-sm text-slate-600">Verfügbare Tabellen (kommagetrennt oder Zeilen)</label>
<textarea name="bridge_tables" class="input mt-1" rows="3" placeholder="z.B. customers, orders"></textarea>
<p class="text-xs text-slate-500 mt-1">Nur diese Tabellen werden als Platzhalter angeboten. Leer = alle.</p>
</div>
<div class="flex flex-col gap-2">
<button type="button" id="btn-validate-bridge" class="btn w-max" data-role="admin">Verbindung prüfen & Tabellen laden</button>
<div id="bridgeTablesPreview" class="flex flex-wrap gap-2 text-sm text-slate-600">Noch nicht geprüft.</div>
</div>
<div class="flex justify-between gap-2 flex-wrap pt-2">
<div class="flex gap-2" data-role="admin">
<button type="button" class="btn" data-download="bridge">Bridge-Datei</button>
<button type="button" class="btn" data-download="sender">Sender-Datei</button>
</div>
<button type="submit" class="btn ms-auto">Einstellungen speichern</button>
</div>
</form>
</section>
</main>
<div id="toast-root"></div>
<script src="<?= $base ?>/assets/js/toast.js?v=<?= htmlspecialchars($assetVersion, ENT_QUOTES) ?>"></script>
<script type="module" src="<?= $base ?>/assets/js/account.js?v=<?= htmlspecialchars($assetVersion, ENT_QUOTES) ?>"></script>
</body>
</html>