diff --git a/public/index.php b/public/index.php index 97e2ad3..3f4f743 100644 --- a/public/index.php +++ b/public/index.php @@ -142,19 +142,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($proj && hash_equals($proj['slug'], $confirmSlug)) { $pdo->beginTransaction(); - // 1. Delete associated activations $pdo->prepare('DELETE a FROM license_activations a JOIN license_licenses l ON a.license_id = l.id WHERE l.product_id = :id') ->execute([':id' => $id]); - // 2. Delete associated licenses $pdo->prepare('DELETE FROM license_licenses WHERE product_id = :id') ->execute([':id' => $id]); - // 3. Delete associated releases $pdo->prepare('DELETE FROM updateservice_releases WHERE product_slug = :slug') ->execute([':slug' => $proj['slug']]); - // 4. Delete project $delStmt = $pdo->prepare('DELETE FROM dc_projects WHERE id = :id'); $delStmt->execute([':id' => $id]); @@ -289,19 +285,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } - // Edit Watchdog Monitor + // Edit Watchdog Monitor (Full Update) if ($action === 'edit_watchdog_monitor') { $oldSource = trim($_POST['old_source'] ?? ''); $newSource = trim($_POST['new_source'] ?? $oldSource); + $type = trim($_POST['type'] ?? 'host'); $group = trim($_POST['group_key'] ?? 'Default'); $parent = trim($_POST['parent_source'] ?? ''); + $os = trim($_POST['os'] ?? ''); $interval = (int)($_POST['interval'] ?? 60); $notes = trim($_POST['notes'] ?? ''); if ($oldSource && $newSource) { $monRepo = new MonitorRepo($pdo); - $monRepo->updateMonitor($oldSource, $newSource, 'default', $group, $parent, $notes, null, $interval); - $msg = "Monitor '{$newSource}' wurde aktualisiert."; + $monRepo->updateMonitor($oldSource, $newSource, 'default', $type, $group, $parent, $os, $notes, null, $interval); + $msg = "Monitor '{$newSource}' wurde erfolgreich aktualisiert."; } } @@ -330,11 +328,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($action === 'create_agent_token') { $source = trim($_POST['token_source'] ?? ''); $name = trim($_POST['token_name'] ?? ''); - if ($name) { - $tokMgr = new TokenManager($pdo); - $res = $tokMgr->createToken($source, $name); - $msg = "Agent-Token für '{$name}' generiert: {$res['raw_token']}"; + if (empty($name)) { + $name = "Token for " . ($source ?: 'General'); } + $tokMgr = new TokenManager($pdo); + $res = $tokMgr->createToken($source, $name); + $msg = "Agent-Token generiert: {$res['raw_token']}"; } // Revoke Agent Token @@ -392,6 +391,17 @@ $auditLogs = $pdo->query('SELECT * FROM license_audit_log ORDER BY created_at DE $monitorRepo = new MonitorRepo($pdo); $monitors = $monitorRepo->getAllMonitors(); +$tokenManager = new TokenManager($pdo); +$agentTokens = $tokenManager->getAllTokens(); + +// Map Active Tokens per Monitor Source +$tokensBySource = []; +foreach ($agentTokens as $tok) { + if (!$tok['revoked'] && !empty($tok['monitor_source'])) { + $tokensBySource[$tok['monitor_source']] = $tok; + } +} + // Flatten Tree for Hierarchy Rendering (Up to 3 levels: Hypervisor -> Host -> App) function buildMonitorTree(array $monitors): array { $childrenOf = []; @@ -449,9 +459,6 @@ foreach ($monitors as $m) { $eventLog = new EventLog($pdo); $recentEvents = $eventLog->getRecentEvents(100); -$tokenManager = new TokenManager($pdo); -$agentTokens = $tokenManager->getAllTokens(); - $updateMgr = new UpdateManager($pdo); $releases = $updateMgr->getReleases(); @@ -579,7 +586,7 @@ $baseUrl = $protocol . '://' . $host; .form-input { background: rgba(255,255,255,0.04); border: 1px solid var(--border-glass); border-radius: 10px; padding: 0.65rem 0.85rem; color: #fff; font-size: 0.875rem; outline: none; font-family: 'Manrope', system-ui; transition: border-color 0.2s; } .form-input:focus { border-color: var(--primary); } - /* Dropdown Option List Styling Fix (Readable text across all browsers) */ + /* Dropdown Option List Styling Fix (Readable dark text/bg across all operating systems & browsers) */ select.form-input option { background-color: #0e121c; color: #EDEFF5; @@ -591,10 +598,10 @@ $baseUrl = $protocol . '://' . $host; .alert-success { background: rgba(18,212,138,0.15); border: 1px solid rgba(18,212,138,0.3); color: #a7f3d0; } .alert-danger { background: rgba(246,70,93,0.15); border: 1px solid rgba(246,70,93,0.3); color: #fca5a5; } - /* Safety Modal */ + /* Modals */ .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(10px); display: none; align-items: center; justify-content: center; z-index: 200; } .modal-backdrop.active { display: flex; } - .modal-card { background: #0e121c; border: 1px solid rgba(246,70,93,0.3); border-radius: 18px; padding: 2rem; max-width: 500px; width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,0.8); } + .modal-card { background: #0e121c; border: 1px solid var(--border-glass); border-radius: 18px; padding: 2rem; max-width: 550px; width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,0.8); } .tab-content, .subtab-content { display: none; } .tab-content.active, .subtab-content.active { display: block; } @@ -865,6 +872,59 @@ $baseUrl = $protocol . '://' . $host; + +
= htmlspecialchars($m['type']) ?>= htmlspecialchars(substr($tokenData['raw_token'], 0, 10)) ?>...
+
+
+
+