feat: technical role can view all applications with search, separate /all route
- Add GET /applications/all endpoint for admin/technical with search by user name/email/ID - GET /applications now always returns only the current user's apps (fix for technical seeing all apps) - Technical role can view/edit/delete any application (same as admin) - Add 'All Applications' page with search bar, user info columns, status badges - Add 'All Applications' link to admin and technical sidebar navigation - Add user relation to Application TypeScript interface
This commit is contained in:
@@ -84,11 +84,22 @@ export class ApplicationsService {
|
||||
});
|
||||
}
|
||||
|
||||
async findAll(): Promise<Application[]> {
|
||||
return this.appsRepository.find({
|
||||
relations: ['user', 'deployments'],
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
async findAll(search?: string): Promise<Application[]> {
|
||||
const qb = this.appsRepository
|
||||
.createQueryBuilder('app')
|
||||
.leftJoinAndSelect('app.user', 'user')
|
||||
.leftJoinAndSelect('app.deployments', 'deployments')
|
||||
.orderBy('app.createdAt', 'DESC');
|
||||
|
||||
if (search && search.trim()) {
|
||||
const s = `%${search.trim()}%`;
|
||||
qb.where(
|
||||
'(user.firstName ILIKE :s OR user.lastName ILIKE :s OR user.email ILIKE :s OR CAST(app.userId AS TEXT) ILIKE :s OR app.name ILIKE :s)',
|
||||
{ s },
|
||||
);
|
||||
}
|
||||
|
||||
return qb.getMany();
|
||||
}
|
||||
|
||||
async findOne(id: string, userId?: string): Promise<Application> {
|
||||
|
||||
Reference in New Issue
Block a user