cat-documents-ng 0.2.73 → 0.2.74
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.
|
@@ -2380,6 +2380,11 @@ class DocumentUploadService {
|
|
|
2380
2380
|
let formData = new FormData();
|
|
2381
2381
|
formData.append(SHARED.FILE, uploadedFile, uploadedFile.name);
|
|
2382
2382
|
formData.append(SHARED.CONTEXT_ID, contextId || this.contextId);
|
|
2383
|
+
// Debug: Check what's actually in the FormData
|
|
2384
|
+
console.log("FormData entries:");
|
|
2385
|
+
for (let [key, value] of formData.entries()) {
|
|
2386
|
+
console.log(`${key}:`, value);
|
|
2387
|
+
}
|
|
2383
2388
|
return formData;
|
|
2384
2389
|
}
|
|
2385
2390
|
else {
|
|
@@ -2948,10 +2953,10 @@ class DocumentUploadComponent {
|
|
|
2948
2953
|
* Processes each selected file for templated upload.
|
|
2949
2954
|
* @param event - Event containing the selected files
|
|
2950
2955
|
*/
|
|
2951
|
-
onSelectedFiles(event) {
|
|
2952
|
-
event.currentFiles
|
|
2953
|
-
this.handleTemplatedUpload(file);
|
|
2954
|
-
}
|
|
2956
|
+
async onSelectedFiles(event) {
|
|
2957
|
+
for (const file of event.currentFiles) {
|
|
2958
|
+
await this.handleTemplatedUpload(file);
|
|
2959
|
+
}
|
|
2955
2960
|
this.fileUploader.clear();
|
|
2956
2961
|
}
|
|
2957
2962
|
/**
|
|
@@ -3007,7 +3012,7 @@ class DocumentUploadComponent {
|
|
|
3007
3012
|
* Sets up progress tracking and upload listener for the file.
|
|
3008
3013
|
* @param file - The file to be uploaded
|
|
3009
3014
|
*/
|
|
3010
|
-
handleTemplatedUpload(file) {
|
|
3015
|
+
async handleTemplatedUpload(file) {
|
|
3011
3016
|
if (!this.formService.validateContextId(this.contextId, 'Context ID is required for upload.'))
|
|
3012
3017
|
return;
|
|
3013
3018
|
// Set initial progress to show upload starting
|
|
@@ -3023,49 +3028,58 @@ class DocumentUploadComponent {
|
|
|
3023
3028
|
});
|
|
3024
3029
|
return;
|
|
3025
3030
|
}
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3031
|
+
// Debug: Check FormData contents in component
|
|
3032
|
+
console.log("Component FormData entries:");
|
|
3033
|
+
for (let [key, value] of formData.entries()) {
|
|
3034
|
+
console.log(`${key}:`, value);
|
|
3035
|
+
}
|
|
3036
|
+
return new Promise((resolve, reject) => {
|
|
3037
|
+
this.uploadService.create(formData).subscribe({
|
|
3038
|
+
next: (response) => {
|
|
3039
|
+
if (response) {
|
|
3040
|
+
console.log("Upload response:", response);
|
|
3041
|
+
// Create uploaded file object with response data
|
|
3042
|
+
const formattedSize = this.businessService.formatFileSize(file.size, this.config);
|
|
3043
|
+
const uploadedFile = {
|
|
3044
|
+
file: file,
|
|
3045
|
+
formattedSize: formattedSize,
|
|
3046
|
+
progress: SHARED.UPLOAD_PROGRESS_100,
|
|
3047
|
+
uploadResponse: response,
|
|
3048
|
+
url: response.url,
|
|
3049
|
+
contentType: response.contentType,
|
|
3050
|
+
fileName: response.fileName,
|
|
3051
|
+
size: response.size
|
|
3052
|
+
};
|
|
3053
|
+
// Add to uploaded files array only after successful response
|
|
3054
|
+
this.uploadedFiles.push(uploadedFile);
|
|
3055
|
+
// Update progress tracking
|
|
3056
|
+
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
|
|
3057
|
+
// Validate form and emit changes
|
|
3058
|
+
this.validateForm();
|
|
3059
|
+
this.onFormValidationChange.emit();
|
|
3060
|
+
// Show success message
|
|
3061
|
+
this.messageService.add({
|
|
3062
|
+
severity: 'success',
|
|
3063
|
+
summary: 'Upload Success',
|
|
3064
|
+
detail: `File "${response.fileName}" uploaded successfully`
|
|
3065
|
+
});
|
|
3066
|
+
console.log(`File "${response.fileName}" uploaded successfully`);
|
|
3067
|
+
resolve(); // Resolve the promise on success
|
|
3068
|
+
}
|
|
3069
|
+
},
|
|
3070
|
+
error: (error) => {
|
|
3071
|
+
console.error("Upload error:", error);
|
|
3072
|
+
// Update progress to show error
|
|
3073
|
+
this.fileProgress.set(file, -1);
|
|
3074
|
+
// Show error message
|
|
3050
3075
|
this.messageService.add({
|
|
3051
|
-
severity: '
|
|
3052
|
-
summary: 'Upload
|
|
3053
|
-
detail:
|
|
3076
|
+
severity: 'error',
|
|
3077
|
+
summary: 'Upload Failed',
|
|
3078
|
+
detail: error?.message || 'Failed to upload file'
|
|
3054
3079
|
});
|
|
3055
|
-
|
|
3080
|
+
reject(error); // Reject the promise on error
|
|
3056
3081
|
}
|
|
3057
|
-
}
|
|
3058
|
-
error: (error) => {
|
|
3059
|
-
console.error("Upload error:", error);
|
|
3060
|
-
// Update progress to show error
|
|
3061
|
-
this.fileProgress.set(file, -1);
|
|
3062
|
-
// Show error message
|
|
3063
|
-
this.messageService.add({
|
|
3064
|
-
severity: 'error',
|
|
3065
|
-
summary: 'Upload Failed',
|
|
3066
|
-
detail: error?.message || 'Failed to upload file'
|
|
3067
|
-
});
|
|
3068
|
-
}
|
|
3082
|
+
});
|
|
3069
3083
|
});
|
|
3070
3084
|
}
|
|
3071
3085
|
/**
|