diff --git a/frontend/src/pages/Firmware.jsx b/frontend/src/pages/Firmware.jsx index b972823..3907fd6 100644 --- a/frontend/src/pages/Firmware.jsx +++ b/frontend/src/pages/Firmware.jsx @@ -16,6 +16,7 @@ export default function Firmware() { const [firmwareData, setFirmwareData] = useState(null) const [installerData, setInstallerData] = useState(null) const [agents, setAgents] = useState([]) + const [customers, setCustomers] = useState([]) const [loading, setLoading] = useState(true) const [uploading, setUploading] = useState(false) const [installerUploading, setInstallerUploading] = useState(false) @@ -30,14 +31,16 @@ export default function Firmware() { const load = async () => { try { - const [fw, ag, inst] = await Promise.all([ + const [fw, ag, inst, cu] = await Promise.all([ api.getFirmwareInfo().catch(() => null), api.getAgents().catch(() => []), api.getInstallerInfo().catch(() => null), + api.getCustomers().catch(() => []), ]) setFirmwareData(fw) setAgents(Array.isArray(ag) ? ag : []) setInstallerData(inst) + setCustomers(Array.isArray(cu) ? cu : []) } finally { setLoading(false) } @@ -299,14 +302,16 @@ export default function Firmware() { - {/* Agent List */} -
-
-

Agents

+ {/* Agent List — nach Kunde gruppiert */} +
+
+ + Agents ({agents.length}) + {hasAnyFirmware && (
-
- {agents.map((agent) => { - const outdated = needsUpdate(agent) - const pending = agent.update_requested - const agentPlatform = agent.platform || 'freebsd' - const fw = getFwForAgent(agent) - const platformLabel = agentPlatform === 'linux' ? 'Linux' : 'FreeBSD' - const platformColor = agentPlatform === 'linux' ? 'bg-blue-900/50 text-blue-400' : 'bg-orange-900/50 text-orange-400' + {(() => { + // Gruppieren nach customer_id + const groups = {} + agents.forEach(a => { + const gid = a.customer_id ?? '__none__' + if (!groups[gid]) groups[gid] = [] + groups[gid].push(a) + }) + const sorted = Object.entries(groups).sort(([a], [b]) => { + if (a === '__none__') return 1 + if (b === '__none__') return -1 + const ca = customers.find(c => c.id === parseInt(a)) + const cb = customers.find(c => c.id === parseInt(b)) + return (ca?.number || '').localeCompare(cb?.number || '') + }) + return sorted.map(([gid, gAgents]) => { + const customer = gid !== '__none__' ? customers.find(c => c.id === parseInt(gid)) : null return ( -
-
-
- - {agent.name} - {platformLabel} -
-
- - Version: {agent.agent_version || '--'} - {fw && (aktuell: v{fw.version})} - {!fw && (keine Firmware fuer {platformLabel})} - - {pending && ( - - Update ausstehend - - )} - {!outdated && fw && agent.agent_version && ( - - Aktuell - - )} -
-
-
- {pending ? ( - - ) : outdated ? ( - - ) : null} +
+
+ + {customer ? `${customer.number} — ${customer.name}` : 'Kein Kunde'} + + ({gAgents.length})
+ {gAgents.map(agent => { + const outdated = needsUpdate(agent) + const pending = agent.update_requested + const agentPlatform = agent.platform || 'freebsd' + const fw = getFwForAgent(agent) + const isLinux = agentPlatform === 'linux' + return ( +
+ + {agent.name} + + {isLinux ? 'Linux' : 'BSD'} + + + v{agent.agent_version || '—'} + {fw && outdated && → v{fw.version}} + + {pending && ( + ausstehend + )} + {pending ? ( + + ) : outdated ? ( + + ) : fw ? ( + + ) : null} +
+ ) + })}
) - })} -
+ }) + })()}
)