diff --git a/frontend/src/pages/Customers.jsx b/frontend/src/pages/Customers.jsx index 09cd29d..370e8fc 100644 --- a/frontend/src/pages/Customers.jsx +++ b/frontend/src/pages/Customers.jsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react' import api from '../api/client' import { copyToClipboard } from '../utils/clipboard' -import { Plus, Trash2, Edit2, X, Check, ChevronDown, ChevronRight, Copy, Key } from 'lucide-react' +import { Plus, Trash2, Edit2, X, Check, ChevronDown, ChevronRight, Copy, Key, Monitor } from 'lucide-react' const PERM_LABELS = { agent: { label: 'Agent', color: 'text-blue-400 bg-blue-900/30 border-blue-700/50' }, @@ -198,10 +198,12 @@ export default function Customers() { function CustomerKeyPanel({ customerId }) { const [keys, setKeys] = useState(null) + const [agents, setAgents] = useState(null) const [copied, setCopied] = useState(null) useEffect(() => { api.getCustomerAPIKeys(customerId).then(setKeys) + api.getCustomerAgents(customerId).then(setAgents) }, [customerId]) const copyKey = (key, id) => { @@ -210,49 +212,74 @@ function CustomerKeyPanel({ customerId }) { setTimeout(() => setCopied(null), 2000) } - if (keys === null) { + const loading = keys === null || agents === null + if (loading) { return
Laden...
} - if (keys.length === 0) { - return ( -
- - Keine API-Keys fuer diesen Kunden -
- ) - } + // Agent-Key fuer diesen Kunden ermitteln (zum Abgleich welcher Agent ihn nutzt) + const agentKey = keys.find(k => k.permissions === 'agent') return ( -
-
- - API-Keys +
+ + {/* Agents */} +
+
+ + Agents ({agents.length}) +
+ {agents.length === 0 ? ( +
Keine Agents zugeordnet
+ ) : ( + agents.map((a) => ( +
+ + {a.name} + {a.agent_version || '—'} +
+ )) + )}
- {keys.map((k) => { - const perm = PERM_LABELS[k.permissions] || PERM_LABELS.read - return ( -
- - {perm.label} - - {k.name} - - {k.key.substring(0, 8)}...{k.key.substring(k.key.length - 4)} - - -
- ) - })} + + {/* API-Keys */} +
+
+ + API-Keys +
+ {keys.length === 0 ? ( +
Keine Keys
+ ) : ( + keys.map((k) => { + const perm = PERM_LABELS[k.permissions] || PERM_LABELS.read + return ( +
+ + {perm.label} + + + {k.key.substring(0, 8)}...{k.key.substring(k.key.length - 4)} + + +
+ ) + }) + )} +
+
) }