rebuild to module

This commit is contained in:
2026-03-03 02:13:17 +01:00
parent ffb52c6789
commit e61f9fb889
23 changed files with 7618 additions and 73 deletions

26
modules/kea/module.json Normal file
View File

@@ -0,0 +1,26 @@
{
"title": "KEA DHCP",
"version": "1.0.0",
"description": "Verwaltung von KEA DHCP Hosts und Reservierungen.",
"setup": {
"fields": [
{ "name": "db.host", "label": "DB Host", "type": "text", "required": true },
{ "name": "db.port", "label": "DB Port", "type": "number", "required": true },
{ "name": "db.dbname", "label": "DB Name", "type": "text", "required": true },
{ "name": "db.schema", "label": "DB Schema", "type": "text", "required": false },
{ "name": "db.user", "label": "DB User", "type": "text", "required": true },
{ "name": "db.password", "label": "DB Passwort", "type": "password", "required": true },
{ "name": "kea_db_version", "label": "KEA DB Version", "type": "text", "required": false },
{ "name": "kea_auto_init", "label": "KEA Auto-Init", "type": "checkbox", "required": false }
]
},
"db_defaults": {
"driver": "pgsql",
"host": "localhost",
"port": 5432,
"dbname": "",
"schema": "public",
"user": "",
"password": ""
}
}

View File

@@ -0,0 +1,22 @@
<?php
use App\Repository\KeaHostRepository;
$module = modules()->get('kea');
$fallback = $module['db_defaults'] ?? [];
$pdo = modules()->modulePdo('kea', $fallback);
$hosts = [];
$error = null;
if ($pdo) {
try {
$repo = new KeaHostRepository($pdo);
$hosts = $repo->findAll(50);
} catch (\Exception $e) {
$error = "Datenbankfehler: " . $e->getMessage();
}
} else {
$error = "Modul nicht konfiguriert. Bitte Setup ausführen.";
}
module_tpl('kea', 'dashboard', compact('hosts', 'error'));

View File

@@ -0,0 +1,74 @@
<?php
/**
* @var array $hosts Die Liste der KEA-Hosts.
* @var string|null $error Eine Fehlermeldung, falls vorhanden.
*/
?>
<div class="px-4 py-6 sm:px-0">
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-semibold text-white">KEA DHCP Hosts</h1>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded shadow transition-colors">
+ Neuer Host
</button>
</div>
<?php if ($error): ?>
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
<p class="font-bold">Fehler</p>
<p><?= e($error) ?></p>
</div>
<?php endif; ?>
<div class="bg-gray-800 shadow overflow-hidden sm:rounded-lg border border-gray-700">
<div class="px-4 py-5 sm:px-6 border-b border-gray-700">
<h3 class="text-lg leading-6 font-medium text-gray-200">
Registrierte Geräte
</h3>
<p class="mt-1 max-w-2xl text-sm text-gray-400">
Übersicht der statischen Reservierungen und bekannten Clients.
</p>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-gray-900">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Hostname</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">IP Adresse</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">MAC Adresse</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Kontext</th>
<th scope="col" class="relative px-6 py-3">
<span class="sr-only">Edit</span>
</th>
</tr>
</thead>
<tbody class="bg-gray-800 divide-y divide-gray-700">
<?php if (empty($hosts)): ?>
<tr>
<td colspan="5" class="px-6 py-4 text-center text-sm text-gray-500">Keine Hosts gefunden.</td>
</tr>
<?php else: ?>
<?php foreach ($hosts as $host): ?>
<tr class="hover:bg-gray-750 transition-colors">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">
<?= e($host['hostname'] ?: 'Unbekannt') ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300 font-mono">
<?= e($host['ipv4_address']) ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400 font-mono">
<?= e($host['dhcp_identifier']) ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400">
<?= e($host['user_context'] ?? '-') ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="#" class="text-indigo-400 hover:text-indigo-300">Bearbeiten</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>