Merge branch 'VM/RED-8363' into 'master'
RED-8363 - UI should reject unsupported file types directly based on license Closes RED-8363 See merge request redactmanager/red-ui!312
This commit is contained in:
commit
f3222a70ed
@ -9,4 +9,5 @@ export enum LicenseFeatures {
|
||||
PDFTRON = 'pdftron',
|
||||
ANALYSIS_CAPACITY_BYTES = 'analysisCapacityBytes',
|
||||
RETENTION_CAPACITY_BYTES = 'retentionCapacityBytes',
|
||||
SUPPORT_MS_OFFICE_FORMATS = 'supportMSOfficeFormats',
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { interval, Subject, Subscription } from 'rxjs';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { IFileUploadResult, OverwriteFileOption, OverwriteFileOptions } from '@red/domain';
|
||||
import { isAcceptedFileType, isCsv, isZip } from '@utils/file-drop-utils';
|
||||
import { isAcceptedFileType, isCsv, isDocument, isZip } from '@utils/file-drop-utils';
|
||||
import { ErrorMessageService, GenericService, Toaster } from '@iqser/common-ui';
|
||||
import { FilesMapService } from '@services/files/files-map.service';
|
||||
import { switchMap, tap, throttleTime } from 'rxjs/operators';
|
||||
@ -13,6 +13,8 @@ import { FilesService } from '@services/files/files.service';
|
||||
import { UploadDownloadDialogService } from './upload-download-dialog.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { HeadersConfiguration } from '@iqser/common-ui/lib/utils';
|
||||
import { LicenseService } from '@services/license.service';
|
||||
import { LicenseFeatures } from '../../admin/screens/license/utils/constants';
|
||||
|
||||
export interface ActiveUpload {
|
||||
subscription: Subscription;
|
||||
@ -39,6 +41,7 @@ export class FileUploadService extends GenericService<IFileUploadResult> impleme
|
||||
private readonly _configService: ConfigService,
|
||||
private readonly _dialogService: UploadDownloadDialogService,
|
||||
private readonly _errorMessageService: ErrorMessageService,
|
||||
private readonly _licenseService: LicenseService,
|
||||
private readonly _toaster: Toaster,
|
||||
) {
|
||||
super();
|
||||
@ -72,6 +75,7 @@ export class FileUploadService extends GenericService<IFileUploadResult> impleme
|
||||
const maxSizeMB = this._configService.values.MAX_FILE_SIZE_MB;
|
||||
const maxSizeBytes = maxSizeMB * 1024 * 1024;
|
||||
const dossierFiles = this._filesMapService.get(dossierId);
|
||||
const supportMsOfficeFormats = this._licenseService.getFeature(LicenseFeatures.SUPPORT_MS_OFFICE_FORMATS)?.value as boolean;
|
||||
let option: OverwriteFileOption = localStorage.getItem('overwriteFileOption') as OverwriteFileOption;
|
||||
for (let idx = 0; idx < files.length; ++idx) {
|
||||
const file = files[idx];
|
||||
@ -115,7 +119,7 @@ export class FileUploadService extends GenericService<IFileUploadResult> impleme
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!isAcceptedFileType(file)) {
|
||||
if (!isAcceptedFileType(file, supportMsOfficeFormats)) {
|
||||
file.completed = true;
|
||||
file.error = {
|
||||
message: this._translateService.instant('upload-status.error.file-type'),
|
||||
|
||||
@ -8,10 +8,9 @@ const validDocumentMimeTypes = [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/pdf',
|
||||
];
|
||||
|
||||
const validDocumentExtensions = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf'];
|
||||
const validDocumentExtensions = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
|
||||
|
||||
export function isPdf(file: FileUploadModel): boolean {
|
||||
return file.file.type?.toLowerCase() === 'application/pdf' || file.file.name.toLowerCase().endsWith('.pdf');
|
||||
@ -32,8 +31,8 @@ export function isDocument(file: FileUploadModel): boolean {
|
||||
|
||||
export type Files = FileList | File[];
|
||||
|
||||
export function isAcceptedFileType(file: FileUploadModel): boolean {
|
||||
return isPdf(file) || isZip(file) || isDocument(file) || isCsv(file);
|
||||
export function isAcceptedFileType(file: FileUploadModel, supportMsOfficeFormats = false): boolean {
|
||||
return isPdf(file) || isZip(file) || isCsv(file) || (isDocument(file) && supportMsOfficeFormats);
|
||||
}
|
||||
|
||||
export function convertFiles(files: FileList | File[], dossier: Dossier): FileUploadModel[] {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 42cc494e2f3ff18182198bced1320b40c8b41d5e
|
||||
Subproject commit 6f255d68b49e921ff458a59056c8bad6cede4abd
|
||||
@ -1,7 +1,7 @@
|
||||
export interface ILicenseFeature {
|
||||
readonly name: string;
|
||||
readonly type: string;
|
||||
readonly value: string;
|
||||
readonly value: string | boolean;
|
||||
}
|
||||
|
||||
export interface ILicense {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user