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:
keyhan
2026-04-06 14:43:46 +03:30
parent a64f8407b9
commit 8243ac7df2
5 changed files with 281 additions and 15 deletions
@@ -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> {