mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 04:07:54 +00:00
fix commissioning
This commit is contained in:
@@ -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.' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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': '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user