cat-documents-ng 0.2.84 → 0.2.85
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.
|
@@ -1299,7 +1299,7 @@ class DocumentService {
|
|
|
1299
1299
|
* @returns {Observable<any>} Observable that emits the newly created document.
|
|
1300
1300
|
*/
|
|
1301
1301
|
create(entity) {
|
|
1302
|
-
const headers = { 'Authorization': 'Bearer
|
|
1302
|
+
const headers = { 'Authorization': 'Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f' };
|
|
1303
1303
|
return this.http.post(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD_FILE}`, entity, { headers }).pipe(tap((newEntity) => this.documentStore.add(newEntity)));
|
|
1304
1304
|
}
|
|
1305
1305
|
/**
|
|
@@ -1711,7 +1711,7 @@ class DocumentHttpService {
|
|
|
1711
1711
|
* @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
|
|
1712
1712
|
*/
|
|
1713
1713
|
getDocumentCatagories(contextId) {
|
|
1714
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1714
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1715
1715
|
return this.http.get(`${this.apiUrl}${URLS.DOCUMENTS_CATAGORIES}/${contextId}`, { headers }).pipe(tap((response) => {
|
|
1716
1716
|
// Store only the categories array, not the entire response
|
|
1717
1717
|
if (response && response.categories) {
|
|
@@ -1770,7 +1770,7 @@ class DocumentHttpService {
|
|
|
1770
1770
|
* @returns {Observable<DocumentModel>} An observable that emits the updated DocumentModel.
|
|
1771
1771
|
*/
|
|
1772
1772
|
updateDocumentName(documentId, payload) {
|
|
1773
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1773
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1774
1774
|
return this.http.put(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${documentId}`, payload, { headers }).pipe(catchError((error) => {
|
|
1775
1775
|
return throwError(() => new Error(error));
|
|
1776
1776
|
}));
|
|
@@ -1783,7 +1783,7 @@ class DocumentHttpService {
|
|
|
1783
1783
|
getUserListByContextId(contextId) {
|
|
1784
1784
|
if (!contextId)
|
|
1785
1785
|
return EMPTY;
|
|
1786
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1786
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1787
1787
|
return this.http.get(`${this.apiUrl}${URLS.USERLIST}${contextId}`, { headers }).pipe(tap((userList) => {
|
|
1788
1788
|
this.documentStore.setUserList(userList);
|
|
1789
1789
|
}), catchError((error) => {
|
|
@@ -1809,7 +1809,7 @@ class DocumentHttpService {
|
|
|
1809
1809
|
if (categoryId) {
|
|
1810
1810
|
params = params.set(SHARED.CATEGORY, categoryId);
|
|
1811
1811
|
}
|
|
1812
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1812
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1813
1813
|
return this.http.get(url, { params, headers }).pipe(tap((statusData) => {
|
|
1814
1814
|
this.documentStore.setStatusData(statusData);
|
|
1815
1815
|
}), catchError((error) => {
|
|
@@ -1840,7 +1840,7 @@ class DocumentHttpService {
|
|
|
1840
1840
|
if (searchKey) {
|
|
1841
1841
|
params = params.set(SHARED.SEARCH_KEY, searchKey);
|
|
1842
1842
|
}
|
|
1843
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1843
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1844
1844
|
return this.http.get(`${this.apiUrl}${URLS.GETALL}/${contextId}`, { params, headers }).pipe(tap((response) => {
|
|
1845
1845
|
if (response.documents) {
|
|
1846
1846
|
this.documentStore.setDocumentList(response.documents);
|
|
@@ -1853,7 +1853,7 @@ class DocumentHttpService {
|
|
|
1853
1853
|
if (!documentId) {
|
|
1854
1854
|
return of([]);
|
|
1855
1855
|
}
|
|
1856
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1856
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1857
1857
|
return this.http.get(`${this.apiUrl}${URLS.DOCUMENT_HISTORY}${documentId}`, { headers });
|
|
1858
1858
|
}
|
|
1859
1859
|
/**
|
|
@@ -1864,7 +1864,7 @@ class DocumentHttpService {
|
|
|
1864
1864
|
getCategoriesBySource(source) {
|
|
1865
1865
|
if (!source)
|
|
1866
1866
|
return EMPTY;
|
|
1867
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1867
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1868
1868
|
return this.http.get(`${this.apiUrl}${URLS.GET_CATEGORIES_BY_SOURCE}${source}`, { headers }).pipe(catchError((error) => {
|
|
1869
1869
|
return throwError(() => new Error(error));
|
|
1870
1870
|
}));
|
|
@@ -1877,7 +1877,7 @@ class DocumentHttpService {
|
|
|
1877
1877
|
getDocumentTypesByCategory(categoryId) {
|
|
1878
1878
|
if (!categoryId)
|
|
1879
1879
|
return EMPTY;
|
|
1880
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1880
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1881
1881
|
return this.http.get(`${this.apiUrl}${URLS.GET_DOCUMENT_TYPES_BY_CATEGORY}${categoryId}`, { headers }).pipe(catchError((error) => {
|
|
1882
1882
|
return throwError(() => new Error(error));
|
|
1883
1883
|
}));
|
|
@@ -1888,7 +1888,7 @@ class DocumentHttpService {
|
|
|
1888
1888
|
* @returns {Observable<any>} Observable that emits the upload response.
|
|
1889
1889
|
*/
|
|
1890
1890
|
uploadFile(formData) {
|
|
1891
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1891
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1892
1892
|
return this.http.post(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD_FILE}`, formData, { headers }).pipe(catchError((error) => {
|
|
1893
1893
|
return throwError(() => new Error(error));
|
|
1894
1894
|
}));
|
|
@@ -1899,7 +1899,7 @@ class DocumentHttpService {
|
|
|
1899
1899
|
* @returns {Observable<any>} Observable that emits the save response.
|
|
1900
1900
|
*/
|
|
1901
1901
|
saveDocumentUpload(payload) {
|
|
1902
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1902
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1903
1903
|
return this.http.post(`${this.apiUrl}${URLS.SAVE_DOCUMENT_UPLOAD}`, payload, { headers }).pipe(catchError((error) => {
|
|
1904
1904
|
return throwError(() => new Error(error));
|
|
1905
1905
|
}));
|
|
@@ -1915,7 +1915,7 @@ class DocumentHttpService {
|
|
|
1915
1915
|
const payload = {
|
|
1916
1916
|
statusUpdateDescription: statusUpdateDescription
|
|
1917
1917
|
};
|
|
1918
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1918
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1919
1919
|
return this.http.put(`${this.apiUrl}${URLS.UPDATE_DOCUMENT_STATUS}${documentId}/${status}`, payload, { headers }).pipe(tap((response) => {
|
|
1920
1920
|
if (response && response.status) {
|
|
1921
1921
|
const normalizedStatus = this.normalizeStatus(response.status);
|
|
@@ -1949,7 +1949,7 @@ class DocumentHttpService {
|
|
|
1949
1949
|
* @returns {Observable<any>} Observable that emits the delete response
|
|
1950
1950
|
*/
|
|
1951
1951
|
deleteDocument(documentId, contextId) {
|
|
1952
|
-
let headers = new HttpHeaders({ Authorization: `Bearer
|
|
1952
|
+
let headers = new HttpHeaders({ Authorization: `Bearer 498dad38-e776-4d9a-ad2a-71d8064d657f` });
|
|
1953
1953
|
return this.http.delete(`${this.apiUrl}${URLS.DELETE_DOCUMENT}${documentId}`, { headers }).pipe(tap(() => {
|
|
1954
1954
|
this.getDocumentCatagories(contextId).subscribe();
|
|
1955
1955
|
this.getUserListByContextId(contextId).subscribe();
|
|
@@ -2889,57 +2889,20 @@ class DocumentUploadComponent {
|
|
|
2889
2889
|
onApplicantSelectionChange() { this.validateAndEmit(); }
|
|
2890
2890
|
/**
|
|
2891
2891
|
* Handles file selection from the file upload component.
|
|
2892
|
-
* Processes
|
|
2892
|
+
* Processes each selected file for templated upload.
|
|
2893
2893
|
* @param event - Event containing the selected files
|
|
2894
2894
|
*/
|
|
2895
2895
|
async onSelectedFiles(event) {
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
const uploadPromises = event.currentFiles.map(file => this.handleTemplatedUpload(file));
|
|
2901
|
-
// Execute all uploads in parallel
|
|
2902
|
-
const results = await Promise.allSettled(uploadPromises);
|
|
2903
|
-
// Process results and handle any failures
|
|
2904
|
-
let successCount = 0;
|
|
2905
|
-
let failureCount = 0;
|
|
2906
|
-
results.forEach((result, index) => {
|
|
2907
|
-
const file = event.currentFiles[index];
|
|
2908
|
-
if (result.status === 'fulfilled') {
|
|
2909
|
-
successCount++;
|
|
2910
|
-
}
|
|
2911
|
-
else {
|
|
2912
|
-
failureCount++;
|
|
2913
|
-
console.error(`Failed to upload file ${index + 1}/${event.currentFiles.length}: ${file.name}`, result.reason);
|
|
2914
|
-
}
|
|
2915
|
-
});
|
|
2916
|
-
// Show summary message if there were failures
|
|
2917
|
-
if (failureCount > 0) {
|
|
2918
|
-
this.messageService.add({
|
|
2919
|
-
severity: 'warn',
|
|
2920
|
-
summary: 'Upload Summary',
|
|
2921
|
-
detail: `${successCount} file(s) uploaded successfully, ${failureCount} file(s) failed.`
|
|
2922
|
-
});
|
|
2896
|
+
for (let i = 0; i < event.currentFiles.length; i++) {
|
|
2897
|
+
const file = event.currentFiles[i];
|
|
2898
|
+
try {
|
|
2899
|
+
await this.handleTemplatedUpload(file);
|
|
2923
2900
|
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
severity: 'success',
|
|
2927
|
-
summary: 'Upload Complete',
|
|
2928
|
-
detail: `All ${successCount} file(s) uploaded successfully.`
|
|
2929
|
-
});
|
|
2901
|
+
catch (error) {
|
|
2902
|
+
console.error(`Failed to upload file ${i + 1}/${event.currentFiles.length}: ${file.name}`, error);
|
|
2930
2903
|
}
|
|
2931
2904
|
}
|
|
2932
|
-
|
|
2933
|
-
console.error('Unexpected error during file uploads:', error);
|
|
2934
|
-
this.messageService.add({
|
|
2935
|
-
severity: 'error',
|
|
2936
|
-
summary: 'Upload Error',
|
|
2937
|
-
detail: 'An unexpected error occurred during file uploads.'
|
|
2938
|
-
});
|
|
2939
|
-
}
|
|
2940
|
-
finally {
|
|
2941
|
-
this.fileUploader.clear();
|
|
2942
|
-
}
|
|
2905
|
+
this.fileUploader.clear();
|
|
2943
2906
|
}
|
|
2944
2907
|
/**
|
|
2945
2908
|
* Loads the list of applicants for the current context.
|
|
@@ -2991,33 +2954,35 @@ class DocumentUploadComponent {
|
|
|
2991
2954
|
}
|
|
2992
2955
|
/**
|
|
2993
2956
|
* Handles templated upload for a single file.
|
|
2957
|
+
* Sets up progress tracking and upload listener for the file.
|
|
2994
2958
|
* @param file - The file to be uploaded
|
|
2995
2959
|
*/
|
|
2996
2960
|
async handleTemplatedUpload(file) {
|
|
2997
2961
|
if (!this.formService.validateContextId(this.contextId, 'Context ID is required for upload.'))
|
|
2998
2962
|
return;
|
|
2999
|
-
// Add file with initial state
|
|
3000
|
-
const fileIndex = this.uploadedFiles.length;
|
|
3001
2963
|
this.uploadedFiles.push({
|
|
3002
|
-
file,
|
|
2964
|
+
file: file,
|
|
3003
2965
|
formattedSize: this.businessService.formatFileSize(file.size, this.config),
|
|
3004
2966
|
progress: SHARED.UPLOAD_PROGRESS_10,
|
|
3005
|
-
uploadResponse: {
|
|
2967
|
+
uploadResponse: {
|
|
2968
|
+
fileName: file.name,
|
|
2969
|
+
contentType: file.type,
|
|
2970
|
+
url: SHARED.EMPTY,
|
|
2971
|
+
size: this.businessService.formatFileSize(file.size, this.config)
|
|
2972
|
+
},
|
|
3006
2973
|
url: undefined,
|
|
3007
2974
|
});
|
|
3008
2975
|
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_10);
|
|
3009
2976
|
try {
|
|
3010
2977
|
const response = await this.documentUploadService.uploadFile(file, this.contextId);
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
uploadResponse: response,
|
|
3016
|
-
url: response.url,
|
|
3017
|
-
contentType: response.contentType,
|
|
2978
|
+
const formattedSize = this.businessService.formatFileSize(file.size, this.config);
|
|
2979
|
+
const uploadedFile = {
|
|
2980
|
+
file: file, formattedSize: formattedSize, progress: SHARED.UPLOAD_PROGRESS_100,
|
|
2981
|
+
uploadResponse: response, url: response.url, contentType: response.contentType,
|
|
3018
2982
|
fileName: response.fileName,
|
|
3019
2983
|
size: response.size
|
|
3020
2984
|
};
|
|
2985
|
+
this.uploadedFiles.push(uploadedFile);
|
|
3021
2986
|
this.fileProgress.set(file, SHARED.UPLOAD_PROGRESS_100);
|
|
3022
2987
|
this.validateForm();
|
|
3023
2988
|
this.onFormValidationChange.emit();
|