FEAT: Connection Details new version

This commit is contained in:
Victor Radael
2022-08-26 19:24:03 -03:00
parent 0f079a7b22
commit e94ace09d0
4 changed files with 19 additions and 29 deletions
+17 -27
View File
@@ -123,28 +123,10 @@ export class ConnectionController {
@Get('/:id')
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async getConnection(
@User() user,
@Headers('Dadosfera-Lang') language,
@Param('id') id,
): Promise<ConnectionRes> {
this.logger.info('/connections - Get Connection');
const { user_id, customer_id, customer_name } = user;
const response: any = await this.clientService.getConnection({
body: { id },
info: { user_id, customer_id, customer_name, language },
});
return response;
}
@Get('/:id/details')
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async getConnectionDetails(
@User() user,
@Param('id') id,
@Query('details') details,
): Promise<ConnectionDetailsRes> {
this.logger.info('/connections - Get Connection Details');
@@ -152,17 +134,25 @@ export class ConnectionController {
const response: any = await this.clientService.getConnectionDetails({
body: { id },
info: { user_id, customer_id, customer_name },
info: { user_id, customer_id, customer_name, details },
});
delete response.connection.user_id;
delete response.connection.customer_id;
delete response.connection.customer_name;
if (details === 'true') {
const properties = JSON.parse(response.connection.properties);
Object.assign(response.connection, {
pipelines: JSON.parse(response.connection.pipelines),
connection_controls: properties.connection_controls,
config_controls: properties.config_controls,
connection_steps: properties.connection_steps,
});
Object.assign(response.connection, {
properties: JSON.parse(response.connection.properties),
pipelines: JSON.parse(response.connection.pipelines),
});
delete response.connection.properties;
} else {
Object.assign(response.connection, {
properties: JSON.parse(response.connection.properties),
pipelines: JSON.parse(response.connection.pipelines),
});
}
return response;
}