mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-10 01:49:08 +00:00
FEAT: pii
This commit is contained in:
@@ -346,7 +346,7 @@ export class CatalogController {
|
||||
@Language() language: LanguageEnum,
|
||||
@Param('id') id: string,
|
||||
): Promise<IPreviewResponse> {
|
||||
const { customer_name, customer_id, user_id, username } = user;
|
||||
const { customer_name, customer_id, user_id, username, customer_modules } = user;
|
||||
|
||||
this.logger.info(`/catalog - ON GET DATA DOCS ROUTE`, {
|
||||
user_id,
|
||||
@@ -359,6 +359,7 @@ export class CatalogController {
|
||||
user_id,
|
||||
username,
|
||||
language,
|
||||
is_mask: customer_modules.some(mod => mod === 'pii')
|
||||
});
|
||||
|
||||
const preview = await this.catalogService.getDatasetPreview(id, metadata);
|
||||
@@ -863,15 +864,27 @@ export class CatalogController {
|
||||
@RequireModule(
|
||||
DADOSFERA_MODULES_KEYS.PII
|
||||
)
|
||||
async getPiiReporter(@User() user: RequestUser, @Res() res: Response) {
|
||||
async getPiiReporter(@User() user: RequestUser, @Res() res: Response, @Query('type') type: "html" | "csv") {
|
||||
this.logger.info('GET pii-reporter');
|
||||
const metadata = PackTheMetadata(user);
|
||||
|
||||
try {
|
||||
const reporterHtml = await this.catalogService.getPiiReporter(metadata);
|
||||
const reporter = await this.catalogService.getPiiReporter(metadata, type);
|
||||
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
return res.send(reporterHtml);
|
||||
if (type === "html") {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
} else if (type === "csv") {
|
||||
res.setHeader('Content-Type', 'text/csv');
|
||||
} else if (type === "pdf") {
|
||||
res.setHeader('Content-Type', 'application/pdf');
|
||||
}
|
||||
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const filename = `relatorio-pii-${timestamp}.${type}`;
|
||||
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
||||
|
||||
return res.send(reporter);
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user