diff --git a/messages/en-US.json b/messages/en-US.json index 608dd000..9d668dfe 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -2269,5 +2269,6 @@ "remoteExitNodeRegenerateAndDisconnectConfirmation": "Are you sure you want to regenerate the credentials and disconnect this remote exit node?", "remoteExitNodeRegenerateAndDisconnectWarning": "This will regenerate the credentials and immediately disconnect the remote exit node. The remote exit node will need to be restarted with the new credentials.", "remoteExitNodeRegenerateCredentialsConfirmation": "Are you sure you want to regenerate the credentials for this remote exit node?", - "remoteExitNodeRegenerateCredentialsWarning": "This will regenerate the credentials. The remote exit node will stay connected until you manually restart it and use the new credentials." + "remoteExitNodeRegenerateCredentialsWarning": "This will regenerate the credentials. The remote exit node will stay connected until you manually restart it and use the new credentials.", + "agent": "Agent" } diff --git a/server/lib/calculateUserClientsForOrgs.ts b/server/lib/calculateUserClientsForOrgs.ts index 4cde8657..f7666a36 100644 --- a/server/lib/calculateUserClientsForOrgs.ts +++ b/server/lib/calculateUserClientsForOrgs.ts @@ -15,6 +15,7 @@ import { getNextAvailableClientSubnet } from "@server/lib/ip"; import logger from "@server/logger"; import { rebuildClientAssociationsFromClient } from "./rebuildClientAssociations"; import { sendTerminateClient } from "@server/routers/client/terminate"; +import { getUniqueClientName } from "@server/db/names"; export async function calculateUserClientsForOrgs( userId: string, @@ -176,6 +177,8 @@ export async function calculateUserClientsForOrgs( const subnet = newSubnet.split("/")[0]; const updatedSubnet = `${subnet}/${org.subnet.split("/")[1]}`; + const niceId = await getUniqueClientName(orgId); + // Create the client const [newClient] = await transaction .insert(clients) @@ -186,7 +189,8 @@ export async function calculateUserClientsForOrgs( name: olm.name || "User Client", subnet: updatedSubnet, olmId: olm.olmId, - type: "olm" + type: "olm", + niceId }) .returning(); diff --git a/server/routers/client/listClients.ts b/server/routers/client/listClients.ts index 58144967..68cd9aa0 100644 --- a/server/routers/client/listClients.ts +++ b/server/routers/client/listClients.ts @@ -129,7 +129,8 @@ function queryClients(orgId: string, accessibleClientIds: number[], filter?: "us userId: clients.userId, username: users.username, userEmail: users.email, - niceId: clients.niceId + niceId: clients.niceId, + agent: olms.agent }) .from(clients) .leftJoin(orgs, eq(clients.orgId, orgs.orgId)) diff --git a/src/app/[orgId]/settings/clients/machine/page.tsx b/src/app/[orgId]/settings/clients/machine/page.tsx index d55498b1..e1a904ad 100644 --- a/src/app/[orgId]/settings/clients/machine/page.tsx +++ b/src/app/[orgId]/settings/clients/machine/page.tsx @@ -57,7 +57,8 @@ export default async function ClientsPage(props: ClientsPageProps) { userId: client.userId, username: client.username, userEmail: client.userEmail, - niceId: client.niceId + niceId: client.niceId, + agent: client.agent }; }; diff --git a/src/app/[orgId]/settings/clients/user/page.tsx b/src/app/[orgId]/settings/clients/user/page.tsx index 399588fc..28288fd2 100644 --- a/src/app/[orgId]/settings/clients/user/page.tsx +++ b/src/app/[orgId]/settings/clients/user/page.tsx @@ -53,7 +53,9 @@ export default async function ClientsPage(props: ClientsPageProps) { olmUpdateAvailable: client.olmUpdateAvailable || false, userId: client.userId, username: client.username, - userEmail: client.userEmail + userEmail: client.userEmail, + niceId: client.niceId, + agent: client.agent }; }; diff --git a/src/components/MachineClientsTable.tsx b/src/components/MachineClientsTable.tsx index ea30b52e..7ac10eb7 100644 --- a/src/components/MachineClientsTable.tsx +++ b/src/components/MachineClientsTable.tsx @@ -41,6 +41,7 @@ export type ClientRow = { username: string | null; userEmail: string | null; niceId: string; + agent: string | null; }; type ClientTableProps = { @@ -65,7 +66,6 @@ export default function MachineClientsTable({ const [isRefreshing, startTransition] = useTransition(); const defaultMachineColumnVisibility = { - client: false, subnet: false, userId: false, niceId: false @@ -226,7 +226,7 @@ export default function MachineClientsTable({ }, { accessorKey: "client", - friendlyName: t("client"), + friendlyName: t("agent"), header: ({ column }) => { return ( ); @@ -247,19 +247,18 @@ export default function MachineClientsTable({ return (
- -
- Olm - {originalRow.olmVersion && ( - - v{originalRow.olmVersion} - - )} -
-
- {originalRow.olmUpdateAvailable && ( - + {originalRow.agent && originalRow.olmVersion ? ( + + {originalRow.agent + + " v" + + originalRow.olmVersion} + + ) : ( + "-" )} + {/*originalRow.olmUpdateAvailable && ( + + )*/}
); } diff --git a/src/components/UserDevicesTable.tsx b/src/components/UserDevicesTable.tsx index cd203b51..88a0d4a8 100644 --- a/src/components/UserDevicesTable.tsx +++ b/src/components/UserDevicesTable.tsx @@ -40,6 +40,8 @@ export type ClientRow = { userId: string | null; username: string | null; userEmail: string | null; + niceId: string; + agent: string | null; }; type ClientTableProps = { @@ -60,8 +62,8 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { const [isRefreshing, startTransition] = useTransition(); const defaultUserColumnVisibility = { - client: false, - subnet: false + subnet: false, + niceId: false }; const refreshData = () => { @@ -123,6 +125,25 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { ); } }, + { + accessorKey: "niceId", + friendlyName: t("identifier"), + header: ({ column }) => { + return ( + + ); + } + }, { accessorKey: "userEmail", friendlyName: "User", @@ -261,7 +282,7 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { }, { accessorKey: "client", - friendlyName: t("client"), + friendlyName: t("agent"), header: ({ column }) => { return ( ); @@ -282,19 +303,19 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { return (
- -
- Olm - {originalRow.olmVersion && ( - - v{originalRow.olmVersion} - - )} -
-
- {originalRow.olmUpdateAvailable && ( - + {originalRow.agent && originalRow.olmVersion ? ( + + {originalRow.agent + + " v" + + originalRow.olmVersion} + + ) : ( + "-" )} + + {/*originalRow.olmUpdateAvailable && ( + + )*/}
); } @@ -320,62 +341,52 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { } ]; - // Only include actions column if there are rows without userIds - if (hasRowsWithoutUserId) { - baseColumns.push({ - id: "actions", - enableHiding: false, - header: () => , - cell: ({ row }) => { - const clientRow = row.original; - return !clientRow.userId ? ( -
- - - - - - {/* */} - {/* */} - {/* View settings */} - {/* */} - {/* */} - { - setSelectedClient(clientRow); - setIsDeleteModalOpen(true); - }} - > - - Delete - - - - - - - -
- ) : null; - } - }); - } + + + {/* */} + {/* */} + {/* View settings */} + {/* */} + {/* */} + { + setSelectedClient(clientRow); + setIsDeleteModalOpen(true); + }} + > + Delete + + + + + + + + ) : null; + } + }); return baseColumns; }, [hasRowsWithoutUserId, t]);