This commit is contained in:
2026-01-12 23:57:46 +01:00
parent b05f59e554
commit 47327a12e0
9 changed files with 421 additions and 58 deletions

View File

@@ -2,10 +2,9 @@
$appBaseUrl = $GLOBALS['app_base_url'] ?? '';
$defaultNavLinks = [
['id' => 'dashboard', 'label' => 'Dashboard', 'href' => $appBaseUrl . '/admin/dashboard.php'],
['id' => 'settings', 'label' => 'Administration','href' => $appBaseUrl . '/admin/settings.php'],
['id' => 'bridge', 'label' => 'Bridge Setup', 'href' => $appBaseUrl . '/admin/bridge.php'],
['id' => 'profile', 'label' => 'Mein Konto', 'href' => $appBaseUrl . '/admin/profile.php'],
['id' => 'dashboard', 'label' => 'Dashboard', 'href' => $appBaseUrl . '/admin/dashboard.php'],
['id' => 'settings', 'label' => 'API & Tabellen', 'href' => $appBaseUrl . '/admin/settings.php'],
['id' => 'profile', 'label' => 'Mein Konto', 'href' => $appBaseUrl . '/admin/profile.php'],
];
if (empty($navLinks)) {

View File

@@ -21,10 +21,22 @@ require dirname(__DIR__) . '/../structure/layout_start.php';
</div>
<form id="bridgeSetupForm" class="space-y-4">
<div>
<label class="block text-sm text-slate-600">Tabellen-Whitelist (optional)</label>
<textarea name="tables" class="input mt-1" rows="3" placeholder="z.B. customers, orders"></textarea>
<p class="text-xs text-slate-500 mt-1">Kommagetrennt oder je Zeile eine Tabelle. Leer lassen = keine Einschränkung.</p>
<div id="selectedTables" class="flex flex-wrap gap-2 text-sm text-slate-600 mt-2">Noch keine Tabellen angegeben.</div>
<label class="block text-sm text-slate-600">Tabellen-Whitelist (Bridge-Datei)</label>
<div class="grid md:grid-cols-[1fr_auto_1fr] gap-3 mt-2">
<div>
<p class="text-xs text-slate-500 mb-1">Alle Tabellen (Bridge-Endpunkt)</p>
<select id="bridgeTablesAll" class="input" size="8" multiple></select>
</div>
<div class="flex flex-col gap-2 justify-center">
<button type="button" id="bridgeTablesAdd" class="btn" aria-label="Zur Whitelist hinzufuegen">→</button>
<button type="button" id="bridgeTablesRemove" class="btn" aria-label="Aus Whitelist entfernen">←</button>
</div>
<div>
<p class="text-xs text-slate-500 mb-1">Whitelist fuer Bridge-Datei</p>
<select id="bridgeTablesSelected" class="input" size="8" multiple></select>
</div>
</div>
<p class="text-xs text-slate-500 mt-2">Die Auswahl bestimmt, welche Tabellen in der Bridge-Datei erlaubt sind.</p>
</div>
<fieldset class="border border-slate-200 rounded-xl p-4">

View File

@@ -42,7 +42,7 @@ require dirname(__DIR__) . '/../structure/layout_start.php';
</section>
<section class="section-card">
<p class="text-sm text-slate-600">Teammitglieder, Absender und Integrationen verwaltest du im Bereich <strong>Administration</strong>. Öffne ihn über das Avatar-Menü oben rechts.</p>
<p class="text-sm text-slate-600">Teammitglieder, Absender und Integrationen verwaltest du im Bereich <strong>API &amp; Tabellen</strong>. Öffne ihn über das Avatar-Menü oben rechts.</p>
</section>
</main>

View File

@@ -1,5 +1,5 @@
<?php
$pageTitle = 'Email Template System Administration';
$pageTitle = 'Email Template System API & Tabellen';
$pageId = 'admin';
$navActive = 'settings';
require __DIR__ . '/accountsetup_config.php';
@@ -110,10 +110,6 @@ require dirname(__DIR__) . '/../structure/layout_start.php';
<button type="button" class="btn" data-rotate="external">Neu erstellen</button>
</div>
</div>
<div class="flex flex-col gap-2">
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/bridge.php') ?>" class="btn w-max" data-role="admin">Bridge-Setup & Tabellen öffnen</a>
<p class="text-xs text-slate-500">Dort kannst du Tabellen-Filter sowie DB-Quellen für die Bridge-Datei konfigurieren.</p>
</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>
@@ -123,9 +119,180 @@ require dirname(__DIR__) . '/../structure/layout_start.php';
</div>
</form>
</section>
<section class="section-card" data-role="admin">
<div class="flex items-center justify-between flex-wrap gap-3 mb-3">
<div>
<h4>Bridge-Datei & Tabellenfreigaben</h4>
<p class="text-sm text-slate-600">Die Bridge-Konfiguration dient ausschliesslich der Erstellung der Bridge-Datei und steuert, welche Tabellen dort freigegeben sind.</p>
</div>
<div class="flex gap-2 flex-wrap">
<button type="button" id="btn-open-bridge-setup" class="btn">Bridge-Setup oeffnen</button>
<button type="button" id="btn-admin-load-bridge" class="btn">Tabellen vom Bridge-Endpunkt laden</button>
</div>
</div>
<div class="grid md:grid-cols-[1fr_auto_1fr] gap-3">
<div>
<p class="text-xs text-slate-500 mb-1">Freigegebene Tabellen (Bridge-Datei)</p>
<select id="adminBridgeTablesAll" class="input" size="8" multiple></select>
</div>
<div class="flex flex-col gap-2 justify-center">
<button type="button" id="adminBridgeTablesAdd" class="btn" aria-label="Zur Placeholder-Auswahl hinzufuegen">→</button>
<button type="button" id="adminBridgeTablesRemove" class="btn" aria-label="Aus Placeholder-Auswahl entfernen">←</button>
</div>
<div>
<p class="text-xs text-slate-500 mb-1">Tabellen fuer Placeholder-Auswahl</p>
<select id="adminBridgeTablesSelected" class="input" size="8" multiple></select>
</div>
</div>
<p class="text-xs text-slate-500 mt-2">Nur diese Tabellen erscheinen spaeter bei der Placeholder-Auswahl.</p>
</section>
</main>
<div id="toast-root"></div>
<dialog id="bridgeSetupDialog" class="rounded-xl max-w-4xl w-[92vw]">
<div class="flex items-center justify-between gap-3 border-b border-slate-200 pb-3 mb-4">
<h3 class="text-lg font-semibold">Bridge-Setup</h3>
<button type="button" id="btn-close-bridge-setup" class="btn">Schliessen</button>
</div>
<div class="space-y-4">
<p class="text-sm text-slate-600">
Diese Angaben werden nur verwendet, um die <strong>emailtemplate_bridge.php</strong> zu generieren. Das EmailTemplate-System selbst behält Zugriff auf alle Tabellen; die hier definierten Whitelists greifen ausschliesslich in der Bridge-Datei.
</p>
<form id="bridgeSetupForm" class="space-y-4">
<div>
<label class="block text-sm text-slate-600">Tabellen-Whitelist (Bridge-Datei)</label>
<div class="grid md:grid-cols-[1fr_auto_1fr] gap-3 mt-2">
<div>
<p class="text-xs text-slate-500 mb-1">Alle Tabellen (Bridge-Endpunkt)</p>
<select id="bridgeTablesAll" class="input" size="8" multiple></select>
</div>
<div class="flex flex-col gap-2 justify-center">
<button type="button" id="bridgeTablesAdd" class="btn" aria-label="Zur Whitelist hinzufuegen">→</button>
<button type="button" id="bridgeTablesRemove" class="btn" aria-label="Aus Whitelist entfernen">←</button>
</div>
<div>
<p class="text-xs text-slate-500 mb-1">Whitelist fuer Bridge-Datei</p>
<select id="bridgeTablesSelected" class="input" size="8" multiple></select>
</div>
</div>
<p class="text-xs text-slate-500 mt-2">Die Auswahl bestimmt, welche Tabellen in der Bridge-Datei erlaubt sind.</p>
</div>
<fieldset class="border border-slate-200 rounded-xl p-4">
<legend class="px-2 text-sm font-semibold">Datenbankquelle</legend>
<p class="text-xs text-slate-500 mb-3">Die Auswahl bestimmt, welche Werte in die Bridge-Datei geschrieben werden.</p>
<div class="flex flex-wrap gap-4 text-sm text-slate-600 mb-3">
<label class="inline-flex items-center gap-2">
<input type="radio" name="db_mode" value="direct" checked> Direkte Angaben (Host, DB, Benutzer …)
</label>
<label class="inline-flex items-center gap-2">
<input type="radio" name="db_mode" value="config"> Aus bestehender Konfigurationsdatei laden
</label>
</div>
<div id="directFields" class="grid md:grid-cols-2 gap-3">
<label class="block text-sm text-slate-600">Server / Host
<input type="text" name="direct_host" class="input mt-1" placeholder="127.0.0.1">
</label>
<label class="block text-sm text-slate-600">Port
<input type="number" name="direct_port" class="input mt-1" placeholder="3306">
</label>
<label class="block text-sm text-slate-600">Datenbankname
<input type="text" name="direct_database" class="input mt-1" placeholder="kunden_db">
</label>
<label class="block text-sm text-slate-600">Zeichensatz
<input type="text" name="direct_charset" class="input mt-1" value="utf8mb4">
</label>
<label class="block text-sm text-slate-600">Benutzername
<input type="text" name="direct_user" class="input mt-1" placeholder="db_user">
</label>
<label class="block text-sm text-slate-600">Passwort
<input type="text" name="direct_password" class="input mt-1" placeholder="••••">
</label>
</div>
<div id="configFields" class="hidden space-y-3">
<div>
<label class="block text-sm text-slate-600">Pfad zur Konfigurationsdatei</label>
<input type="text" name="config_file" class="input mt-1" placeholder="../config/database.php">
<p class="text-xs text-slate-500 mt-1">Relativ zur Bridge-Datei oder absolut. Die Datei sollte ein Array oder Objekt mit den Zugangsdaten liefern.</p>
<button type="button" id="btn-config-example" class="btn mt-2 text-xs" data-role="admin">Beispiel: Array-Mapping</button>
</div>
<div>
<label class="block text-sm text-slate-600">Basis-Pfad im Array (optional)</label>
<input type="text" name="config_base" class="input mt-1" placeholder="database.connections.mysql">
<p class="text-xs text-slate-500 mt-1">Dot-Notation, um in verschachtelte Arrays zu springen.</p>
</div>
<div class="grid md:grid-cols-2 gap-3">
<label class="block text-sm text-slate-600">Host-Key
<input type="text" name="config_host_key" class="input mt-1" placeholder="host">
</label>
<label class="block text-sm text-slate-600">Port-Key
<input type="text" name="config_port_key" class="input mt-1" placeholder="port">
</label>
<label class="block text-sm text-slate-600">DB-Name-Key
<input type="text" name="config_database_key" class="input mt-1" placeholder="database">
</label>
<label class="block text-sm text-slate-600">Charset-Key
<input type="text" name="config_charset_key" class="input mt-1" placeholder="charset">
</label>
<label class="block text-sm text-slate-600">User-Key
<input type="text" name="config_user_key" class="input mt-1" placeholder="username">
</label>
<label class="block text-sm text-slate-600">Passwort-Key
<input type="text" name="config_password_key" class="input mt-1" placeholder="password">
</label>
</div>
<p class="text-xs text-slate-500">Alle Keys nutzen Dot-Notation relativ zum Basis-Pfad.</p>
</div>
</fieldset>
<div class="flex flex-wrap gap-2 items-center">
<button type="button" id="btn-load-remote" class="btn" data-role="admin">Tabellen vom Bridge-Endpunkt laden</button>
<span class="text-xs text-slate-500">Nutzt Bridge-URL/Token aus den Einstellungen und uebernimmt optional DB-Settings aus der Bridge-Datei.</span>
<button type="submit" class="btn">Bridge-Setup speichern</button>
</div>
<div id="setupStatus" class="text-xs text-slate-500">Noch nicht gespeichert.</div>
</form>
</div>
</dialog>
<dialog id="configExampleDialog" class="rounded-xl max-w-2xl w-[90vw]">
<form method="dialog" class="space-y-3">
<h3 class="text-lg font-semibold">Beispiel: Mapping einer Config-Datei</h3>
<p class="text-sm text-slate-600">Angenommen, deine <code>../config/database.php</code> liefert folgendes Array:</p>
<pre class="bg-slate-900 text-slate-100 text-xs p-3 rounded-lg overflow-auto"><?php echo htmlspecialchars(<<<'PHP'
<?php
return [
'database' => [
'connections' => [
'default' => [
'host' => '127.0.0.1',
'port' => 3306,
'database' => 'kunden_db',
'username' => 'dbuser',
'password' => 'secret',
'charset' => 'utf8mb4',
],
],
],
];
PHP, ENT_QUOTES); ?></pre>
<p class="text-sm text-slate-600">Dann trägst du ein:</p>
<ul class="text-sm text-slate-700 list-disc ps-5">
<li><strong>Pfad zur Konfigurationsdatei:</strong> <code>../config/database.php</code></li>
<li><strong>Basis-Pfad:</strong> <code>database.connections.default</code></li>
<li><strong>Host-/Port-/DB-/User-/Pass-/Charset-Key:</strong> jeweils <code>host</code>, <code>port</code>, <code>database</code>, <code>username</code>, <code>password</code>, <code>charset</code></li>
</ul>
<p class="text-sm text-slate-600">Die Bridge liest dann automatisch die Werte aus diesem Array und baut daraus den DSN.</p>
<div class="text-right">
<button type="submit" class="btn">Verstanden</button>
</div>
</form>
</dialog>
<?php
tpl_add_script(app_asset_url('/assets/js/toast.js'));
tpl_add_script(app_asset_url('/assets/js/account.js'), 'footer', false, false, '', null, true);

View File

@@ -3,10 +3,9 @@
$appBaseUrl = $layoutContext['app_base_url'] ?? '';
$navLinks = $navLinks ?? [
['id' => 'dashboard', 'label' => 'Dashboard', 'href' => $appBaseUrl . '/admin/dashboard.php'],
['id' => 'settings', 'label' => 'Administration','href' => $appBaseUrl . '/admin/settings.php'],
['id' => 'bridge', 'label' => 'Bridge Setup', 'href' => $appBaseUrl . '/admin/bridge.php'],
['id' => 'profile', 'label' => 'Mein Konto', 'href' => $appBaseUrl . '/admin/profile.php'],
['id' => 'dashboard', 'label' => 'Dashboard', 'href' => $appBaseUrl . '/admin/dashboard.php'],
['id' => 'settings', 'label' => 'API & Tabellen', 'href' => $appBaseUrl . '/admin/settings.php'],
['id' => 'profile', 'label' => 'Mein Konto', 'href' => $appBaseUrl . '/admin/profile.php'],
];
$navActive = $navActive ?? null;
@@ -48,8 +47,7 @@ $showNavLinks = !$hasHeaderTabs && !empty($navLinks);
<div id="userMenuPanel" class="user-menu hidden" role="menu">
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/profile.php') ?>" class="user-menu-item" data-menu="profile">Profil</a>
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/dashboard.php') ?>" class="user-menu-item" data-role="admin">Dashboard</a>
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/settings.php') ?>" class="user-menu-item" data-role="admin">Administration</a>
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/bridge.php') ?>" class="user-menu-item" data-role="admin">Bridge Setup</a>
<a href="<?= htmlspecialchars($appBaseUrl . '/admin/settings.php') ?>" class="user-menu-item" data-role="admin">API & Tabellen</a>
<button id="btn-logout" type="button" class="user-menu-item text-red-600">Logout</button>
</div>
</div>