cat-documents-ng 0.1.27 → 0.1.30

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 (92) hide show
  1. package/ng-package.json +11 -0
  2. package/package.json +20 -25
  3. package/{Shared/constant/ERROR.d.ts → src/Shared/constant/ERROR.ts} +38 -36
  4. package/src/Shared/constant/PERMISSIONS.ts +16 -0
  5. package/src/Shared/constant/SHARED.ts +312 -0
  6. package/{Shared/constant/URLS.d.ts → src/Shared/constant/URLS.ts} +65 -60
  7. package/src/Shared/services/app-config.service.spec.ts +19 -0
  8. package/src/Shared/services/app-config.service.ts +73 -0
  9. package/{Shared/services/global-error.handler.d.ts → src/Shared/services/global-error.handler.ts} +29 -27
  10. package/src/Shared/services/session.service.spec.ts +16 -0
  11. package/src/Shared/services/session.service.ts +76 -0
  12. package/src/assets/config/api.config.json +20 -0
  13. package/src/lib/document/components/document-container/document-container.component.html +14 -0
  14. package/src/lib/document/components/document-container/document-container.component.scss +8 -0
  15. package/src/lib/document/components/document-container/document-container.component.spec.ts +110 -0
  16. package/src/lib/document/components/document-container/document-container.component.ts +173 -0
  17. package/src/lib/document/components/document-list/document-list.component.html +81 -0
  18. package/src/lib/document/components/document-list/document-list.component.scss +82 -0
  19. package/src/lib/document/components/document-list/document-list.component.spec.ts +96 -0
  20. package/src/lib/document/components/document-list/document-list.component.ts +244 -0
  21. package/src/lib/document/components/document-list-item/document-list-item.component.html +36 -0
  22. package/src/lib/document/components/document-list-item/document-list-item.component.scss +34 -0
  23. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +75 -0
  24. package/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
  25. package/src/lib/document/components/document-upload/document-upload.component.html +56 -0
  26. package/src/lib/document/components/document-upload/document-upload.component.scss +32 -0
  27. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +95 -0
  28. package/src/lib/document/components/document-upload/document-upload.component.ts +162 -0
  29. package/src/lib/document/components/document-viewer/document-viewer.component.html +98 -0
  30. package/src/lib/document/components/document-viewer/document-viewer.component.scss +54 -0
  31. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +79 -0
  32. package/src/lib/document/components/document-viewer/document-viewer.component.ts +106 -0
  33. package/src/lib/document/components/folder-block/folder-block.component.html +46 -0
  34. package/src/lib/document/components/folder-block/folder-block.component.scss +9 -0
  35. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +70 -0
  36. package/{lib/document/components/folder-block/folder-block.component.d.ts → src/lib/document/components/folder-block/folder-block.component.ts} +53 -37
  37. package/src/lib/document/components/folder-container/folder-container.component.html +2 -0
  38. package/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
  39. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +27 -0
  40. package/src/lib/document/components/folder-container/folder-container.component.ts +37 -0
  41. package/src/lib/document/components/linked-document/linked-document.component.html +23 -0
  42. package/src/lib/document/components/linked-document/linked-document.component.scss +10 -0
  43. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +61 -0
  44. package/src/lib/document/components/linked-document/linked-document.component.ts +49 -0
  45. package/src/lib/document/directives/document.directive.ts +32 -0
  46. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  47. package/src/lib/document/directives/permission.directive.ts +66 -0
  48. package/src/lib/document/document.module.ts +241 -0
  49. package/{lib/document/models/document-alert.model.d.ts → src/lib/document/models/document-alert.model.ts} +45 -38
  50. package/src/lib/document/models/document-type.model.ts +44 -0
  51. package/src/lib/document/models/document.model.ts +53 -0
  52. package/{lib/document/models/folder.model.d.ts → src/lib/document/models/folder.model.ts} +35 -29
  53. package/src/lib/document/services/document-http.service.spec.ts +119 -0
  54. package/src/lib/document/services/document-http.service.ts +125 -0
  55. package/src/lib/document/services/document-upload.service.spec.ts +99 -0
  56. package/src/lib/document/services/document-upload.service.ts +127 -0
  57. package/src/lib/document/services/document.service.ts +29 -0
  58. package/src/lib/document/services/file-format.service.spec.ts +16 -0
  59. package/src/lib/document/services/file-format.service.ts +41 -0
  60. package/src/lib/document/state/document.query.ts +52 -0
  61. package/{lib/document/state/document.service.d.ts → src/lib/document/state/document.service.ts} +95 -64
  62. package/{lib/document/state/document.state.d.ts → src/lib/document/state/document.state.ts} +52 -36
  63. package/src/lib/document/state/document.store.ts +51 -0
  64. package/{public-api.d.ts → src/public-api.ts} +10 -6
  65. package/tsconfig.lib.json +15 -0
  66. package/tsconfig.lib.prod.json +11 -0
  67. package/tsconfig.spec.json +15 -0
  68. package/Shared/constant/PERMISSIONS.d.ts +0 -15
  69. package/Shared/constant/SHARED.d.ts +0 -209
  70. package/Shared/services/app-config.service.d.ts +0 -51
  71. package/Shared/services/session.service.d.ts +0 -46
  72. package/fesm2022/cat-documents-ng.mjs +0 -2508
  73. package/fesm2022/cat-documents-ng.mjs.map +0 -1
  74. package/index.d.ts +0 -5
  75. package/lib/document/components/document-container/document-container.component.d.ts +0 -85
  76. package/lib/document/components/document-list/document-list.component.d.ts +0 -157
  77. package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
  78. package/lib/document/components/document-upload/document-upload.component.d.ts +0 -120
  79. package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -72
  80. package/lib/document/components/folder-container/folder-container.component.d.ts +0 -29
  81. package/lib/document/components/linked-document/linked-document.component.d.ts +0 -38
  82. package/lib/document/directives/document.directive.d.ts +0 -20
  83. package/lib/document/directives/permission.directive.d.ts +0 -38
  84. package/lib/document/document.module.d.ts +0 -40
  85. package/lib/document/models/document-type.model.d.ts +0 -37
  86. package/lib/document/models/document.model.d.ts +0 -44
  87. package/lib/document/services/document-http.service.d.ts +0 -69
  88. package/lib/document/services/document-upload.service.d.ts +0 -67
  89. package/lib/document/services/document.service.d.ts +0 -20
  90. package/lib/document/services/file-format.service.d.ts +0 -23
  91. package/lib/document/state/document.query.d.ts +0 -41
  92. package/lib/document/state/document.store.d.ts +0 -28
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/cat-document-lib",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "assets": [
8
+ "src/assets"
9
+ ]
10
+
11
+ }
package/package.json CHANGED
@@ -1,25 +1,20 @@
1
- {
2
- "name": "cat-documents-ng",
3
- "version": "0.1.27",
4
- "peerDependencies": {
5
- "@angular/common": "^19.0.0",
6
- "@angular/core": "^19.0.0"
7
- },
8
- "dependencies": {
9
- "tslib": "^2.3.0"
10
- },
11
- "typings": "index.d.ts",
12
- "sideEffects": false,
13
- "main": "bundles/cat-document-lib.umd.js",
14
- "module": "fesm2022/cat-documents-ng.mjs",
15
- "es2015": "fesm2015/cat-document-lib.js",
16
- "exports": {
17
- "./package.json": {
18
- "default": "./package.json"
19
- },
20
- ".": {
21
- "types": "./index.d.ts",
22
- "default": "./fesm2022/cat-documents-ng.mjs"
23
- }
24
- }
25
- }
1
+ {
2
+ "name": "cat-documents-ng",
3
+
4
+ "version": "0.1.30",
5
+ "peerDependencies": {
6
+ "@angular/common": "^19.0.0",
7
+ "@angular/core": "^19.0.0"
8
+ },
9
+ "dependencies": {
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "typings": "index.d.ts",
13
+ "sideEffects": false,
14
+ "main": "bundles/cat-document-lib.umd.js",
15
+ "module": "fesm2015/cat-document-lib.js",
16
+ "es2015": "fesm2015/cat-document-lib.js",
17
+ "devDependencies": {
18
+ "@types/jest": "^29.5.14"
19
+ }
20
+ }
@@ -1,36 +1,38 @@
1
- /**
2
- * A utility class containing common error messages.
3
- * @class ERRORS
4
- */
5
- export declare class ERRORS {
6
- /**
7
- * Error message for invalid recipient.
8
- * @static
9
- * @type {string}
10
- */
11
- static INVALID_RECIPIENT: string;
12
- /**
13
- * Error message for invalid document.
14
- * @static
15
- * @type {string}
16
- */
17
- static ERROR_FETCHING_DOCUMENTS: string;
18
- /**
19
- * Error message for invalid document.
20
- * @static
21
- * @type {string}
22
- */
23
- static ERROR_FETCHING_FOLDERS: string;
24
- /**
25
- * Error message for invalid document.
26
- * @static
27
- * @type {string}
28
- */
29
- static ERROR_ALLDOCUMENT_MISSING: string;
30
- /**
31
- * Error message for invalid document.
32
- * @static
33
- * @type {string}
34
- */
35
- static ERROR_DOCUMENT_TYPES: string;
36
- }
1
+ /**
2
+ * A utility class containing common error messages.
3
+ * @class ERRORS
4
+ */
5
+ export class ERRORS {
6
+ /**
7
+ * Error message for invalid recipient.
8
+ * @static
9
+ * @type {string}
10
+ */
11
+ static INVALID_RECIPIENT = "Invalid recipient: The recipient cannot be empty.";
12
+
13
+ /**
14
+ * Error message for invalid document.
15
+ * @static
16
+ * @type {string}
17
+ */
18
+ static ERROR_FETCHING_DOCUMENTS = "Error fetching documents:";
19
+ /**
20
+ * Error message for invalid document.
21
+ * @static
22
+ * @type {string}
23
+ */
24
+ static ERROR_FETCHING_FOLDERS = "Error fetching folders:";
25
+
26
+ /**
27
+ * Error message for invalid document.
28
+ * @static
29
+ * @type {string}
30
+ */
31
+ static ERROR_ALLDOCUMENT_MISSING = "allDocumentTypes is missing in the response:";
32
+ /**
33
+ * Error message for invalid document.
34
+ * @static
35
+ * @type {string}
36
+ */
37
+ static ERROR_DOCUMENT_TYPES = "Error fetching document types:";
38
+ }
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * Storing all permission properties.
4
+ * @export
5
+ * @class PERMISSIONS
6
+ * @typedef {PERMISSIONS}
7
+ */
8
+ export class PERMISSIONS{
9
+
10
+ /**
11
+ * Access permission.
12
+ * @static
13
+ * @type {string}
14
+ */
15
+ static DOCUMENT_POST = 'Documents-POST'
16
+ }
@@ -0,0 +1,312 @@
1
+ /**
2
+ * The `SHARED` class contains shared constants used across the application.
3
+ * These constants are related to document statuses and other shared data.
4
+ */
5
+ export class SHARED {
6
+
7
+ /**
8
+ * Represents the stores userData.
9
+ */
10
+ static SESSIONKEY = 'userData';
11
+ /**
12
+ * Represents the count of missing files.
13
+ */
14
+ static MISSINGCOUNT = 2;
15
+
16
+ /**
17
+ * Represents the count of pending files.
18
+ */
19
+ static PENDINGCOUNT = 3;
20
+
21
+ /**
22
+ * Represents an empty string.
23
+ */
24
+ static EMPTY = "";
25
+
26
+ /**
27
+ * Represents an true.
28
+ * @static
29
+ * @type {boolean}
30
+ */
31
+ static TRUE: boolean = true;
32
+
33
+
34
+ /**
35
+ * Represents an false.
36
+ * @static
37
+ * @type {boolean}
38
+ */
39
+ static FALSE: boolean = false;
40
+
41
+ /**
42
+ * Represents an INITIAL_COUNT.
43
+ */
44
+ static INITIAL_COUNT = 0
45
+ /**
46
+ * Represents an INITIAL_VALUE.
47
+ */
48
+ static INITIAL_VALUE = 0
49
+
50
+ /**
51
+ * Represents the constant value for one (1).
52
+ * @static
53
+ * @type {number}
54
+ */
55
+ static ONE: number = 1
56
+
57
+ /**
58
+ * Represents the constant value for two (2).
59
+ * @static
60
+ * @type {number}
61
+ */
62
+ static TWO: number = 2
63
+
64
+ /**
65
+ * Represents the constant value for ten (10).
66
+ * @static
67
+ * @type {number}
68
+ */
69
+ static TEN: number = 10
70
+
71
+ /**
72
+ * Represents the constant string value 'files' used for file-related operations.
73
+ * @static
74
+ * @type {string}
75
+ */
76
+ static FILE: string = 'file';
77
+
78
+ /**
79
+ * Represents the array of file size units ('B', 'KB', 'MB') used for file size formatting.
80
+ * @static
81
+ * @type {string[]}
82
+ */
83
+ static FILE_SIZE_UNITS: string[] = ['B', 'KB', 'MB'];
84
+
85
+ /**
86
+ * Show SEVERITY value.
87
+ * @static
88
+ * @type {'error'}
89
+ */
90
+ static SEVERITY:string = 'error'
91
+ /**
92
+ * Show SEVERITY value.
93
+ * @static
94
+ * @type {'error'}
95
+ */
96
+ static SUCCESS_SEVERITY:string = 'success'
97
+
98
+ /**
99
+ * Show upload summery if it's failed.
100
+ * @static
101
+ * @type {'Upload Failed'}
102
+ */
103
+ static UPLOAD_SUMMERY:string = 'Upload Failed'
104
+
105
+ /**
106
+ * Show upload summery if it's success.
107
+ * @static
108
+ * @type {'Document uploaded successfully.'}
109
+ */
110
+ static UPLOAD_SUCCESS:string = 'Document uploaded successfully.'
111
+
112
+ /**
113
+ * Represent empty array.
114
+ * @static
115
+ * @type {{}}
116
+ */
117
+ static EMPTY_ARRAY = []
118
+
119
+ /**
120
+ * Represent contextId.
121
+ * @static
122
+ * @type {string}
123
+ */
124
+ static CONTEXT_ID : string = 'contextId'
125
+
126
+ /**
127
+ * Represent fileSize.
128
+ * @static
129
+ * @type {string}
130
+ */
131
+ static FILE_SIZE : string = 'fileSize'
132
+ /**
133
+ * Represent documentName.
134
+ * @static
135
+ * @type {string}
136
+ */
137
+ static DOCUMENT_NAME : string = 'documentName'
138
+ /**
139
+ * Represent documentTypeId.
140
+ * @static
141
+ * @type {string}
142
+ */
143
+ static DOCUMENT_TYPE_ID : string = 'documentTypeId'
144
+
145
+ /**
146
+ * Represent upload summery.
147
+ * @static
148
+ * @type {string}
149
+ */
150
+ static UPLOAD_ERROR_SUMMERY : string = 'Form Data Missing'
151
+
152
+ /**
153
+ * Represent upload error details.
154
+ * @static
155
+ * @type {string}
156
+ */
157
+ static UPLOAD_ERROR_DETAILS : string = 'Required form data is missing. Please ensure the document and all required fields are provided.'
158
+
159
+ /**
160
+ * Represents the message prefix for a successful document name update.
161
+ * @static
162
+ * @type {string}
163
+ */
164
+ static UPDATE_DOCUMENT_NAME :string = 'Document name updated for ID:'
165
+ }
166
+
167
+ /**
168
+ * `DUMMYDOCUMENTLIST` is a mock list of document objects used for testing and development purposes.
169
+ * Each document includes an ID, file name, status, and document URL.
170
+ */
171
+ export const DUMMYDOCUMENTLIST = [
172
+ {
173
+ _id: 1,
174
+ fileName: 'Document 1',
175
+ status: 'pending',
176
+ documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
177
+ },
178
+ {
179
+ _id: 2,
180
+ fileName: 'Document 2',
181
+ status: 'verified',
182
+ documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
183
+ },
184
+ {
185
+ _id: 3,
186
+ fileName: 'Document 3',
187
+ status: 'sentReminder',
188
+ documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
189
+ },
190
+ {
191
+ _id: 4,
192
+ fileName: 'Document 4',
193
+ status: 'pending',
194
+ documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
195
+ },
196
+ ];
197
+
198
+ /**
199
+ * `FOLDERPANEL` is a mock list of folder data representing various folders in the application.
200
+ * Each folder contains an ID, file count, text description, missing files count, and pending files count.
201
+ */
202
+ export const FOLDERPANEL = [
203
+ {
204
+ _id: 'folder1',
205
+ fileCount: 10,
206
+ text: 'Documents',
207
+ missingFiles: 3,
208
+ pendingFiles: 2,
209
+ },
210
+ {
211
+ _id: 'folder2',
212
+ fileCount: 5,
213
+ text: 'Images',
214
+ missingFiles: 0,
215
+ pendingFiles: 1,
216
+ },
217
+ {
218
+ _id: 'folder3',
219
+ fileCount: 20,
220
+ text: 'Reports',
221
+ missingFiles: 5,
222
+ pendingFiles: 0,
223
+ },
224
+ {
225
+ _id: 'folder4',
226
+ fileCount: 8,
227
+ text: 'Videos',
228
+ missingFiles: 0,
229
+ pendingFiles: 0,
230
+ },
231
+ {
232
+ _id: 'folder5',
233
+ fileCount: 15,
234
+ text: 'Archives',
235
+ missingFiles: 1,
236
+ pendingFiles: 3,
237
+ }
238
+ ];
239
+
240
+ /**
241
+ * Dummy data for sumaery.
242
+ * @type {{}}
243
+ */
244
+ export const DUMMYSUMMARY = [
245
+ {
246
+ status: 'Valuation report requested on 10th Oct 2024',
247
+ date: '15/10/2020 10:30',
248
+ icon: 'pi pi-shopping-cart',
249
+ color: '#9C27B0',
250
+ image: 'game-controller.jpg',
251
+ },
252
+ {
253
+ status: 'Valuation report received on 13th Oct 2024',
254
+ date: '15/10/2020 14:00',
255
+ icon: 'pi pi-cog',
256
+ color: '#673AB7',
257
+ },
258
+ {
259
+ status: 'Waiting for Valuation Report to be accepted',
260
+ date: '15/10/2020 16:15',
261
+ icon: 'pi pi-shopping-cart',
262
+ color: '#FF9800',
263
+ },
264
+ ];
265
+
266
+ /**
267
+ * Dummy data for list box.
268
+ * @type {{}}
269
+ */
270
+ export const COUNTRIES = [
271
+ { name: 'Any Word', code: 'NY', checked: false },
272
+ { name: 'Case Sensitive', code: 'RM', checked: false },
273
+ { name: 'Wildcard Search', code: 'LDN', checked: false },
274
+ { name: 'Whole Word Only', code: 'IST', checked: false },
275
+ ];
276
+
277
+ /**
278
+ * Default supported image types.
279
+ * @type {{}}
280
+ */
281
+ export const SUPPORTED_IMAGE_TYPES = [
282
+ 'image/png'
283
+ ];
284
+
285
+ /**
286
+ * @constant {Array<{label: string, value: string, files: string[]}>} DOCUMENTTYPES
287
+ * An array of document type objects containing labels, values, and associated files.
288
+ */
289
+
290
+ export const DOCUMENTTYPES= [
291
+ {
292
+ label: "BankStatement",
293
+ value: "bank_statement",
294
+ },
295
+ {
296
+ label: "Payslip",
297
+ value: "payslip",
298
+ },
299
+ {
300
+ label: "Selfie",
301
+ value: "selfie",
302
+ },
303
+ {
304
+ label: "Other",
305
+ value: "other",
306
+ }
307
+ ];
308
+
309
+ export const DocumentAlertList = [
310
+ { status: 'Pending', isAlert: true, alertMessage: 'The name on the payslip does not match either the driver name or the policyholder name.' },
311
+ { status: 'Verified', isAlert: false, alertMessage: 'Document is verified successfully.' },
312
+ ];
@@ -1,60 +1,65 @@
1
- /**
2
- * Class that holds the URLs used throughout the application.
3
- * These URLs are typically used for making API requests and accessing various resources.
4
- * @class URLS
5
- * @typedef {URLS}
6
- */
7
- export declare class URLS {
8
- /**
9
- * The URL to fetch the application configuration file.
10
- * This JSON file typically contains settings and options for the application.
11
- * @static
12
- * @type {string}
13
- */
14
- static CONFIGFILEURL: string;
15
- /**
16
- * The URL endpoint for document uploads.
17
- * Used to send documents to the server for storage or processing.
18
- * @static
19
- * @type {string}
20
- */
21
- static DOCUMENT_UPLOAD: string;
22
- /**
23
- * The query parameter to pass a context ID in API requests.
24
- * Used to specify the context for certain API calls, such as filtering or scoping the request.
25
- * @static
26
- * @type {string}
27
- */
28
- static CONTEXT: string;
29
- /**
30
- * The query parameter to pass a document ID in API requests.
31
- * @static
32
- * @type {string}
33
- */
34
- static DOCUMENT_TYPES: string;
35
- /**
36
- * The query parameter to pass a context ID in API requests.
37
- * @static
38
- * @type {string}
39
- */
40
- static FOLDERS: string;
41
- /**
42
- * The query parameter to pass a document ID in API requests.
43
- * @static
44
- * @type {string}
45
- */
46
- static ALERT_BY_DOCUMENT_ID: string;
47
- /**
48
- * The query parameter to pass a document ID in API requests.
49
- * @static
50
- * @type {string}
51
- */
52
- static PARENT_DOCUMENT_TYPE_ID: string;
53
- /**
54
- * The query parameter to pass a context ID in API requests.
55
- * Used to specify the context for certain API calls, such as filtering or scoping the request.
56
- * @static
57
- * @type {string}
58
- */
59
- static CONTEXT_ID: string;
60
- }
1
+ /**
2
+ * Class that holds the URLs used throughout the application.
3
+ * These URLs are typically used for making API requests and accessing various resources.
4
+ * @class URLS
5
+ * @typedef {URLS}
6
+ */
7
+ export class URLS {
8
+ /**
9
+ * The URL to fetch the application configuration file.
10
+ * This JSON file typically contains settings and options for the application.
11
+ * @static
12
+ * @type {string}
13
+ */
14
+ static CONFIGFILEURL = "assets/config/api.config.json";
15
+
16
+ /**
17
+ * The URL endpoint for document uploads.
18
+ * Used to send documents to the server for storage or processing.
19
+ * @static
20
+ * @type {string}
21
+ */
22
+ static DOCUMENT_UPLOAD = "Documents";
23
+
24
+ /**
25
+ * The query parameter to pass a context ID in API requests.
26
+ * Used to specify the context for certain API calls, such as filtering or scoping the request.
27
+ * @static
28
+ * @type {string}
29
+ */
30
+ static CONTEXT = "?contextId=";
31
+
32
+ /**
33
+ * The query parameter to pass a document ID in API requests.
34
+ * @static
35
+ * @type {string}
36
+ */
37
+ static DOCUMENT_TYPES = "documentTypes";
38
+ /**
39
+ * The query parameter to pass a context ID in API requests.
40
+ * @static
41
+ * @type {string}
42
+ */
43
+ static FOLDERS = "/folders?contextId=";
44
+ /**
45
+ * The query parameter to pass a document ID in API requests.
46
+ * @static
47
+ * @type {string}
48
+ */
49
+ static ALERT_BY_DOCUMENT_ID = "alerts?documentId=";
50
+ /**
51
+ * The query parameter to pass a document ID in API requests.
52
+ * @static
53
+ * @type {string}
54
+ */
55
+ static PARENT_DOCUMENT_TYPE_ID = "parentDocumentType?parentDocumentTypeId=";
56
+
57
+ /**
58
+ * The query parameter to pass a context ID in API requests.
59
+ * Used to specify the context for certain API calls, such as filtering or scoping the request.
60
+ * @static
61
+ * @type {string}
62
+ */
63
+
64
+ static CONTEXT_ID = "&contextId=";
65
+ }
@@ -0,0 +1,19 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { AppConfigService } from './app-config.service';
4
+ import { HttpClientModule } from '@angular/common/http';
5
+
6
+ describe('AppConfigService', () => {
7
+ let service: AppConfigService;
8
+
9
+ beforeEach(() => {
10
+ TestBed.configureTestingModule({
11
+ imports: [HttpClientModule],
12
+ });
13
+ service = TestBed.inject(AppConfigService);
14
+ });
15
+
16
+ it('should be created', () => {
17
+ expect(service).toBeTruthy();
18
+ });
19
+ });
@@ -0,0 +1,73 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Injectable } from '@angular/core';
3
+ import { firstValueFrom } from 'rxjs';
4
+ import { URLS } from '../constant/URLS';
5
+
6
+ /**
7
+ * Service that handles loading and providing configuration settings for the application.
8
+ * It fetches configuration data from a remote server and exposes various configuration options.
9
+ * @class AppConfigService
10
+ * @typedef {AppConfigService}
11
+ */
12
+ @Injectable({
13
+ providedIn: 'root'
14
+ })
15
+ export class AppConfigService {
16
+
17
+ /**
18
+ * Holds the configuration data loaded from the server.
19
+ * @private
20
+ * @type {*}
21
+ */
22
+ private appConfig: any;
23
+
24
+ /**
25
+ * Creates an instance of AppConfigService.
26
+ * Initializes the HttpClient for making HTTP requests.
27
+ * @class
28
+ * @param {HttpClient} http - The HttpClient service used for making HTTP requests.
29
+ */
30
+ constructor(private http: HttpClient) {}
31
+
32
+ /**
33
+ * Loads the application configuration from the server by making an HTTP request to the configuration URL.
34
+ * This method retrieves the configuration data and assigns it to the appConfig property.
35
+ * @async
36
+ * @returns {*}
37
+ */
38
+ async loadAppConfig() {
39
+ try {
40
+ this.appConfig = await firstValueFrom(this.http.get(URLS.CONFIGFILEURL));
41
+ } catch (error) {
42
+ throw new Error("Api url is missing.")
43
+ }
44
+ }
45
+
46
+
47
+ /**
48
+ * Returns the base URL for the API from the loaded configuration.
49
+ * @readonly
50
+ * @type {*}
51
+ */
52
+ get apiBaseUrl() {
53
+ return this.appConfig?.documentApiUrl;
54
+ }
55
+
56
+ /**
57
+ * Returns the local server API URL from the loaded configuration.
58
+ * @readonly
59
+ * @type {*}
60
+ */
61
+ get localServerApi() {
62
+ return this.appConfig?.localServerApi;
63
+ }
64
+
65
+ /**
66
+ * Returns the visibility options from the loaded configuration.
67
+ * @readonly
68
+ * @type {*}
69
+ */
70
+ get visibilityOptions() {
71
+ return this.appConfig?.visibilityOption;
72
+ }
73
+ }