fix(20): add SNMP profiles settings link and device_count to profile list
Adds SNMP Device Profiles card to SettingsPage for discoverability. Adds device_count correlated subquery to profile list SQL and schema field so the frontend profile cards show accurate device counts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,11 +79,17 @@ async def list_profiles(
|
|||||||
|
|
||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
text("""
|
text("""
|
||||||
SELECT id, tenant_id, name, description, sys_object_id, vendor,
|
SELECT sp.id, sp.tenant_id, sp.name, sp.description, sp.sys_object_id, sp.vendor,
|
||||||
category, is_system, created_at, updated_at
|
sp.category, sp.is_system, sp.created_at, sp.updated_at,
|
||||||
FROM snmp_profiles
|
COALESCE(dc.device_count, 0) AS device_count
|
||||||
WHERE tenant_id = :tenant_id OR tenant_id IS NULL
|
FROM snmp_profiles sp
|
||||||
ORDER BY is_system DESC, name ASC
|
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)},
|
{"tenant_id": str(tenant_id)},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class SNMPProfileResponse(BaseModel):
|
|||||||
vendor: Optional[str] = None
|
vendor: Optional[str] = None
|
||||||
category: Optional[str] = None
|
category: Optional[str] = None
|
||||||
is_system: bool
|
is_system: bool
|
||||||
|
device_count: int = 0
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
updated_at: datetime
|
updated_at: datetime
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,23 @@ export function SettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* SNMP Profiles */}
|
||||||
|
{isTenantAdmin(user) && (
|
||||||
|
<div className="rounded-lg border border-border bg-panel px-4 py-3 space-y-1">
|
||||||
|
<SectionHeader icon={Monitor} title="SNMP Profiles" />
|
||||||
|
<Link
|
||||||
|
to="/settings/snmp-profiles"
|
||||||
|
className="flex items-center justify-between py-2 px-1 rounded hover:bg-elevated/30 transition-colors group"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span className="text-sm text-text-primary">SNMP Device Profiles</span>
|
||||||
|
<p className="text-xs text-text-muted">Manage OID collection profiles, upload MIBs, test against live devices</p>
|
||||||
|
</div>
|
||||||
|
<ChevronRight className="h-4 w-4 text-text-muted group-hover:text-text-primary transition-colors" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Maintenance — super_admin only */}
|
{/* Maintenance — super_admin only */}
|
||||||
{isSuperAdmin(user) && (
|
{isSuperAdmin(user) && (
|
||||||
<div className="rounded-lg border border-border bg-panel px-4 py-3 space-y-1">
|
<div className="rounded-lg border border-border bg-panel px-4 py-3 space-y-1">
|
||||||
|
|||||||
Reference in New Issue
Block a user