cat-documents-ng 1.0.6 → 1.0.7

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.
Files changed (211) hide show
  1. package/README.md +322 -322
  2. package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
  3. package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
  4. package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
  5. package/Shared/constant/ERROR.d.ts +52 -0
  6. package/Shared/constant/SHARED.d.ts +546 -0
  7. package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +25 -31
  8. package/Shared/services/app-config.service.d.ts +51 -0
  9. package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
  10. package/Shared/services/session.service.d.ts +46 -0
  11. package/Shared/shared.module.d.ts +14 -0
  12. package/fesm2022/cat-documents-ng.mjs +11405 -0
  13. package/fesm2022/cat-documents-ng.mjs.map +1 -0
  14. package/index.d.ts +5 -0
  15. package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
  16. package/lib/document/components/document-container/document-container.component.d.ts +162 -0
  17. package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
  18. package/lib/document/components/document-history/document-history.component.d.ts +160 -0
  19. package/lib/document/components/document-list/document-list.component.d.ts +299 -0
  20. package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
  21. package/lib/document/components/document-search/document-search.component.d.ts +77 -0
  22. package/lib/document/components/document-status/document-status.component.d.ts +24 -0
  23. package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
  24. package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
  25. package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
  26. package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
  27. package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -28
  28. package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
  29. package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
  30. package/lib/document/components/request-document/request-document.component.d.ts +69 -0
  31. package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
  32. package/lib/document/components/user-list/user-list.component.d.ts +34 -0
  33. package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
  34. package/lib/document/directives/document.directive.d.ts +20 -0
  35. package/lib/document/directives/permission.directive.d.ts +38 -0
  36. package/lib/document/document.module.d.ts +60 -0
  37. package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +4 -11
  38. package/lib/document/models/document-category.model.d.ts +24 -0
  39. package/lib/document/models/document-history.model.d.ts +94 -0
  40. package/lib/document/models/document-list-response.model.d.ts +33 -0
  41. package/lib/document/models/document-type.model.d.ts +37 -0
  42. package/lib/document/models/document.model.d.ts +44 -0
  43. package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +4 -10
  44. package/lib/document/models/status-data.model.d.ts +27 -0
  45. package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
  46. package/lib/document/models/user-list.model.d.ts +8 -0
  47. package/lib/document/services/csv-parser.service.d.ts +88 -0
  48. package/lib/document/services/document-actions.service.d.ts +48 -0
  49. package/lib/document/services/document-content-type.service.d.ts +85 -0
  50. package/lib/document/services/document-history-style.service.d.ts +34 -0
  51. package/lib/document/services/document-history.service.d.ts +42 -0
  52. package/lib/document/services/document-http.service.d.ts +179 -0
  53. package/lib/document/services/document-list.service.d.ts +74 -0
  54. package/lib/document/services/document-menu.service.d.ts +122 -0
  55. package/lib/document/services/document-scroll.service.d.ts +55 -0
  56. package/lib/document/services/document-table-builder.service.d.ts +38 -0
  57. package/lib/document/services/document-upload-business.service.d.ts +107 -0
  58. package/lib/document/services/document-upload-data.service.d.ts +40 -0
  59. package/lib/document/services/document-upload-form.service.d.ts +41 -0
  60. package/lib/document/services/document-upload.service.d.ts +99 -0
  61. package/lib/document/services/document-viewer.service.d.ts +97 -0
  62. package/lib/document/services/document-zoom.service.d.ts +81 -0
  63. package/lib/document/services/document.service.d.ts +161 -0
  64. package/lib/document/services/eml-parser.service.d.ts +116 -0
  65. package/lib/document/services/excel-parser.service.d.ts +169 -0
  66. package/lib/document/services/file-format.service.d.ts +34 -0
  67. package/lib/document/services/status-calculator.service.d.ts +20 -0
  68. package/lib/document/services/user-list.service.d.ts +29 -0
  69. package/lib/document/state/document.query.d.ts +243 -0
  70. package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
  71. package/lib/document/state/document.state.d.ts +61 -0
  72. package/lib/document/state/document.store.d.ts +56 -0
  73. package/package.json +11 -5
  74. package/{src/public-api.ts → public-api.d.ts} +0 -4
  75. package/ng-package.json +0 -10
  76. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +0 -3
  77. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +0 -13
  78. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -70
  79. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +0 -133
  80. package/src/Shared/components/table-primary/table-primary.component.html +0 -66
  81. package/src/Shared/components/table-primary/table-primary.component.scss +0 -227
  82. package/src/Shared/components/table-primary/table-primary.component.spec.ts +0 -23
  83. package/src/Shared/components/table-primary/table-primary.component.ts +0 -143
  84. package/src/Shared/components/table-primary/table-primary.model.ts +0 -21
  85. package/src/Shared/constant/ERROR.ts +0 -55
  86. package/src/Shared/constant/PERMISSIONS.ts +0 -17
  87. package/src/Shared/constant/SHARED.ts +0 -936
  88. package/src/Shared/services/app-config.service.spec.ts +0 -19
  89. package/src/Shared/services/app-config.service.ts +0 -73
  90. package/src/Shared/services/session.service.spec.ts +0 -16
  91. package/src/Shared/services/session.service.ts +0 -76
  92. package/src/Shared/shared.module.ts +0 -25
  93. package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +0 -1
  94. package/src/lib/document/components/document-actions/document-actions.component.html +0 -59
  95. package/src/lib/document/components/document-actions/document-actions.component.scss +0 -362
  96. package/src/lib/document/components/document-actions/document-actions.component.spec.ts +0 -297
  97. package/src/lib/document/components/document-actions/document-actions.component.ts +0 -163
  98. package/src/lib/document/components/document-container/document-container.component.html +0 -36
  99. package/src/lib/document/components/document-container/document-container.component.scss +0 -144
  100. package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
  101. package/src/lib/document/components/document-container/document-container.component.ts +0 -363
  102. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +0 -332
  103. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +0 -1877
  104. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +0 -258
  105. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +0 -664
  106. package/src/lib/document/components/document-history/document-history.component.html +0 -96
  107. package/src/lib/document/components/document-history/document-history.component.scss +0 -392
  108. package/src/lib/document/components/document-history/document-history.component.spec.ts +0 -93
  109. package/src/lib/document/components/document-history/document-history.component.ts +0 -373
  110. package/src/lib/document/components/document-list/document-list.component.html +0 -46
  111. package/src/lib/document/components/document-list/document-list.component.scss +0 -513
  112. package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -486
  113. package/src/lib/document/components/document-list/document-list.component.ts +0 -682
  114. package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
  115. package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
  116. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
  117. package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
  118. package/src/lib/document/components/document-search/document-search.component.html +0 -64
  119. package/src/lib/document/components/document-search/document-search.component.scss +0 -206
  120. package/src/lib/document/components/document-search/document-search.component.spec.ts +0 -82
  121. package/src/lib/document/components/document-search/document-search.component.ts +0 -163
  122. package/src/lib/document/components/document-status/document-status.component.html +0 -31
  123. package/src/lib/document/components/document-status/document-status.component.scss +0 -192
  124. package/src/lib/document/components/document-status/document-status.component.spec.ts +0 -23
  125. package/src/lib/document/components/document-status/document-status.component.ts +0 -87
  126. package/src/lib/document/components/document-upload/document-upload.component.html +0 -160
  127. package/src/lib/document/components/document-upload/document-upload.component.scss +0 -235
  128. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
  129. package/src/lib/document/components/document-upload/document-upload.component.ts +0 -668
  130. package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -50
  131. package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -187
  132. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
  133. package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -261
  134. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +0 -48
  135. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +0 -320
  136. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +0 -59
  137. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +0 -150
  138. package/src/lib/document/components/documents-menu/documents-menu.component.html +0 -44
  139. package/src/lib/document/components/documents-menu/documents-menu.component.scss +0 -363
  140. package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +0 -23
  141. package/src/lib/document/components/documents-menu/documents-menu.component.ts +0 -316
  142. package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
  143. package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
  144. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
  145. package/src/lib/document/components/folder-container/folder-container.component.html +0 -56
  146. package/src/lib/document/components/folder-container/folder-container.component.scss +0 -20
  147. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
  148. package/src/lib/document/components/folder-container/folder-container.component.ts +0 -328
  149. package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
  150. package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
  151. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
  152. package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
  153. package/src/lib/document/components/request-document/request-document.component.html +0 -86
  154. package/src/lib/document/components/request-document/request-document.component.scss +0 -16
  155. package/src/lib/document/components/request-document/request-document.component.ts +0 -278
  156. package/src/lib/document/components/sidebar/sidebar.component.html +0 -75
  157. package/src/lib/document/components/sidebar/sidebar.component.scss +0 -157
  158. package/src/lib/document/components/sidebar/sidebar.component.spec.ts +0 -114
  159. package/src/lib/document/components/sidebar/sidebar.component.ts +0 -223
  160. package/src/lib/document/components/user-list/user-list.component.html +0 -33
  161. package/src/lib/document/components/user-list/user-list.component.scss +0 -118
  162. package/src/lib/document/components/user-list/user-list.component.spec.ts +0 -23
  163. package/src/lib/document/components/user-list/user-list.component.ts +0 -181
  164. package/src/lib/document/constant/DOCUMENT_HISTORY.ts +0 -52
  165. package/src/lib/document/directives/document.directive.ts +0 -32
  166. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  167. package/src/lib/document/directives/permission.directive.ts +0 -72
  168. package/src/lib/document/document.module.ts +0 -351
  169. package/src/lib/document/models/document-category.model.ts +0 -30
  170. package/src/lib/document/models/document-history.model.ts +0 -109
  171. package/src/lib/document/models/document-list-response.model.ts +0 -37
  172. package/src/lib/document/models/document-type.model.ts +0 -44
  173. package/src/lib/document/models/document.model.ts +0 -53
  174. package/src/lib/document/models/status-data.model.ts +0 -31
  175. package/src/lib/document/models/uploaded-file-response.model.ts +0 -7
  176. package/src/lib/document/models/user-list.model.ts +0 -10
  177. package/src/lib/document/services/csv-parser.service.spec.ts +0 -97
  178. package/src/lib/document/services/csv-parser.service.ts +0 -303
  179. package/src/lib/document/services/document-actions.service.ts +0 -125
  180. package/src/lib/document/services/document-content-type.service.ts +0 -193
  181. package/src/lib/document/services/document-history-style.service.ts +0 -138
  182. package/src/lib/document/services/document-history.service.ts +0 -129
  183. package/src/lib/document/services/document-http.service.spec.ts +0 -119
  184. package/src/lib/document/services/document-http.service.ts +0 -497
  185. package/src/lib/document/services/document-list.service.ts +0 -195
  186. package/src/lib/document/services/document-menu.service.ts +0 -277
  187. package/src/lib/document/services/document-scroll.service.ts +0 -138
  188. package/src/lib/document/services/document-severity.service.ts +0 -98
  189. package/src/lib/document/services/document-table-builder.service.ts +0 -82
  190. package/src/lib/document/services/document-upload-business.service.ts +0 -326
  191. package/src/lib/document/services/document-upload-data.service.ts +0 -82
  192. package/src/lib/document/services/document-upload-form.service.ts +0 -149
  193. package/src/lib/document/services/document-upload.service.spec.ts +0 -99
  194. package/src/lib/document/services/document-upload.service.ts +0 -209
  195. package/src/lib/document/services/document-viewer.service.ts +0 -279
  196. package/src/lib/document/services/document-zoom.service.spec.ts +0 -56
  197. package/src/lib/document/services/document-zoom.service.ts +0 -164
  198. package/src/lib/document/services/document.service.ts +0 -356
  199. package/src/lib/document/services/eml-parser.service.ts +0 -444
  200. package/src/lib/document/services/excel-parser.service.spec.ts +0 -66
  201. package/src/lib/document/services/excel-parser.service.ts +0 -483
  202. package/src/lib/document/services/file-format.service.spec.ts +0 -16
  203. package/src/lib/document/services/file-format.service.ts +0 -63
  204. package/src/lib/document/services/status-calculator.service.ts +0 -44
  205. package/src/lib/document/services/user-list.service.ts +0 -77
  206. package/src/lib/document/state/document.query.ts +0 -378
  207. package/src/lib/document/state/document.state.ts +0 -100
  208. package/src/lib/document/state/document.store.ts +0 -200
  209. package/tsconfig.lib.json +0 -15
  210. package/tsconfig.lib.prod.json +0 -11
  211. package/tsconfig.spec.json +0 -15
