add optinal apps

This commit is contained in:
keyhan
2026-04-23 15:26:49 +03:30
parent f481a57d8f
commit 38748b0827
16 changed files with 3091 additions and 144 deletions
@@ -136,6 +136,50 @@ export class ApplicationsController {
return result;
}
@Get(':id/storage')
@ApiOperation({ summary: 'Get comprehensive storage usage (database + app storage)' })
async getStorageUsage(@Param('id') id: string, @Request() req: any) {
const isStaff = req.user.role === UserRole.ADMIN || req.user.role === UserRole.TECHNICAL;
const app = await this.applicationsService.findOne(id, isStaff ? undefined : req.user.id);
const usage = await this.kubernetesService.getStorageUsage(app);
return {
applicationId: app.id,
applicationName: app.name,
...usage,
// Configured sizes from entity
configured: {
dbStorageSize: app.dbStorageSize || '1Gi',
appStorageSize: app.appStorageSize || '2Gi',
},
};
}
@Patch(':id/app-storage')
@ApiOperation({ summary: 'Resize (expand) app storage PVC' })
async resizeAppStorage(
@Param('id') id: string,
@Request() req: any,
@Body() body: { size: string },
) {
const isStaff = req.user.role === UserRole.ADMIN || req.user.role === UserRole.TECHNICAL;
const app = await this.applicationsService.findOne(id, isStaff ? undefined : req.user.id);
if (!body.size || !/^\d+Gi$/.test(body.size)) {
throw new BadRequestException('Size must be in format like "2Gi", "5Gi", "10Gi"');
}
const result = await this.kubernetesService.resizeAppStoragePvc(app, body.size);
if (result.success) {
// Update the saved size in the DB
await this.applicationsService.update(id, app.userId, { appStorageSize: body.size } as any);
}
return result;
}
@Get()
@ApiOperation({ summary: 'List my applications' })
async findAll(@Request() req: any) {