adasd
This commit is contained in:
@@ -6,7 +6,6 @@ use App\Repository\KeaHostMetadataRepository;
|
||||
$module = modules()->get('kea');
|
||||
$fallback = $module['db_defaults'] ?? [];
|
||||
|
||||
$pdo = modules()->modulePdo('kea', $fallback);
|
||||
$settings = modules()->settings('kea');
|
||||
$metadataFallback = is_array($module['metadata_db_defaults'] ?? null) ? $module['metadata_db_defaults'] : [];
|
||||
$metadataConfig = is_array($settings['metadata_db'] ?? null)
|
||||
@@ -15,11 +14,18 @@ $metadataConfig = is_array($settings['metadata_db'] ?? null)
|
||||
$metadataRepo = null;
|
||||
$hosts = [];
|
||||
$error = null;
|
||||
$warnings = [];
|
||||
|
||||
try {
|
||||
$pdo = modules()->modulePdo('kea', $fallback);
|
||||
if (!empty($metadataConfig['driver']) && !empty($metadataConfig['dbname'])) {
|
||||
$metadataRepo = new KeaHostMetadataRepository(Database::createFromArray($metadataConfig));
|
||||
$metadataRepo->ensureSchema();
|
||||
try {
|
||||
$metadataRepo = new KeaHostMetadataRepository(Database::createFromArray($metadataConfig));
|
||||
$metadataRepo->ensureSchema();
|
||||
} catch (\Throwable $e) {
|
||||
$warnings[] = 'Nexus DHCP Zusatzdatenbank nicht verfuegbar: ' . $e->getMessage();
|
||||
$metadataRepo = null;
|
||||
}
|
||||
}
|
||||
|
||||
$repo = new KeaHostRepository($pdo, $metadataRepo);
|
||||
@@ -28,4 +34,4 @@ try {
|
||||
$error = "Datenbankfehler: " . $e->getMessage();
|
||||
}
|
||||
|
||||
module_tpl('kea', 'dashboard', compact('hosts', 'error'));
|
||||
module_tpl('kea', 'dashboard', compact('hosts', 'error', 'warnings'));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/**
|
||||
* @var array $hosts Die Liste der KEA-Hosts.
|
||||
* @var string|null $error Eine Fehlermeldung, falls vorhanden.
|
||||
* @var array $warnings Hinweise, falls Zusatzdaten nicht geladen werden konnten.
|
||||
*/
|
||||
?>
|
||||
<div class="px-4 py-6 sm:px-0">
|
||||
@@ -19,6 +20,12 @@
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach (($warnings ?? []) as $warning): ?>
|
||||
<div class="bg-yellow-900 border-l-4 border-yellow-500 text-yellow-100 p-4 mb-6" role="alert">
|
||||
<p><?= e((string)$warning) ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<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">
|
||||
@@ -32,6 +39,7 @@
|
||||
<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">Quelle</th>
|
||||
<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>
|
||||
@@ -45,11 +53,16 @@
|
||||
<tbody class="bg-gray-800 divide-y divide-gray-700">
|
||||
<?php if (empty($hosts)): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="px-6 py-4 text-center text-sm text-gray-500">Keine Hosts gefunden.</td>
|
||||
<td colspan="7" class="px-6 py-4 text-center text-sm text-gray-500">
|
||||
Keine Reservierungen oder aktiven Leases 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 text-gray-300">
|
||||
<?= ($host['source'] ?? '') === 'lease' ? 'Lease' : 'Reservierung' ?>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-white">
|
||||
<?= e($host['hostname'] ?: 'Unbekannt') ?>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user