include site name in target dropdown in public resources table

This commit is contained in:
miloschwartz
2026-04-12 15:09:40 -07:00
parent e118e5b047
commit 89471a0174
3 changed files with 15 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import {
resourcePincode, resourcePincode,
resources, resources,
roleResources, roleResources,
sites,
targetHealthCheck, targetHealthCheck,
targets, targets,
userResources userResources
@@ -138,6 +139,7 @@ export type ResourceWithTargets = {
port: number; port: number;
enabled: boolean; enabled: boolean;
healthStatus: "healthy" | "unhealthy" | "unknown" | null; healthStatus: "healthy" | "unhealthy" | "unknown" | null;
siteName: string | null;
}>; }>;
}; };
@@ -446,14 +448,16 @@ export async function listResources(
port: targets.port, port: targets.port,
enabled: targets.enabled, enabled: targets.enabled,
healthStatus: targetHealthCheck.hcHealth, healthStatus: targetHealthCheck.hcHealth,
hcEnabled: targetHealthCheck.hcEnabled hcEnabled: targetHealthCheck.hcEnabled,
siteName: sites.name
}) })
.from(targets) .from(targets)
.where(inArray(targets.resourceId, resourceIdList)) .where(inArray(targets.resourceId, resourceIdList))
.leftJoin( .leftJoin(
targetHealthCheck, targetHealthCheck,
eq(targetHealthCheck.targetId, targets.targetId) eq(targetHealthCheck.targetId, targets.targetId)
); )
.leftJoin(sites, eq(targets.siteId, sites.siteId));
// avoids TS issues with reduce/never[] // avoids TS issues with reduce/never[]
const map = new Map<number, ResourceWithTargets>(); const map = new Map<number, ResourceWithTargets>();

View File

@@ -95,7 +95,8 @@ export default async function ProxyResourcesPage(
ip: target.ip, ip: target.ip,
port: target.port, port: target.port,
enabled: target.enabled, enabled: target.enabled,
healthStatus: target.healthStatus healthStatus: target.healthStatus,
siteName: target.siteName
})) }))
}; };
}); });

View File

@@ -54,6 +54,7 @@ export type TargetHealth = {
port: number; port: number;
enabled: boolean; enabled: boolean;
healthStatus: "healthy" | "unhealthy" | "unknown" | null; healthStatus: "healthy" | "unhealthy" | "unknown" | null;
siteName: string | null;
}; };
export type ResourceRow = { export type ResourceRow = {
@@ -274,7 +275,9 @@ export default function ProxyResourcesTable({
} }
className="h-3 w-3" className="h-3 w-3"
/> />
{`${target.ip}:${target.port}`} {target.siteName
? `${target.siteName} (${target.ip}:${target.port})`
: `${target.ip}:${target.port}`}
</div> </div>
<span <span
className={`capitalize ${ className={`capitalize ${
@@ -301,7 +304,9 @@ export default function ProxyResourcesTable({
status="unknown" status="unknown"
className="h-3 w-3" className="h-3 w-3"
/> />
{`${target.ip}:${target.port}`} {target.siteName
? `${target.siteName} (${target.ip}:${target.port})`
: `${target.ip}:${target.port}`}
</div> </div>
<span className="text-muted-foreground"> <span className="text-muted-foreground">
{!target.enabled {!target.enabled