fix commissioning

This commit is contained in:
hannathkadher
2025-04-21 10:58:14 +04:00
parent c677be400c
commit ed3c526efd
11 changed files with 214 additions and 64 deletions
+10 -2
View File
@@ -5,6 +5,7 @@ import {
Delete,
Get,
Header,
HttpStatus,
Param,
Post,
Put,
@@ -12,6 +13,7 @@ import {
Res,
UseGuards,
} from '@nestjs/common';
import { Response } from 'express';
import {
ApiBearerAuth,
ApiOperation,
@@ -115,7 +117,13 @@ export class ProjectController {
@Param() params: GetProjectParam,
@Res() res: Response,
): Promise<void> {
const csvStream = await this.projectService.exportToCsv(params);
csvStream.pipe(res as unknown as NodeJS.WritableStream);
try {
const csvStream = await this.projectService.exportToCsv(params);
csvStream.pipe(res as unknown as NodeJS.WritableStream);
} catch (error) {
res
.status(error.status || HttpStatus.INTERNAL_SERVER_ERROR)
.json({ message: error.message || 'Failed to generate CSV file.' });
}
}
}
+18 -21
View File
@@ -254,17 +254,16 @@ export class ProjectService {
const stream = new PassThrough();
const csvStream = format({
headers: [
'Project Name',
'Project UUID',
'Device ID',
'Community Name',
'Community UUID',
'Space Location',
'Space Name',
'Space UUID',
'Space Location',
'Subspace Name',
'Subspace UUID',
'Tag',
'Tag Product Name',
'Product Name',
'Community UUID',
'Space UUID',
'Subspace UUID',
],
});
@@ -306,17 +305,16 @@ export class ProjectService {
for (const productAllocation of subspace.productAllocations || []) {
for (const tag of productAllocation.tags || []) {
csvStream.write({
'Project Name': project.name,
'Project UUID': project.uuid,
'Device ID': '',
'Community Name': space.community?.name || '',
'Community UUID': space.community?.uuid || '',
'Space Location': spaceLocation,
'Space Name': space.spaceName,
'Space UUID': space.uuid,
'Space Location': spaceLocation,
'Subspace Name': subspace.subspaceName || '',
'Subspace UUID': subspace.uuid,
Tag: tag.name,
'Tag Product Name': productAllocation.product.name || '',
'Product Name': productAllocation.product.name || '',
'Community UUID': space.community?.uuid || '',
'Space UUID': space.uuid,
'Subspace UUID': subspace.uuid,
});
}
}
@@ -325,17 +323,16 @@ export class ProjectService {
for (const productAllocation of space.productAllocations || []) {
for (const tag of productAllocation.tags || []) {
csvStream.write({
'Project Name': project.name,
'Project UUID': project.uuid,
'Device ID': '',
'Community Name': space.community?.name || '',
'Community UUID': space.community?.uuid || '',
'Space Location': spaceLocation,
'Space Name': space.spaceName,
'Space UUID': space.uuid,
'Space Location': spaceLocation,
'Subspace Name': '',
'Subspace UUID': '',
Tag: tag.name,
'Tag Product Name': productAllocation.product.name || '',
'Product Name': productAllocation.product.name || '',
'Community UUID': space.community?.uuid || '',
'Space UUID': space.uuid,
'Subspace UUID': '',
});
}
}