Skip to content

Commit b3a2e44

Browse files
authored
Merge pull request #2467 from intersective/prerelease
Hotfix 2.4.5.1
2 parents 5676a36 + b3c9e11 commit b3a2e44

3 files changed

Lines changed: 20 additions & 27 deletions

File tree

projects/v3/src/app/components/file-upload/file-upload.component.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UppyUploaderService } from './../uppy-uploader/uppy-uploader.service';
1+
import { UppyUploaderService, ALLOWED_FILE_TYPES } from './../uppy-uploader/uppy-uploader.service';
22
import { Component, ElementRef, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
33
import { AbstractControl } from '@angular/forms';
44
import { Subject } from 'rxjs';
@@ -10,14 +10,6 @@ import { DashboardOptions } from '@uppy/dashboard';
1010
type FileMetadata = { [key: string]: any };
1111
type FileBody = { [key: string]: any };
1212

13-
const ALLOWED_FILE_TYPES = [
14-
'image/*',
15-
'video/*',
16-
'.jpeg',
17-
'.png',
18-
'application/pdf',
19-
];
20-
2113
const UPPY_PROPS: DashboardOptions<any, any> = {
2214
inline: true,
2315
width: '100%',

projects/v3/src/app/components/uppy-uploader/uppy-uploader.component.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { UppyFileData, UppyUploaderService } from './uppy-uploader.service';
1+
import { UppyFileData, UppyUploaderService, ALLOWED_FILE_TYPES } from './uppy-uploader.service';
22
import { environment } from '@v3/environments/environment';
33
import { NotificationsService } from './../../services/notifications.service';
44
import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core';
55
import { Uppy, UppyFile, UppyOptions, } from '@uppy/core';
66
import { ModalController } from '@ionic/angular';
77
import { BrowserStorageService } from '../../services/storage.service';
8-
import { UtilsService } from '../../services/utils.service';
98

109
type FileMetadata = { [key: string]: any };
1110
type FileBody = { [key: string]: any };
@@ -18,13 +17,6 @@ type FileBody = { [key: string]: any };
1817
export class UppyUploaderComponent implements OnInit, OnDestroy {
1918
@Input() source!: "chat" | "profile" | "assessment" | "any" | "video" | "document" | "image";
2019
@Input() tusEndpoint?: string = environment.uppyConfig.tusUrl; // tusUrl
21-
@Input() allowedFileTypes: string[] = [
22-
"image/*",
23-
"video/*",
24-
".jpeg",
25-
".png",
26-
"application/pdf",
27-
];
2820
@Output() uploadComplete = new EventEmitter<any>();
2921

3022
uploadedFile: UppyFile<any, any> | null = null;
@@ -44,7 +36,6 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
4436
private modalController: ModalController,
4537
private storageService: BrowserStorageService,
4638
private uppyUploaderService: UppyUploaderService,
47-
private utils: UtilsService,
4839
) {
4940
this.uppyProps.height = '500px';
5041
this.uppyProps.note = "Upload a file here";
@@ -59,13 +50,11 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
5950
throw new Error("source is required.");
6051
}
6152

62-
this.allowedFileTypes = this.loadAllowedFileTypes();
63-
6453
this.uppy = this.uppyUploaderService.createUppyInstance(this.source, this.tusEndpoint, {
6554
onAfterResponse: this.onAfterResponse.bind(this),
6655
onUploadSuccess: this.onUploadSuccess.bind(this),
6756
}, {
68-
allowedFileTypes: this.allowedFileTypes,
57+
allowedFileTypes: this.loadAllowedFileTypes(),
6958
});
7059
}
7160

@@ -85,11 +74,7 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
8574
case "chat":
8675
case "any":
8776
default:
88-
return [
89-
"image/*",
90-
"video/*",
91-
"application/*"
92-
];
77+
return ALLOWED_FILE_TYPES;
9378
}
9479
}
9580

projects/v3/src/app/components/uppy-uploader/uppy-uploader.service.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ const UPPY_PROPS = {
7373
doneButtonHandler: null,
7474
};
7575

76+
export const ALLOWED_FILE_TYPES = [
77+
'image/*',
78+
'video/*',
79+
'.jpeg',
80+
'.png',
81+
'application/pdf',
82+
'text/plain', // .txt
83+
'text/csv', // .csv
84+
'application/msword', // .doc
85+
'application/vnd.ms-excel', // .xls
86+
'application/vnd.ms-powerpoint', // .ppt
87+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx
88+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx
89+
'application/vnd.openxmlformats-officedocument.presentationml.presentation', // .pptx
90+
];
91+
7692
@Injectable({
7793
providedIn: 'root'
7894
})

0 commit comments

Comments
 (0)