cat-documents-ng 0.2.68 → 0.2.69
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.
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Injectable, EventEmitter, Output, ViewChild, Input, ViewEncapsulation, Component, ChangeDetectionStrategy, Directive, NgModule, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i2$1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
|
-
import { firstValueFrom, tap, EMPTY, catchError, throwError, of, combineLatest, Subject, Observable, takeUntil, Subscription, debounceTime as debounceTime$1, distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs';
|
|
5
|
+
import { firstValueFrom, tap, EMPTY, catchError, throwError, of, combineLatest, Subject, Observable, from, concatMap, takeUntil, Subscription, debounceTime as debounceTime$1, distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs';
|
|
6
6
|
import { __decorate } from 'tslib';
|
|
7
7
|
import { EntityStore, StoreConfig, QueryEntity } from '@datorama/akita';
|
|
8
8
|
import * as i2 from '@angular/common/http';
|
|
@@ -2939,10 +2939,15 @@ class DocumentUploadComponent {
|
|
|
2939
2939
|
* @param event - Event containing the selected files
|
|
2940
2940
|
*/
|
|
2941
2941
|
onSelectedFiles(event) {
|
|
2942
|
-
event.currentFiles.
|
|
2943
|
-
|
|
2942
|
+
from(event.currentFiles).pipe(concatMap(file => this.uploadFile$(file)) // Upload one file at a time
|
|
2943
|
+
).subscribe({
|
|
2944
|
+
complete: () => {
|
|
2945
|
+
console.log('✅ All files uploaded sequentially.');
|
|
2946
|
+
this.fileUploader.clear();
|
|
2947
|
+
this.cdr.detectChanges();
|
|
2948
|
+
this.onFormValidationChange.emit();
|
|
2949
|
+
}
|
|
2944
2950
|
});
|
|
2945
|
-
this.fileUploader.clear();
|
|
2946
2951
|
}
|
|
2947
2952
|
/**
|
|
2948
2953
|
* Loads the list of applicants for the current context.
|
|
@@ -2997,34 +3002,73 @@ class DocumentUploadComponent {
|
|
|
2997
3002
|
* Sets up progress tracking and upload listener for the file.
|
|
2998
3003
|
* @param file - The file to be uploaded
|
|
2999
3004
|
*/
|
|
3000
|
-
handleTemplatedUpload(file) {
|
|
3001
|
-
|
|
3002
|
-
|
|
3005
|
+
// handleTemplatedUpload(file: File): void {
|
|
3006
|
+
// if (!this.formService.validateContextId(this.contextId, 'Context ID is required for upload.')) return;
|
|
3007
|
+
// const formsData = this.documentService.handleCreateFormData(file, this.contextId);
|
|
3008
|
+
// console.log("1",formsData);
|
|
3009
|
+
// if (!formsData) {
|
|
3010
|
+
// this.messageService.add({severity: SHARED.SEVERITY,summary: SHARED.UPLOAD_ERROR_SUMMERY,detail: SHARED.UPLOAD_ERROR_DETAILS});
|
|
3011
|
+
// return;
|
|
3012
|
+
// }
|
|
3013
|
+
// this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_10);
|
|
3014
|
+
// const formattedSize = this.businessService.formatFileSize(file.size, this.config);
|
|
3015
|
+
// const uploadedFile = this.businessService.createUploadedFile(file, formattedSize);
|
|
3016
|
+
// uploadedFile.progress = SHARED.UPLOAD_PROGRESS_10;
|
|
3017
|
+
// console.log("2",uploadedFile);
|
|
3018
|
+
// this.uploadService.create(formsData).subscribe({
|
|
3019
|
+
// next: (event) => {
|
|
3020
|
+
// console.log("3",event);
|
|
3021
|
+
// uploadedFile.uploadResponse = event;
|
|
3022
|
+
// uploadedFile.progress = SHARED.UPLOAD_PROGRESS_100;
|
|
3023
|
+
// uploadedFile.url = event?.url;
|
|
3024
|
+
// uploadedFile.contentType = event?.contentType;
|
|
3025
|
+
// this.uploadedFiles.push(event);
|
|
3026
|
+
// this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
|
|
3027
|
+
// // this.uploadCompleted.emit({ file, response: event });
|
|
3028
|
+
// this.cdr.detectChanges();
|
|
3029
|
+
// this.onFormValidationChange.emit();
|
|
3030
|
+
// console.log("4 uploadedFiles",this.uploadedFiles);
|
|
3031
|
+
// },
|
|
3032
|
+
// error: (error) => {
|
|
3033
|
+
// this.messageService.add({severity: SHARED.SEVERITY,summary: SHARED.UPLOAD_SUMMERY,detail: error?.message});
|
|
3034
|
+
// }
|
|
3035
|
+
// });
|
|
3036
|
+
// }
|
|
3037
|
+
uploadFile$(file) {
|
|
3038
|
+
if (!this.formService.validateContextId(this.contextId, 'Context ID is required for upload.')) {
|
|
3039
|
+
return of(null);
|
|
3040
|
+
}
|
|
3003
3041
|
const formsData = this.documentService.handleCreateFormData(file, this.contextId);
|
|
3042
|
+
console.log("1 formsData", formsData);
|
|
3004
3043
|
if (!formsData) {
|
|
3005
|
-
this.messageService.add({
|
|
3006
|
-
|
|
3044
|
+
this.messageService.add({
|
|
3045
|
+
severity: SHARED.SEVERITY,
|
|
3046
|
+
summary: SHARED.UPLOAD_ERROR_SUMMERY,
|
|
3047
|
+
detail: SHARED.UPLOAD_ERROR_DETAILS
|
|
3048
|
+
});
|
|
3049
|
+
return of(null);
|
|
3007
3050
|
}
|
|
3008
|
-
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_10);
|
|
3009
3051
|
const formattedSize = this.businessService.formatFileSize(file.size, this.config);
|
|
3010
3052
|
const uploadedFile = this.businessService.createUploadedFile(file, formattedSize);
|
|
3011
3053
|
uploadedFile.progress = SHARED.UPLOAD_PROGRESS_10;
|
|
3012
3054
|
this.uploadedFiles.push(uploadedFile);
|
|
3013
|
-
this.
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3055
|
+
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_10);
|
|
3056
|
+
console.log("2 uploadedFiles", this.uploadedFiles);
|
|
3057
|
+
return this.uploadService.create(formsData).pipe(tap((event) => {
|
|
3058
|
+
console.log("3 event", event);
|
|
3059
|
+
uploadedFile.uploadResponse = event;
|
|
3060
|
+
uploadedFile.progress = SHARED.UPLOAD_PROGRESS_100;
|
|
3061
|
+
uploadedFile.url = event?.url;
|
|
3062
|
+
uploadedFile.contentType = event?.contentType;
|
|
3063
|
+
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
|
|
3064
|
+
}), catchError((error) => {
|
|
3065
|
+
this.messageService.add({
|
|
3066
|
+
severity: SHARED.SEVERITY,
|
|
3067
|
+
summary: SHARED.UPLOAD_SUMMERY,
|
|
3068
|
+
detail: error?.message || 'Upload failed'
|
|
3069
|
+
});
|
|
3070
|
+
return of(null); // Continue with next file
|
|
3071
|
+
}));
|
|
3028
3072
|
}
|
|
3029
3073
|
/**
|
|
3030
3074
|
* Removes a document from the uploaded files list.
|