cat-documents-ng 1.0.0 → 1.0.1

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 (32) hide show
  1. package/angular.json +2 -2
  2. package/package.json +3 -1
  3. package/projects/cat-document-lib/ng-package.json +2 -3
  4. package/projects/cat-document-lib/src/assets/images/document.png +0 -0
  5. package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.html +6 -1
  6. package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.ts +79 -11
  7. package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.html +35 -1
  8. package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.scss +12 -0
  9. package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.ts +63 -11
  10. package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.html +33 -0
  11. package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.scss +22 -0
  12. package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +23 -0
  13. package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
  14. package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.html +56 -0
  15. package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.scss +26 -0
  16. package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.spec.ts +24 -0
  17. package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.ts +175 -0
  18. package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.html +244 -0
  19. package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.scss +36 -0
  20. package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +21 -0
  21. package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.ts +125 -0
  22. package/projects/cat-document-lib/src/lib/document/document.module.ts +171 -8
  23. package/projects/cat-document-lib/src/lib/document/models/document.model.ts +39 -3
  24. package/projects/cat-document-lib/src/lib/document/services/file-format.service.spec.ts +16 -0
  25. package/projects/cat-document-lib/src/lib/document/services/file-format.service.ts +41 -0
  26. package/projects/cat-document-lib/src/lib/document/state/document.service.ts +83 -11
  27. package/projects/cat-document-lib/src/shared/constant/SHARED.ts +125 -0
  28. package/projects/cat-document-lib/src/shared/constant/URLS.ts +31 -0
  29. package/projects/cat-document-lib/src/shared/services/app-config.service.spec.ts +16 -0
  30. package/projects/cat-document-lib/src/shared/services/app-config.service.ts +73 -0
  31. package/src/app/app.module.ts +4 -3
  32. package/src/styles.scss +38 -4
