mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 17:57:10 +00:00
fix the upload state not updating
This commit is contained in:
parent
f285db2b5c
commit
0d43264684
1 changed files with 12 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input, OnChanges, SimpleChanges, HostListener, PLATFORM_ID, inject } from '@angular/core';
|
import { Component, OnInit, Input, OnChanges, SimpleChanges, HostListener, PLATFORM_ID, inject, ChangeDetectorRef } from '@angular/core';
|
||||||
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
|
@ -1595,7 +1595,7 @@ export class UploadComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
private platformId = inject(PLATFORM_ID);
|
private platformId = inject(PLATFORM_ID);
|
||||||
|
|
||||||
constructor(private formService: FormService, private formPreviewService: FormPreviewService, private snackBar: MatSnackBar) {}
|
constructor(private formService: FormService, private formPreviewService: FormPreviewService, private snackBar: MatSnackBar, private cdr: ChangeDetectorRef) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
|
@ -1832,10 +1832,12 @@ export class UploadComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Upload queue processing error:', error);
|
console.error('Upload queue processing error:', error);
|
||||||
this.snackBar.open('Upload process encountered an error', 'Close', {
|
this.resetUploadState();
|
||||||
|
this.snackBar.open('Upload process encountered an error', 'Close', {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
panelClass: ['error-snackbar']
|
panelClass: ['error-snackbar']
|
||||||
});
|
});
|
||||||
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1902,6 +1904,7 @@ export class UploadComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetUploadState();
|
this.resetUploadState();
|
||||||
|
this.cdr.detectChanges();
|
||||||
this.loadForms();
|
this.loadForms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1911,18 +1914,14 @@ export class UploadComponent implements OnInit, OnChanges {
|
||||||
this.snackBar.open('Upload paused', 'Close', { duration: 2000 });
|
this.snackBar.open('Upload paused', 'Close', { duration: 2000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
async resumeUpload() {
|
resumeUpload() {
|
||||||
this.uploadPaused = false;
|
this.uploadPaused = false;
|
||||||
this.saveUploadState();
|
this.saveUploadState();
|
||||||
this.snackBar.open('Upload resumed', 'Close', {
|
this.snackBar.open('Upload resumed', 'Close', {
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
verticalPosition: 'top'
|
verticalPosition: 'top'
|
||||||
});
|
});
|
||||||
|
// The active processQueueAsync loop detects uploadPaused=false and continues on its own.
|
||||||
// Continue processing from where we left off
|
|
||||||
if (this.isUploading && !this.uploadStopped) {
|
|
||||||
await this.processQueueAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelUpload() {
|
async cancelUpload() {
|
||||||
|
|
@ -1940,6 +1939,7 @@ export class UploadComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetUploadState();
|
this.resetUploadState();
|
||||||
|
this.cdr.detectChanges();
|
||||||
this.snackBar.open('Upload cancelled', 'Close', { duration: 3000 });
|
this.snackBar.open('Upload cancelled', 'Close', { duration: 3000 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue