cat-documents-ng 0.0.4 → 0.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.
- package/.github/PULL_REQUEST_TEMPLATE.md +32 -0
- package/.github/workflows/pr-validation.yml +87 -0
- package/.husky/pre-commit +4 -0
- package/README.md +59 -63
- package/angular.json +119 -0
- package/eslint.config.cjs +148 -0
- package/package.json +66 -25
- package/projects/cat-document-lib/README.md +63 -0
- package/projects/cat-document-lib/jest.config.mjs +18 -0
- package/projects/cat-document-lib/ng-package.json +11 -0
- package/projects/cat-document-lib/package-lock.json +599 -0
- package/projects/cat-document-lib/package.json +19 -0
- package/projects/cat-document-lib/setup-jest.ts +10 -0
- package/projects/cat-document-lib/src/Shared/constant/SHARED.ts +232 -0
- package/{Shared/constant/URLS.d.ts → projects/cat-document-lib/src/Shared/constant/URLS.ts} +31 -29
- package/projects/cat-document-lib/src/Shared/services/app-config.service.spec.ts +16 -0
- package/projects/cat-document-lib/src/Shared/services/app-config.service.ts +73 -0
- package/{Shared/services/global-error.handler.d.ts → projects/cat-document-lib/src/Shared/services/global-error.handler.ts} +29 -27
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.html +6 -0
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.ts +82 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.html +35 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.scss +12 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.ts +73 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.html +33 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.scss +22 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +23 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.html +56 -0
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.scss +26 -0
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.spec.ts +24 -0
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.ts +184 -0
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.html +244 -0
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.scss +36 -0
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +21 -0
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.ts +125 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.html +46 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -0
- package/{lib/document/components/folder-block/folder-block.component.d.ts → projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.ts} +51 -37
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.html +2 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.ts +29 -0
- package/projects/cat-document-lib/src/lib/document/document.module.ts +191 -0
- package/projects/cat-document-lib/src/lib/document/models/document.model.ts +39 -0
- package/{lib/document/models/folder.model.d.ts → projects/cat-document-lib/src/lib/document/models/folder.model.ts} +35 -29
- package/projects/cat-document-lib/src/lib/document/services/file-format.service.spec.ts +16 -0
- package/projects/cat-document-lib/src/lib/document/services/file-format.service.ts +41 -0
- package/projects/cat-document-lib/src/lib/document/state/document.query.ts +23 -0
- package/{lib/document/state/document.service.d.ts → projects/cat-document-lib/src/lib/document/state/document.service.ts} +95 -64
- package/{lib/document/state/document.state.d.ts → projects/cat-document-lib/src/lib/document/state/document.state.ts} +39 -30
- package/projects/cat-document-lib/src/lib/document/state/document.store.ts +23 -0
- package/{public-api.d.ts → projects/cat-document-lib/src/public-api.ts} +8 -3
- package/projects/cat-document-lib/tsconfig.lib.json +15 -0
- package/projects/cat-document-lib/tsconfig.lib.prod.json +11 -0
- package/projects/cat-document-lib/tsconfig.spec.json +15 -0
- package/public/favicon.ico +0 -0
- package/src/app/app.component.html +1 -0
- package/src/app/app.component.scss +0 -0
- package/src/app/app.component.spec.ts +29 -0
- package/src/app/app.component.ts +15 -0
- package/src/app/app.module.ts +60 -0
- package/src/app/app.routing.module.ts +19 -0
- package/src/index.html +13 -0
- package/src/main.ts +5 -0
- package/src/styles.scss +39 -0
- package/tsconfig.app.json +15 -0
- package/tsconfig.json +32 -0
- package/Shared/constant/SHARED.d.ts +0 -150
- package/Shared/services/app-config.service.d.ts +0 -51
- package/fesm2022/cat-documents-ng.mjs +0 -1411
- package/fesm2022/cat-documents-ng.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/document/components/document-container/document-container.component.d.ts +0 -44
- package/lib/document/components/document-list/document-list.component.d.ts +0 -47
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
- package/lib/document/components/document-upload/document-upload.component.d.ts +0 -113
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -113
- package/lib/document/components/folder-container/folder-container.component.d.ts +0 -28
- package/lib/document/document.module.d.ts +0 -35
- package/lib/document/models/document.model.d.ts +0 -33
- package/lib/document/services/file-format.service.d.ts +0 -23
- package/lib/document/state/document.store.d.ts +0 -20
- /package/{src → projects/cat-document-lib/src}/assets/images/FolderImg.png +0 -0
- /package/{src → projects/cat-document-lib/src}/assets/images/Frame.png +0 -0
- /package/{src → projects/cat-document-lib/src}/assets/images/document.png +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
* Represents the count of missing files.
|
|
8
|
+
*/
|
|
9
|
+
static MISSINGCOUNT = 2;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents the count of pending files.
|
|
13
|
+
*/
|
|
14
|
+
static PENDINGCOUNT = 3;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents an empty string.
|
|
18
|
+
*/
|
|
19
|
+
static EMPTY = "";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents an true.
|
|
23
|
+
* @static
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
*/
|
|
26
|
+
static TRUE: boolean = true;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents an false.
|
|
31
|
+
* @static
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
*/
|
|
34
|
+
static FALSE: boolean = false;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Represents an INITIAL_COUNT.
|
|
38
|
+
*/
|
|
39
|
+
static INITIAL_COUNT = 0
|
|
40
|
+
/**
|
|
41
|
+
* Represents an INITIAL_VALUE.
|
|
42
|
+
*/
|
|
43
|
+
static INITIAL_VALUE = 0
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Represents the constant value for one (1).
|
|
47
|
+
* @static
|
|
48
|
+
* @type {number}
|
|
49
|
+
*/
|
|
50
|
+
static ONE: number = 1
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Represents the constant value for two (2).
|
|
54
|
+
* @static
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
static TWO: number = 2
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents the constant value for ten (10).
|
|
61
|
+
* @static
|
|
62
|
+
* @type {number}
|
|
63
|
+
*/
|
|
64
|
+
static TEN: number = 10
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the constant string value 'files' used for file-related operations.
|
|
68
|
+
* @static
|
|
69
|
+
* @type {string}
|
|
70
|
+
*/
|
|
71
|
+
static FILE: string = 'file';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Represents the array of file size units ('B', 'KB', 'MB') used for file size formatting.
|
|
75
|
+
* @static
|
|
76
|
+
* @type {string[]}
|
|
77
|
+
*/
|
|
78
|
+
static FILE_SIZE_UNITS: string[] = ['B', 'KB', 'MB'];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Show SEVERITY value.
|
|
82
|
+
* @static
|
|
83
|
+
* @type {'error'}
|
|
84
|
+
*/
|
|
85
|
+
static SEVERITY:string = 'error'
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Show upload summery if it's failed.
|
|
89
|
+
* @static
|
|
90
|
+
* @type {'Upload Failed'}
|
|
91
|
+
*/
|
|
92
|
+
static UPLOAD_SUMMERY:string = 'Upload Failed'
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Represent empty array.
|
|
96
|
+
* @static
|
|
97
|
+
* @type {{}}
|
|
98
|
+
*/
|
|
99
|
+
static EMPTY_ARRAY = []
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Represent contextId.
|
|
103
|
+
* @static
|
|
104
|
+
* @type {string}
|
|
105
|
+
*/
|
|
106
|
+
static CONTEXT_ID : string = 'contextId'
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Represent fileSize.
|
|
110
|
+
* @static
|
|
111
|
+
* @type {string}
|
|
112
|
+
*/
|
|
113
|
+
static FILE_SIZE : string = 'fileSize'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `DUMMYDOCUMENTLIST` is a mock list of document objects used for testing and development purposes.
|
|
118
|
+
* Each document includes an ID, file name, status, and document URL.
|
|
119
|
+
*/
|
|
120
|
+
export const DUMMYDOCUMENTLIST = [
|
|
121
|
+
{
|
|
122
|
+
_id: 1,
|
|
123
|
+
fileName: 'Document 1',
|
|
124
|
+
status: 'pending',
|
|
125
|
+
documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
_id: 2,
|
|
129
|
+
fileName: 'Document 2',
|
|
130
|
+
status: 'verified',
|
|
131
|
+
documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
_id: 3,
|
|
135
|
+
fileName: 'Document 3',
|
|
136
|
+
status: 'sentReminder',
|
|
137
|
+
documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
_id: 4,
|
|
141
|
+
fileName: 'Document 4',
|
|
142
|
+
status: 'pending',
|
|
143
|
+
documentUrl: 'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf',
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* `FOLDERPANEL` is a mock list of folder data representing various folders in the application.
|
|
149
|
+
* Each folder contains an ID, file count, text description, missing files count, and pending files count.
|
|
150
|
+
*/
|
|
151
|
+
export const FOLDERPANEL = [
|
|
152
|
+
{
|
|
153
|
+
_id: 'folder1',
|
|
154
|
+
fileCount: 10,
|
|
155
|
+
text: 'Documents',
|
|
156
|
+
missingFiles: 3,
|
|
157
|
+
pendingFiles: 2,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
_id: 'folder2',
|
|
161
|
+
fileCount: 5,
|
|
162
|
+
text: 'Images',
|
|
163
|
+
missingFiles: 0,
|
|
164
|
+
pendingFiles: 1,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
_id: 'folder3',
|
|
168
|
+
fileCount: 20,
|
|
169
|
+
text: 'Reports',
|
|
170
|
+
missingFiles: 5,
|
|
171
|
+
pendingFiles: 0,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
_id: 'folder4',
|
|
175
|
+
fileCount: 8,
|
|
176
|
+
text: 'Videos',
|
|
177
|
+
missingFiles: 0,
|
|
178
|
+
pendingFiles: 0,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
_id: 'folder5',
|
|
182
|
+
fileCount: 15,
|
|
183
|
+
text: 'Archives',
|
|
184
|
+
missingFiles: 1,
|
|
185
|
+
pendingFiles: 3,
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Dummy data for sumaery.
|
|
191
|
+
* @type {{}}
|
|
192
|
+
*/
|
|
193
|
+
export const DUMMYSUMMARY = [
|
|
194
|
+
{
|
|
195
|
+
status: 'Valuation report requested on 10th Oct 2024',
|
|
196
|
+
date: '15/10/2020 10:30',
|
|
197
|
+
icon: 'pi pi-shopping-cart',
|
|
198
|
+
color: '#9C27B0',
|
|
199
|
+
image: 'game-controller.jpg',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
status: 'Valuation report received on 13th Oct 2024',
|
|
203
|
+
date: '15/10/2020 14:00',
|
|
204
|
+
icon: 'pi pi-cog',
|
|
205
|
+
color: '#673AB7',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
status: 'Waiting for Valuation Report to be accepted',
|
|
209
|
+
date: '15/10/2020 16:15',
|
|
210
|
+
icon: 'pi pi-shopping-cart',
|
|
211
|
+
color: '#FF9800',
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Dummy data for list box.
|
|
217
|
+
* @type {{}}
|
|
218
|
+
*/
|
|
219
|
+
export const COUNTRIES = [
|
|
220
|
+
{ name: 'Any Word', code: 'NY', checked: false },
|
|
221
|
+
{ name: 'Case Sensitive', code: 'RM', checked: false },
|
|
222
|
+
{ name: 'Wildcard Search', code: 'LDN', checked: false },
|
|
223
|
+
{ name: 'Whole Word Only', code: 'IST', checked: false },
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Default supported image types.
|
|
228
|
+
* @type {{}}
|
|
229
|
+
*/
|
|
230
|
+
export const SUPPORTED_IMAGE_TYPES = [
|
|
231
|
+
'image/png'
|
|
232
|
+
];
|
|
@@ -1,29 +1,31 @@
|
|
|
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
|
|
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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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/app.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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { AppConfigService } from './app-config.service';
|
|
4
|
+
|
|
5
|
+
describe('AppConfigService', () => {
|
|
6
|
+
let service: AppConfigService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(AppConfigService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -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?.apiUrl;
|
|
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
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { ErrorHandler, Injector } from '@angular/core';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { ErrorHandler, Injectable, Injector } from '@angular/core';
|
|
2
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GlobalErrorHandler is a custom error handler that implements the ErrorHandler interface.
|
|
6
|
+
* It is used to handle both HTTP errors and other types of errors globally in the application.
|
|
7
|
+
* @class
|
|
8
|
+
* @implements {ErrorHandler}
|
|
9
|
+
* @decorator {Injectable}
|
|
10
|
+
*/
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class GlobalErrorHandler implements ErrorHandler {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of GlobalErrorHandler.
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {Injector} injector - The Angular injector used to get instances of services.
|
|
17
|
+
*/
|
|
18
|
+
constructor(private injector: Injector) { }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Handles errors globally in the application.
|
|
22
|
+
*
|
|
23
|
+
* @param {any} error - The error object that needs to be handled.
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
handleError(error: any): void {
|
|
27
|
+
console.error('GlobalErrorHandler:', error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
3
|
+
import { DocumentService } from '../../state/document.service';
|
|
4
|
+
import { DocumentModel } from '../../models/document.model';
|
|
5
|
+
import { URLS } from '../../../../Shared/constant/URLS';
|
|
6
|
+
import { Subscription } from 'rxjs';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*This component is responsible for managing and displaying a list of documents.
|
|
11
|
+
* @class DocumentContainerComponent
|
|
12
|
+
* @typedef {DocumentContainerComponent}
|
|
13
|
+
*/
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'lib-document-container',
|
|
16
|
+
standalone: false,
|
|
17
|
+
templateUrl: './document-container.component.html',
|
|
18
|
+
styleUrl: './document-container.component.scss'
|
|
19
|
+
})
|
|
20
|
+
export class DocumentContainerComponent implements OnInit{
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of DocumentContainerComponent.
|
|
24
|
+
* @class
|
|
25
|
+
* @param {DocumentService} documentService - Service to manage document-related operations.
|
|
26
|
+
*/
|
|
27
|
+
constructor(public documentService : DocumentService){
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get contextId in input.
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
@Input() contextId : string = "786755";
|
|
35
|
+
/**
|
|
36
|
+
* The list of dummy documents.
|
|
37
|
+
* @type {Array}
|
|
38
|
+
*/
|
|
39
|
+
documentList : DocumentModel[] = []
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Holds the subscription to manage observable cleanup.
|
|
43
|
+
* @private
|
|
44
|
+
* @type {Subscription}
|
|
45
|
+
*/
|
|
46
|
+
private subscription: Subscription = new Subscription();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Call document service method to get the document by contextId.
|
|
50
|
+
*/
|
|
51
|
+
ngOnInit(): void {
|
|
52
|
+
const documentSubscription = this.documentService
|
|
53
|
+
.getById(`${URLS.CONTEXT}${this.contextId}`)
|
|
54
|
+
.subscribe({
|
|
55
|
+
/**
|
|
56
|
+
* Handles the successful API response.
|
|
57
|
+
* @param {DocumentModel[]} res - The list of documents returned by the API.
|
|
58
|
+
*/
|
|
59
|
+
next: (res: DocumentModel[]) => {
|
|
60
|
+
if (res) {
|
|
61
|
+
this.documentList = res;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Handles errors that occur during the API call.
|
|
66
|
+
* Logs the error to the console.
|
|
67
|
+
* @param {any} err - The error object returned from the API.
|
|
68
|
+
*/
|
|
69
|
+
error: (err) => {
|
|
70
|
+
throw new Error(err)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.subscription.add(documentSubscription);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Unsubscribe subscription on destroy of component .
|
|
78
|
+
*/
|
|
79
|
+
ngOnDestroy(): void {
|
|
80
|
+
this.subscription.unsubscribe();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<div class="document-viewer">
|
|
2
|
+
<p-dialog [(visible)]="isdialogVisible" [modal]="true" (onHide)="handleCloseModel()" [style]="{ width: '100vw' }"
|
|
3
|
+
[draggable]="false" [closable]="true">
|
|
4
|
+
<document-viewer [selectedDocument]="selectedDocument"></document-viewer>
|
|
5
|
+
</p-dialog>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="col-12 p-0">
|
|
9
|
+
<div class="card p-0 document-list-wrapper">
|
|
10
|
+
<p-accordion>
|
|
11
|
+
<p-accordionTab [selected]="true" class="line-height-2 m-0">
|
|
12
|
+
<ng-template pTemplate="header" let-active="active">
|
|
13
|
+
<div class="flex align-items-center justify-content-between w-full">
|
|
14
|
+
<span class="flex align-items-center gap-2">
|
|
15
|
+
Documents
|
|
16
|
+
</span>
|
|
17
|
+
<button pButton pRipple class="p-button-raised" type="button" label="Upload File"
|
|
18
|
+
style="border-radius: 10px;" (click)="handleFileUploadClick($event)"></button>
|
|
19
|
+
</div>
|
|
20
|
+
</ng-template>
|
|
21
|
+
@for(document of documentList; track document){
|
|
22
|
+
<lib-document-list-item [document]="document"
|
|
23
|
+
(documentClick)="handleClickForDocument($event)"></lib-document-list-item>
|
|
24
|
+
}
|
|
25
|
+
</p-accordionTab>
|
|
26
|
+
</p-accordion>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="grid">
|
|
30
|
+
<div class="col-12">
|
|
31
|
+
<p-sidebar [(visible)]="isSidebarVisible" position="right" [styleClass]="'right-sidebar'">
|
|
32
|
+
<lib-document-upload [contextId]="contextId"></lib-document-upload>
|
|
33
|
+
</p-sidebar>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { DocumentModel } from '../../models/document.model';
|
|
3
|
+
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This component is responsible for displaying a list of documents.
|
|
8
|
+
* @class DocumentListComponent
|
|
9
|
+
* @typedef {DocumentListComponent}
|
|
10
|
+
*/
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'lib-document-list',
|
|
13
|
+
standalone: false,
|
|
14
|
+
templateUrl: './document-list.component.html',
|
|
15
|
+
styleUrls: ['./document-list.component.scss'],
|
|
16
|
+
encapsulation: ViewEncapsulation.None
|
|
17
|
+
})
|
|
18
|
+
export class DocumentListComponent {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represent contextId
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
@Input() contextId : string = SHARED.EMPTY
|
|
25
|
+
|
|
26
|
+
selectedDocument !: DocumentModel
|
|
27
|
+
/**
|
|
28
|
+
* Default visbility of sidebar
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
isSidebarVisible: boolean = SHARED.FALSE
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Default visbility of dialog
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
isdialogVisible: boolean = SHARED.FALSE
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The list of documents to display.
|
|
41
|
+
* @type {DocumentModel[]}
|
|
42
|
+
*/
|
|
43
|
+
@Input() documentList: DocumentModel[] = [];
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handles the click event for file upload.
|
|
48
|
+
* Prevents event propagation and displays the sidebar.
|
|
49
|
+
* @param {MouseEvent} event - The click event triggered by the user.
|
|
50
|
+
*/
|
|
51
|
+
handleFileUploadClick(event: MouseEvent): void {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
this.isSidebarVisible = SHARED.TRUE;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Select a individual document.
|
|
59
|
+
* @param {*} docuemnt - The document that was clicked by the user.
|
|
60
|
+
*/
|
|
61
|
+
handleClickForDocument(docuemnt: DocumentModel) {
|
|
62
|
+
this.isdialogVisible = SHARED.TRUE
|
|
63
|
+
this.selectedDocument = docuemnt
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Close dialog.
|
|
68
|
+
*/
|
|
69
|
+
handleCloseModel(){
|
|
70
|
+
this.selectedDocument = {_id : SHARED.INITIAL_VALUE};
|
|
71
|
+
this.isdialogVisible = SHARED.FALSE
|
|
72
|
+
}
|
|
73
|
+
}
|