mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 02:29:09 +00:00
feat: adds pagination in identities table
This commit is contained in:
@@ -346,7 +346,10 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
.extend({
|
||||
isInstanceAdmin: z.boolean()
|
||||
})
|
||||
.array()
|
||||
.array(),
|
||||
meta: z.object({
|
||||
total: z.number()
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -360,8 +363,15 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
...req.query
|
||||
});
|
||||
|
||||
const count = await server.services.superAdmin.countIdentities({
|
||||
...req.query
|
||||
});
|
||||
|
||||
return {
|
||||
identities
|
||||
identities,
|
||||
meta: {
|
||||
total: count
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,5 +60,26 @@ export const identityDALFactory = (db: TDbClient) => {
|
||||
}
|
||||
};
|
||||
|
||||
return { ...identityOrm, getTrustedIpsByAuthMethod, getIdentitiesByFilter };
|
||||
const countIdentitiesByFilter = async ({ searchTerm }: { searchTerm: string }) => {
|
||||
interface CountResult {
|
||||
count: string;
|
||||
}
|
||||
try {
|
||||
const count = await db
|
||||
.replicaNode()(TableName.Identity)
|
||||
.where((qb) => {
|
||||
if (searchTerm) {
|
||||
void qb.whereILike(`${TableName.Identity}.name`, `%${searchTerm}%`);
|
||||
}
|
||||
})
|
||||
.count("*")
|
||||
.first();
|
||||
|
||||
return parseInt((count as unknown as CountResult).count || "0", 10);
|
||||
} catch (error) {
|
||||
throw new DatabaseError({ error, name: "Count identities by filter" });
|
||||
}
|
||||
};
|
||||
|
||||
return { ...identityOrm, getTrustedIpsByAuthMethod, getIdentitiesByFilter, countIdentitiesByFilter };
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
TAdminGetUsersDTO,
|
||||
TAdminIntegrationConfig,
|
||||
TAdminSignUpDTO,
|
||||
TCountIdentitiesDTO,
|
||||
TCountOrganizationsDTO,
|
||||
TCreateOrganizationDTO,
|
||||
TGetOrganizationsDTO,
|
||||
@@ -1037,6 +1038,13 @@ export const superAdminServiceFactory = ({
|
||||
}));
|
||||
};
|
||||
|
||||
const countIdentities = async ({ searchTerm }: TCountIdentitiesDTO) => {
|
||||
const count = await identityDAL.countIdentitiesByFilter({
|
||||
searchTerm
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
const grantServerAdminAccessToUser = async (userId: string) => {
|
||||
if (!licenseService.onPremFeatures?.instanceUserManagement) {
|
||||
throw new BadRequestError({
|
||||
@@ -1145,6 +1153,7 @@ export const superAdminServiceFactory = ({
|
||||
getUsers,
|
||||
deleteUser,
|
||||
getIdentities,
|
||||
countIdentities,
|
||||
getAdminIntegrationsConfig,
|
||||
updateRootEncryptionStrategy,
|
||||
getConfiguredEncryptionStrategies,
|
||||
|
||||
@@ -38,6 +38,10 @@ export type TCountOrganizationsDTO = {
|
||||
searchTerm: string;
|
||||
};
|
||||
|
||||
export type TCountIdentitiesDTO = {
|
||||
searchTerm: string;
|
||||
};
|
||||
|
||||
export type TCreateOrganizationDTO = {
|
||||
name: string;
|
||||
inviteAdminEmails: string[];
|
||||
|
||||
Reference in New Issue
Block a user