cat-documents-ng 1.0.4 → 1.0.6

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 (210) hide show
  1. package/ng-package.json +10 -0
  2. package/package.json +5 -11
  3. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +3 -0
  4. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +13 -0
  5. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +70 -0
  6. package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +133 -0
  7. package/src/Shared/components/table-primary/table-primary.component.html +66 -0
  8. package/src/Shared/components/table-primary/table-primary.component.scss +227 -0
  9. package/src/Shared/components/table-primary/table-primary.component.spec.ts +23 -0
  10. package/src/Shared/components/table-primary/table-primary.component.ts +143 -0
  11. package/src/Shared/components/table-primary/table-primary.model.ts +21 -0
  12. package/src/Shared/constant/ERROR.ts +55 -0
  13. package/src/Shared/constant/PERMISSIONS.ts +17 -0
  14. package/src/Shared/constant/SHARED.ts +936 -0
  15. package/{Shared/constant/URLS.d.ts → src/Shared/constant/URLS.ts} +31 -25
  16. package/src/Shared/services/app-config.service.spec.ts +19 -0
  17. package/src/Shared/services/app-config.service.ts +73 -0
  18. package/{Shared/services/global-error.handler.d.ts → src/Shared/services/global-error.handler.ts} +11 -9
  19. package/src/Shared/services/session.service.spec.ts +16 -0
  20. package/src/Shared/services/session.service.ts +76 -0
  21. package/src/Shared/shared.module.ts +25 -0
  22. package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +1 -0
  23. package/src/lib/document/components/document-actions/document-actions.component.html +59 -0
  24. package/src/lib/document/components/document-actions/document-actions.component.scss +362 -0
  25. package/src/lib/document/components/document-actions/document-actions.component.spec.ts +297 -0
  26. package/src/lib/document/components/document-actions/document-actions.component.ts +163 -0
  27. package/src/lib/document/components/document-container/document-container.component.html +36 -0
  28. package/src/lib/document/components/document-container/document-container.component.scss +144 -0
  29. package/src/lib/document/components/document-container/document-container.component.spec.ts +110 -0
  30. package/src/lib/document/components/document-container/document-container.component.ts +363 -0
  31. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +332 -0
  32. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +1877 -0
  33. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +258 -0
  34. package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +664 -0
  35. package/src/lib/document/components/document-history/document-history.component.html +96 -0
  36. package/src/lib/document/components/document-history/document-history.component.scss +392 -0
  37. package/src/lib/document/components/document-history/document-history.component.spec.ts +93 -0
  38. package/src/lib/document/components/document-history/document-history.component.ts +373 -0
  39. package/src/lib/document/components/document-list/document-list.component.html +46 -0
  40. package/src/lib/document/components/document-list/document-list.component.scss +513 -0
  41. package/src/lib/document/components/document-list/document-list.component.spec.ts +486 -0
  42. package/src/lib/document/components/document-list/document-list.component.ts +682 -0
  43. package/src/lib/document/components/document-list-item/document-list-item.component.html +36 -0
  44. package/src/lib/document/components/document-list-item/document-list-item.component.scss +34 -0
  45. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +75 -0
  46. package/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
  47. package/src/lib/document/components/document-search/document-search.component.html +64 -0
  48. package/src/lib/document/components/document-search/document-search.component.scss +206 -0
  49. package/src/lib/document/components/document-search/document-search.component.spec.ts +82 -0
  50. package/src/lib/document/components/document-search/document-search.component.ts +163 -0
  51. package/src/lib/document/components/document-status/document-status.component.html +31 -0
  52. package/src/lib/document/components/document-status/document-status.component.scss +192 -0
  53. package/src/lib/document/components/document-status/document-status.component.spec.ts +23 -0
  54. package/src/lib/document/components/document-status/document-status.component.ts +87 -0
  55. package/src/lib/document/components/document-upload/document-upload.component.html +160 -0
  56. package/src/lib/document/components/document-upload/document-upload.component.scss +235 -0
  57. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +95 -0
  58. package/src/lib/document/components/document-upload/document-upload.component.ts +668 -0
  59. package/src/lib/document/components/document-viewer/document-viewer.component.html +50 -0
  60. package/src/lib/document/components/document-viewer/document-viewer.component.scss +187 -0
  61. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +79 -0
  62. package/src/lib/document/components/document-viewer/document-viewer.component.ts +261 -0
  63. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +48 -0
  64. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +320 -0
  65. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +59 -0
  66. package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +150 -0
  67. package/src/lib/document/components/documents-menu/documents-menu.component.html +44 -0
  68. package/src/lib/document/components/documents-menu/documents-menu.component.scss +363 -0
  69. package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +23 -0
  70. package/src/lib/document/components/documents-menu/documents-menu.component.ts +316 -0
  71. package/src/lib/document/components/folder-block/folder-block.component.html +46 -0
  72. package/src/lib/document/components/folder-block/folder-block.component.scss +9 -0
  73. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +70 -0
  74. package/{lib/document/components/folder-block/folder-block.component.d.ts → src/lib/document/components/folder-block/folder-block.component.ts} +28 -12
  75. package/src/lib/document/components/folder-container/folder-container.component.html +56 -0
  76. package/src/lib/document/components/folder-container/folder-container.component.scss +20 -0
  77. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +27 -0
  78. package/src/lib/document/components/folder-container/folder-container.component.ts +328 -0
  79. package/src/lib/document/components/linked-document/linked-document.component.html +23 -0
  80. package/src/lib/document/components/linked-document/linked-document.component.scss +10 -0
  81. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +61 -0
  82. package/src/lib/document/components/linked-document/linked-document.component.ts +49 -0
  83. package/src/lib/document/components/request-document/request-document.component.html +86 -0
  84. package/src/lib/document/components/request-document/request-document.component.scss +16 -0
  85. package/src/lib/document/components/request-document/request-document.component.ts +278 -0
  86. package/src/lib/document/components/sidebar/sidebar.component.html +75 -0
  87. package/src/lib/document/components/sidebar/sidebar.component.scss +157 -0
  88. package/src/lib/document/components/sidebar/sidebar.component.spec.ts +114 -0
  89. package/src/lib/document/components/sidebar/sidebar.component.ts +223 -0
  90. package/src/lib/document/components/user-list/user-list.component.html +33 -0
  91. package/src/lib/document/components/user-list/user-list.component.scss +118 -0
  92. package/src/lib/document/components/user-list/user-list.component.spec.ts +23 -0
  93. package/src/lib/document/components/user-list/user-list.component.ts +181 -0
  94. package/src/lib/document/constant/DOCUMENT_HISTORY.ts +52 -0
  95. package/src/lib/document/directives/document.directive.ts +32 -0
  96. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  97. package/src/lib/document/directives/permission.directive.ts +72 -0
  98. package/src/lib/document/document.module.ts +351 -0
  99. package/{lib/document/models/document-alert.model.d.ts → src/lib/document/models/document-alert.model.ts} +11 -4
  100. package/src/lib/document/models/document-category.model.ts +30 -0
  101. package/src/lib/document/models/document-history.model.ts +109 -0
  102. package/src/lib/document/models/document-list-response.model.ts +37 -0
  103. package/src/lib/document/models/document-type.model.ts +44 -0
  104. package/src/lib/document/models/document.model.ts +53 -0
  105. package/{lib/document/models/folder.model.d.ts → src/lib/document/models/folder.model.ts} +10 -4
  106. package/src/lib/document/models/status-data.model.ts +31 -0
  107. package/src/lib/document/models/uploaded-file-response.model.ts +7 -0
  108. package/src/lib/document/models/user-list.model.ts +10 -0
  109. package/src/lib/document/services/csv-parser.service.spec.ts +97 -0
  110. package/src/lib/document/services/csv-parser.service.ts +303 -0
  111. package/src/lib/document/services/document-actions.service.ts +125 -0
  112. package/src/lib/document/services/document-content-type.service.ts +193 -0
  113. package/src/lib/document/services/document-history-style.service.ts +138 -0
  114. package/src/lib/document/services/document-history.service.ts +129 -0
  115. package/src/lib/document/services/document-http.service.spec.ts +119 -0
  116. package/src/lib/document/services/document-http.service.ts +497 -0
  117. package/src/lib/document/services/document-list.service.ts +195 -0
  118. package/src/lib/document/services/document-menu.service.ts +277 -0
  119. package/src/lib/document/services/document-scroll.service.ts +138 -0
  120. package/src/lib/document/services/document-severity.service.ts +98 -0
  121. package/src/lib/document/services/document-table-builder.service.ts +82 -0
  122. package/src/lib/document/services/document-upload-business.service.ts +326 -0
  123. package/src/lib/document/services/document-upload-data.service.ts +82 -0
  124. package/src/lib/document/services/document-upload-form.service.ts +149 -0
  125. package/src/lib/document/services/document-upload.service.spec.ts +99 -0
  126. package/src/lib/document/services/document-upload.service.ts +209 -0
  127. package/src/lib/document/services/document-viewer.service.ts +279 -0
  128. package/src/lib/document/services/document-zoom.service.spec.ts +56 -0
  129. package/src/lib/document/services/document-zoom.service.ts +164 -0
  130. package/src/lib/document/services/document.service.ts +356 -0
  131. package/src/lib/document/services/eml-parser.service.ts +444 -0
  132. package/src/lib/document/services/excel-parser.service.spec.ts +66 -0
  133. package/src/lib/document/services/excel-parser.service.ts +483 -0
  134. package/src/lib/document/services/file-format.service.spec.ts +16 -0
  135. package/src/lib/document/services/file-format.service.ts +63 -0
  136. package/src/lib/document/services/status-calculator.service.ts +44 -0
  137. package/src/lib/document/services/user-list.service.ts +77 -0
  138. package/src/lib/document/state/document.query.ts +378 -0
  139. package/{lib/document/state/document.service.d.ts → src/lib/document/state/document.service.ts} +46 -15
  140. package/src/lib/document/state/document.state.ts +100 -0
  141. package/src/lib/document/state/document.store.ts +200 -0
  142. package/{public-api.d.ts → src/public-api.ts} +4 -0
  143. package/tsconfig.lib.json +15 -0
  144. package/tsconfig.lib.prod.json +11 -0
  145. package/tsconfig.spec.json +15 -0
  146. package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +0 -44
  147. package/Shared/components/table-primary/table-primary.component.d.ts +0 -31
  148. package/Shared/components/table-primary/table-primary.model.d.ts +0 -19
  149. package/Shared/constant/ERROR.d.ts +0 -52
  150. package/Shared/constant/SHARED.d.ts +0 -546
  151. package/Shared/services/app-config.service.d.ts +0 -51
  152. package/Shared/services/session.service.d.ts +0 -46
  153. package/Shared/shared.module.d.ts +0 -14
  154. package/fesm2022/cat-documents-ng.mjs +0 -11392
  155. package/fesm2022/cat-documents-ng.mjs.map +0 -1
  156. package/index.d.ts +0 -5
  157. package/lib/document/components/document-actions/document-actions.component.d.ts +0 -78
  158. package/lib/document/components/document-container/document-container.component.d.ts +0 -162
  159. package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +0 -291
  160. package/lib/document/components/document-history/document-history.component.d.ts +0 -160
  161. package/lib/document/components/document-list/document-list.component.d.ts +0 -299
  162. package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
  163. package/lib/document/components/document-search/document-search.component.d.ts +0 -77
  164. package/lib/document/components/document-status/document-status.component.d.ts +0 -24
  165. package/lib/document/components/document-upload/document-upload.component.d.ts +0 -321
  166. package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -137
  167. package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +0 -33
  168. package/lib/document/components/documents-menu/documents-menu.component.d.ts +0 -110
  169. package/lib/document/components/folder-container/folder-container.component.d.ts +0 -162
  170. package/lib/document/components/linked-document/linked-document.component.d.ts +0 -39
  171. package/lib/document/components/request-document/request-document.component.d.ts +0 -69
  172. package/lib/document/components/sidebar/sidebar.component.d.ts +0 -109
  173. package/lib/document/components/user-list/user-list.component.d.ts +0 -34
  174. package/lib/document/constant/DOCUMENT_HISTORY.d.ts +0 -41
  175. package/lib/document/directives/document.directive.d.ts +0 -20
  176. package/lib/document/directives/permission.directive.d.ts +0 -38
  177. package/lib/document/document.module.d.ts +0 -60
  178. package/lib/document/models/document-category.model.d.ts +0 -24
  179. package/lib/document/models/document-history.model.d.ts +0 -94
  180. package/lib/document/models/document-list-response.model.d.ts +0 -33
  181. package/lib/document/models/document-type.model.d.ts +0 -37
  182. package/lib/document/models/document.model.d.ts +0 -44
  183. package/lib/document/models/status-data.model.d.ts +0 -27
  184. package/lib/document/models/uploaded-file-response.model.d.ts +0 -7
  185. package/lib/document/models/user-list.model.d.ts +0 -8
  186. package/lib/document/services/csv-parser.service.d.ts +0 -88
  187. package/lib/document/services/document-actions.service.d.ts +0 -48
  188. package/lib/document/services/document-content-type.service.d.ts +0 -85
  189. package/lib/document/services/document-history-style.service.d.ts +0 -34
  190. package/lib/document/services/document-history.service.d.ts +0 -42
  191. package/lib/document/services/document-http.service.d.ts +0 -179
  192. package/lib/document/services/document-list.service.d.ts +0 -74
  193. package/lib/document/services/document-menu.service.d.ts +0 -122
  194. package/lib/document/services/document-scroll.service.d.ts +0 -55
  195. package/lib/document/services/document-table-builder.service.d.ts +0 -38
  196. package/lib/document/services/document-upload-business.service.d.ts +0 -107
  197. package/lib/document/services/document-upload-data.service.d.ts +0 -40
  198. package/lib/document/services/document-upload-form.service.d.ts +0 -41
  199. package/lib/document/services/document-upload.service.d.ts +0 -99
  200. package/lib/document/services/document-viewer.service.d.ts +0 -97
  201. package/lib/document/services/document-zoom.service.d.ts +0 -81
  202. package/lib/document/services/document.service.d.ts +0 -161
  203. package/lib/document/services/eml-parser.service.d.ts +0 -116
  204. package/lib/document/services/excel-parser.service.d.ts +0 -169
  205. package/lib/document/services/file-format.service.d.ts +0 -34
  206. package/lib/document/services/status-calculator.service.d.ts +0 -20
  207. package/lib/document/services/user-list.service.d.ts +0 -29
  208. package/lib/document/state/document.query.d.ts +0 -243
  209. package/lib/document/state/document.state.d.ts +0 -61
  210. package/lib/document/state/document.store.d.ts +0 -56
