reload files while uploading every 2.5 seconds

This commit is contained in:
Dan Percic 2021-11-15 16:07:37 +02:00
parent 1249e41089
commit ea07ca5b21
3 changed files with 10 additions and 16 deletions

View File

@ -41,7 +41,7 @@
<ng-container *ngIf="dossierStats$ | async as stats"> <ng-container *ngIf="dossierStats$ | async as stats">
<div *ngIf="stats.hasFiles" class="mt-24"> <div *ngIf="stats.hasFiles" class="mt-24">
<redaction-simple-doughnut-chart <redaction-simple-doughnut-chart
[config]="calculateChartConfig(stats.fileCountPerWorkflowStatus)" [config]="calculateChartConfig(stats)"
[radius]="63" [radius]="63"
[strokeWidth]="15" [strokeWidth]="15"
[subtitle]="'dossier-overview.dossier-details.charts.documents-in-dossier' | translate" [subtitle]="'dossier-overview.dossier-details.charts.documents-in-dossier' | translate"

View File

@ -6,15 +6,7 @@ import { UserService } from '@services/user.service';
import { FilterService, shareLast, Toaster } from '@iqser/common-ui'; import { FilterService, shareLast, Toaster } from '@iqser/common-ui';
import { fileStatusTranslations } from '../../../../translations/file-status-translations'; import { fileStatusTranslations } from '../../../../translations/file-status-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { import { Dossier, DossierAttributeWithValue, DossierStats, IDossierRequest, StatusSorter, User } from '@red/domain';
Dossier,
DossierAttributeWithValue,
DossierStats,
FileCountPerWorkflowStatus,
IDossierRequest,
StatusSorter,
User,
} from '@red/domain';
import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossiersService } from '@services/entity-services/dossiers.service';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@ -65,9 +57,9 @@ export class DossierDetailsComponent {
return this._userService.managerUsers.map(manager => manager.id); return this._userService.managerUsers.map(manager => manager.id);
} }
calculateChartConfig(filesCount: FileCountPerWorkflowStatus): DoughnutChartConfig[] { calculateChartConfig(stats: DossierStats): DoughnutChartConfig[] {
const documentsChartData: DoughnutChartConfig[] = Object.keys(filesCount).map(status => ({ const documentsChartData: DoughnutChartConfig[] = Object.keys(stats.fileCountPerWorkflowStatus).map(status => ({
value: filesCount[status], value: stats.fileCountPerWorkflowStatus[status],
color: status, color: status,
label: fileStatusTranslations[status], label: fileStatusTranslations[status],
key: status, key: status,

View File

@ -37,7 +37,10 @@ export class FileUploadService extends GenericService<IFileUploadResult> {
protected readonly _injector: Injector, protected readonly _injector: Injector,
) { ) {
super(_injector, 'upload'); super(_injector, 'upload');
interval(2500).subscribe(() => { interval(2500).subscribe(async () => {
if (this.activeUploads > 0) {
await this._appStateService.reloadActiveDossierFiles();
}
this._handleUploads(); this._handleUploads();
}); });
} }
@ -174,7 +177,7 @@ export class FileUploadService extends GenericService<IFileUploadResult> {
this.activeUploads++; this.activeUploads++;
const obs = this.uploadFileForm(uploadFile.dossierId, uploadFile.file); const obs = this.uploadFileForm(uploadFile.dossierId, uploadFile.file);
return obs.subscribe( return obs.subscribe(
async event => { event => {
if (event.type === HttpEventType.UploadProgress) { if (event.type === HttpEventType.UploadProgress) {
uploadFile.progress = Math.round((event.loaded / (event.total || event.loaded)) * 100); uploadFile.progress = Math.round((event.loaded / (event.total || event.loaded)) * 100);
this._applicationRef.tick(); this._applicationRef.tick();
@ -190,7 +193,6 @@ export class FileUploadService extends GenericService<IFileUploadResult> {
}; };
} }
this._removeUpload(uploadFile); this._removeUpload(uploadFile);
await this._appStateService.reloadActiveDossierFiles();
} }
}, },
(err: HttpErrorResponse) => { (err: HttpErrorResponse) => {