fix progress attempt

This commit is contained in:
Timo 2020-12-03 11:00:33 +02:00
parent 77861eb510
commit eb63ec6895

View File

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { ApplicationRef, Injectable } from '@angular/core';
import { FileUploadModel } from './model/file-upload.model';
import { AppStateService } from '../state/app-state.service';
import { HttpEventType } from '@angular/common/http';
@ -16,7 +16,11 @@ export class FileUploadService {
private _pendingUploads: FileUploadModel[] = [];
private _activeUploads: Subscription[] = [];
constructor(private readonly _appStateService: AppStateService, private readonly _fileManagementControllerService: FileManagementControllerService) {
constructor(
private readonly _appStateService: AppStateService,
private readonly _applicationRef: ApplicationRef,
private readonly _fileManagementControllerService: FileManagementControllerService
) {
interval(2500).subscribe((val) => {
this._handleUploads();
});
@ -69,6 +73,7 @@ export class FileUploadService {
async (event) => {
if (event.type === HttpEventType.UploadProgress) {
uploadFile.progress = Math.round((event.loaded / (event.total || event.loaded)) * 100);
this._applicationRef.tick();
}
if (event.type === HttpEventType.Response) {
if (event.status < 300) {