Skip to content

fix: improve UI #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.table-container {
max-height: 400px;
max-height: 350px;
overflow-y: auto;
}

4 changes: 2 additions & 2 deletions apps/portal/src/app/features/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class FileService {
private graphqlService: GraphqlService,
private apollo: Apollo,
) {
this.jobIdsSubject.next(JSON.parse(localStorage.getItem('jobIds') || '[]'));
this.jobIdsSubject.next(JSON.parse(sessionStorage.getItem('jobIds') || '[]'));
}

updateJobIds(jobId: number): void {
const jobIds = [...this.jobIdsSubject.value, jobId];
localStorage.setItem('jobIds', JSON.stringify(jobIds));
sessionStorage.setItem('jobIds', JSON.stringify(jobIds));
this.jobIdsSubject.next(jobIds);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<div class="main flex justify-content-center mt-5">
<div class="transcript-analyzer">
<div class="buttons flex flex-column align-items-center mb-3">
<input
type="file"
#fileInput
style="display: none"
(change)="onFileSelected($event)"
accept=".vtt,.txt"
/>
<p-button (click)="fileInput.click()" severity="success">{{
'TRANSCRIPT.BUTTONS.UPLOAD' | translate
}}</p-button>
<span *ngIf="selectedFileName" class="file-name text-base">{{ selectedFileName }}</span>
<span *ngIf="limitError" class="error">{{ 'TRANSCRIPT.ERRORS.FILE_SIZE' | translate }}</span>
<span *ngIf="invalidTypeError" class="error">{{
'TRANSCRIPT.ERRORS.FILE_TYPE' | translate
}}</span>
<div class="transcript-analyzer mt-3 p-6 border-round-xl">
<p-fileUpload
name="file"
[url]="''"
accept=".vtt,.txt"
(onSelect)="onFileSelected($event)"
[maxFileSize]="maxFileSize"
[auto]="true"
chooseLabel="{{ 'TRANSCRIPT.BUTTONS.CHOOSE' | translate }}"
styleClass="mb-4 text-center"
></p-fileUpload>
<div class="flex flex-column align-items-center mb-3">
<p-button (click)="summarizeTranscript()">{{
'TRANSCRIPT.BUTTONS.SUMMARIZE' | translate
}}</p-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@ body {
height: 90vh;

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

button {
margin: 30px 0;
}

.file-name {
bottom: 70%;
color: #333;
}
}

.error {
bottom: 70%;
color: red;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,20 @@ export class TranscriptAnalyzerComponent {
this.translate.setDefaultLang('en');
}

fileType = '';

limitError = false;

invalidTypeError = false;

maxFileSize: number = 10 * 1024 * 1024; // 10 MB

selectedFileName = '';

selectedFile: File | null = null;

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

if (file) {
if (!this.isValidFileType(file)) {
this.limitError = false;
this.invalidTypeError = true;
this.selectedFileName = '';
this.selectedFile = null;
} else if (!this.isValidFileSize(file)) {
this.invalidTypeError = false;
this.limitError = true;
this.selectedFileName = '';
this.selectedFile = null;
} else {
this.selectedFileName = file.name;
this.limitError = false;
this.invalidTypeError = false;
this.selectedFile = file;
}
this.selectedFile = file;
}
}

isValidFileType(file: File): boolean {
this.fileType = file.type;
return this.fileType === 'text/plain' || this.fileType === 'text/vtt';
}

isValidFileSize(file: File): boolean {
return file.size <= this.maxFileSize;
}

// eslint-disable-next-line
summarizeTranscript(): void {
// eslint-disable-next-line
Expand All @@ -85,9 +54,9 @@ export class TranscriptAnalyzerComponent {
const jobId = result?.data?.createSummary?.jobId;

if (jobId) {
const jobIdsArray = JSON.parse(localStorage.getItem('jobIds') || '[]');
const jobIdsArray = JSON.parse(sessionStorage.getItem('jobIds') || '[]');
jobIdsArray.push(jobId);
localStorage.setItem('jobIds', JSON.stringify(jobIdsArray));
sessionStorage.setItem('jobIds', JSON.stringify(jobIdsArray));
this.fileService.updateJobIds(jobId);
}
},
Expand Down
1 change: 1 addition & 0 deletions apps/portal/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"FILE_UPLOAD": "File upload failed. Please try again."
},
"BUTTONS": {
"CHOOSE": "Choose File",
"UPLOAD": "Upload File",
"SUMMARIZE": "Summarize Me"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portal</title>
<title>Transcript Summarization</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
Expand Down