feat: Excel export of all projects for full-access admins
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Controller, Get, Res, UseGuards } from '@nestjs/common';
|
||||
import type { Response } from 'express';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { FullAccessGuard } from '../auth/full-access.guard';
|
||||
import { ExportService } from './export.service';
|
||||
|
||||
@Controller('export')
|
||||
@UseGuards(JwtAuthGuard, FullAccessGuard)
|
||||
export class ExportController {
|
||||
constructor(private readonly exportService: ExportService) {}
|
||||
|
||||
@Get('projects.xlsx')
|
||||
async projectsXlsx(@Res() res: Response) {
|
||||
const { buffer, filename } = await this.exportService.buildWorkbook();
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
);
|
||||
res.setHeader(
|
||||
'Content-Disposition',
|
||||
`attachment; filename="${filename}"; filename*=UTF-8''${encodeURIComponent(filename)}`,
|
||||
);
|
||||
res.send(buffer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user