Skip to content

Commit 04667c7

Browse files
fix: improve UI (#24)
1 parent 58b40d6 commit 04667c7

File tree

13 files changed

+73
-84
lines changed

13 files changed

+73
-84
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
!.vscode/tasks.json
1717
!.vscode/launch.json
1818
!.vscode/extensions.json
19+
*dump.rdb

apps/api/.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Server
2-
SERVER_PORT=
2+
SERVER_PORT=3000
33

44
# Node env
5-
NODE_ENV= # Use "development" for graphql playground to work
5+
NODE_ENV=development # Use "development" for graphql playground to work
66

77
# Upload folder location
8-
UPLOAD_FOLDER_PATH= # Use uploads/ as upload folder path
8+
UPLOAD_FOLDER_PATH= # If not present will use "uploads" folder in the root cwd
99

1010
# Database configuration
1111
DB_TYPE=
12-
DB_HOST=
12+
DB_HOST=transcript-summarizer-mariadb
1313
DB_PORT=
1414
DB_USERNAME=
1515
DB_PASSWORD=
1616
DB_NAME=
1717
MARIADB_DOCKER_PORT= 3307
1818

1919
# Redis configuration
20-
REDIS_HOST=
21-
REDIS_PORT=
22-
REDIS_DOCKER_PORT=6397
20+
DB_HOST=transcript-summarizer-redis
21+
REDIS_PORT=6379
22+
REDIS_DOCKER_PORT=6379
2323

2424
OPENAI_API_KEY="sk-your api key"
2525
GPT_MODEL="gpt-4o"

apps/api/src/jobs/consumers/summary/summary.consumer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class SummaryConsumer {
4747

4848
this.logger.log(`Generating summary for job with ID: ${jobId}`);
4949
const summaryText = await this.meetingSummarizerService.generateMeetingSummary(fileContent);
50-
summary.outputText = summaryText;
50+
summary.outputText =
51+
summaryText ||
52+
'Summary could not be generated, please check if its a valid teams transcript file';
5153
// Update job status to SUCCESS
5254
summary.jobStatus = JobStatus.SUCCESS;
5355
this.logger.log(`Summary generated successfully for job with ID: ${jobId}`);

apps/api/src/modules/summary/summary.service.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import { SummaryResponse } from './dto/summary-response.dto';
1212
import { v4 as uuidv4 } from 'uuid';
1313
import { SummaryQueueProducer } from 'src/jobs/producers/summary/summary.producer';
1414
import * as fs from 'fs-extra';
15-
import { ConfigService } from '@nestjs/config';
16-
import { config } from 'dotenv';
17-
18-
config();
19-
20-
const configService = new ConfigService();
15+
import { uploadDir } from 'src/main';
2116

2217
@Injectable()
2318
export class SummaryService extends CoreService<Summary> {
@@ -40,18 +35,15 @@ export class SummaryService extends CoreService<Summary> {
4035

4136
const uniqueIdentifier = uuidv4().replace(/-/g, '').substring(0, 10);
4237
const modifiedFilename = `${uniqueIdentifier}_${filename}`;
43-
const uploadPath = configService.get('UPLOAD_FOLDER_PATH')?.replace(/[^\w\s/]/g, '') ?? null;
44-
45-
const uploadFolder = join(process.cwd(), 'uploads');
4638

47-
if (uploadPath) {
48-
const absoluteUploadPath = resolve(uploadPath);
39+
if (uploadDir) {
40+
const absoluteUploadPath = resolve(uploadDir);
4941
await fs.ensureDir(absoluteUploadPath);
5042
} else {
51-
await fs.ensureDir(uploadFolder);
43+
await fs.ensureDir(uploadDir);
5244
}
5345

54-
const fileLocation = join(uploadPath || uploadFolder, modifiedFilename);
46+
const fileLocation = join(uploadDir, modifiedFilename);
5547

5648
return new Promise((resolve, reject) => {
5749
createReadStream()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
<h1 class="mt-4 mb-6 text-center text-cyan-400 text-5xl font-semibold">
2+
{{ 'COMMON.TITLE' | translate }}
3+
</h1>
14
<router-outlet></router-outlet>
25
<p-toast key="tst"></p-toast>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.table-container {
2-
max-height: 400px;
2+
max-height: 350px;
33
overflow-y: auto;
44
}
55

apps/portal/src/app/features/file-processor/file-processor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class FileProcessorComponent implements OnInit, OnDestroy {
134134
downloadFile(summary: string | null | undefined, fileName: string): void {
135135
if (summary !== undefined && summary !== null) {
136136
const blob = new Blob([summary], { type: 'text/markdown' });
137-
FileSaver.saveAs(blob, `${fileName}.md`);
137+
FileSaver.saveAs(blob, `${fileName.replace(/\.(txt|vtt)$/i, '')}.md`);
138138
}
139139
}
140140
}

apps/portal/src/app/features/file.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export class FileService {
2121

2222
updateJobIds(jobId: number): void {
2323
const jobIds = [...this.jobIdsSubject.value, jobId];
24-
2524
sessionStorage.setItem('jobIds', JSON.stringify(jobIds));
2625
this.jobIdsSubject.next(jobIds);
2726
}

apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.html

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<div class="main flex justify-content-center mt-5">
2-
<div class="transcript-analyzer">
3-
<div class="buttons flex flex-column align-items-center mb-3">
4-
<input
5-
type="file"
6-
#fileInput
7-
style="display: none"
8-
(change)="onFileSelected($event)"
9-
accept=".vtt,.txt"
10-
/>
11-
<p-button (click)="fileInput.click()" severity="success">{{
12-
'TRANSCRIPT.BUTTONS.UPLOAD' | translate
13-
}}</p-button>
14-
<span *ngIf="selectedFileName" class="file-name text-base">{{ selectedFileName }}</span>
15-
<span *ngIf="limitError" class="error">{{ 'TRANSCRIPT.ERRORS.FILE_SIZE' | translate }}</span>
16-
<span *ngIf="invalidTypeError" class="error">{{
17-
'TRANSCRIPT.ERRORS.FILE_TYPE' | translate
18-
}}</span>
19-
<p-button (click)="summarizeTranscript()">{{
2+
<div class="transcript-analyzer mt-3 p-6 border-round-xl">
3+
<p-fileUpload
4+
name="file"
5+
[url]="''"
6+
accept=".vtt,.txt"
7+
(onSelect)="onFileSelected($event)"
8+
(onUpload)="onFileSelected($event)"
9+
[maxFileSize]="maxFileSize"
10+
(onRemove)="onRemove()"
11+
[showCancelButton]="false"
12+
[showUploadButton]="false"
13+
chooseLabel="{{ 'TRANSCRIPT.BUTTONS.CHOOSE' | translate }}"
14+
styleClass="mb-2 text-center"
15+
></p-fileUpload>
16+
<p-messages severity="info" styleClass="mb-5">
17+
<ng-template pTemplate class="flex justify-content-between">
18+
<div>{{ 'TRANSCRIPT.UPLOAD_INFO.ACCEPTED_FILE' | translate }}</div>
19+
<div class="ml-5">{{ 'TRANSCRIPT.UPLOAD_INFO.MAX_FILE_SIZE' | translate }}</div>
20+
</ng-template>
21+
</p-messages>
22+
<div class="flex flex-column align-items-center mt-3 mb-3">
23+
<p-button (click)="summarizeTranscript()" [disabled]="!selectedFile" severity="success">{{
2024
'TRANSCRIPT.BUTTONS.SUMMARIZE' | translate
2125
}}</p-button>
2226
</div>

apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.scss

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ body {
44
height: 90vh;
55

66
.transcript-analyzer {
7-
@include styleclass('flex flex-column justify-content-center align-items-center relative p-6 border-round-xl');
87
border: 3px solid #4d4dff;
98
box-shadow: 0 4px 9px rgba(0, 0, 0, 0.9);
9+
}
1010

11-
button {
12-
margin: 30px 0;
11+
.p-fileupload {
12+
.p-fileupload-filename {
13+
width: 200px;
1314
}
15+
}
1416

15-
.file-name {
16-
bottom: 70%;
17-
color: #333;
18-
}
17+
.p-fileupload-content{
18+
padding: 32px;
19+
}
20+
21+
.p-message-error{
22+
margin-bottom: 0;
1923
}
2024

21-
.error {
22-
bottom: 70%;
23-
color: red;
25+
.p-message-wrapper{
26+
display: flex;
27+
justify-content: space-around;
2428
}
2529
}

apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.ts

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,27 @@ export class TranscriptAnalyzerComponent {
1919
this.translate.setDefaultLang('en');
2020
}
2121

22-
fileType = '';
23-
24-
limitError = false;
25-
26-
invalidTypeError = false;
27-
2822
maxFileSize: number = 10 * 1024 * 1024; // 10 MB
2923

30-
selectedFileName = '';
31-
3224
selectedFile: File | null = null;
3325

3426
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3527
onFileSelected(event: any): void {
36-
const file: File = event.target.files[0];
28+
const { files } = event.originalEvent.target;
29+
const file: File = files[0];
3730

3831
if (file) {
39-
if (!this.isValidFileType(file)) {
40-
this.limitError = false;
41-
this.invalidTypeError = true;
42-
this.selectedFileName = '';
43-
this.selectedFile = null;
44-
} else if (!this.isValidFileSize(file)) {
45-
this.invalidTypeError = false;
46-
this.limitError = true;
47-
this.selectedFileName = '';
48-
this.selectedFile = null;
49-
} else {
50-
this.selectedFileName = file.name;
51-
this.limitError = false;
52-
this.invalidTypeError = false;
53-
this.selectedFile = file;
54-
}
32+
this.selectedFile = file;
5533
}
5634
}
5735

58-
isValidFileType(file: File): boolean {
59-
this.fileType = file.type;
60-
return this.fileType === 'text/plain' || this.fileType === 'text/vtt';
36+
onClear(): void {
37+
this.selectedFile = null;
6138
}
6239

63-
isValidFileSize(file: File): boolean {
64-
return file.size <= this.maxFileSize;
40+
onRemove(): void {
41+
this.selectedFile = null;
6542
}
66-
6743
// eslint-disable-next-line
6844
summarizeTranscript(): void {
6945
// eslint-disable-next-line

apps/portal/src/assets/i18n/en.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
{
2+
"COMMON": {
3+
"TITLE": "Transcript Summarizer"
4+
},
25
"ERRORS": {
36
"UNHANDLED_ERROR": "Something went wrong",
47
"API_ERROR": "Something went wrong while fetching data"
58
},
69
"TRANSCRIPT": {
10+
"UPLOAD_INFO": {
11+
"ACCEPTED_FILE": "Accepted File: .vtt, .txt",
12+
"MAX_FILE_SIZE": "Max File Size: 10.00MB"
13+
},
714
"ERRORS": {
815
"FILE_TYPE": "Please upload a VTT or TXT file only.",
916
"FILE_SIZE": "File size should not exceed 10 MB.",
1017
"NO_FILE": "Please select a file.",
1118
"FILE_UPLOAD": "File upload failed. Please try again."
1219
},
1320
"BUTTONS": {
21+
"CHOOSE": "Choose File",
1422
"UPLOAD": "Upload File",
1523
"SUMMARIZE": "Summarize Me"
1624
}

apps/portal/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<html lang="en">
44
<head>
55
<meta charset="utf-8">
6-
<title>Portal</title>
6+
<title>Transcript Summarizer</title>
77
<base href="/">
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link rel="icon" type="image/x-icon" href="favicon.ico">

0 commit comments

Comments
 (0)