cat-documents-ng 1.0.6 → 1.0.8

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,664 +0,0 @@
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
- }