@@ -0,0 +1,664 @@
1
+ import {
2
+ Component,
3
+ Input,
4
+ OnChanges,
5
+ SimpleChanges,
6
+ ViewEncapsulation,
7
+ OnInit,
8
+ HostListener,
9
+ } from '@angular/core';
10
+ import { OPEN_DOCUMENT_EXTENSIONS, SHARED, SUPPORTED_IMAGE_TYPES } from '../../../../Shared/constant/SHARED';
11
+ import { ExcelParserService, ExcelRowData, ParsedExcelData } from '../../services/excel-parser.service';
12
+ import { CsvParserService, CsvRowData, ParsedCsvData } from '../../services/csv-parser.service';
13
+ import { EmlParserService, ParsedEmailData } from '../../services/eml-parser.service';
14
+ import { DocumentHttpService } from '../../services/document-http.service';
15
+ import { DocumentZoomService } from '../../services/document-zoom.service';
16
+ import { DocumentListItem } from '../../models/document-list-response.model';
17
+ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
18
+
19
+ /**
20
+ * Component for viewing different types of document content.
21
+ * Supports PDF, images, and other document formats.
22
+ * @class DocumentContentViewerComponent
23
+ * @typedef {DocumentContentViewerComponent}
24
+ */
25
+ @Component({
26
+ selector: 'document-content-viewer',
27
+ templateUrl: './document-content-viewer.component.html',
28
+ standalone: false,
29
+ styleUrl: './document-content-viewer.component.scss',
30
+ encapsulation: ViewEncapsulation.None,
31
+ })
32
+ export class DocumentContentViewerComponent implements OnChanges, OnInit {
33
+ /**
34
+ * The document URL to display
35
+ * @type {string}
36
+ */
37
+ @Input() documentUrl?: string;
38
+
39
+ /**
40
+ * The content type of the document
41
+ * @type {string}
42
+ */
43
+ @Input() contentType?: string;
44
+
45
+ /**
46
+ * The document name for display purposes
47
+ * @type {string}
48
+ */
49
+ @Input() documentName?: string;
50
+
51
+ /**
52
+ * The selected document for display purposes
53
+ * @type {DocumentListItem}
54
+ */
55
+ @Input() selectedDocument?: DocumentListItem;
56
+
57
+ /**
58
+ * The context ID for the document
59
+ * @type {string}
60
+ */
61
+ @Input() contextId?: string;
62
+
63
+ /**
64
+ * Flag to hide form elements
65
+ * @type {boolean}
66
+ */
67
+ @Input() isFormHide: boolean = false;
68
+ /**
69
+ * Excel data for display
70
+ * @type {any}
71
+ */
72
+ excelData: any = null;
73
+
74
+ /**
75
+ * Parsed Excel data as table rows
76
+ * @type {any[][]}
77
+ */
78
+ excelTableData: any[][] = SHARED.EMPTY_ARRAY;
79
+
80
+ /**
81
+ * Enhanced Excel data with styling information
82
+ * @type {ExcelRowData[]}
83
+ */
84
+ excelStyledData: ExcelRowData[] = SHARED.EMPTY_ARRAY;
85
+
86
+ /**
87
+ * Excel sheet names
88
+ * @type {string[]}
89
+ */
90
+ excelSheets: string[] = SHARED.EMPTY_ARRAY;
91
+
92
+ /**
93
+ * Current active sheet
94
+ * @type {string}
95
+ */
96
+ currentSheet: string = SHARED.EMPTY;
97
+
98
+ /**
99
+ * Loading state for Excel files
100
+ * @type {boolean}
101
+ */
102
+ isLoadingExcel: boolean = false;
103
+
104
+ /**
105
+ * Error state for Excel files
106
+ * @type {string | null}
107
+ */
108
+ excelError: string | null = null;
109
+
110
+ /**
111
+ * Loading state specifically for Word documents
112
+ * @type {boolean}
113
+ */
114
+ isLoadingWordDocument: boolean = false;
115
+
116
+ /**
117
+ * CSV data for display
118
+ * @type {any}
119
+ */
120
+ csvData: any = null;
121
+
122
+ /**
123
+ * Parsed CSV data as table rows
124
+ * @type {any[][]}
125
+ */
126
+ csvTableData: any[][] = SHARED.EMPTY_ARRAY;
127
+
128
+ /**
129
+ * Enhanced CSV data with styling information
130
+ * @type {CsvRowData[]}
131
+ */
132
+ csvStyledData: CsvRowData[] = SHARED.EMPTY_ARRAY;
133
+
134
+ /**
135
+ * Loading state for CSV files
136
+ * @type {boolean}
137
+ */
138
+ isLoadingCsv: boolean = false;
139
+
140
+ /**
141
+ * Error state for CSV files
142
+ * @type {string | null}
143
+ */
144
+ csvError: string | null = null;
145
+
146
+ /**
147
+ * Current zoom level for the document
148
+ * @type {number}
149
+ */
150
+ currentZoom: number = 100;
151
+
152
+ /**
153
+ * Email data for display
154
+ * @type {ParsedEmailData | null}
155
+ */
156
+ emailData: ParsedEmailData | null = null;
157
+
158
+ /**
159
+ * Loading state for Email files
160
+ * @type {boolean}
161
+ */
162
+ isLoadingEmail: boolean = false;
163
+
164
+ /**
165
+ * Error state for Email files
166
+ * @type {string | null}
167
+ */
168
+ emailError: string | null = null;
169
+
170
+
171
+
172
+ /**
173
+ * Constructor
174
+ * @param {ExcelParserService} excelParserService - Service for parsing Excel files
175
+ * @param {CsvParserService} csvParserService - Service for parsing CSV files
176
+ * @param {EmlParserService} emlParserService - Service for parsing EML files
177
+ * @param {DocumentHttpService} documentHttpService - Service for making HTTP requests for Excel/CSV files
178
+ * @param {DocumentZoomService} zoomService - Service for handling zoom functionality
179
+ * @param {DomSanitizer} sanitizer - Service for sanitizing HTML content
180
+ */
181
+ constructor(
182
+ private excelParserService: ExcelParserService,
183
+ private csvParserService: CsvParserService,
184
+ private emlParserService: EmlParserService,
185
+ private documentHttpService: DocumentHttpService,
186
+ private zoomService: DocumentZoomService,
187
+ private sanitizer: DomSanitizer
188
+ ) { }
189
+
190
+ /**
191
+ * Computed property to determine if the document is a PDF
192
+ * @type {boolean}
193
+ */
194
+ get isPdf(): boolean {
195
+ const ext = this.getFileExtension(this.documentName);
196
+ return ext === SHARED.PDF || ext === SHARED.PDF2;
197
+ }
198
+
199
+
200
+ /**
201
+ * Computed property to determine if the document is an Excel file
202
+ * @type {boolean}
203
+ */
204
+ get isExcel(): boolean {
205
+ const ext = this.getFileExtension(this.documentName);
206
+ return ext === SHARED.XLSX || ext === SHARED.XLS;
207
+ }
208
+
209
+ /**
210
+ * Computed property to determine if the document is a Word file
211
+ * @type {boolean}
212
+ */
213
+ get isWord(): boolean {
214
+ const ext = this.getFileExtension(this.documentName);
215
+ return ext === SHARED.DOCX || ext === SHARED.DOC;
216
+ }
217
+
218
+ /**
219
+ * Computed property to determine if the document is a CSV file
220
+ * @type {boolean}
221
+ */
222
+ get isCsv(): boolean {
223
+ const ext = this.getFileExtension(this.documentName);
224
+ return ext === SHARED.CSV;
225
+ }
226
+
227
+ /**
228
+ * Computed property to determine if the document is an email file
229
+ * @type {boolean}
230
+ */
231
+ get isEmail(): boolean {
232
+ return this.contentType === SHARED.EMAIL_RFC822_MIME_TYPE ||
233
+ this.contentType === SHARED.EMAIL_OUTLOOK_MIME_TYPE;
234
+ }
235
+
236
+ /**
237
+ * Computed property to determine if the document is an OpenDocument file
238
+ * @type {boolean}
239
+ */
240
+ get isOpenDocument(): boolean {
241
+ const ext = this.getFileExtension(this.documentName);
242
+ return OPEN_DOCUMENT_EXTENSIONS.includes(ext);
243
+ }
244
+
245
+ /**
246
+ * Computed property to determine if the document has an unsupported content type
247
+ * @type {boolean}
248
+ */
249
+ get isUnsupported(): boolean {
250
+ return !this.isImage && !this.isPdf && !this.isExcel && !this.isWord &&
251
+ !this.isCsv && !this.isEmail && !this.isOpenDocument;
252
+ }
253
+
254
+ /**
255
+ * Computed property to get the appropriate icon for the document type
256
+ * @type {string}
257
+ */
258
+ get documentIcon(): string {
259
+ if (this.isPdf) return SHARED.ICON_FILE_PDF;
260
+ if (this.isImage) return SHARED.ICON_IMAGE;
261
+ if (this.isExcel) return SHARED.ICON_FILE_EXCEL;
262
+ if (this.isWord) return SHARED.ICON_FILE_WORD;
263
+ if (this.isCsv) return SHARED.ICON_FILE;
264
+ if (this.isEmail) return SHARED.ICON_ENVELOPE;
265
+ if (this.isOpenDocument) return SHARED.ICON_FILE;
266
+ return SHARED.ICON_FILE;
267
+ }
268
+
269
+ /**
270
+ * Computed property to get the display text for the document type
271
+ * @type {string}
272
+ */
273
+ get documentTypeText(): string {
274
+ if (this.isPdf) return SHARED.PDF_DOCUMENT;
275
+ if (this.isImage) return SHARED.IMAGE;
276
+ if (this.isExcel) return SHARED.EXCEL_SPREADSHEET;
277
+ if (this.isWord) return SHARED.WORD_DOCUMENT;
278
+ if (this.isCsv) return SHARED.CSV_FILE;
279
+ if (this.isEmail) return SHARED.EMAIL_MESSAGE;
280
+ if (this.isOpenDocument) return SHARED.OPEN_DOCUMENT;
281
+ return SHARED.DOCUMENT;
282
+ }
283
+
284
+ /**
285
+ * Safely gets the styled Excel data for display
286
+ * @type {ExcelRowData[]}
287
+ */
288
+ get safeExcelStyledData(): ExcelRowData[] {
289
+ if (!this.excelStyledData || this.excelStyledData.length === 0) {
290
+ return [{ cells: [{ value: SHARED.NO_DATA_AVAILABLE }] }];
291
+ }
292
+ return this.excelStyledData;
293
+ }
294
+
295
+ /**
296
+ * Safely gets the styled CSV data for display
297
+ * @type {CsvRowData[]}
298
+ */
299
+ get safeCsvStyledData(): CsvRowData[] {
300
+ if (!this.isCsvDataValid()) {
301
+ return [{
302
+ cells: [{
303
+ value: SHARED.NO_DATA_AVAILABLE,
304
+ isHeader: false,
305
+ style: {}
306
+ }]
307
+ }];
308
+ }
309
+
310
+ // Ensure each row has the correct structure
311
+ return this.csvStyledData.map(row => {
312
+ if (!row || !row.cells || !Array.isArray(row.cells)) {
313
+ return {
314
+ cells: [{
315
+ value: SHARED.NO_DATA_AVAILABLE,
316
+ isHeader: false,
317
+ style: {}
318
+ }]
319
+ };
320
+ }
321
+ return row;
322
+ });
323
+ }
324
+
325
+ /**
326
+ * Handles changes to input properties
327
+ * @param {SimpleChanges} changes - The changes object
328
+ */
329
+ ngOnChanges(changes: SimpleChanges): void {
330
+ if (changes[SHARED.DOCUMENT_URL] || changes[SHARED.CONTENT_TYPE]) {
331
+ if (this.isWord && this.documentUrl) {
332
+ this.isLoadingWordDocument = true;
333
+ }
334
+
335
+ this.loadExcelData();
336
+ this.loadCsvData();
337
+ this.loadEmailData();
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Initializes the component
343
+ */
344
+ ngOnInit(): void {
345
+ this.loadExcelData();
346
+ this.loadCsvData();
347
+ this.loadEmailData();
348
+ this.initializeZoom();
349
+ }
350
+
351
+ /**
352
+ * Initializes zoom functionality
353
+ */
354
+ private initializeZoom(): void {
355
+ this.zoomService.zoomLevel$.subscribe(zoom => {
356
+ this.currentZoom = zoom;
357
+ this.applyZoomTransform();
358
+ });
359
+ }
360
+
361
+ /**
362
+ * Handles mouse wheel events for zooming
363
+ */
364
+ @HostListener('wheel', ['$event'])
365
+ onWheel(event: WheelEvent): void {
366
+ this.handleWheelZoom(event);
367
+ }
368
+ /**
369
+ * Handles wheel zoom for document viewers
370
+ */
371
+ handleWheelZoom(event: WheelEvent): void {
372
+ const target = event.target as HTMLElement;
373
+ const isOverDocumentViewer = target.closest(SHARED.DOC_VIEWER_WRAPPER) ||
374
+ target.closest(SHARED.CSV_TABLE_CONTAINER) ||
375
+ target.closest(SHARED.DOCX_CONTAINER) ||
376
+ target.closest(SHARED.PDF_CONTAINER) ||
377
+ target.closest(SHARED.IMAGE_CONTAINER) ||
378
+ target.closest(SHARED.WHEEL_CAPTURE_OVERLAY) ||
379
+ target.closest(SHARED.DOCUMENT_CONTENT_VIEWER_CONTAINER);
380
+
381
+ if (isOverDocumentViewer) {
382
+ if (Math.abs(event.deltaY) > Math.abs(event.deltaX)) {
383
+ if (event.ctrlKey || event.metaKey) {
384
+ event.preventDefault();
385
+ event.stopPropagation();
386
+ this.zoomService.handleWheelZoom(event);
387
+ }
388
+ }
389
+ else if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
390
+ return;
391
+ }
392
+ }
393
+ }
394
+
395
+
396
+
397
+ /**
398
+ * Applies zoom transform to the document viewer
399
+ */
400
+ private applyZoomTransform(): void {
401
+ this.zoomService.applyIframeZoomBySelector(SHARED.EXCEL_ZOOM_WRAPPER);
402
+ this.zoomService.applyIframeZoomBySelector(SHARED.DOC_VIEWER_WRAPPER);
403
+ const csvContainer = document.querySelector(SHARED.CSV_ZOOM_WRAPPER) as HTMLElement;
404
+ if (csvContainer) {
405
+ const zoomScale = this.currentZoom / 100;
406
+ csvContainer.style.transform = `scale(${zoomScale})`;
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Downloads the document
412
+ */
413
+ downloadDocument(): void {
414
+ if (this.documentUrl) {
415
+ const link = document.createElement('a');
416
+ link.href = this.documentUrl;
417
+ link.download = this.documentName || 'document';
418
+ link.target = '_blank';
419
+ document.body.appendChild(link);
420
+ link.click();
421
+ document.body.removeChild(link);
422
+ }
423
+ }
424
+
425
+ /**
426
+ * Opens the document in a new tab
427
+ */
428
+ openInNewTab(): void {
429
+ if (this.documentUrl) {
430
+ window.open(this.documentUrl, '_blank');
431
+ }
432
+ }
433
+
434
+ /**
435
+ * Loads Excel data for display
436
+ */
437
+ private loadExcelData(): void {
438
+ if (this.isExcel && this.documentUrl) {
439
+ this.isLoadingExcel = true;
440
+ this.excelError = null;
441
+
442
+ this.documentHttpService.downloadExcelFile(this.documentUrl)
443
+ .subscribe({
444
+ next: (data: ArrayBuffer) => {
445
+ try {
446
+ this.parseExcelData(data);
447
+ } catch (error) {
448
+ this.excelError = SHARED.ERROR_PARSING_EXCEL_FILE;
449
+ }
450
+ this.isLoadingExcel = false;
451
+ },
452
+ error: (error: any) => {
453
+ console.log(error);
454
+ this.isLoadingExcel = false;
455
+ }
456
+ });
457
+ } else {
458
+ this.resetExcelData();
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Parses Excel data using the service
464
+ * @param {ArrayBuffer} data - Excel file data
465
+ */
466
+ private parseExcelData(data: ArrayBuffer): void {
467
+ const parsedData = this.excelParserService.parseExcelData(data);
468
+
469
+ if (parsedData) {
470
+ this.excelSheets = parsedData.sheets;
471
+ this.currentSheet = parsedData.currentSheet;
472
+ this.excelStyledData = parsedData.styledData;
473
+ this.excelTableData = parsedData.tableData;
474
+ this.excelStyledData = this.excelParserService.ensureDataConsistency(this.excelStyledData);
475
+ this.excelTableData = this.excelParserService.convertToLegacyFormat(this.excelStyledData);
476
+
477
+ this.excelData = {
478
+ type: 'excel',
479
+ sheets: this.excelSheets,
480
+ currentSheet: this.currentSheet,
481
+ tableData: this.excelTableData,
482
+ styledData: this.excelStyledData,
483
+ workbook: parsedData.workbook,
484
+ hasStyling: parsedData.hasStyling
485
+ };
486
+ } else {
487
+ this.excelError = SHARED.ERROR_PARSING_EXCEL_FILE_STRUCTURE;
488
+ }
489
+ }
490
+
491
+ /**
492
+ * Changes the active Excel sheet
493
+ * @param {string} sheetName - Name of the sheet to activate
494
+ */
495
+ changeSheet(sheetName: string): void {
496
+ this.currentSheet = sheetName;
497
+
498
+ if (this.excelData?.workbook) {
499
+ this.excelStyledData = this.excelParserService.parseSheetData(this.excelData.workbook, sheetName);
500
+ this.excelStyledData = this.excelParserService.ensureDataConsistency(this.excelStyledData);
501
+ this.excelTableData = this.excelParserService.convertToLegacyFormat(this.excelStyledData);
502
+ }
503
+ }
504
+
505
+ /**
506
+ * Resets Excel data to initial state
507
+ */
508
+ private resetExcelData(): void {
509
+ this.excelData = null;
510
+ this.excelTableData = SHARED.EMPTY_ARRAY;
511
+ this.excelStyledData = SHARED.EMPTY_ARRAY;
512
+ this.excelSheets = SHARED.EMPTY_ARRAY;
513
+ this.currentSheet = SHARED.EMPTY;
514
+ this.isLoadingExcel = false;
515
+ this.excelError = null;
516
+ }
517
+
518
+ /**
519
+ * Loads CSV data for display
520
+ */
521
+ private loadCsvData(): void {
522
+ if (this.isCsv && this.documentUrl) {
523
+ this.isLoadingCsv = true;
524
+ this.csvError = null;
525
+
526
+ this.documentHttpService.downloadCsvFile(this.documentUrl)
527
+ .subscribe({
528
+ next: (data: string) => {
529
+ try {
530
+ this.parseCsvData(data);
531
+ } catch (error) {
532
+ this.csvError = SHARED.ERROR_PARSING_CSV_FILE;
533
+ this.resetCsvData();
534
+ }
535
+ this.isLoadingCsv = false;
536
+ },
537
+ error: (error: any) => {
538
+ this.csvError = SHARED.ERROR_LOADING_CSV_FILE;
539
+ this.resetCsvData();
540
+ this.isLoadingCsv = false;
541
+ }
542
+ });
543
+ } else {
544
+ this.resetCsvData();
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Parses CSV data using the service
550
+ * @param {string} data - CSV file data
551
+ */
552
+ private parseCsvData(data: string): void {
553
+ try {
554
+ const parsedData = this.csvParserService.parseCsvData(data, {
555
+ delimiter: SHARED.COMMA,
556
+ hasHeaders: true,
557
+ maxRows: 1000
558
+ });
559
+
560
+ if (parsedData && parsedData.styledData && parsedData.styledData.length > 0) {
561
+ this.csvStyledData = parsedData.styledData;
562
+ this.csvTableData = parsedData.rows;
563
+
564
+ this.csvData = {
565
+ type: 'csv',
566
+ headers: parsedData.headers,
567
+ rows: parsedData.rows,
568
+ tableData: parsedData.rows,
569
+ styledData: parsedData.styledData,
570
+ totalRows: parsedData.totalRows,
571
+ totalColumns: parsedData.totalColumns,
572
+ hasHeaders: parsedData.hasHeaders
573
+ };
574
+ } else {
575
+ this.csvError = SHARED.ERROR_PARSING_CSV_DATA;
576
+ this.resetCsvData();
577
+ }
578
+ } catch (error) {
579
+ this.csvError = SHARED.ERROR_PARSING_CSV_FILE;
580
+ this.resetCsvData();
581
+ }
582
+ }
583
+
584
+ /**
585
+ * Resets CSV data to initial state
586
+ */
587
+ private resetCsvData(): void {
588
+ this.csvData = null;
589
+ this.csvTableData = SHARED.EMPTY_ARRAY;
590
+ this.csvStyledData = SHARED.EMPTY_ARRAY;
591
+ this.isLoadingCsv = false;
592
+ this.csvError = null;
593
+ }
594
+
595
+ /**
596
+ * TrackBy function for CSV cells to improve performance
597
+ * @param index - Cell index
598
+ * @param cell - Cell object
599
+ * @returns Unique identifier for the cell
600
+ */
601
+ trackByCell(index: number, cell: any): any {
602
+ return `${index}-${cell.value}`;
603
+ }
604
+
605
+ /**
606
+ * Checks if CSV data is valid and ready for display
607
+ * @returns {boolean} True if CSV data is valid
608
+ */
609
+ private isCsvDataValid(): boolean {
610
+ return this.csvStyledData &&
611
+ this.csvStyledData.length > 0 &&
612
+ this.csvStyledData.every(row => row && row.cells && Array.isArray(row.cells));
613
+ }
614
+
615
+ private getFileExtension(urlOrName?: string): string {
616
+ if (!urlOrName) return SHARED.EMPTY;
617
+ const lastDot = urlOrName.lastIndexOf(SHARED.DOT);
618
+ if (lastDot === -1) return SHARED.EMPTY;
619
+ return urlOrName.substring(lastDot + 1).toLowerCase();
620
+ }
621
+
622
+ get isImage(): boolean {
623
+ const ext = this.getFileExtension(this.documentName);
624
+ return SUPPORTED_IMAGE_TYPES.includes(ext);
625
+ }
626
+
627
+ /**
628
+ * Loads Email data for display
629
+ */
630
+ private loadEmailData(): void {
631
+ if (this.isEmail && this.documentUrl) {
632
+ this.isLoadingEmail = true;
633
+ this.emailError = null;
634
+ this.emailData = null;
635
+
636
+ this.emlParserService.loadAndParseEmail(this.documentUrl)
637
+ .subscribe({
638
+ next: (parsedData: ParsedEmailData) => {
639
+ this.emailData = parsedData;
640
+ this.emailError = null;
641
+ this.isLoadingEmail = false;
642
+ },
643
+ error: (error: any) => {
644
+ this.emailError = error?.message || SHARED.ERROR_LOADING_EMAIL_FILE;
645
+ this.emailData = null;
646
+ this.isLoadingEmail = false;
647
+ }
648
+ });
649
+ } else {
650
+ this.resetEmailData();
651
+ }
652
+ }
653
+
654
+ /**
655
+ * Resets Email data to initial state
656
+ */
657
+ private resetEmailData(): void {
658
+ this.emailData = null;
659
+ this.isLoadingEmail = false;
660
+ this.emailError = null;
661
+ }
662
+
663
+
664
+ }