@@ -1,497 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { catchError, EMPTY, Observable, of, tap, throwError } from 'rxjs';
3
- import { URLS } from '../../../Shared/constant/URLS';
4
- import { SHARED } from '../../../Shared/constant/SHARED';
5
- import { AppConfigService } from '../../../Shared/services/app-config.service';
6
- import { DocumentStore } from '../state/document.store';
7
- import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
8
- import { DocumentTypeModel } from '../models/document-type.model';
9
- import { DocumentAlertModel } from '../models/document-alert.model';
10
- import { DocumentModel } from '../models/document.model';
11
- import { FolderBlockModel } from '../models/folder.model';
12
- import { DocumentCategory } from '../models/document-category.model';
13
- import { UserListModel } from '../models/user-list.model';
14
- import { StatusDataModel } from '../models/status-data.model';
15
- import { DocumentListResponse } from '../models/document-list-response.model';
16
- import { DocumentHistorySection } from '../models/document-history.model';
17
-
18
- /**
19
- * Service for making HTTP requests related to documents.
20
- * Authentication is handled automatically by the HTTP interceptor in the main project.
21
- * @class DocumentHttpService
22
- * @typedef {DocumentHttpService}
23
- */
24
- @Injectable({
25
- providedIn: 'root'
26
- })
27
-
28
- export class DocumentHttpService {
29
-
30
- /**
31
- * Creates an instance of DocumentService.
32
- * @param {DocumentStore} documentStore - Store managing the state of documents.
33
- * @param {HttpClient} http - Angular HTTP client for making API requests.
34
- * @param {AppConfigService} appConfigService - Service for retrieving application configuration, such as API base URL.
35
- */
36
- constructor(
37
- public documentStore: DocumentStore,
38
- private http: HttpClient,
39
- public appConfigService: AppConfigService
40
- ) { }
41
-
42
- /**
43
- * Get api url from appConfigService.
44
- * @readonly
45
- * @type {string}
46
- */
47
- get apiUrl(): string {
48
- return this.appConfigService.apiBaseUrl;
49
- }
50
-
51
- /**
52
- * Fetches a document by its path name and transforms the response for dropdown options.
53
- * Includes error handling for failed API requests.
54
- * @param {string} contextId - The context ID to fetch the document.
55
- * @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
56
- */
57
- getFoldersData(contextId:string | undefined): Observable<FolderBlockModel[]> {
58
- if(!contextId) return EMPTY;
59
-
60
- return this.http.get<FolderBlockModel[]>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}${URLS.FOLDERS}${contextId}`).pipe(
61
- tap((folders: FolderBlockModel[]) => {
62
- this.documentStore.setFolders(folders);
63
- }),
64
- catchError((error) => {
65
- return throwError(() => new Error(error));
66
- })
67
- );
68
- }
69
-
70
- /**
71
- * Fetches a document catagories by its path name.
72
- * Includes error handling for failed API requests.
73
- * @param {string} contextId - The context ID to fetch the document.
74
- * @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
75
- */
76
- getDocumentCatagories(contextId:string): Observable<any> {
77
- let headers = new HttpHeaders( {
78
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
79
- });
80
- return this.http.get<any>(`${this.apiUrl}${URLS.DOCUMENTS_CATAGORIES}/${contextId}`, { headers })
81
- .pipe(
82
- tap((response: any) => {
83
- if (response && response.categories) {
84
- this.documentStore.setDocumentCategories(response.categories);
85
- }
86
- }),
87
- catchError((error) => {
88
- return throwError(() => new Error(error));
89
- })
90
- );
91
- }
92
- /**
93
- * Fetches a document by its path name and transforms the response for dropdown options.
94
- * Includes error handling for failed API requests.
95
- * @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
96
- */
97
- // getDocumentTypes(): Observable<DocumentTypeModel[]> {
98
- // return this.http.get<DocumentTypeModel[]>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${URLS.DOCUMENT_TYPES}`).pipe(
99
- // tap((documentTypes: DocumentTypeModel[]) => {
100
- // this.documentStore.setDocumentTypes(documentTypes);
101
- // }),
102
- // catchError((error) => {
103
- // return throwError(() => new Error(error));
104
- // })
105
- // );
106
- // }
107
-
108
- /**
109
- * Fetches a document by its path name and transforms the response for dropdown options.
110
- * @param {string} documentId - The document ID to fetch the document.
111
- * @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
112
- */
113
- getAlertsByDocumentID(documentId:string): Observable<DocumentAlertModel> {
114
- return this.http.get<DocumentAlertModel>(`${this.apiUrl}${URLS.ALERT_BY_DOCUMENT_ID}${documentId}`).pipe(
115
- tap((documentAlert: DocumentAlertModel) => {
116
- this.documentStore.setDocumentAlert(documentAlert);
117
- }),
118
- catchError((error) => {
119
- return throwError(() => new Error(error));
120
- })
121
- );
122
- }
123
-
124
- /**
125
- * Fetches a document by its folder ID and transforms the response for dropdown options.
126
- * @param {string} folderId - The folder ID to fetch the document.
127
- * @param {string} contextId - The context ID to fetch the document.
128
- * @returns {Observable<any>} Observable that emits the transformed data for dropdown options.
129
- */
130
- getDocumentByFolderID(folderId:string, contextId:string): Observable<DocumentModel[]> {
131
- let headers = new HttpHeaders( {
132
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
133
- });
134
- return this.http.get<DocumentModel[]>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${URLS.PARENT_DOCUMENT_TYPE_ID}${folderId}${URLS.CONTEXT_ID}${contextId}`, { headers }).pipe(
135
- tap((records: DocumentModel[]) => {
136
- this.documentStore.set(records);
137
- }),
138
- catchError((error) => {
139
- return throwError(() => new Error(error));
140
- })
141
- );
142
- }
143
-
144
- /**
145
- * Updates the name of a document.
146
- * This method sends an HTTP PUT request to update the document's file name using the provided document ID and payload.
147
- * In case of an error, it will return an observable that throws an Error.
148
- * @param {string} documentId - The unique identifier of the document to update.
149
- * @param {any} payload - The payload containing the updated document data (e.g., fileName).
150
- * @returns {Observable<DocumentModel>} An observable that emits the updated DocumentModel.
151
- */
152
- updateDocumentName(documentId: string, payload: any): Observable<DocumentModel> {
153
- let headers = new HttpHeaders( {
154
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
155
- });
156
- return this.http.put<DocumentModel>(`${this.apiUrl}${URLS.ALIAS_NAME}${documentId}`, payload, { headers }).pipe(
157
- catchError((error) => {
158
- return throwError(() => new Error(error));
159
- })
160
- );
161
- }
162
-
163
- /**
164
- * Fetches a userlist by its path name.
165
- * @param {string} contextId - The document ID to fetch the document.
166
- * @returns {Observable<UserListModel[]>} Observable that emits the user list data.
167
- */
168
- getUserListByContextId(contextId : string): Observable<UserListModel[]> {
169
- let headers = new HttpHeaders( {
170
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
171
- });
172
- if(!contextId) return EMPTY;
173
- return this.http.get<UserListModel[]>(`${this.apiUrl}${URLS.USERLIST}${contextId}`, { headers }).pipe(
174
- tap((userList: UserListModel[]) => {
175
- this.documentStore.setUserList(userList);
176
- }),
177
- catchError((error) => {
178
- return throwError(() => new Error(error));
179
- })
180
- );
181
- }
182
-
183
- /**
184
- * Fetches document status count data by application ID with optional context ID and category parameters.
185
- * @param {string} applicationId - The application ID to fetch status data.
186
- * @param {string | null} contextId - The context ID (applicant ID) to filter by. If null, uses applicationId.
187
- * @param {string | null} categoryId - The category ID to filter by.
188
- * @returns {Observable<StatusDataModel[]>} Observable that emits the status data.
189
- */
190
- getStatusDocumentCount(applicationId: string, contextId: string | null = null, categoryId: string | null = null): Observable<StatusDataModel[]> {
191
- if(!applicationId) return EMPTY;
192
- let headers = new HttpHeaders( {
193
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
194
- });
195
- let url = `${this.apiUrl}${URLS.STATUS_DOCUMENT_COUNT}${applicationId}`;
196
- let params = new HttpParams();
197
- const contextParam = contextId || null;
198
- if (contextParam) {
199
- params = params.set(SHARED.CONTEXT_ID, contextParam);
200
- }
201
- if (categoryId) {
202
- params = params.set(SHARED.CATEGORY, categoryId);
203
- }
204
- return this.http.get<StatusDataModel[]>(url, { params, headers }).pipe(
205
- tap((statusData: StatusDataModel[]) => {
206
- this.documentStore.setStatusData(statusData);
207
- }),
208
- catchError((error) => {
209
- return throwError(() => new Error(error));
210
- })
211
- );
212
- }
213
-
214
-
215
- /**
216
- * Fetches documents based on selection criteria (user ID, status, and search key).
217
- * This method sends an HTTP GET request with query parameters for the selected filters.
218
- * Note: Menu item filtering has been removed - menu items are now used for navigation only.
219
- * @param {string} contextId - The context ID (applicationId or applicantId).
220
- * @param {string | null} menuItem - Reserved parameter (no longer used for filtering).
221
- * @param {string | null} userId - The selected user ID filter.
222
- * @param {string | null} status - The selected status filter.
223
- * @param {string | null} searchKey - The search key filter.
224
- * @returns {Observable<any>} An observable that emits the filtered document data.
225
- */
226
- getDocumentsBySelection(contextId: string, menuItem: string | null, userId: string | null, status: string | null, searchKey: string | null = null): Observable<any> {
227
- let headers = new HttpHeaders( {
228
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
229
- });
230
- let params = new HttpParams();
231
- if (userId) {
232
- params = params.set(SHARED.CONTEXT_ID, userId);
233
- }
234
-
235
- if (status) {
236
- params = params.set(SHARED.STATUS_PARAM, status);
237
- }
238
-
239
- if (searchKey) {
240
- params = params.set(SHARED.SEARCH_KEY, searchKey);
241
- }
242
- return this.http.get<any>(`${this.apiUrl}${URLS.GETALL}/${contextId}`, { params, headers }).pipe(
243
- tap((response: any) => {
244
- if (response.documents) {
245
- this.documentStore.setDocumentList(response.documents);
246
- }
247
- }),
248
- catchError((error) => {
249
- return throwError(() => new Error(error));
250
- })
251
- );
252
- }
253
-
254
- getDocumentHistory(documentId: string): Observable<DocumentHistorySection[]> {
255
- let headers = new HttpHeaders( {
256
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
257
- });
258
- if (!documentId) {
259
- return of([]);
260
- }
261
- return this.http.get<DocumentHistorySection[]>(`${this.apiUrl}${URLS.DOCUMENT_HISTORY}${documentId}`, { headers }).pipe(
262
- catchError((error) => {
263
- return throwError(() => new Error(error));
264
- })
265
- );
266
- }
267
-
268
- /**
269
- * Fetches document categories by source (Applicant/Application).
270
- * @param {string} source - The source type (Applicant or Application).
271
- * @returns {Observable<DocumentCategory[]>} Observable that emits the categories.
272
- */
273
- getCategoriesBySource(source: string): Observable<DocumentCategory[]> {
274
- if (!source) return EMPTY;
275
- let headers = new HttpHeaders( {
276
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
277
- });
278
- return this.http.get<DocumentCategory[]>(`${this.apiUrl}${URLS.GET_CATEGORIES_BY_SOURCE}${source}`, { headers }).pipe(
279
- catchError((error) => {
280
- return throwError(() => new Error(error));
281
- })
282
- );
283
- }
284
-
285
- /**
286
- * Fetches document types by category ID.
287
- * @param {string} categoryId - The category ID to fetch document types for.
288
- * @returns {Observable<DocumentTypeModel[]>} Observable that emits the document types.
289
- */
290
- getDocumentTypesByCategory(categoryId: string): Observable<DocumentTypeModel[]> {
291
- let headers = new HttpHeaders( {
292
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
293
- });
294
- if (!categoryId) return EMPTY;
295
- return this.http.get<DocumentTypeModel[]>(`${this.apiUrl}${URLS.GET_DOCUMENT_TYPES_BY_CATEGORY}${categoryId}`, { headers }).pipe(
296
- catchError((error) => {
297
- return throwError(() => new Error(error));
298
- })
299
- );
300
- }
301
-
302
- /**
303
- * Uploads a single file using the uploadFile API.
304
- * @param {FormData} formData - The form data containing the file and metadata.
305
- * @returns {Observable<any>} Observable that emits the upload response.
306
- */
307
- uploadFile(formData: FormData): Observable<any> {
308
- let headers = new HttpHeaders( {
309
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
310
- });
311
- return this.http.post<any>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD_FILE}`, formData, { headers }).pipe(
312
- catchError((error) => {
313
- return throwError(() => new Error(error));
314
- })
315
- );
316
- }
317
-
318
- /**
319
- * Saves the complete document upload data.
320
- * @param {any} payload - The document upload payload containing all necessary data.
321
- * @returns {Observable<any>} Observable that emits the save response.
322
- */
323
- saveDocumentUpload(payload: any): Observable<any> {
324
- let headers = new HttpHeaders( {
325
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
326
- });
327
- return this.http.post<any>(`${this.apiUrl}${URLS.SAVE_DOCUMENT_UPLOAD}`, payload, { headers }).pipe(
328
- catchError((error) => {
329
- return throwError(() => new Error(error));
330
- })
331
- );
332
- }
333
-
334
- /**
335
- * Updates the status of a document by document ID
336
- * @param {string} documentId - The ID of the document to update
337
- * @param {string} status - The new status (Approved, Rejected, etc.)
338
- * @param {string} statusUpdateDescription - The description/note for the status update
339
- * @returns {Observable<any>} Observable that emits the updated document data with normalized status
340
- */
341
- updateDocumentStatus(documentId: string, status: string, statusUpdateDescription: string): Observable<any> {
342
- let headers = new HttpHeaders( {
343
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
344
- });
345
- const payload = {
346
- statusUpdateDescription: statusUpdateDescription
347
- };
348
- return this.http.put<any>(`${this.apiUrl}${URLS.UPDATE_DOCUMENT_STATUS}${documentId}/${status}`, payload, { headers }).pipe(
349
- tap((response) => {
350
- if (response && response.status) {
351
- const normalizedStatus = this.normalizeStatus(response.status);
352
- response.normalizedStatus = normalizedStatus;
353
- }
354
- }),
355
- catchError((error) => {
356
- return throwError(() => new Error(error));
357
- })
358
- );
359
- }
360
-
361
- /**
362
- * Normalizes the status from API response to match component expectations
363
- * @param {string} status - The status from API response (Approved, Rejected, etc.)
364
- * @returns {string} Normalized status value
365
- */
366
- private normalizeStatus(status: string): string {
367
- switch (status.toLowerCase()) {
368
- case SHARED.APPROVED:
369
- return SHARED.STATUS_ACCEPTED;
370
- case SHARED.STATUS_REJECTED_LOWERCASE:
371
- return SHARED.STATUS_REJECTED_LOWERCASE;
372
- case SHARED.STATUS_PENDING:
373
- return SHARED.STATUS_PENDING;
374
- default:
375
- return status.toLowerCase();
376
- }
377
- }
378
-
379
- /**
380
- * Deletes a document by its ID and refreshes all data (categories, userlist, status, and document list)
381
- * @param {string} documentId - The ID of the document to delete
382
- * @param {string} contextId - The context ID to refresh all data
383
- * @returns {Observable<any>} Observable that emits the delete response
384
- */
385
- deleteDocument(documentId: string, contextId: string): Observable<any> {
386
- let headers = new HttpHeaders( {
387
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
388
- });
389
- return this.http.delete<any>(`${this.apiUrl}${URLS.DELETE_DOCUMENT}${documentId}`, { headers }).pipe(
390
- tap(() => {
391
- this.getDocumentCatagories(contextId).subscribe();
392
- this.getUserListByContextId(contextId).subscribe();
393
- this.getStatusDocumentCount(contextId).subscribe();
394
- this.getDocumentsBySelection(contextId, null, null, null, null).subscribe();
395
- }),
396
- catchError((error) => {
397
- return throwError(() => new Error(error));
398
- })
399
- );
400
- }
401
-
402
- /**
403
- * Downloads an Excel file with proper authentication headers
404
- * Authentication is handled automatically by the HTTP interceptor
405
- * @param {string} documentUrl - The URL of the Excel file to download
406
- * @returns {Observable<ArrayBuffer>} Observable that emits the file data as ArrayBuffer
407
- */
408
- downloadExcelFile(documentUrl: string): Observable<ArrayBuffer> {
409
- let headers = new HttpHeaders( {
410
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
411
- });
412
- return this.http.get(documentUrl, { headers,
413
- responseType: 'arraybuffer'
414
- }).pipe(
415
- catchError((error) => {
416
- return throwError(() => new Error(error));
417
- })
418
- );
419
- }
420
-
421
- /**
422
- * Downloads a CSV file with proper authentication headers
423
- * Authentication is handled automatically by the HTTP interceptor
424
- * @param {string} documentUrl - The URL of the CSV file to download
425
- * @returns {Observable<string>} Observable that emits the file data as string
426
- */
427
- downloadCsvFile(documentUrl: string): Observable<string> {
428
- let headers = new HttpHeaders( {
429
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
430
- });
431
- return this.http.get(documentUrl, { headers,
432
- responseType: 'text'
433
- }).pipe(
434
- catchError((error) => {
435
- return throwError(() => new Error(error));
436
- })
437
- );
438
- }
439
-
440
-
441
- /**
442
- * Downloads an email file (EML) with appropriate handling for different storage types
443
- * @param documentUrl - URL of the email file
444
- * @returns Observable of file content as text
445
- */
446
- downloadEmailFile(documentUrl: string): Observable<string> {
447
- let headers = new HttpHeaders( {
448
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
449
- });
450
- const isAzureBlobStorage = documentUrl.includes('.blob.core.windows.net');
451
- if (isAzureBlobStorage) {
452
- return this.http.get(documentUrl, { headers,
453
- responseType: 'text'
454
- }).pipe(
455
- catchError((error) => {
456
- return throwError(() => new Error('Failed to download email file. Please check if the file URL is valid and accessible.'));
457
- })
458
- );
459
- } else {
460
- return this.http.get<string>(documentUrl, { headers }
461
- ).pipe(
462
- catchError((error) => {
463
- return throwError(() => new Error('Failed to download email file. Please check if the file URL is valid and accessible.'));
464
- })
465
- );
466
- }
467
- }
468
-
469
- documentRequest(payload: any): Observable<any> {
470
- let headers = new HttpHeaders( {
471
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
472
- });
473
- return this.http.post<any>(`${this.apiUrl}${URLS.DOCUMENT_REQUEST}`, payload, { headers }).pipe(
474
- catchError((error) => {
475
- return throwError(() => new Error(error));
476
- })
477
- );
478
- }
479
-
480
- /**
481
- * Checks if valuation report data exists for the given context ID
482
- * @param {string} contextId - The context ID to check for valuation report data
483
- * @returns {Observable<any>} Observable that emits the valuation report data or empty object
484
- */
485
- getValuationReportByContextId(contextId: string): Observable<any> {
486
- let headers = new HttpHeaders( {
487
- 'Authorization': `Bearer 4fe17947-30bf-4079-b4ea-798ff73cd473`
488
- });
489
- if (!contextId) return EMPTY;
490
- return this.http.get<any>(`${this.apiUrl}${URLS.VALUATION_REPORT}${contextId}`, { headers }).pipe(
491
- catchError((error) => {
492
- // Return empty object if no data found or error occurs
493
- return of(null);
494
- })
495
- );
496
- }
497
- }
@@ -1,195 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Observable, of, throwError } from 'rxjs';
3
- import { DocumentUploadService } from './document-upload.service';
4
- import { DocumentHttpService } from './document-http.service';
5
- import { DocumentQuery } from '../state/document.query';
6
- import { DocumentStore } from '../state/document.store';
7
- import { DocumentTableBuilderService } from './document-table-builder.service';
8
- import { DocumentHelperService } from './document.service';
9
- import { DocumentListItem, DocumentListResponse } from '../models/document-list-response.model';
10
- import { TableData } from '../../../Shared/components/table-primary/table-primary.model';
11
- import { SHARED } from '../../../Shared/constant/SHARED';
12
- import { ERRORS } from '../../../Shared/constant/ERROR';
13
- import { Message } from 'primeng/api';
14
- import { DocumentCategory } from '../models/document-category.model';
15
-
16
-
17
- @Injectable({
18
- providedIn: 'root'
19
- })
20
- export class DocumentListService {
21
-
22
- constructor(
23
- private documentUploadService: DocumentUploadService,
24
- private documentHttpService: DocumentHttpService,
25
- private documentQuery: DocumentQuery,
26
- private documentStore: DocumentStore,
27
- private documentTableBuilder: DocumentTableBuilderService,
28
- private documentHelperService: DocumentHelperService
29
- ) {}
30
-
31
- /**
32
- * Handle file upload click event
33
- */
34
- handleFileUploadClick(): void {
35
- this.documentStore.setMessage(SHARED.EMPTY_ARRAY);
36
- }
37
-
38
- /**
39
- * Handle save click to update document name
40
- */
41
- handleSaveClick(fileName: string, selectedDocument: DocumentListItem): Observable<any> {
42
- const payload = { fileName };
43
- return this.documentHttpService.updateDocumentName(selectedDocument._id, payload);
44
- }
45
-
46
-
47
- /**
48
- * Get completion count for a category
49
- */
50
- getCompletionCount(category: DocumentListResponse): string {
51
- return this.documentTableBuilder.getCompletionCount(category);
52
- }
53
-
54
- /**
55
- * Get pending document count for a category
56
- */
57
- getPendingDocumentCount(category: DocumentListResponse): number {
58
- return this.documentTableBuilder.getPendingDocumentCount(category);
59
- }
60
-
61
- /**
62
- * Get approved document count for a category
63
- */
64
- getApprovedDocumentCount(category: DocumentListResponse): number {
65
- return this.documentTableBuilder.getApprovedDocumentCount(category);
66
- }
67
-
68
-
69
-
70
- /**
71
- * Build document categories from API response
72
- */
73
- buildDocumentCategories(documentListResponse: DocumentListResponse[] | null): {
74
- documentCategories: DocumentListResponse[];
75
- categoryTables: TableData[];
76
- categoryCompletionCounts: string[];
77
- categorySeverities: ('success' | 'info' | 'warning' | 'danger')[];
78
- } {
79
- if (!documentListResponse) {
80
- return {
81
- documentCategories: SHARED.EMPTY_ARRAY,
82
- categoryTables: SHARED.EMPTY_ARRAY,
83
- categoryCompletionCounts: SHARED.EMPTY_ARRAY,
84
- categorySeverities: SHARED.EMPTY_ARRAY
85
- };
86
- }
87
-
88
- // Handle empty response - create a default category to show "No records found"
89
- if (documentListResponse.length === 0) {
90
- const defaultCategory = {
91
- label: SHARED.EMPTY,
92
- categoryDescription: SHARED.NO_DOCUMENTS_FOUND,
93
- list: SHARED.EMPTY_ARRAY,
94
- totalDocs: 0,
95
- acceptedDocs: 0,
96
- completed: '0/0'
97
- };
98
-
99
- return {
100
- documentCategories: [defaultCategory],
101
- categoryTables: [this.documentTableBuilder.buildDocumentTable([])],
102
- categoryCompletionCounts: ['0/0'],
103
- categorySeverities: ['info']
104
- };
105
- }
106
-
107
- const documentCategories = [...documentListResponse];
108
- const categoryTables = documentListResponse.map(category =>
109
- this.documentTableBuilder.buildDocumentTable(category.list)
110
- );
111
- const categoryCompletionCounts = documentListResponse.map(category =>
112
- this.getCompletionCount(category)
113
- );
114
-
115
- // Use the same severity calculation logic as menu items for consistency
116
- const categorySeverities = documentListResponse.map(category => {
117
- // Create a status object similar to what menu items use
118
- const status = {
119
- Pending: category.list.filter(doc => doc.status.toLowerCase() === SHARED.PENDING_STATUS).length,
120
- Reviewing: category.list.filter(doc => doc.status.toLowerCase() === SHARED.REVIEWING_STATUS).length,
121
- Accepted: category.list.filter(doc => doc.status.toLowerCase() === SHARED.APPROVED_STATUS || doc.status.toLowerCase() === SHARED.UPLOADED_STATUS).length,
122
- Rejected: category.list.filter(doc => doc.status.toLowerCase() === SHARED.REJECTED_STATUS).length
123
- };
124
-
125
- // Use the same severity calculation as menu items
126
- const total = status.Pending + status.Reviewing + status.Accepted + status.Rejected;
127
- if (total === 0) return 'info';
128
- if (status.Pending > 0) return 'info';
129
- if (status.Rejected > 0) return 'danger';
130
- if (status.Reviewing > 0) return 'warning';
131
- if (status.Accepted === total && total > 0) return 'success';
132
- return 'warning';
133
- });
134
-
135
- return {
136
- documentCategories,
137
- categoryTables,
138
- categoryCompletionCounts,
139
- categorySeverities
140
- };
141
- }
142
-
143
-
144
-
145
- /**
146
- * Handle table row click
147
- */
148
- handleTableRowClick(rowData: any): DocumentListItem {
149
- return rowData;
150
- }
151
-
152
- /**
153
- * Handle delete action
154
- */
155
- handleDeleteAction(rowData: any, contextId: string): Observable<any> {
156
- if (!rowData._id || !contextId) {
157
- return throwError(() => new Error('Missing required parameters for delete'));
158
- }
159
-
160
- return this.documentHttpService.deleteDocument(rowData._id, contextId);
161
- }
162
-
163
- /**
164
- * Refresh document list for new context
165
- */
166
- refreshDocumentListForNewContext(contextId: string): void {
167
- if (contextId && contextId !== SHARED.EMPTY) {
168
- this.documentStore.setDocumentListResponse(null);
169
- this.documentHelperService.refreshDocumentsWithoutFilters(contextId);
170
- }
171
- }
172
-
173
- /**
174
- * Refresh document list after status update
175
- */
176
- refreshDocumentList(contextId: string): void {
177
- if (contextId) {
178
- this.documentHelperService.refreshDocumentsWithCurrentSelection(contextId);
179
- }
180
- }
181
-
182
- /**
183
- * Setup subscription to document list response
184
- */
185
- setupDocumentListSubscription(): Observable<DocumentListResponse[] | null> {
186
- return this.documentQuery.selectDocumentListResponse();
187
- }
188
-
189
- /**
190
- * Refresh all data with current filters
191
- */
192
- refreshAllDataWithCurrentFilters(contextId: string): void {
193
- this.documentHelperService.refreshAllDataWithCurrentFilters(contextId);
194
- }
195
- }