Spinner on bulk actions

This commit is contained in:
Adina Țeudan 2021-01-08 21:51:51 +02:00
parent 958ee02f07
commit 80bd667d04
2 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,4 @@
<ng-container *ngIf="areSomeFilesSelected">
<ng-container *ngIf="areSomeFilesSelected && !loading">
<redaction-circle-button
(action)="delete()"
*ngIf="canDelete"
@ -55,3 +55,7 @@
icon="red:refresh"
></redaction-circle-button>
</ng-container>
<ng-container *ngIf="loading">
<mat-spinner diameter="15"></mat-spinner>
</ng-container>

View File

@ -17,6 +17,7 @@ import { computerize } from '../../../utils/functions';
export class BulkActionsComponent {
@Input() selectedFileIds: string[];
@Output() private reload = new EventEmitter();
public loading = false;
constructor(
private readonly _appStateService: AppStateService,
@ -57,23 +58,29 @@ export class BulkActionsComponent {
}
public delete() {
this.loading = true;
this._dialogService.openDeleteFilesDialog(null, this._appStateService.activeProject.project.projectId, this.selectedFileIds, () => {
this.reload.emit();
this.loading = false;
this.selectedFileIds.splice(0, this.selectedFileIds.length);
});
}
public assign() {
this.loading = true;
this._dialogService.openBulkAssignFileReviewerDialog(this.selectedFileIds, () => {
this.reload.emit();
this.loading = false;
});
}
public async reanalyse() {
this.loading = true;
const fileIds = this.selectedFiles.filter((file) => this._permissionsService.fileRequiresReanalysis(file)).map((file) => file.fileId);
await this._reanalysisControllerService.reanalyzeFilesForProject(fileIds, this._appStateService.activeProject.projectId).toPromise();
this.reload.emit();
this.loading = false;
}
// Under review
@ -82,10 +89,13 @@ export class BulkActionsComponent {
}
public setToUnderReview() {
this.loading = true;
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileUnderReview(file).toPromise());
Promise.all(promises).then(() => {
this.reload.emit();
this.loading = false;
});
}
@ -95,10 +105,12 @@ export class BulkActionsComponent {
}
public setToUnderApproval() {
this.loading = true;
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileUnderApproval(file).toPromise());
Promise.all(promises).then(() => {
this.reload.emit();
this.loading = false;
});
}
@ -108,10 +120,12 @@ export class BulkActionsComponent {
}
public approveDocuments() {
this.loading = true;
const promises = this.selectedFiles.map((file) => this._fileActionService.setFileApproved(file).toPromise());
Promise.all(promises).then(() => {
this.reload.emit();
this.loading = false;
});
}
@ -122,10 +136,12 @@ export class BulkActionsComponent {
// Bulk Download
downloadRedactedFiles() {
this.loading = true;
this._fileManagementControllerService
.downloadRedactedFiles({ fileIds: this.selectedFiles.map((file) => file.fileId) }, this._appStateService.activeProjectId, false, 'response')
.subscribe((data) => {
download(data, 'redacted_files_' + computerize(this._appStateService.activeProject.name) + '.zip');
this.loading = false;
});
}