data size upload limit
This commit is contained in:
parent
c3e7e64498
commit
b190387fc3
4 changed files with 24 additions and 3 deletions
|
|
@ -63,7 +63,8 @@
|
||||||
(click)="targetChatUser($event)"
|
(click)="targetChatUser($event)"
|
||||||
></app-small-btn>
|
></app-small-btn>
|
||||||
<!-- Warning message -->
|
<!-- Warning message -->
|
||||||
@if (downloadFilesService.uploadFiles.length >= 1){
|
@if (downloadFilesService.uploadFiles.length >= 1 && !fileDataError &&
|
||||||
|
!fileSizeError){
|
||||||
<p class="warningMessage">
|
<p class="warningMessage">
|
||||||
{{ "channel-msg-box.text0" | translate }}
|
{{ "channel-msg-box.text0" | translate }}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -71,6 +72,10 @@
|
||||||
<p class="warningMessage">
|
<p class="warningMessage">
|
||||||
{{ "channel-msg-box.text1" | translate }}
|
{{ "channel-msg-box.text1" | translate }}
|
||||||
</p>
|
</p>
|
||||||
|
} @if(fileSizeError){
|
||||||
|
<p class="warningMessage">
|
||||||
|
{{ "channel-msg-box.text2" | translate }}
|
||||||
|
</p>
|
||||||
}
|
}
|
||||||
<div class="filteredElementWindow">
|
<div class="filteredElementWindow">
|
||||||
@if (toggleBoolean.selectUserInMsgBox) {
|
@if (toggleBoolean.selectUserInMsgBox) {
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ export class ChatMsgBoxComponent {
|
||||||
|
|
||||||
hasFile: boolean = false;
|
hasFile: boolean = false;
|
||||||
fileDataError: boolean = false;
|
fileDataError: boolean = false;
|
||||||
|
fileSizeError: boolean = false;
|
||||||
currentFiles!: FileList;
|
currentFiles!: FileList;
|
||||||
getFileIcons = [
|
getFileIcons = [
|
||||||
'./assets/img/documentIcon.svg',
|
'./assets/img/documentIcon.svg',
|
||||||
|
|
@ -104,9 +105,11 @@ export class ChatMsgBoxComponent {
|
||||||
onFileChange(event: any) {
|
onFileChange(event: any) {
|
||||||
if (this.downloadFilesService.uploadFiles.length < 1) {
|
if (this.downloadFilesService.uploadFiles.length < 1) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
const icon = this.checkIcon({ type: file.type });
|
const fileIcon = this.checkIcon({ type: file.type });
|
||||||
if (icon !== null) {
|
const fileSize = this.checkFileSize(file.size);
|
||||||
|
if (fileIcon !== null && fileIcon && fileSize) {
|
||||||
this.fileDataError = false;
|
this.fileDataError = false;
|
||||||
|
this.fileSizeError = false;
|
||||||
this.currentFiles = event.target.files;
|
this.currentFiles = event.target.files;
|
||||||
this.hasFile = this.currentFiles.length > 0;
|
this.hasFile = this.currentFiles.length > 0;
|
||||||
if (this.currentFiles) {
|
if (this.currentFiles) {
|
||||||
|
|
@ -115,12 +118,23 @@ export class ChatMsgBoxComponent {
|
||||||
this.downloadFilesService.uploadFiles.push(fileInfo);
|
this.downloadFilesService.uploadFiles.push(fileInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (fileIcon) {
|
||||||
|
this.fileSizeError = true;
|
||||||
} else {
|
} else {
|
||||||
this.fileDataError = true;
|
this.fileDataError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkFileSize(fileSize: number): boolean {
|
||||||
|
const maxSizeInBytes = 1 * 1024 * 1024; // Maximum file size of 1 MB
|
||||||
|
if (fileSize <= maxSizeInBytes) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the file type and returns the corresponding icon.
|
* Checks the file type and returns the corresponding icon.
|
||||||
* Img (1): PNG, GIF, JPG, JPEG
|
* Img (1): PNG, GIF, JPG, JPEG
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@
|
||||||
"channel-msg-box": {
|
"channel-msg-box": {
|
||||||
"text0": "Maximal eine Datei pro Nachricht",
|
"text0": "Maximal eine Datei pro Nachricht",
|
||||||
"text1": "Dieses Dateiformat ist ungültig",
|
"text1": "Dieses Dateiformat ist ungültig",
|
||||||
|
"text2": "Dateigröße max. 1 MB",
|
||||||
"placeholder": "Geben Sie Ihre Nachricht ein"
|
"placeholder": "Geben Sie Ihre Nachricht ein"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@
|
||||||
"channel-msg-box": {
|
"channel-msg-box": {
|
||||||
"text0": "Maximum one file per message",
|
"text0": "Maximum one file per message",
|
||||||
"text1": "This file format is invalid",
|
"text1": "This file format is invalid",
|
||||||
|
"text2": "File size max. 1 MB",
|
||||||
"placeholder": "Enter your message"
|
"placeholder": "Enter your message"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue