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,181 @@
1
+
2
+ import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
3
+ import { trigger, state, style, transition, animate } from '@angular/animations';
4
+ import { SHARED, USERLIST } from '../../../../Shared/constant/SHARED';
5
+ import { DocumentStore } from '../../state/document.store';
6
+ import { DocumentQuery } from '../../state/document.query';
7
+ import { UserListModel } from '../../models/user-list.model';
8
+ import { UserListService } from '../../services/user-list.service';
9
+ import { DocumentCategory } from '../../models/document-category.model';
10
+ import { DocumentHelperService } from '../../services/document.service';
11
+ import { Subscription } from 'rxjs';
12
+
13
+ @Component({
14
+ selector: 'lib-user-list',
15
+ standalone : false,
16
+ templateUrl: './user-list.component.html',
17
+ styleUrls: ['./user-list.component.scss'],
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
19
+ animations: [
20
+ trigger('slideInFromTop', [
21
+ state('void', style({
22
+ opacity: 0,
23
+ transform: 'translateY(-10px)'
24
+ })),
25
+ state('*', style({
26
+ opacity: 1,
27
+ transform: 'translateY(0)'
28
+ })),
29
+ transition('void => *', [
30
+ animate('300ms ease-out')
31
+ ])
32
+ ]),
33
+ trigger('fadeIn', [
34
+ state('void', style({
35
+ opacity: 0,
36
+ transform: 'scale(0.8)'
37
+ })),
38
+ state('*', style({
39
+ opacity: 1,
40
+ transform: 'scale(1)'
41
+ })),
42
+ transition('void => *', [
43
+ animate('200ms ease-in-out')
44
+ ])
45
+ ])
46
+ ]
47
+ })
48
+ export class UserListComponent implements OnInit, OnChanges {
49
+
50
+ @Input() userList: UserListModel[] = SHARED.EMPTY_ARRAY;
51
+ @Input() categories: DocumentCategory[] = SHARED.EMPTY_ARRAY;
52
+ @Output() userSelected = new EventEmitter<string>();
53
+
54
+ userData: UserListModel[] = SHARED.EMPTY_ARRAY;
55
+ filteredUserData: UserListModel[] = SHARED.EMPTY_ARRAY;
56
+ selectedUser: string | undefined;
57
+ shouldShowContainer: boolean = true;
58
+
59
+ private userListSubscription: Subscription = new Subscription();
60
+ private categoriesSubscription: Subscription = new Subscription();
61
+
62
+ constructor(
63
+ public documentService : DocumentHelperService,
64
+ private documentStore: DocumentStore,
65
+ private documentQuery: DocumentQuery,
66
+ private userListService: UserListService,
67
+ private cdr: ChangeDetectorRef
68
+ ){
69
+
70
+ }
71
+
72
+ ngOnChanges(changes: SimpleChanges): void {
73
+ if (changes[SHARED.USER_LIST] && !changes[SHARED.USER_LIST].firstChange) {
74
+ this.initializeUserData();
75
+ }
76
+ if (changes[SHARED.CATEGORIES] && !changes[SHARED.CATEGORIES].firstChange) {
77
+ this.updateFilteredUserData();
78
+ }
79
+ }
80
+
81
+ initializeUserData(): void {
82
+ if (this.userList && this.userList.length > 0) {
83
+ this.userData = this.userListService.processUserData(this.userList);
84
+ this.updateFilteredUserData();
85
+ }
86
+ }
87
+
88
+ updateFilteredUserData(): void {
89
+ if (this.userData.length > 0 && this.categories.length > 0) {
90
+ this.filteredUserData = this.userListService.filterUsersByCategory(this.userData, this.categories);
91
+ this.shouldShowContainer = true;
92
+ if (this.selectedUser) {
93
+ const selectedUserInFiltered = this.filteredUserData.find(user => user.name === this.selectedUser);
94
+ if (!selectedUserInFiltered) {
95
+ this.selectedUser = undefined;
96
+ this.documentStore.setSelectedUserId(null);
97
+ this.userSelected.emit(SHARED.EMPTY);
98
+ }
99
+ }
100
+ } else {
101
+ this.filteredUserData = this.userData;
102
+ this.shouldShowContainer = true;
103
+ }
104
+ }
105
+
106
+ ngOnInit(): void {
107
+ this.initializeUserData();
108
+ this.userListSubscription.add(
109
+ this.documentQuery.selectUserList().subscribe(userList => {
110
+ if (userList && userList.length > 0) {
111
+ this.userList = userList;
112
+ this.initializeUserData();
113
+ this.cdr.markForCheck();
114
+ }
115
+ })
116
+ );
117
+
118
+ this.categoriesSubscription.add(
119
+ this.documentQuery.selectDocumentCategories().subscribe(categories => {
120
+ if (categories && categories.length > 0) {
121
+ this.categories = categories;
122
+ this.updateFilteredUserData();
123
+ this.cdr.markForCheck();
124
+ }
125
+ })
126
+ );
127
+
128
+ this.userListSubscription.add(
129
+ this.documentQuery.selectDocumentListResponse().subscribe(() => {
130
+ const currentUserList = this.documentQuery.getUserList();
131
+ if (currentUserList && currentUserList.length > 0) {
132
+ this.userList = currentUserList;
133
+ this.initializeUserData();
134
+ this.cdr.markForCheck();
135
+ }
136
+ })
137
+ );
138
+
139
+ this.documentQuery.selectSelectedUserId().subscribe(userId => {
140
+ if (userId) {
141
+ const user = this.userData.find(u => u._id === userId);
142
+ this.selectedUser = user ? user.name : undefined;
143
+ } else {
144
+ this.selectedUser = undefined;
145
+ }
146
+ this.cdr.markForCheck();
147
+ });
148
+
149
+ this.documentQuery.selectShowUserList().subscribe(show => {
150
+ if (!show && this.selectedUser) {
151
+ this.selectedUser = undefined;
152
+ this.userSelected.emit(SHARED.EMPTY);
153
+ }
154
+ });
155
+ }
156
+
157
+ onUserSelect(username: string, id: string): void {
158
+ if (this.selectedUser === username) {
159
+ this.selectedUser = undefined;
160
+ this.userListService.unselectUser();
161
+ this.userSelected.emit(SHARED.EMPTY);
162
+ } else {
163
+ this.selectedUser = username;
164
+ this.documentStore.setSelectedUserId(id);
165
+ this.userSelected.emit(username);
166
+ }
167
+ }
168
+
169
+ getAvatarColor(color: string | undefined): string {
170
+ if (!color) {
171
+ return SHARED.DEFAULT_COLOR;
172
+ }
173
+ return SHARED.COLOR_MAP[color as keyof typeof SHARED.COLOR_MAP] || SHARED.DEFAULT_COLOR;
174
+ }
175
+
176
+
177
+ ngOnDestroy(): void {
178
+ this.userListSubscription.unsubscribe();
179
+ this.categoriesSubscription.unsubscribe();
180
+ }
181
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Constants for Document History labels and styling
3
+ */
4
+ export const DOCUMENT_HISTORY = {
5
+ // Document History Labels
6
+ LABELS: {
7
+ DOCUMENT_REQUESTED: 'Document Requested',
8
+ DOCUMENT_UPLOADED: 'Document Uploaded',
9
+ DOCUMENT_REJECTED: 'Document Rejected',
10
+ DOCUMENT_ACCEPTED: 'Document Accepted'
11
+ },
12
+
13
+ // Icon classes for different actions
14
+ ICONS: {
15
+ DOCUMENT_REQUESTED: 'pi pi-file',
16
+ DOCUMENT_UPLOADED: 'pi pi-cloud-upload',
17
+ DOCUMENT_REJECTED: 'pi pi-times',
18
+ DOCUMENT_ACCEPTED: 'pi pi-check'
19
+ },
20
+
21
+ // Text color classes - matching the design in the image
22
+ TEXT_COLORS: {
23
+ DOCUMENT_REQUESTED: 'text-gray-700', // Dark gray for better readability
24
+ DOCUMENT_UPLOADED: 'text-green-700', // Dark green for uploaded
25
+ DOCUMENT_REJECTED: 'text-red-700', // Dark red for rejected
26
+ DOCUMENT_ACCEPTED: 'text-green-700' // Dark green for accepted
27
+ },
28
+
29
+ // Background color classes - matching the light gray design from image
30
+ BG_COLORS: {
31
+ DOCUMENT_REQUESTED: 'bg-gray-100', // Light gray like in the image
32
+ DOCUMENT_UPLOADED: 'bg-green-50', // Very light green
33
+ DOCUMENT_REJECTED: 'bg-red-50', // Very light red
34
+ DOCUMENT_ACCEPTED: 'bg-green-50' // Very light green
35
+ },
36
+
37
+ // Border color classes - subtle borders
38
+ BORDER_COLORS: {
39
+ DOCUMENT_REQUESTED: 'border-gray-300', // Medium gray border
40
+ DOCUMENT_UPLOADED: 'border-green-300', // Light green border
41
+ DOCUMENT_REJECTED: 'border-red-300', // Light red border
42
+ DOCUMENT_ACCEPTED: 'border-green-300' // Light green border
43
+ },
44
+
45
+ // Icon background color classes - matching the circular icon design
46
+ ICON_BG_COLORS: {
47
+ DOCUMENT_REQUESTED: 'icon-bg-blue', // Blue for requested (as shown in image)
48
+ DOCUMENT_UPLOADED: 'icon-bg-green', // Green for uploaded
49
+ DOCUMENT_REJECTED: 'icon-bg-red', // Red for rejected
50
+ DOCUMENT_ACCEPTED: 'icon-bg-green' // Green for accepted
51
+ }
52
+ };
@@ -0,0 +1,32 @@
1
+ import { Directive, TemplateRef, ViewContainerRef } from "@angular/core";
2
+ import { DocumentModel } from "../models/document.model";
3
+ import { DocumentHelperService } from "../services/document.service";
4
+
5
+ /**
6
+ * Directive to display the document data
7
+ */
8
+ @Directive({
9
+ selector: '[doc]',
10
+ standalone: false
11
+ })
12
+ export class DocumentDirective {
13
+
14
+ /**
15
+ * Creates an instance of DocumentDirective.
16
+ * @param documentService Service to get the document data.
17
+ * @param templateRef Reference to the template.
18
+ * @param vcr View container reference to manage the view.
19
+ */
20
+ constructor(
21
+ private documentService: DocumentHelperService,
22
+ private templateRef: TemplateRef<any>,
23
+ private vcr: ViewContainerRef
24
+ ) {
25
+ this.documentService.get().subscribe((document: DocumentModel | null) => {
26
+ this.vcr.clear();
27
+ if (document) {
28
+ this.vcr.createEmbeddedView(this.templateRef, { $implicit: document });
29
+ }
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,72 @@
1
+ import { Directive, Input, ElementRef, Renderer2, SimpleChanges, OnChanges } from '@angular/core';
2
+ import { SessionService } from '../../../Shared/services/session.service';
3
+
4
+ /**
5
+ * Directive to conditionally show or hide elements based on user permissions.
6
+ * @class HasPermissionDirective
7
+ * @typedef {HasPermissionDirective}
8
+ */
9
+ @Directive({
10
+ selector: '[permission]',
11
+ standalone: false
12
+ })
13
+ export class HasPermissionDirective implements OnChanges {
14
+
15
+ /**
16
+ * The required permission(s) to display the element.
17
+ * Accepts a single string or an array of strings.
18
+ * @type {string | string[]}
19
+ */
20
+ @Input() permission?: string | string[];
21
+
22
+ /**
23
+ * Creates an instance of HasPermissionDirective.
24
+ * @param {ElementRef} el - Reference to the host element.
25
+ * @param {Renderer2} renderer - Angular Renderer for DOM manipulation.
26
+ * @param {SessionService} sessionService - Service to retrieve user permissions.
27
+ */
28
+ constructor(
29
+ private el: ElementRef,
30
+ private renderer: Renderer2,
31
+ public sessionService: SessionService
32
+ ) {}
33
+
34
+ /**
35
+ * Lifecycle hook that is called when input properties change.
36
+ * @param {SimpleChanges} changes - The changes in input properties.
37
+ */
38
+ ngOnChanges(changes: SimpleChanges) {
39
+ if (changes['permission']) {
40
+ this.checkPermission();
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Checks if the user has the required permission(s).
46
+ * Hides the element if the permission is not found.
47
+ */
48
+ private checkPermission() {
49
+ // If no permission is required (empty string, null, or undefined), show the element
50
+ if (!this.permission || this.permission === '' || (Array.isArray(this.permission) && this.permission.length === 0)) {
51
+ this.renderer.removeStyle(this.el.nativeElement, 'display');
52
+ return;
53
+ }
54
+
55
+ const userPermissionsObjects = this.sessionService.getUserPermissions();
56
+ const userPermissionNames = userPermissionsObjects?.map((perm: any) => perm.name) || [];
57
+
58
+ const requiredPermissions = Array.isArray(this.permission)
59
+ ? this.permission
60
+ : [this.permission];
61
+
62
+ const hasPermission = requiredPermissions.some(permission =>
63
+ userPermissionNames.includes(permission)
64
+ );
65
+
66
+ if (!hasPermission) {
67
+ this.renderer.setStyle(this.el.nativeElement, 'display', 'none');
68
+ } else {
69
+ this.renderer.removeStyle(this.el.nativeElement, 'display');
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,351 @@
1
+ import { APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { DocumentContainerComponent } from './components/document-container/document-container.component';
4
+ import { FolderContainerComponent } from './components/folder-container/folder-container.component';
5
+ import { FolderBlockComponent } from './components/folder-block/folder-block.component';
6
+ import { DocumentListComponent } from './components/document-list/document-list.component';
7
+ import { AccordionModule } from 'primeng/accordion';
8
+ import { DocumentListItemComponent } from './components/document-list-item/document-list-item.component';
9
+ import { ButtonModule } from 'primeng/button';
10
+ import { SidebarModule } from 'primeng/sidebar';
11
+ import { FileUploadModule } from 'primeng/fileupload';
12
+ import { DocumentUploadComponent } from './components/document-upload/document-upload.component';
13
+ import { MessageService } from 'primeng/api';
14
+ import { ConfirmationService } from 'primeng/api';
15
+ import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
16
+ import { ProgressBarModule } from 'primeng/progressbar';
17
+ import { BadgeModule } from 'primeng/badge';
18
+ import { ListboxModule } from 'primeng/listbox';
19
+ import { TimelineModule } from 'primeng/timeline';
20
+ import { CheckboxModule } from 'primeng/checkbox';
21
+ import { InputTextareaModule } from 'primeng/inputtextarea';
22
+ import { FormsModule } from '@angular/forms';
23
+ import { DocumentViewerComponent } from './components/document-viewer/document-viewer.component';
24
+ import { DocumentHistoryComponent } from './components/document-history/document-history.component';
25
+ import { DocumentContentViewerComponent } from './components/document-content-viewer/document-content-viewer.component';
26
+ import { DocumentZoomControlsComponent } from './components/document-zoom-controls/document-zoom-controls.component';
27
+ import { PdfViewerModule } from 'ng2-pdf-viewer';
28
+ import { NgxDocViewerModule } from 'ngx-doc-viewer';
29
+ import { DialogModule } from 'primeng/dialog';
30
+ import { AppConfigService } from '../../Shared/services/app-config.service';
31
+ import { GlobalErrorHandler } from '../../Shared/services/global-error.handler';
32
+ import { DropdownModule } from 'primeng/dropdown';
33
+ import { InputTextModule } from 'primeng/inputtext';
34
+ import { DocumentDirective } from './directives/document.directive';
35
+ import { LinkedDocumentComponent } from './components/linked-document/linked-document.component';
36
+ import { DocumentsMenuComponent } from './components/documents-menu/documents-menu.component';
37
+ import { MenuModule } from 'primeng/menu';
38
+ import { PanelMenuModule } from 'primeng/panelmenu';
39
+ import { CardModule } from 'primeng/card';
40
+ import { TableModule } from 'primeng/table';
41
+ import { UserListComponent } from './components/user-list/user-list.component';
42
+ import { DocumentStatusComponent } from './components/document-status/document-status.component';
43
+ import { DocumentActionsComponent } from './components/document-actions/document-actions.component';
44
+ import { DocumentSearchComponent } from './components/document-search/document-search.component';
45
+ import { SharedModule } from '../../Shared/shared.module';
46
+ import { DocumentActionsService } from './services/document-actions.service';
47
+ import { DocumentContentTypeService } from './services/document-content-type.service';
48
+ import { SidebarComponent } from './components/sidebar/sidebar.component';
49
+ import { RequestDocumentComponent } from './components/request-document/request-document.component';
50
+ import { RadioButtonModule } from 'primeng/radiobutton';
51
+ import { ToastModule } from 'primeng/toast';
52
+ import { TooltipModule } from 'primeng/tooltip';
53
+ import { MessagesModule } from 'primeng/messages';
54
+ import { MessageModule } from 'primeng/message';
55
+
56
+ /**
57
+ * @module DocumentModule
58
+ *
59
+ * The `DocumentModule` handles the organization and display of document and folder components
60
+ * in the application. This module is designed to support features like folder containers,
61
+ * document lists, and individual document items.
62
+ */
63
+ @NgModule({
64
+ declarations: [
65
+ /**
66
+ * The main container for managing documents.
67
+ * DocumentContainerComponent
68
+ */
69
+ DocumentContainerComponent,
70
+
71
+ /**
72
+ * A container component to manage folders.
73
+ * FolderContainerComponent
74
+ */
75
+ FolderContainerComponent,
76
+
77
+ /**
78
+ * A block component that represents an individual folder.
79
+ * FolderBlockComponent
80
+ */
81
+ FolderBlockComponent,
82
+
83
+ /**
84
+ * A component to display a list of documents.
85
+ * DocumentListComponent
86
+ */
87
+ DocumentListComponent,
88
+
89
+ /**
90
+ * A component representing an individual item in the document list.
91
+ * DocumentListItemComponent
92
+ */
93
+ DocumentListItemComponent,
94
+
95
+ /**
96
+ * A component representing to upload a file.
97
+ */
98
+ DocumentUploadComponent,
99
+
100
+ /**
101
+ * A component representing and allow you to view the document.
102
+ */
103
+ DocumentViewerComponent,
104
+
105
+ /**
106
+ * A component representing document history timeline.
107
+ */
108
+ DocumentHistoryComponent,
109
+
110
+ /**
111
+ * A reusable component for viewing different types of document content.
112
+ */
113
+ DocumentContentViewerComponent,
114
+
115
+ /**
116
+ * A component providing zoom controls for document viewing.
117
+ */
118
+ DocumentZoomControlsComponent,
119
+
120
+ /**
121
+ * A directive to show the document.
122
+ */
123
+ DocumentDirective,
124
+
125
+ /**
126
+ * A component which have linked documents.
127
+ */
128
+ LinkedDocumentComponent,
129
+ DocumentsMenuComponent,
130
+ UserListComponent,
131
+ DocumentStatusComponent,
132
+ DocumentActionsComponent,
133
+ DocumentSearchComponent,
134
+ /**
135
+ * A sidebar component for content projection.
136
+ */
137
+ SidebarComponent,
138
+ /**
139
+ * A component to request a document (without upload), with description.
140
+ */
141
+ RequestDocumentComponent,
142
+
143
+ ],
144
+ imports: [
145
+ /**
146
+ * Angular's CommonModule is imported to access common directives like `ngIf` and `ngFor`.
147
+ */
148
+ CommonModule,
149
+
150
+ /**
151
+ * PrimeNG AccordionModule is used for creating collapsible sections in the UI.
152
+ */
153
+ AccordionModule,
154
+
155
+ /**
156
+ * HttpClientModule for the http calls
157
+ */
158
+ HttpClientModule,
159
+
160
+ /**
161
+ * PrimeNG ButtonModule is used for creating buttons in the UI.
162
+ */
163
+ ButtonModule,
164
+
165
+ /**
166
+ * PrimeNG SidebarModule is used for creating sidebars.
167
+ */
168
+ SidebarModule,
169
+
170
+ /**
171
+ * PrimeNG FileUploadModule is used for uploading file.
172
+ */
173
+ FileUploadModule,
174
+
175
+ /**
176
+ * PrimeNG ProgressBarModule is used for showing progress.
177
+ */
178
+ ProgressBarModule,
179
+
180
+ /**
181
+ * PrimeNG BadgeModule is used for showing badge value.
182
+ */
183
+ BadgeModule,
184
+
185
+ /**
186
+ * PrimeNG ListboxModule is used for showing listbox value.
187
+ */
188
+ ListboxModule,
189
+
190
+ /**
191
+ * PrimeNG CheckboxModule is used for showing checkbox value.
192
+ */
193
+ CheckboxModule,
194
+
195
+ /**
196
+ * PrimeNG RadioButtonModule is used for showing radio button values.
197
+ */
198
+ RadioButtonModule,
199
+
200
+ /**
201
+ * PrimeNG TimelineModule is used for showing timeline value.
202
+ */
203
+ TimelineModule,
204
+ /**
205
+ * PrimeNG InputTextareaModule is used for showing textarea value.
206
+ */
207
+ InputTextareaModule,
208
+ /**
209
+ * FormsModule to handle the forms.
210
+ */
211
+ FormsModule,
212
+ /**
213
+ * PdfViewerModule to handle and make visible the pdf.
214
+ */
215
+ PdfViewerModule,
216
+ /**
217
+ * NgxDocViewerModule to handle and make visible Office documents.
218
+ */
219
+ NgxDocViewerModule,
220
+ /**
221
+ * PrimeNG DialogModule is used for showing dialog.
222
+ */
223
+ DialogModule,
224
+ /**
225
+ * PrimeNG DropdownModule is used for creating dropdown menus, allowing users to select options from a list.
226
+ */
227
+ DropdownModule,
228
+ /**
229
+ * PrimeNG InputTextModule is used for creating InputTextFeilds, allowing users to enter name for a document.
230
+ */
231
+ InputTextModule,
232
+
233
+ MenuModule,
234
+ PanelMenuModule,
235
+ CardModule,
236
+ TableModule,
237
+ SharedModule,
238
+ InputTextareaModule,
239
+ ToastModule,
240
+ TooltipModule,
241
+ MessagesModule,
242
+ MessageModule
243
+
244
+ ],
245
+ exports: [
246
+ /**
247
+ * Exports the `DocumentContainerComponent` to be used in other modules.
248
+ */
249
+ DocumentContainerComponent,
250
+ /**
251
+ * Exports the `DocumentViewerComponent` to be used in other modules.
252
+ */
253
+ DocumentViewerComponent,
254
+
255
+ /**
256
+ * Exports the `DocumentContentViewerComponent` to be used in other modules.
257
+ */
258
+ DocumentContentViewerComponent,
259
+
260
+ /**
261
+ * Exports the `DocumentZoomControlsComponent` to be used in other modules.
262
+ */
263
+ DocumentZoomControlsComponent,
264
+ /**
265
+ * Exports the `DocumentActionsComponent` to be used in other modules.
266
+ */
267
+ DocumentActionsComponent,
268
+ /**
269
+ * A component to display a list of documents.
270
+ * DocumentListComponent
271
+ */
272
+ DocumentListComponent,
273
+
274
+ /**
275
+ * A component for uploading documents.
276
+ * DocumentUploadComponent
277
+ */
278
+ DocumentUploadComponent,
279
+
280
+ /**
281
+ * A directive to show the document.
282
+ */
283
+ DocumentDirective,
284
+
285
+ /**
286
+ * A component for searching documents.
287
+ */
288
+ DocumentSearchComponent,
289
+
290
+ /**
291
+ * A sidebar component for content projection.
292
+ */
293
+ SidebarComponent,
294
+ RequestDocumentComponent,
295
+
296
+
297
+ ],
298
+ providers: [
299
+ /**
300
+ * Provide the messageservice to be used in other components.
301
+ */
302
+ MessageService,
303
+
304
+ /**
305
+ * Provide the DocumentActionsService to be used in other components.
306
+ */
307
+ DocumentActionsService,
308
+
309
+ /**
310
+ * Provide the DocumentContentTypeService to be used in other components.
311
+ */
312
+ DocumentContentTypeService,
313
+
314
+ /**
315
+ * Provide the ConfirmationService to be used in other components.
316
+ */
317
+ ConfirmationService,
318
+
319
+ /**
320
+ * Provide the messageservice to be used in other components.
321
+ */
322
+ { provide: GlobalErrorHandler, useClass: GlobalErrorHandler },
323
+ /**
324
+ * Initializes the application configuration by loading it from the AppConfigService
325
+ * before the application starts.
326
+ * This ensures that the configuration is available for the rest of the app when needed.
327
+ * The configuration is loaded asynchronously using the APP_INITIALIZER.
328
+ * @returns {Function} - A function that loads the configuration from the AppConfigService.
329
+ */
330
+ {
331
+ provide: APP_INITIALIZER,
332
+ /**
333
+ * This useFactory is executed when the app initializes.
334
+ * It calls the AppConfigService to load the configuration.
335
+ * If an error occurs, it throws an error.
336
+ * @param {AppConfigService} configService - The service responsible for loading the application configuration.
337
+ * @returns {Function} - A function that loads the configuration from the AppConfigService.
338
+ */
339
+ useFactory: (configService: AppConfigService) => () =>
340
+ configService.loadAppConfig().catch((error) => {
341
+ throw new Error(error);
342
+ }),
343
+ deps: [AppConfigService],
344
+ multi: true,
345
+ },
346
+
347
+ ]
348
+ ,
349
+ schemas: [CUSTOM_ELEMENTS_SCHEMA]
350
+ })
351
+ export class DocumentModule { }