restricted to PDF mimetype

This commit is contained in:
Timo 2020-12-07 18:30:14 +02:00
parent 273d374063
commit ce785a7ba4
4 changed files with 14 additions and 4 deletions

View File

@ -12,7 +12,7 @@
<span translate="project-overview.upload-files-btn"></span>
</button>
<input #fileInput (change)="handleFileUploadEvent($event)" class="file-upload-input" multiple="true" type="file" />
<input #fileInput (change)="handleFileUploadEvent($event)" class="file-upload-input" multiple="true" type="file" accept="application/pdf" />
<button [routerLink]="['/ui/projects/']" mat-icon-button class="close-btn">
<mat-icon svgIcon="red:close"></mat-icon>

View File

@ -15,11 +15,11 @@ import { Router } from '@angular/router';
import { UserService } from '../user/user.service';
import { forkJoin } from 'rxjs';
import { tap } from 'rxjs/operators';
import { download } from '../utils/file-download-utils';
import { humanize } from '../utils/functions';
import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper';
import { ProjectWrapper } from './model/project.wrapper';
import { saveAs } from 'file-saver';
export interface AppState {
projects: ProjectWrapper[];
activeProjectId: string;
@ -183,11 +183,20 @@ export class AppStateService {
return activeFileWrapper;
}
private _automaticallyReanalyseErrorFiles(project: ProjectWrapper) {
project.files.forEach((file) => {
if (file.status === 'ERROR') {
this._reanalysisControllerService.reanalyzeFile(project.projectId, file.fileId).subscribe(() => {});
}
});
}
async getFiles(project?: ProjectWrapper) {
if (!project) {
project = this.activeProject;
}
const files = await this._statusControllerService.getProjectStatus(project.project.projectId).toPromise();
const oldFiles = [...project.files];
const fileStatusChangedEvent = [];
@ -217,7 +226,7 @@ export class AppStateService {
}
project.files = files.map((f) => new FileStatusWrapper(f, this._userService.getNameForId(f.currentReviewer)));
this._automaticallyReanalyseErrorFiles(project);
this._computeStats();
fileReanalysedEvent.forEach((file) => this.fileReanalysed.emit(file));

View File

@ -2,7 +2,7 @@
<ngx-dropzone (change)="handleFileInput($event.addedFiles)" class="file-drop-zone">
<ngx-dropzone-label>{{ 'project-overview.upload-files' | translate }}</ngx-dropzone-label>
</ngx-dropzone>
<input type="file" multiple hidden />
<input type="file" multiple hidden accept="application/pdf" />
<button (click)="close()" class="close-icon" mat-icon-button>
<mat-icon svgIcon="red:close"></mat-icon>

View File

@ -34,6 +34,7 @@ export class FileUploadService {
}
uploadFiles(files: FileUploadModel[]) {
files = files.filter((file) => file.file.type.toLowerCase() === 'application/pdf');
files.sort((a, b) => a.file.size - b.file.size);
this.files.push(...files);
files.forEach((newFile) => {