@@ -1,24 +1,187 @@
1
- import { NgModule } from '@angular/core';
1
+ import { APP_INITIALIZER, NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { DocumentContainerComponent } from './components/document-container/document-container.component';
4
- import { DocumentListComponent } from './components/document-list/document-list.component';
5
- import { FolderBlockComponent } from './components/folder-block/folder-block.component';
6
4
  import { FolderContainerComponent } from './components/folder-container/folder-container.component';
7
-
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 { HttpClientModule } from '@angular/common/http';
15
+ import { ProgressBarModule } from 'primeng/progressbar';
16
+ import { BadgeModule } from 'primeng/badge';
17
+ import { ListboxModule } from 'primeng/listbox';
18
+ import { TimelineModule } from 'primeng/timeline';
19
+ import { CheckboxModule } from 'primeng/checkbox';
20
+ import { InputTextareaModule } from 'primeng/inputtextarea';
21
+ import { FormsModule } from '@angular/forms';
22
+ import { DocumentViewerComponent } from './components/document-viewer/document-viewer.component';
23
+ import { PdfViewerModule } from 'ng2-pdf-viewer';
24
+ import { DialogModule } from 'primeng/dialog';
25
+ import { AppConfigService } from '../../Shared/services/app-config.service';
26
+ import { GlobalErrorHandler } from '../../Shared/services/global-error.handler';
8
27
 
9
28
  /**
10
- *
29
+ * @module DocumentModule
30
+ *
31
+ * The `DocumentModule` handles the organization and display of document and folder components
32
+ * in the application. This module is designed to support features like folder containers,
33
+ * document lists, and individual document items.
11
34
  */
12
35
  @NgModule({
13
36
  declarations: [
37
+ /**
38
+ * The main container for managing documents.
39
+ * DocumentContainerComponent
40
+ */
14
41
  DocumentContainerComponent,
15
- DocumentListComponent,
42
+
43
+ /**
44
+ * A container component to manage folders.
45
+ * FolderContainerComponent
46
+ */
47
+ FolderContainerComponent,
48
+
49
+ /**
50
+ * A block component that represents an individual folder.
51
+ * FolderBlockComponent
52
+ */
16
53
  FolderBlockComponent,
17
- FolderContainerComponent
54
+
55
+ /**
56
+ * A component to display a list of documents.
57
+ * DocumentListComponent
58
+ */
59
+ DocumentListComponent,
60
+
61
+ /**
62
+ * A component representing an individual item in the document list.
63
+ * DocumentListItemComponent
64
+ */
65
+ DocumentListItemComponent,
66
+
67
+ /**
68
+ * A component representing to upload a file.
69
+ */
70
+ DocumentUploadComponent,
71
+
72
+ /**
73
+ * A component representing and allow you to view the document.
74
+ */
75
+ DocumentViewerComponent,
76
+
18
77
  ],
19
78
  imports: [
79
+ /**
80
+ * Angular's CommonModule is imported to access common directives like `ngIf` and `ngFor`.
81
+ */
20
82
  CommonModule,
83
+
84
+ /**
85
+ * PrimeNG AccordionModule is used for creating collapsible sections in the UI.
86
+ */
87
+ AccordionModule,
88
+
89
+ /**
90
+ * HttpClienModule for the http calls
91
+ */
92
+ HttpClientModule,
93
+
94
+ /**
95
+ * PrimeNG ButtonModule is used for creating buttons in the UI.
96
+ */
97
+ ButtonModule,
98
+
99
+ /**
100
+ * PrimeNG SidebarModule is used for creating sidebar in the UI.
101
+ */
102
+ SidebarModule,
103
+
104
+ /**
105
+ * PrimeNG FileUploadModule is used for uploading file.
106
+ */
107
+ FileUploadModule,
108
+
109
+ /**
110
+ * PrimeNG ProgressBarModule is used for showing progress.
111
+ */
112
+ ProgressBarModule,
113
+
114
+ /**
115
+ * PrimeNG BadgeModule is used for showing badge value.
116
+ */
117
+ BadgeModule,
118
+
119
+ /**
120
+ * PrimeNG ListboxModule is used for showing listbox value.
121
+ */
122
+ ListboxModule,
123
+
124
+ /**
125
+ * PrimeNG CheckboxModule is used for showing checkbox value.
126
+ */
127
+ CheckboxModule,
128
+
129
+ /**
130
+ * PrimeNG TimelineModule is used for showing timeline value.
131
+ */
132
+ TimelineModule,
133
+ /**
134
+ * PrimeNG InputTextareaModule is used for showing textarea value.
135
+ */
136
+ InputTextareaModule,
137
+ /**
138
+ * FormsModule to handle the forms.
139
+ */
140
+ FormsModule,
141
+ /**
142
+ * PdfViewerModule to handle and make visible the pdf.
143
+ */
144
+ PdfViewerModule,
145
+ /**
146
+ * PrimeNG DialogModule is used for showing dialog.
147
+ */
148
+ DialogModule
149
+ ],
150
+ exports: [
151
+ /**
152
+ * Exports the `DocumentContainerComponent` to be used in other modules.
153
+ */
154
+ DocumentContainerComponent
21
155
  ],
22
- exports : [DocumentContainerComponent]
156
+ providers: [
157
+ /**
158
+ * Provide the messageservice to be used in other components.
159
+ */
160
+ MessageService,
161
+
162
+ /**
163
+ * Provide the messageservice to be used in other components.
164
+ */
165
+ { provide: GlobalErrorHandler, useClass: GlobalErrorHandler },
166
+ /**
167
+ * Initializes the application configuration by loading it from the AppConfigService
168
+ * before the application starts.
169
+ * This ensures that the configuration is available for the rest of the app when needed.
170
+ * The configuration is loaded asynchronously using the APP_INITIALIZER.
171
+ * @returns {Function} - A function that loads the configuration from the AppConfigService.
172
+ */
173
+ {
174
+ provide: APP_INITIALIZER,
175
+ /**
176
+ * This useFactory is executed when the app initializes.
177
+ */
178
+ useFactory: (configService: AppConfigService) => () =>
179
+ configService.loadAppConfig().catch((error) => {
180
+ throw new Error(error);
181
+ }),
182
+ deps: [AppConfigService],
183
+ multi: true,
184
+ }
185
+ ]
23
186
  })
24
187
  export class DocumentModule { }
@@ -1,3 +1,39 @@
1
- export class DocumentModel{
2
-
3
- }
1
+ import { SHARED } from "../../../Shared/constant/SHARED";
2
+
3
+ /**
4
+ * Represents a document model.
5
+ *
6
+ * This class contains the structure for document-related data, including file name,
7
+ * status, and document URL.
8
+ */
9
+ export class DocumentModel {
10
+ /**
11
+ * The unique identifier for the document.
12
+ * @type {number}
13
+ */
14
+ _id: number = SHARED.INITIAL_COUNT;
15
+
16
+ /**
17
+ * The name of the document file.
18
+ * @type {?string}
19
+ */
20
+ fileName?: string;
21
+
22
+ /**
23
+ * The current status of the document.
24
+ * @type {?string}
25
+ */
26
+ status?: string;
27
+
28
+ /**
29
+ * The URL where the document is hosted or stored.
30
+ * @type {?string}
31
+ */
32
+ documentUrl?: string;
33
+
34
+ /**
35
+ * Date of document get uploaded
36
+ * @type {?Date}
37
+ */
38
+ createdAt?: Date
39
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { FileFormatService } from './file-format.service';
4
+
5
+ describe('FileFormatService', () => {
6
+ let service: FileFormatService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(FileFormatService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,41 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { SHARED } from '../../../Shared/constant/SHARED';
3
+ import { PrimeNGConfig } from 'primeng/api';
4
+
5
+ /**
6
+ * Description placeholder
7
+ * @class FileFormatService
8
+ * @typedef {FileFormatService}
9
+ */
10
+ @Injectable({
11
+ providedIn: 'root'
12
+ })
13
+ export class FileFormatService {
14
+
15
+ /**
16
+ * Creates an instance of FileFormatService.
17
+ * @constructor
18
+ */
19
+ constructor() { }
20
+
21
+ /**
22
+ * Description placeholder
23
+ * @param {number} bytes
24
+ * @param {PrimeNGConfig} config
25
+ * @returns {string}
26
+ */
27
+ formatFileSize(bytes: number, config:PrimeNGConfig): string {
28
+ const kilobyte = 1024;
29
+ const decimalPlaces = SHARED.ONE;
30
+ const sizes = config.translation.fileSizeTypes || SHARED.FILE_SIZE_UNITS;
31
+ if (bytes < kilobyte) {
32
+ return `${bytes} ${sizes[SHARED.INITIAL_COUNT]}`;
33
+ } else if (bytes < kilobyte * kilobyte) {
34
+ const kbSize = bytes / kilobyte;
35
+ return `${parseFloat(kbSize.toFixed(decimalPlaces))} ${sizes[SHARED.ONE]}`;
36
+ } else {
37
+ const mbSize = bytes / (kilobyte * kilobyte);
38
+ return `${parseFloat(mbSize.toFixed(decimalPlaces))} ${sizes[SHARED.TWO]}`;
39
+ }
40
+ }
41
+ }
@@ -1,23 +1,95 @@
1
1
  import { Injectable } from '@angular/core';
2
2
  import { HttpClient } from '@angular/common/http';
3
3
  import { DocumentStore } from './document.store';
4
+ import { Observable, tap } from 'rxjs';
5
+ import { AppConfigService } from '../../../Shared/services/app-config.service';
6
+ import { URLS } from '../../../Shared/constant/URLS';
7
+ import { DocumentModel } from '../models/document.model';
4
8
 
5
9
  /**
6
10
  * Service for managing document-related operations.
7
- *
8
11
  * The `DocumentService` acts as a bridge between the application and the backend API for handling document-related data.
9
12
  * It interacts with the `DocumentStore` for state management and uses `HttpClient` for making HTTP requests.
10
-
11
- * Creates an instance of `DocumentService`.
12
- *
13
- * @param {DocumentStore} doumentStore - The store that manages the state of documents.
14
- * @param {HttpClient} http - The Angular HTTP client for making API requests.
15
- */
13
+ * Creates an instance of `DocumentService`.
14
+ * @param {DocumentStore} documentStore - The store that manages the state of documents.
15
+ * @param {HttpClient} http - The Angular HTTP client for making API requests.
16
+ */
16
17
  @Injectable({ providedIn: 'root' })
17
18
  export class DocumentService {
18
19
 
19
- constructor(
20
- public documentStore: DocumentStore,
21
- private http: HttpClient, // Changed to private for better encapsulation
22
- ) { }
20
+ /**
21
+ * Creates an instance of DocumentService.
22
+ * @param {DocumentStore} documentStore - Store managing the state of documents.
23
+ * @param {HttpClient} http - Angular HTTP client for making API requests.
24
+ * @param {AppConfigService} appConfigService - Service for retrieving application configuration, such as API base URL.
25
+ */
26
+ constructor(
27
+ public documentStore: DocumentStore,
28
+ private http: HttpClient,
29
+ public appConfigService: AppConfigService
30
+ ) { }
31
+
32
+ /**
33
+ * Get api url from appConfigService.
34
+ * @readonly
35
+ * @type {string}
36
+ */
37
+ get apiUrl(): string {
38
+ return this.appConfigService.apiBaseUrl;
39
+ }
40
+
41
+ /**
42
+ * Sends a request to create a new document.
43
+ * @param {*} entity - The data of the document to be created.
44
+ * @returns {Observable<any>} Observable that emits the newly created document.
45
+ */
46
+ create(entity: any): Observable<any> {
47
+ return this.http.post<any>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}`, entity).pipe(
48
+ tap((newEntity: any) => this.documentStore.add(newEntity))
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Fetches all documents from the backend.
54
+ * @returns {Observable<DocumentModel[]>} Observable that emits an array of documents.
55
+ */
56
+ getAll(): Observable<DocumentModel[]> {
57
+ return this.http.get<DocumentModel[]>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}`).pipe(
58
+ tap((entities: DocumentModel[]) => this.documentStore.set(entities))
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Fetches a document by its ID.
64
+ * @param {string} id - The unique identifier of the document.
65
+ * @returns {Observable<any>} Observable that emits the retrieved document.
66
+ */
67
+ getById(id: string): Observable<any> {
68
+ return this.http.get<any>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${id}`).pipe(
69
+ tap((entity: any) => this.documentStore.upsert(id, entity))
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Updates an existing document by its ID.
75
+ * @param {string} id - The unique identifier of the document.
76
+ * @param {DocumentModel} entity - The updated data of the document.
77
+ * @returns {Observable<DocumentModel>} Observable that emits the updated document.
78
+ */
79
+ update(id: string, entity: DocumentModel): Observable<DocumentModel> {
80
+ return this.http.put<DocumentModel>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${id}`, entity).pipe(
81
+ tap((updatedEntity: DocumentModel) => this.documentStore.update(id, updatedEntity))
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Deletes a document by its ID.
87
+ * @param {string} id - The unique identifier of the document to be deleted.
88
+ * @returns {Observable<void>} Observable that completes when the document is deleted.
89
+ */
90
+ delete(id: string): Observable<void> {
91
+ return this.http.delete<void>(`${this.apiUrl}${URLS.DOCUMENT_UPLOAD}/${id}`).pipe(
92
+ tap(() => this.documentStore.remove(id))
93
+ );
94
+ }
23
95
  }
@@ -17,6 +17,86 @@ export class SHARED {
17
17
  * Represents an empty string.
18
18
  */
19
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 = []
20
100
  }
21
101
 
22
102
  /**
@@ -91,3 +171,48 @@ export const FOLDERPANEL = [
91
171
  pendingFiles: 3,
92
172
  }
93
173
  ];
174
+
175
+ /**
176
+ * Dummy data for sumaery.
177
+ * @type {{}}
178
+ */
179
+ export const DUMMYSUMMARY = [
180
+ {
181
+ status: 'Valuation report requested on 10th Oct 2024',
182
+ date: '15/10/2020 10:30',
183
+ icon: 'pi pi-shopping-cart',
184
+ color: '#9C27B0',
185
+ image: 'game-controller.jpg',
186
+ },
187
+ {
188
+ status: 'Valuation report received on 13th Oct 2024',
189
+ date: '15/10/2020 14:00',
190
+ icon: 'pi pi-cog',
191
+ color: '#673AB7',
192
+ },
193
+ {
194
+ status: 'Waiting for Valuation Report to be accepted',
195
+ date: '15/10/2020 16:15',
196
+ icon: 'pi pi-shopping-cart',
197
+ color: '#FF9800',
198
+ },
199
+ ];
200
+
201
+ /**
202
+ * Dummy data for list box.
203
+ * @type {{}}
204
+ */
205
+ export const COUNTRIES = [
206
+ { name: 'Any Word', code: 'NY', checked: false },
207
+ { name: 'Case Sensitive', code: 'RM', checked: false },
208
+ { name: 'Wildcard Search', code: 'LDN', checked: false },
209
+ { name: 'Whole Word Only', code: 'IST', checked: false },
210
+ ];
211
+
212
+ /**
213
+ * Default supported image types.
214
+ * @type {{}}
215
+ */
216
+ export const SUPPORTED_IMAGE_TYPES = [
217
+ 'image/png'
218
+ ];
@@ -0,0 +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 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,11 +1,12 @@
1
- import { NgModule } from '@angular/core';
1
+ import { APP_INITIALIZER, NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { AppRoutingModule } from './app.routing.module';
4
4
  import { AppComponent } from './app.component';
5
5
  import { BrowserModule } from '@angular/platform-browser';
6
6
  import { DocumentModule } from '../../projects/cat-document-lib/src/public-api';
7
7
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
8
- import { GlobalErrorHandler } from '../../projects/cat-document-lib/src/shared/services/global-error.handler';
8
+ import { AppConfigService } from '../../projects/cat-document-lib/src/Shared/services/app-config.service';
9
+ import { GlobalErrorHandler } from '../../projects/cat-document-lib/src/Shared/services/global-error.handler';
9
10
 
10
11
  /**
11
12
  * The root module of the Angular application.
@@ -52,7 +53,7 @@ import { GlobalErrorHandler } from '../../projects/cat-document-lib/src/shared/s
52
53
  /**
53
54
  * Registers the global error handler for the application.
54
55
  */
55
- {provide: GlobalErrorHandler, useClass: GlobalErrorHandler}
56
+
56
57
  ]
57
58
 
58
59
  })