diff --git a/backend/app/routers/snmp_profiles.py b/backend/app/routers/snmp_profiles.py index 119c966..173e860 100644 --- a/backend/app/routers/snmp_profiles.py +++ b/backend/app/routers/snmp_profiles.py @@ -79,11 +79,17 @@ async def list_profiles( result = await db.execute( text(""" - SELECT id, tenant_id, name, description, sys_object_id, vendor, - category, is_system, created_at, updated_at - FROM snmp_profiles - WHERE tenant_id = :tenant_id OR tenant_id IS NULL - ORDER BY is_system DESC, name ASC + SELECT sp.id, sp.tenant_id, sp.name, sp.description, sp.sys_object_id, sp.vendor, + sp.category, sp.is_system, sp.created_at, sp.updated_at, + COALESCE(dc.device_count, 0) AS device_count + FROM snmp_profiles sp + LEFT JOIN LATERAL ( + SELECT COUNT(*) AS device_count + FROM devices d + WHERE d.snmp_profile_id = sp.id + ) dc ON true + WHERE sp.tenant_id = :tenant_id OR sp.tenant_id IS NULL + ORDER BY sp.is_system DESC, sp.name ASC """), {"tenant_id": str(tenant_id)}, ) diff --git a/backend/app/schemas/snmp_profile.py b/backend/app/schemas/snmp_profile.py index c0a2a8e..1546b53 100644 --- a/backend/app/schemas/snmp_profile.py +++ b/backend/app/schemas/snmp_profile.py @@ -75,6 +75,7 @@ class SNMPProfileResponse(BaseModel): vendor: Optional[str] = None category: Optional[str] = None is_system: bool + device_count: int = 0 created_at: datetime updated_at: datetime diff --git a/frontend/src/components/settings/SettingsPage.tsx b/frontend/src/components/settings/SettingsPage.tsx index 83a5c0f..3ca01fe 100644 --- a/frontend/src/components/settings/SettingsPage.tsx +++ b/frontend/src/components/settings/SettingsPage.tsx @@ -167,6 +167,23 @@ export function SettingsPage() { )} + {/* SNMP Profiles */} + {isTenantAdmin(user) && ( +
Manage OID collection profiles, upload MIBs, test against live devices
+