cat-documents-ng 0.2.70 → 0.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2941,6 +2941,10 @@ class DocumentUploadComponent {
2941
2941
  * @param event - Event containing the selected files
2942
2942
  */
2943
2943
  onSelectedFiles(event) {
2944
+ // Clear previous files and progress
2945
+ this.uploadedFiles = [];
2946
+ this.fileProgress.clear();
2947
+ // Process files sequentially using concatMap
2944
2948
  from(event.currentFiles).pipe(concatMap(file => this.uploadFile$(file)) // Upload one file at a time
2945
2949
  ).subscribe({
2946
2950
  complete: () => {
@@ -3041,7 +3045,7 @@ class DocumentUploadComponent {
3041
3045
  return of(null);
3042
3046
  }
3043
3047
  const formsData = this.documentService.handleCreateFormData(file, this.contextId);
3044
- console.log("3 formsData", formsData);
3048
+ console.log("1 formsData", formsData);
3045
3049
  if (!formsData) {
3046
3050
  this.messageService.add({
3047
3051
  severity: SHARED.SEVERITY,
@@ -3050,27 +3054,31 @@ class DocumentUploadComponent {
3050
3054
  });
3051
3055
  return of(null);
3052
3056
  }
3053
- // const formattedSize = this.businessService.formatFileSize(file.size, this.config);
3054
- // const uploadedFile = this.businessService.createUploadedFile(file, formattedSize);
3055
- // uploadedFile.progress = SHARED.UPLOAD_PROGRESS_10;
3056
- // this.uploadedFiles.push(uploadedFile);
3057
+ // Set initial progress for the file
3057
3058
  this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_10);
3058
- console.log("4 formData", formsData);
3059
+ console.log("2 Starting upload for file:", file.name);
3059
3060
  return this.uploadService.create(formsData).pipe(tap((event) => {
3060
- console.log("5 event", event);
3061
- // uploadedFile.uploadResponse = event;
3062
- // uploadedFile.progress = SHARED.UPLOAD_PROGRESS_100;
3063
- // uploadedFile.url = event?.url;
3064
- // uploadedFile.contentType = event?.contentType;
3065
- this.uploadedFiles.push(event);
3061
+ console.log("3 event", event);
3062
+ // Create uploaded file object with response data
3063
+ const formattedSize = this.businessService.formatFileSize(file.size, this.config);
3064
+ const uploadedFile = this.businessService.createUploadedFile(file, formattedSize);
3065
+ uploadedFile.uploadResponse = event;
3066
+ uploadedFile.progress = SHARED.UPLOAD_PROGRESS_100;
3067
+ uploadedFile.url = event?.url;
3068
+ uploadedFile.contentType = event?.contentType;
3069
+ // Add to uploadedFiles array AFTER successful upload
3070
+ this.uploadedFiles.push(uploadedFile);
3066
3071
  this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
3072
+ console.log("4 File uploaded successfully:", file.name, "Total files:", this.uploadedFiles.length);
3067
3073
  }), catchError((error) => {
3068
3074
  this.messageService.add({
3069
3075
  severity: SHARED.SEVERITY,
3070
3076
  summary: SHARED.UPLOAD_SUMMERY,
3071
3077
  detail: error?.message || 'Upload failed'
3072
3078
  });
3073
- return of(null); // Continue with next file
3079
+ // Mark file as failed
3080
+ this.fileProgress.set(file, -1);
3081
+ return of(null);
3074
3082
  }));
3075
3083
  }
3076
3084
  /**