Skip to content

Commit 3294a69

Browse files
committed
feat: Enhance report model and service to include original filename and file size, update frontend components for improved file metadata display
1 parent a545dcf commit 3294a69

File tree

7 files changed

+69
-16
lines changed

7 files changed

+69
-16
lines changed

backend/src/reports/models/report.model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export class Report {
6060
@ApiProperty({ description: 'File path of the report' })
6161
filePath: string;
6262

63+
@ApiProperty({ description: 'Original filename of the uploaded file' })
64+
originalFilename: string;
65+
66+
@ApiProperty({ description: 'File size in bytes' })
67+
fileSize: number;
68+
6369
@ApiProperty({ description: 'Creation timestamp' })
6470
createdAt: string;
6571

backend/src/reports/reports.controller.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,28 @@ export class ReportsController {
157157
type: 'string',
158158
description: 'S3 file path for the report',
159159
},
160+
originalFilename: {
161+
type: 'string',
162+
description: 'Original filename of the uploaded file',
163+
},
164+
fileSize: {
165+
type: 'number',
166+
description: 'Size of the file in bytes',
167+
},
160168
},
161169
required: ['filePath'],
162170
},
163-
description: 'S3 file path for the report',
171+
description: 'S3 file path and metadata for the report',
164172
})
165173
@Post()
166174
async createReport(
167175
@Body('filePath') filePath: string,
176+
@Body('originalFilename') originalFilename: string,
177+
@Body('fileSize') fileSize: number,
168178
@Req() request: RequestWithUser,
169179
): Promise<Report> {
170180
const userId = this.extractUserId(request);
171-
return this.reportsService.saveReport(filePath, userId);
181+
return this.reportsService.saveReport(filePath, userId, originalFilename, fileSize);
172182
}
173183

174184
private extractUserId(request: RequestWithUser): string {

backend/src/reports/reports.service.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,20 @@ export class ReportsService {
282282
}
283283
}
284284

285-
async saveReport(filePath: string, userId: string): Promise<Report> {
285+
/**
286+
* Save a new report to DynamoDB
287+
* @param filePath S3 object path of the uploaded file
288+
* @param userId User ID of the report owner
289+
* @param originalFilename Original filename of the uploaded file
290+
* @param fileSize Size of the file in bytes
291+
* @returns The saved report
292+
*/
293+
async saveReport(
294+
filePath: string,
295+
userId: string,
296+
originalFilename: string = 'Unknown filename',
297+
fileSize: number = 0,
298+
): Promise<Report> {
286299
if (!filePath) {
287300
throw new NotFoundException('File URL is required');
288301
}
@@ -296,6 +309,8 @@ export class ReportsService {
296309
id: uuidv4(),
297310
userId,
298311
filePath,
312+
originalFilename,
313+
fileSize,
299314
title: 'New Report',
300315
bookmarked: false,
301316
category: '',

frontend/src/common/api/reportService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export const uploadReport = async (
7575
`${API_URL}/api/reports`,
7676
{
7777
filePath: s3Key,
78+
originalFilename: file.name,
79+
fileSize: file.size,
7880
},
7981
config,
8082
);

frontend/src/common/models/medicalReport.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export interface MedicalReport {
5353
summary: string;
5454
status: ReportStatus;
5555
filePath: string;
56+
originalFilename: string;
57+
fileSize: number;
5658
createdAt: string; // ISO date string
5759
updatedAt: string; // ISO date string
5860
}

frontend/src/pages/Reports/ReportDetailPage.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,28 +551,28 @@
551551
}
552552

553553
&__comments-section {
554-
background-color: #ebecfd;
555-
opacity: 0.9;
554+
background-color: #F0F2FF;
556555
border-radius: 16px;
557-
padding: 16px;
556+
padding: 24px;
558557
margin-bottom: 16px;
559558
}
560559

561560
&__comments-title {
562561
font-family: 'Inter', sans-serif;
563-
font-size: 13px;
562+
font-size: 18px;
564563
font-weight: 600;
565-
color: #313e4c;
566-
margin: 0 0 8px 0;
564+
color: #313E4C;
565+
margin: 0 0 12px 0;
567566
letter-spacing: 0.26px;
568567
}
569568

570569
&__comments-text {
571570
font-family: 'Inter', sans-serif;
572-
font-size: 13px;
573-
color: #313e4c;
574-
line-height: 20px;
571+
font-size: 16px;
572+
color: #313E4C;
573+
line-height: 24px;
575574
margin: 0;
575+
font-weight: 400;
576576
}
577577

578578
&__uploaded-file {

frontend/src/pages/Reports/components/OriginalReport.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ interface OriginalReportProps {
88
}
99

1010
const OriginalReport: React.FC<OriginalReportProps> = ({ reportData }) => {
11+
// Function to format file size in KB or MB
12+
const formatFileSize = (bytes: number): string => {
13+
if (bytes < 1024) return bytes + ' B';
14+
else if (bytes < 1048576) return Math.round(bytes / 1024) + ' KB';
15+
else return (bytes / 1048576).toFixed(1) + ' MB';
16+
};
17+
18+
// Get filename from originalFilename or fall back to file path
19+
const filename =
20+
reportData.originalFilename || reportData.filePath.split('/').pop() || 'Unknown file';
21+
22+
// Format file size if available
23+
const fileSize = reportData.fileSize ? formatFileSize(reportData.fileSize) : 'Unknown size';
24+
1125
return (
1226
<div className="report-detail-page__original-report">
1327
{/* Test results table */}
@@ -45,6 +59,12 @@ const OriginalReport: React.FC<OriginalReportProps> = ({ reportData }) => {
4559
))}
4660
</div>
4761

62+
{/* Medical Comments Section */}
63+
<div className="report-detail-page__comments-section">
64+
<h4 className="report-detail-page__comments-title">Medical Comments:</h4>
65+
<div className="report-detail-page__comments-text">{reportData.summary}</div>
66+
</div>
67+
4868
{/* Uploaded File Section */}
4969
<div className="report-detail-page__uploaded-file">
5070
<h4 className="report-detail-page__uploaded-file-title">Uploaded file</h4>
@@ -53,11 +73,9 @@ const OriginalReport: React.FC<OriginalReportProps> = ({ reportData }) => {
5373
<Icon icon="filePdf" />
5474
</div>
5575
<div className="report-detail-page__file-details">
56-
<div className="report-detail-page__file-name">
57-
{reportData.filePath.split('/').pop() || 'Exam_11_01_2024.pdf'}
58-
</div>
76+
<div className="report-detail-page__file-name">{filename}</div>
5977
<div className="report-detail-page__file-info">
60-
<span className="report-detail-page__file-size">92 kb</span>
78+
<span className="report-detail-page__file-size">{fileSize}</span>
6179
<span className="report-detail-page__file-separator"></span>
6280
<span className="report-detail-page__file-date">
6381
Uploaded ({format(new Date(reportData.createdAt), 'MM/dd/yyyy')})

0 commit comments

Comments
 (0)