@acorex/connectivity 20.6.0-next.6 → 20.6.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ import { AXPApplicationLoader, AXPApplication, AXPFeatureLoader, AXPFeature, AXP
|
|
|
9
9
|
import * as i3 from '@acorex/connectivity/utils';
|
|
10
10
|
import * as i1 from '@acorex/platform/runtime';
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
12
|
+
import { AXPUserAvatarProvider, AXPUserAvatarData } from '@acorex/platform/layout/components';
|
|
13
|
+
import * as _acorex_modules_report_management from '@acorex/modules/report-management';
|
|
14
|
+
import { AXPReportCategoryProvider, AXPReportCategory, AXPReportDefinitionProvider, AXPReportDefinition } from '@acorex/modules/report-management';
|
|
12
15
|
|
|
13
16
|
declare class AXCApiEntityStorageService implements AXPEntityStorageService<string, any> {
|
|
14
17
|
private http;
|
|
@@ -207,6 +210,15 @@ declare class AXMOidcTenantLoader implements AXPTenantLoader {
|
|
|
207
210
|
static ɵprov: i0.ɵɵInjectableDeclaration<AXMOidcTenantLoader>;
|
|
208
211
|
}
|
|
209
212
|
|
|
213
|
+
declare class AXCApiUserAvatarProvider implements AXPUserAvatarProvider {
|
|
214
|
+
private userService;
|
|
215
|
+
private sessionService;
|
|
216
|
+
private http;
|
|
217
|
+
private readonly configs;
|
|
218
|
+
private readonly baseUrl;
|
|
219
|
+
provide(userId: string): Promise<AXPUserAvatarData>;
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
declare class APIGoogleStrategy extends AXPAuthStrategy {
|
|
211
223
|
private aXMAuthConfigs;
|
|
212
224
|
private oauthService;
|
|
@@ -234,5 +246,192 @@ declare class APIGoogleStrategy extends AXPAuthStrategy {
|
|
|
234
246
|
static ɵprov: i0.ɵɵInjectableDeclaration<APIGoogleStrategy>;
|
|
235
247
|
}
|
|
236
248
|
|
|
237
|
-
|
|
238
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Execute Report DTO - Response from report execution API
|
|
251
|
+
*/
|
|
252
|
+
interface AXPExecuteReportDto {
|
|
253
|
+
type: string;
|
|
254
|
+
items: Record<string, unknown>[];
|
|
255
|
+
totalCount: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* API Response for Category endpoint
|
|
259
|
+
* Used by: GET /api/v1/global/report-management/category
|
|
260
|
+
* GET /api/v1/global/report-management/category/{parentId}
|
|
261
|
+
*/
|
|
262
|
+
interface AXCReportCategoryApiResponse {
|
|
263
|
+
totalCount: number;
|
|
264
|
+
items: AXCReportCategoryApiItem[];
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Category Item with recursive structure
|
|
268
|
+
* Each category can contain child categories (folderItems) and reports (reportDefinitionItems)
|
|
269
|
+
*/
|
|
270
|
+
interface AXCReportCategoryApiItem {
|
|
271
|
+
reportCategoryParentId: string | null;
|
|
272
|
+
name: string;
|
|
273
|
+
title: string;
|
|
274
|
+
description: string | null;
|
|
275
|
+
folderCount: number;
|
|
276
|
+
itemCount: number;
|
|
277
|
+
isArchived: boolean;
|
|
278
|
+
reportDefinitionItems: AXCReportDefinitionApiItem[];
|
|
279
|
+
folderItems: AXCReportCategoryApiItem[];
|
|
280
|
+
id: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Report Definition Item (in category list, without full layout)
|
|
284
|
+
*/
|
|
285
|
+
interface AXCReportDefinitionApiItem {
|
|
286
|
+
categoryIds: string[];
|
|
287
|
+
name: string;
|
|
288
|
+
title: string;
|
|
289
|
+
description: string | null;
|
|
290
|
+
isArchived: boolean;
|
|
291
|
+
id: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Full Report Definition with complete details including layouts
|
|
295
|
+
* Used by: GET /api/v1/global/report-management/report/{reportId}
|
|
296
|
+
*/
|
|
297
|
+
interface AXCReportDefinitionApiResponse {
|
|
298
|
+
id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
title: string;
|
|
301
|
+
description: string | null;
|
|
302
|
+
categoryIds: string[];
|
|
303
|
+
parameterGroups: AXCReportParameterGroup[];
|
|
304
|
+
layouts: AXCReportLayoutDefinition[];
|
|
305
|
+
defaultLayoutId: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Parameter Group for report parameters
|
|
309
|
+
*/
|
|
310
|
+
interface AXCReportParameterGroup {
|
|
311
|
+
name: string;
|
|
312
|
+
title: string;
|
|
313
|
+
parameters: AXCReportParameter[];
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Report Parameter definition
|
|
317
|
+
*/
|
|
318
|
+
interface AXCReportParameter {
|
|
319
|
+
path: string;
|
|
320
|
+
title: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
widget: {
|
|
323
|
+
type: string;
|
|
324
|
+
path?: string | null;
|
|
325
|
+
options?: any;
|
|
326
|
+
valueTransforms?: any;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Layout Definition for report display
|
|
331
|
+
*/
|
|
332
|
+
interface AXCReportLayoutDefinition {
|
|
333
|
+
id: string;
|
|
334
|
+
title: string;
|
|
335
|
+
layout: any;
|
|
336
|
+
dataSource?: {
|
|
337
|
+
type: string;
|
|
338
|
+
name?: string;
|
|
339
|
+
provider?: string;
|
|
340
|
+
};
|
|
341
|
+
export?: {
|
|
342
|
+
fileNameTemplate: string;
|
|
343
|
+
pdf?: any;
|
|
344
|
+
excel?: any;
|
|
345
|
+
csv?: any;
|
|
346
|
+
};
|
|
347
|
+
isDefault?: boolean;
|
|
348
|
+
}
|
|
349
|
+
declare class AXCReportManagementDataService {
|
|
350
|
+
private readonly http;
|
|
351
|
+
private readonly configs;
|
|
352
|
+
private readonly baseUrl;
|
|
353
|
+
private categoryDataCache;
|
|
354
|
+
private rootCategoriesCache;
|
|
355
|
+
private pendingRequests;
|
|
356
|
+
private pendingRootCategoriesRequest;
|
|
357
|
+
/**
|
|
358
|
+
* Fetch root categories (no parent). Only root categories without reports and children.
|
|
359
|
+
* Uses cache and pending requests to avoid duplicate API calls.
|
|
360
|
+
*/
|
|
361
|
+
getRootCategories(): Promise<AXCReportCategoryApiItem[]>;
|
|
362
|
+
/**
|
|
363
|
+
* Fetch category data for a given parentId.
|
|
364
|
+
* Returns the parent category with its FolderItems (children) and ReportDefinitionItems (reports).
|
|
365
|
+
* Uses cache to avoid duplicate API calls.
|
|
366
|
+
*/
|
|
367
|
+
getCategoryData(parentId: string): Promise<AXCReportCategoryApiItem | undefined>;
|
|
368
|
+
/**
|
|
369
|
+
* Fetch both child categories and reports for a given parentId.
|
|
370
|
+
* This method ensures only one API call is made and both results are returned.
|
|
371
|
+
*/
|
|
372
|
+
getCategoryChildrenAndReports(parentId: string): Promise<{
|
|
373
|
+
categories: AXCReportCategoryApiItem[];
|
|
374
|
+
reports: AXCReportDefinitionApiItem[];
|
|
375
|
+
}>;
|
|
376
|
+
/**
|
|
377
|
+
* Fetch child categories of a given parent.
|
|
378
|
+
* Uses getCategoryData to get FolderItems (children) from the parent category.
|
|
379
|
+
*/
|
|
380
|
+
getChildCategories(parentId: string): Promise<AXCReportCategoryApiItem[]>;
|
|
381
|
+
/**
|
|
382
|
+
* Fetch report definitions that belong to a specific category.
|
|
383
|
+
* Uses getCategoryData to get ReportDefinitionItems (reports) from the category.
|
|
384
|
+
*/
|
|
385
|
+
getCategoryReports(categoryId: string): Promise<AXCReportDefinitionApiItem[]>;
|
|
386
|
+
/**
|
|
387
|
+
* Fetch a single category by id.
|
|
388
|
+
* First checks cache, then uses getCategoryData if not found in cache.
|
|
389
|
+
*/
|
|
390
|
+
getCategoryById(id: string): Promise<AXCReportCategoryApiItem | undefined>;
|
|
391
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AXCReportManagementDataService, never>;
|
|
392
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AXCReportManagementDataService>;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Category provider that uses the shared data service.
|
|
396
|
+
* Both providers use the same dataService instance which ensures proper caching.
|
|
397
|
+
*/
|
|
398
|
+
declare class AXCReportCategoryApiProvider implements AXPReportCategoryProvider {
|
|
399
|
+
private readonly dataService;
|
|
400
|
+
getList(parentId?: string): Promise<AXPReportCategory[]>;
|
|
401
|
+
getById(id: string): Promise<AXPReportCategory | undefined>;
|
|
402
|
+
private mapApiCategoryToReportCategory;
|
|
403
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AXCReportCategoryApiProvider, never>;
|
|
404
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AXCReportCategoryApiProvider>;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Definition provider that uses the shared data service.
|
|
408
|
+
* Both providers use the same dataService instance which ensures proper caching.
|
|
409
|
+
*/
|
|
410
|
+
declare class AXCReportDefinitionApiProvider implements AXPReportDefinitionProvider {
|
|
411
|
+
private readonly dataService;
|
|
412
|
+
private readonly http;
|
|
413
|
+
getList(categoryId: string): Promise<AXPReportDefinition[]>;
|
|
414
|
+
getById(id: string): Promise<AXPReportDefinition | undefined>;
|
|
415
|
+
private mapApiReportDefinitionItemToReportDefinition;
|
|
416
|
+
private mapApiReportDefinitionToReportDefinition;
|
|
417
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AXCReportDefinitionApiProvider, never>;
|
|
418
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AXCReportDefinitionApiProvider>;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Both providers use the same dataService instance (which is a singleton),
|
|
422
|
+
* ensuring they share the same cache and only one API call is made when both
|
|
423
|
+
* getCategories and getReportsByCategoryId are called for the same categoryId.
|
|
424
|
+
*/
|
|
425
|
+
declare const AXC_REPORT_CATEGORY_API_PROVIDER: {
|
|
426
|
+
provide: i0.InjectionToken<_acorex_modules_report_management.AXPReportCategoryProviderToken[]>;
|
|
427
|
+
useClass: typeof AXCReportCategoryApiProvider;
|
|
428
|
+
multi: boolean;
|
|
429
|
+
};
|
|
430
|
+
declare const AXC_REPORT_DEFINITION_API_PROVIDER: {
|
|
431
|
+
provide: i0.InjectionToken<_acorex_modules_report_management.AXPReportDefinitionProviderToken[]>;
|
|
432
|
+
useClass: typeof AXCReportDefinitionApiProvider;
|
|
433
|
+
multi: boolean;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
437
|
+
export type { AXCReportCategoryApiItem, AXCReportCategoryApiResponse, AXCReportDefinitionApiItem, AXCReportDefinitionApiResponse, AXCReportLayoutDefinition, AXCReportParameter, AXCReportParameterGroup, AXPExecuteReportDto, AXPOAuthExternalCredentials, AXPUserPassCredentials, ApplicationConfiguration, Auth, Culture, IAuthenticationDataModel, Language, Localization, NameValue, Resource };
|
|
@@ -8,11 +8,14 @@ import { kebabCase } from 'lodash-es';
|
|
|
8
8
|
import { firstValueFrom, catchError, of, map, BehaviorSubject, tap, filter, take, switchMap, delay } from 'rxjs';
|
|
9
9
|
import * as i2 from '@acorex/platform/auth';
|
|
10
10
|
import { AXPAuthStrategy, AXPSessionService, JwtUtil, TimeUtil, PkceUtil, AXPAuthModule, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER } from '@acorex/platform/auth';
|
|
11
|
+
import { AXP_USER_AVATAR_PROVIDER } from '@acorex/platform/layout/components';
|
|
11
12
|
import { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/layout/widgets';
|
|
12
13
|
import * as i1$1 from 'angular-oauth2-oidc';
|
|
13
14
|
import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
|
|
14
15
|
import { AXM_AUTH_CONFIG_TOKEN } from '@acorex/modules/auth';
|
|
15
16
|
import { Router } from '@angular/router';
|
|
17
|
+
import { AXMUsersEntityService } from '@acorex/modules/security-management';
|
|
18
|
+
import { AXPDataGenerator } from '@acorex/platform/core';
|
|
16
19
|
import { AXCUtilsModule, AXCExternalAuthorizationService } from '@acorex/connectivity/utils';
|
|
17
20
|
import { AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
|
|
18
21
|
import { AXP_REPORT_CATEGORY_PROVIDER, AXP_REPORT_DEFINITION_PROVIDER } from '@acorex/modules/report-management';
|
|
@@ -789,6 +792,63 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
789
792
|
type: Injectable
|
|
790
793
|
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
|
791
794
|
|
|
795
|
+
class AXCApiUserAvatarProvider {
|
|
796
|
+
constructor() {
|
|
797
|
+
this.userService = inject(AXMUsersEntityService);
|
|
798
|
+
this.sessionService = inject(AXPSessionService);
|
|
799
|
+
this.http = inject(HttpClient);
|
|
800
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
|
801
|
+
this.baseUrl = this.configs.baseUrl;
|
|
802
|
+
}
|
|
803
|
+
async provide(userId) {
|
|
804
|
+
// Check if requesting current user info
|
|
805
|
+
const currentUser = this.sessionService.user;
|
|
806
|
+
const isCurrentUser = currentUser?.id === userId;
|
|
807
|
+
if (isCurrentUser) {
|
|
808
|
+
// Use OpenIddict /connect/userinfo endpoint for current user
|
|
809
|
+
try {
|
|
810
|
+
// Extract base URL without /api suffix and add /connect/userinfo
|
|
811
|
+
const authority = this.baseUrl.replace(/\/api$/, '');
|
|
812
|
+
const userInfoUrl = `${authority}/connect/userinfo`;
|
|
813
|
+
const token = this.sessionService.getToken();
|
|
814
|
+
// Add Authorization header if token exists (interceptor will also add it, but explicit is better)
|
|
815
|
+
const headers = new HttpHeaders();
|
|
816
|
+
if (token) {
|
|
817
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
818
|
+
}
|
|
819
|
+
const userInfo = await firstValueFrom(this.http.get(userInfoUrl, { headers }));
|
|
820
|
+
const [firstName, lastName] = (userInfo.name || userInfo.sub || '').split(' ') || ['', ''];
|
|
821
|
+
return {
|
|
822
|
+
id: userInfo.sub || userId,
|
|
823
|
+
username: userInfo.preferred_username || userInfo.name || '',
|
|
824
|
+
firstName: firstName || userInfo.given_name || '',
|
|
825
|
+
lastName: lastName || userInfo.family_name || '',
|
|
826
|
+
status: 'online',
|
|
827
|
+
avatarUrl: userInfo.picture || 'https://via.placeholder.com/150',
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
catch (error) {
|
|
831
|
+
console.error('Failed to load userinfo from /connect/userinfo, falling back to entity service', error);
|
|
832
|
+
// Fallback to entity service if userinfo endpoint fails
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
// Use entity service for other users or as fallback
|
|
836
|
+
const user = await this.userService.getOne(userId);
|
|
837
|
+
if (!user) {
|
|
838
|
+
throw new Error(`User not found for ${userId}`);
|
|
839
|
+
}
|
|
840
|
+
const [firstName, lastName] = user.displayName.split(' ') || ['', ''];
|
|
841
|
+
return {
|
|
842
|
+
id: user.id,
|
|
843
|
+
username: user.username,
|
|
844
|
+
firstName: firstName || '',
|
|
845
|
+
lastName: lastName || '',
|
|
846
|
+
status: 'online',
|
|
847
|
+
avatarUrl: `https://avatar.iran.liara.run/public/${AXPDataGenerator.pick([35, 22, 16, 6, 31])}`,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
792
852
|
//#endregion
|
|
793
853
|
//#region ---- Helper Functions ----
|
|
794
854
|
// /**
|
|
@@ -839,26 +899,142 @@ class AXCReportManagementDataService {
|
|
|
839
899
|
this.http = inject(HttpClient);
|
|
840
900
|
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
|
841
901
|
this.baseUrl = this.configs.baseUrl;
|
|
842
|
-
//
|
|
843
|
-
this.
|
|
844
|
-
this.
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
902
|
+
// Cache for category data to avoid duplicate API calls
|
|
903
|
+
this.categoryDataCache = new Map();
|
|
904
|
+
this.rootCategoriesCache = null;
|
|
905
|
+
this.pendingRequests = new Map();
|
|
906
|
+
this.pendingRootCategoriesRequest = null;
|
|
907
|
+
}
|
|
908
|
+
//#region ---- Lazy Category/Report Fetching ----
|
|
909
|
+
/**
|
|
910
|
+
* Fetch root categories (no parent). Only root categories without reports and children.
|
|
911
|
+
* Uses cache and pending requests to avoid duplicate API calls.
|
|
912
|
+
*/
|
|
913
|
+
async getRootCategories() {
|
|
914
|
+
// Check if already cached
|
|
915
|
+
if (this.rootCategoriesCache !== null) {
|
|
916
|
+
return this.rootCategoriesCache;
|
|
849
917
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
918
|
+
// Check if there's already a pending request
|
|
919
|
+
if (this.pendingRootCategoriesRequest !== null) {
|
|
920
|
+
return this.pendingRootCategoriesRequest;
|
|
921
|
+
}
|
|
922
|
+
// Create the request and cache it
|
|
923
|
+
const requestPromise = (async () => {
|
|
924
|
+
try {
|
|
925
|
+
const url = `${this.baseUrl}/v1/global/report-management/category`;
|
|
926
|
+
const params = { Skip: 0, Take: 1000 };
|
|
927
|
+
const response = await firstValueFrom(this.http.get(url, { params }));
|
|
928
|
+
const all = response.items ?? [];
|
|
929
|
+
const rootCategories = all.filter((i) => !i.reportCategoryParentId);
|
|
930
|
+
// Cache the result
|
|
931
|
+
this.rootCategoriesCache = rootCategories;
|
|
932
|
+
return rootCategories;
|
|
933
|
+
}
|
|
934
|
+
finally {
|
|
935
|
+
// Remove from pending requests after completion
|
|
936
|
+
this.pendingRootCategoriesRequest = null;
|
|
937
|
+
}
|
|
938
|
+
})();
|
|
939
|
+
this.pendingRootCategoriesRequest = requestPromise;
|
|
940
|
+
return requestPromise;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Fetch category data for a given parentId.
|
|
944
|
+
* Returns the parent category with its FolderItems (children) and ReportDefinitionItems (reports).
|
|
945
|
+
* Uses cache to avoid duplicate API calls.
|
|
946
|
+
*/
|
|
947
|
+
async getCategoryData(parentId) {
|
|
948
|
+
// Check if already cached
|
|
949
|
+
if (this.categoryDataCache.has(parentId)) {
|
|
950
|
+
return this.categoryDataCache.get(parentId);
|
|
951
|
+
}
|
|
952
|
+
// Check if there's already a pending request for this category
|
|
953
|
+
if (this.pendingRequests.has(parentId)) {
|
|
954
|
+
return this.pendingRequests.get(parentId);
|
|
955
|
+
}
|
|
956
|
+
// Create the request and cache it
|
|
957
|
+
const requestPromise = (async () => {
|
|
958
|
+
try {
|
|
959
|
+
const url = `${this.baseUrl}/v1/global/report-management/category/${parentId}`;
|
|
960
|
+
const response = await firstValueFrom(this.http.get(url));
|
|
961
|
+
const categoryData = response.items?.[0];
|
|
962
|
+
// Cache the result
|
|
963
|
+
this.categoryDataCache.set(parentId, categoryData);
|
|
964
|
+
return categoryData;
|
|
965
|
+
}
|
|
966
|
+
catch {
|
|
967
|
+
const undefinedResult = undefined;
|
|
968
|
+
this.categoryDataCache.set(parentId, undefinedResult);
|
|
969
|
+
return undefinedResult;
|
|
970
|
+
}
|
|
971
|
+
finally {
|
|
972
|
+
// Remove from pending requests after completion
|
|
973
|
+
this.pendingRequests.delete(parentId);
|
|
974
|
+
}
|
|
975
|
+
})();
|
|
976
|
+
this.pendingRequests.set(parentId, requestPromise);
|
|
977
|
+
return requestPromise;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Fetch both child categories and reports for a given parentId.
|
|
981
|
+
* This method ensures only one API call is made and both results are returned.
|
|
982
|
+
*/
|
|
983
|
+
async getCategoryChildrenAndReports(parentId) {
|
|
984
|
+
const categoryData = await this.getCategoryData(parentId);
|
|
985
|
+
return {
|
|
986
|
+
categories: categoryData?.folderItems ?? [],
|
|
987
|
+
reports: categoryData?.reportDefinitionItems ?? [],
|
|
988
|
+
};
|
|
858
989
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
990
|
+
/**
|
|
991
|
+
* Fetch child categories of a given parent.
|
|
992
|
+
* Uses getCategoryData to get FolderItems (children) from the parent category.
|
|
993
|
+
*/
|
|
994
|
+
async getChildCategories(parentId) {
|
|
995
|
+
const categoryData = await this.getCategoryData(parentId);
|
|
996
|
+
return categoryData?.folderItems ?? [];
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Fetch report definitions that belong to a specific category.
|
|
1000
|
+
* Uses getCategoryData to get ReportDefinitionItems (reports) from the category.
|
|
1001
|
+
*/
|
|
1002
|
+
async getCategoryReports(categoryId) {
|
|
1003
|
+
const categoryData = await this.getCategoryData(categoryId);
|
|
1004
|
+
return categoryData?.reportDefinitionItems ?? [];
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Fetch a single category by id.
|
|
1008
|
+
* First checks cache, then uses getCategoryData if not found in cache.
|
|
1009
|
+
*/
|
|
1010
|
+
async getCategoryById(id) {
|
|
1011
|
+
// First check if it's in cache (from previous getCategoryData calls)
|
|
1012
|
+
if (this.categoryDataCache.has(id)) {
|
|
1013
|
+
return this.categoryDataCache.get(id);
|
|
1014
|
+
}
|
|
1015
|
+
// Try to get from category data endpoint (which will cache it)
|
|
1016
|
+
const categoryData = await this.getCategoryData(id);
|
|
1017
|
+
if (categoryData) {
|
|
1018
|
+
return categoryData;
|
|
1019
|
+
}
|
|
1020
|
+
// Fallback: search in root categories cache
|
|
1021
|
+
if (this.rootCategoriesCache) {
|
|
1022
|
+
const found = this.rootCategoriesCache.find((c) => c.id === id);
|
|
1023
|
+
if (found) {
|
|
1024
|
+
return found;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
// Last resort: search in all categories (but this should rarely happen)
|
|
1028
|
+
try {
|
|
1029
|
+
const url = `${this.baseUrl}/v1/global/report-management/category`;
|
|
1030
|
+
const params = { Skip: 0, Take: 1000 };
|
|
1031
|
+
const response = await firstValueFrom(this.http.get(url, { params }));
|
|
1032
|
+
const all = response.items ?? [];
|
|
1033
|
+
return all.find((c) => c.id === id);
|
|
1034
|
+
}
|
|
1035
|
+
catch {
|
|
1036
|
+
return undefined;
|
|
1037
|
+
}
|
|
862
1038
|
}
|
|
863
1039
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportManagementDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
864
1040
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportManagementDataService }); }
|
|
@@ -868,34 +1044,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
868
1044
|
}] });
|
|
869
1045
|
//#endregion
|
|
870
1046
|
//#region ---- API Providers ----
|
|
1047
|
+
/**
|
|
1048
|
+
* Category provider that uses the shared data service.
|
|
1049
|
+
* Both providers use the same dataService instance which ensures proper caching.
|
|
1050
|
+
*/
|
|
871
1051
|
class AXCReportCategoryApiProvider {
|
|
872
1052
|
constructor() {
|
|
873
1053
|
this.dataService = inject(AXCReportManagementDataService);
|
|
874
|
-
// Cache to store processed categories
|
|
875
|
-
this.categoriesCache = new Map();
|
|
876
1054
|
}
|
|
877
1055
|
async getList(parentId) {
|
|
878
|
-
// Check cache first
|
|
879
|
-
if (this.categoriesCache.has(parentId)) {
|
|
880
|
-
return this.categoriesCache.get(parentId);
|
|
881
|
-
}
|
|
882
1056
|
try {
|
|
883
|
-
//
|
|
884
|
-
const allCategoriesData = await this.dataService.getAllCategoriesData();
|
|
885
|
-
// Filter categories based on parentId
|
|
886
|
-
let filteredItems;
|
|
1057
|
+
// For root level, get root categories (each category includes folderItems in API response)
|
|
887
1058
|
if (!parentId) {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
// Child categories
|
|
893
|
-
filteredItems = allCategoriesData.filter((item) => item.reportCategoryParentId === parentId);
|
|
1059
|
+
const filteredItems = await this.dataService.getRootCategories();
|
|
1060
|
+
// Each root category has folderItems in the API response, but we only return the root categories themselves
|
|
1061
|
+
// The folderItems are preserved in the API response structure, similar to child state
|
|
1062
|
+
return filteredItems.map((item) => this.mapApiCategoryToReportCategory(item));
|
|
894
1063
|
}
|
|
895
|
-
|
|
896
|
-
//
|
|
897
|
-
|
|
898
|
-
|
|
1064
|
+
// For child level, get categories from category data (which includes folderItems)
|
|
1065
|
+
// This ensures we use the same API response that getList for definitions will use
|
|
1066
|
+
// The folderItems structure is preserved, similar to root state
|
|
1067
|
+
const categoryData = await this.dataService.getCategoryData(parentId);
|
|
1068
|
+
const filteredItems = categoryData?.folderItems ?? [];
|
|
1069
|
+
return filteredItems.map((item) => this.mapApiCategoryToReportCategory(item));
|
|
899
1070
|
}
|
|
900
1071
|
catch (error) {
|
|
901
1072
|
console.error('Error fetching report categories:', error);
|
|
@@ -904,9 +1075,7 @@ class AXCReportCategoryApiProvider {
|
|
|
904
1075
|
}
|
|
905
1076
|
async getById(id) {
|
|
906
1077
|
try {
|
|
907
|
-
|
|
908
|
-
const allCategoriesData = await this.dataService.getAllCategoriesData();
|
|
909
|
-
const apiItem = allCategoriesData.find((item) => item.id === id);
|
|
1078
|
+
const apiItem = await this.dataService.getCategoryById(id);
|
|
910
1079
|
if (!apiItem) {
|
|
911
1080
|
return undefined;
|
|
912
1081
|
}
|
|
@@ -927,48 +1096,32 @@ class AXCReportCategoryApiProvider {
|
|
|
927
1096
|
hasReport: apiItem.itemCount > 0, // reportDefinitionItems = files
|
|
928
1097
|
};
|
|
929
1098
|
}
|
|
930
|
-
// Method to clear cache when needed
|
|
931
|
-
clearCache() {
|
|
932
|
-
this.categoriesCache.clear();
|
|
933
|
-
this.dataService.clearCache();
|
|
934
|
-
}
|
|
935
1099
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportCategoryApiProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
936
1100
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportCategoryApiProvider }); }
|
|
937
1101
|
}
|
|
938
1102
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportCategoryApiProvider, decorators: [{
|
|
939
1103
|
type: Injectable
|
|
940
1104
|
}] });
|
|
1105
|
+
/**
|
|
1106
|
+
* Definition provider that uses the shared data service.
|
|
1107
|
+
* Both providers use the same dataService instance which ensures proper caching.
|
|
1108
|
+
*/
|
|
941
1109
|
class AXCReportDefinitionApiProvider {
|
|
942
1110
|
constructor() {
|
|
943
1111
|
this.dataService = inject(AXCReportManagementDataService);
|
|
944
1112
|
this.http = inject(HttpClient);
|
|
945
|
-
// Cache to store report definitions by category to avoid unnecessary API calls
|
|
946
|
-
this.reportDefinitionsCache = new Map();
|
|
947
1113
|
}
|
|
948
1114
|
async getList(categoryId) {
|
|
949
|
-
// Check cache first
|
|
950
|
-
if (this.reportDefinitionsCache.has(categoryId)) {
|
|
951
|
-
return this.reportDefinitionsCache.get(categoryId);
|
|
952
|
-
}
|
|
953
1115
|
try {
|
|
954
|
-
//
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
// Cache empty result to avoid repeated API calls
|
|
960
|
-
this.reportDefinitionsCache.set(categoryId, []);
|
|
961
|
-
return [];
|
|
962
|
-
}
|
|
963
|
-
const reportDefinitions = categoryItem.reportDefinitionItems.map((item) => this.mapApiReportDefinitionItemToReportDefinition(item));
|
|
964
|
-
// Cache the result
|
|
965
|
-
this.reportDefinitionsCache.set(categoryId, reportDefinitions);
|
|
1116
|
+
// Use getCategoryData which is cached and shared with getCategories
|
|
1117
|
+
// This ensures only one API call is made when both getCategories and getReportsByCategoryId are called
|
|
1118
|
+
const categoryData = await this.dataService.getCategoryData(categoryId);
|
|
1119
|
+
const defs = categoryData?.reportDefinitionItems ?? [];
|
|
1120
|
+
const reportDefinitions = defs.map((item) => this.mapApiReportDefinitionItemToReportDefinition(item));
|
|
966
1121
|
return reportDefinitions;
|
|
967
1122
|
}
|
|
968
1123
|
catch (error) {
|
|
969
1124
|
console.error('Error fetching report definitions:', error);
|
|
970
|
-
// Cache empty result to avoid repeated failed API calls
|
|
971
|
-
this.reportDefinitionsCache.set(categoryId, []);
|
|
972
1125
|
return [];
|
|
973
1126
|
}
|
|
974
1127
|
}
|
|
@@ -1027,11 +1180,6 @@ class AXCReportDefinitionApiProvider {
|
|
|
1027
1180
|
};
|
|
1028
1181
|
return res;
|
|
1029
1182
|
}
|
|
1030
|
-
// Method to clear cache when needed
|
|
1031
|
-
clearCache() {
|
|
1032
|
-
this.reportDefinitionsCache.clear();
|
|
1033
|
-
this.dataService.clearCache();
|
|
1034
|
-
}
|
|
1035
1183
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportDefinitionApiProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1036
1184
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXCReportDefinitionApiProvider }); }
|
|
1037
1185
|
}
|
|
@@ -1039,7 +1187,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
1039
1187
|
type: Injectable
|
|
1040
1188
|
}] });
|
|
1041
1189
|
//#endregion
|
|
1190
|
+
//#endregion
|
|
1042
1191
|
//#region ---- Provider Exports ----
|
|
1192
|
+
/**
|
|
1193
|
+
* Both providers use the same dataService instance (which is a singleton),
|
|
1194
|
+
* ensuring they share the same cache and only one API call is made when both
|
|
1195
|
+
* getCategories and getReportsByCategoryId are called for the same categoryId.
|
|
1196
|
+
*/
|
|
1043
1197
|
const AXC_REPORT_CATEGORY_API_PROVIDER = {
|
|
1044
1198
|
provide: AXP_REPORT_CATEGORY_PROVIDER,
|
|
1045
1199
|
useClass: AXCReportCategoryApiProvider,
|
|
@@ -1121,7 +1275,11 @@ class AXCApiModule {
|
|
|
1121
1275
|
selectValueStrategy: 'valueField',
|
|
1122
1276
|
lookupValueStrategy: 'valueField',
|
|
1123
1277
|
},
|
|
1124
|
-
}
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
provide: AXP_USER_AVATAR_PROVIDER,
|
|
1281
|
+
useClass: AXCApiUserAvatarProvider,
|
|
1282
|
+
},
|
|
1125
1283
|
], imports: [OAuthModule.forRoot(),
|
|
1126
1284
|
AXPAuthModule.forRoot({
|
|
1127
1285
|
strategies: [AXCAPIOidcStrategy],
|
|
@@ -1171,7 +1329,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
1171
1329
|
selectValueStrategy: 'valueField',
|
|
1172
1330
|
lookupValueStrategy: 'valueField',
|
|
1173
1331
|
},
|
|
1174
|
-
}
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
provide: AXP_USER_AVATAR_PROVIDER,
|
|
1335
|
+
useClass: AXCApiUserAvatarProvider,
|
|
1336
|
+
},
|
|
1175
1337
|
],
|
|
1176
1338
|
}]
|
|
1177
1339
|
}] });
|
|
@@ -1451,5 +1613,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
1451
1613
|
* Generated bundle index. Do not edit.
|
|
1452
1614
|
*/
|
|
1453
1615
|
|
|
1454
|
-
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportManagementApiModule, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
1616
|
+
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
1455
1617
|
//# sourceMappingURL=acorex-connectivity-api.mjs.map
|