@acorex/modules 18.0.9 → 18.0.11

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 (81) hide show
  1. package/application-management/README.md +4 -0
  2. package/application-management/index.d.ts +1 -0
  3. package/application-management/lib/application-management.module.d.ts +6 -0
  4. package/auth/lib/account/profile/profile-slot.component.d.ts +5 -0
  5. package/auth/lib/auth.config.d.ts +2 -2
  6. package/backend/lib/auth/oidc/index.d.ts +0 -2
  7. package/backend/lib/auth/oidc/oidc.strategy.d.ts +41 -9
  8. package/backend/lib/auth/oidc/signincallback.component.d.ts +1 -3
  9. package/backend/lib/backend.module.d.ts +4 -3
  10. package/backend/lib/data/api/file.service.d.ts +16 -0
  11. package/backend/lib/data/index.d.ts +1 -0
  12. package/esm2022/application-management/acorex-modules-application-management.mjs +5 -0
  13. package/esm2022/application-management/index.mjs +2 -0
  14. package/esm2022/application-management/lib/application-management.module.mjs +16 -0
  15. package/esm2022/auth/lib/account/account.module.mjs +24 -19
  16. package/esm2022/auth/lib/account/app-chooser/app-chooser-list.component.mjs +3 -3
  17. package/esm2022/auth/lib/account/app-chooser/app-chooser-slot.component.mjs +4 -4
  18. package/esm2022/auth/lib/account/app-chooser/app-chooser.component.mjs +3 -3
  19. package/esm2022/auth/lib/account/profile/profile-slot.component.mjs +26 -8
  20. package/esm2022/auth/lib/account/tenant-chooser/tenant-chooser-dropdown.component.mjs +3 -3
  21. package/esm2022/auth/lib/account/tenant-chooser/tenant-chooser.component.mjs +5 -5
  22. package/esm2022/auth/lib/auth.config.mjs +1 -1
  23. package/esm2022/auth/lib/auth.module.mjs +4 -4
  24. package/esm2022/auth/lib/error-handler.mjs +3 -3
  25. package/esm2022/auth/lib/forgot/password/password.component.mjs +4 -4
  26. package/esm2022/auth/lib/login/login.module.mjs +4 -4
  27. package/esm2022/auth/lib/login/password/password.component.mjs +8 -7
  28. package/esm2022/auth/lib/shared/layouts/blank/blank.layout.mjs +3 -3
  29. package/esm2022/auth/lib/shared/layouts/master/master.layout.mjs +3 -3
  30. package/esm2022/auth/lib/shared/services/idle.service.mjs +3 -3
  31. package/esm2022/auth/lib/store/auth.effects.mjs +3 -3
  32. package/esm2022/auth/lib/two-factor/two-factor-code/two-factor-code.component.mjs +4 -4
  33. package/esm2022/auth/lib/two-factor/two-factor.module.mjs +4 -4
  34. package/esm2022/backend/lib/auth/oidc/application.loader.mjs +3 -3
  35. package/esm2022/backend/lib/auth/oidc/configuration.service.mjs +3 -3
  36. package/esm2022/backend/lib/auth/oidc/index.mjs +1 -3
  37. package/esm2022/backend/lib/auth/oidc/oidc.strategy.mjs +195 -56
  38. package/esm2022/backend/lib/auth/oidc/permission.loader.mjs +3 -3
  39. package/esm2022/backend/lib/auth/oidc/signincallback.component.mjs +8 -11
  40. package/esm2022/backend/lib/auth/oidc/tenant.loader.mjs +3 -3
  41. package/esm2022/backend/lib/backend.module.mjs +23 -9
  42. package/esm2022/backend/lib/data/api/data-provider.mjs +3 -3
  43. package/esm2022/backend/lib/data/api/file.service.mjs +101 -0
  44. package/esm2022/backend/lib/data/index.mjs +2 -1
  45. package/esm2022/backend/lib/data/local/local-data-provider.mjs +3 -3
  46. package/esm2022/log-management/lib/log-management.module.mjs +4 -4
  47. package/esm2022/notification/lib/notification.module.mjs +4 -4
  48. package/fesm2022/acorex-modules-application-management.mjs +23 -0
  49. package/fesm2022/acorex-modules-application-management.mjs.map +1 -0
  50. package/fesm2022/{acorex-modules-auth-acorex-modules-auth-BjhfeQT8.mjs → acorex-modules-auth-acorex-modules-auth-B8LgaiHl.mjs} +78 -56
  51. package/fesm2022/acorex-modules-auth-acorex-modules-auth-B8LgaiHl.mjs.map +1 -0
  52. package/fesm2022/{acorex-modules-auth-app-chooser.component-B-wfsJob.mjs → acorex-modules-auth-app-chooser.component-DYP5fP8W.mjs} +6 -6
  53. package/fesm2022/{acorex-modules-auth-app-chooser.component-B-wfsJob.mjs.map → acorex-modules-auth-app-chooser.component-DYP5fP8W.mjs.map} +1 -1
  54. package/fesm2022/{acorex-modules-auth-blank.layout-BOdRxDNv.mjs → acorex-modules-auth-blank.layout-Bq822Iz4.mjs} +4 -4
  55. package/fesm2022/{acorex-modules-auth-blank.layout-BOdRxDNv.mjs.map → acorex-modules-auth-blank.layout-Bq822Iz4.mjs.map} +1 -1
  56. package/fesm2022/{acorex-modules-auth-login.module-CcNDUqEl.mjs → acorex-modules-auth-login.module-B3xEQTTg.mjs} +8 -8
  57. package/fesm2022/{acorex-modules-auth-login.module-CcNDUqEl.mjs.map → acorex-modules-auth-login.module-B3xEQTTg.mjs.map} +1 -1
  58. package/fesm2022/{acorex-modules-auth-master.layout-BGy5Vo5H.mjs → acorex-modules-auth-master.layout-DczZtXmF.mjs} +5 -5
  59. package/fesm2022/{acorex-modules-auth-master.layout-BGy5Vo5H.mjs.map → acorex-modules-auth-master.layout-DczZtXmF.mjs.map} +1 -1
  60. package/fesm2022/{acorex-modules-auth-password.component-BZfvv8yV.mjs → acorex-modules-auth-password.component-BaeFOot_.mjs} +6 -6
  61. package/fesm2022/{acorex-modules-auth-password.component-BZfvv8yV.mjs.map → acorex-modules-auth-password.component-BaeFOot_.mjs.map} +1 -1
  62. package/fesm2022/{acorex-modules-auth-password.component-IzjzV-ia.mjs → acorex-modules-auth-password.component-CJMstlMr.mjs} +10 -9
  63. package/fesm2022/acorex-modules-auth-password.component-CJMstlMr.mjs.map +1 -0
  64. package/fesm2022/{acorex-modules-auth-routes-JW0JYsnX.mjs → acorex-modules-auth-routes-DScu3qYW.mjs} +2 -2
  65. package/fesm2022/{acorex-modules-auth-routes-JW0JYsnX.mjs.map → acorex-modules-auth-routes-DScu3qYW.mjs.map} +1 -1
  66. package/fesm2022/{acorex-modules-auth-tenant-chooser.component-Bkyqj03k.mjs → acorex-modules-auth-tenant-chooser.component-CHr5_kh7.mjs} +6 -6
  67. package/fesm2022/{acorex-modules-auth-tenant-chooser.component-Bkyqj03k.mjs.map → acorex-modules-auth-tenant-chooser.component-CHr5_kh7.mjs.map} +1 -1
  68. package/fesm2022/{acorex-modules-auth-two-factor-code.component-ChMhFBJL.mjs → acorex-modules-auth-two-factor-code.component-B_7l39pX.mjs} +5 -5
  69. package/fesm2022/{acorex-modules-auth-two-factor-code.component-ChMhFBJL.mjs.map → acorex-modules-auth-two-factor-code.component-B_7l39pX.mjs.map} +1 -1
  70. package/fesm2022/{acorex-modules-auth-two-factor.module-Biz85Ffl.mjs → acorex-modules-auth-two-factor.module-BzdjoEGS.mjs} +7 -7
  71. package/fesm2022/{acorex-modules-auth-two-factor.module-Biz85Ffl.mjs.map → acorex-modules-auth-two-factor.module-BzdjoEGS.mjs.map} +1 -1
  72. package/fesm2022/acorex-modules-auth.mjs +1 -1
  73. package/fesm2022/acorex-modules-backend.mjs +579 -370
  74. package/fesm2022/acorex-modules-backend.mjs.map +1 -1
  75. package/fesm2022/acorex-modules-log-management.mjs +4 -4
  76. package/fesm2022/acorex-modules-notification.mjs +4 -4
  77. package/package.json +13 -7
  78. package/backend/lib/auth/oidc/usermanager.service.d.ts +0 -15
  79. package/esm2022/backend/lib/auth/oidc/usermanager.service.mjs +0 -37
  80. package/fesm2022/acorex-modules-auth-acorex-modules-auth-BjhfeQT8.mjs.map +0 -1
  81. package/fesm2022/acorex-modules-auth-password.component-IzjzV-ia.mjs.map +0 -1
@@ -1,157 +1,22 @@
1
- import * as i1$1 from '@acorex/modules/auth';
1
+ import * as i2 from '@acorex/modules/auth';
2
2
  import { AXM_AUTH_CONFIG_TOKEN, AXMAuthModule } from '@acorex/modules/auth';
3
- import * as i2$1 from '@acorex/platform/auth';
3
+ import * as i3 from '@acorex/platform/auth';
4
4
  import { AXPSessionService, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER, AXPAuthModule } from '@acorex/platform/auth';
5
5
  import { AXP_ROOT_CONFIG_TOKEN, AXPDataProvider } from '@acorex/platform/common';
6
+ import { AXPFileManagementService } from '@acorex/platform/widgets';
6
7
  import * as i0 from '@angular/core';
7
- import { inject, Injectable, Inject, Injector, Component, NgModule } from '@angular/core';
8
- import * as i2 from '@angular/router';
8
+ import { inject, Injectable, Component, NgModule } from '@angular/core';
9
+ import * as i1$1 from '@angular/router';
9
10
  import { ROUTES } from '@angular/router';
10
11
  import * as i1 from '@angular/common/http';
11
- import { HttpParams } from '@angular/common/http';
12
- import { firstValueFrom, map, BehaviorSubject, tap, filter, take, of, switchMap, delay } from 'rxjs';
13
- import { UserManager, WebStorageStateStore } from 'oidc-client-ts';
12
+ import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
13
+ import { map, BehaviorSubject, tap, filter, take, of, switchMap, delay, firstValueFrom, Observable } from 'rxjs';
14
+ import * as i1$3 from 'angular-oauth2-oidc';
15
+ import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
16
+ import { AXNetworkService, AXUploadStatus, AXDownloadStatus } from '@acorex/core/network';
14
17
  import { get, isNil, isEmpty, endsWith, startsWith, includes, lte, gte, lt, gt, isEqual, orderBy } from 'lodash-es';
15
18
  import * as i1$2 from '@acorex/platform/mocks';
16
19
 
17
- class AXMBackendDataProvider {
18
- constructor(http) {
19
- this.http = http;
20
- this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
21
- this.mainUrl = this.configs.baseUrl;
22
- }
23
- insertOne(entity, entityItem) {
24
- const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}`;
25
- return firstValueFrom(this.http.post(url, entityItem));
26
- }
27
- insertMany(entity, entityList) {
28
- const promises = entityList.map((entity) => {
29
- const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}`;
30
- return firstValueFrom(this.http.post(url, entity));
31
- });
32
- return Promise.all(promises);
33
- }
34
- getOne(entity, id) {
35
- const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}${id ? '/' + id : ''}`;
36
- return firstValueFrom(this.http.get(url));
37
- }
38
- getMany(entity, params) {
39
- let httpParams = new HttpParams().set('Skip', params?.skip?.toString() ?? '0').set('Take', params?.take?.toString() ?? '10');
40
- if (params?.sort && params?.sort.length > 0) {
41
- const sortParam = params?.sort.map((sort) => `${sort.field}:${sort.dir}`).join(',');
42
- httpParams = httpParams.set('$orderby', sortParam);
43
- }
44
- const buildFilterString = (filters) => {
45
- return filters
46
- .map((f) => {
47
- if (f.filters) {
48
- return buildFilterString(f.filters);
49
- }
50
- else {
51
- return `${f.field} ${f.operator.type} ${f.value}`;
52
- }
53
- })
54
- .join(',');
55
- };
56
- let filterString = params?.customFilter ? params.customFilter : '';
57
- if (params?.filter) {
58
- const filter = params.filter;
59
- if (filter.filters) {
60
- // Construct filter string from provided filters
61
- const dynamicFilters = buildFilterString(filter.filters);
62
- // Append dynamic filters to custom filter, if both exist
63
- filterString = filterString ? `${filterString},${dynamicFilters}` : dynamicFilters;
64
- }
65
- }
66
- // Set the $filter parameter if there are any filters
67
- if (filterString) {
68
- httpParams = httpParams.set('$filter', filterString);
69
- }
70
- function capitalizeFirstLetter(str) {
71
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
72
- }
73
- function generateQueryString(filter) {
74
- if (!filter.filters) {
75
- // Base case: single filter
76
- return `${capitalizeFirstLetter(filter.field)} ${filter.operator.type} ${filter.value}`;
77
- }
78
- else if (!filter.filters.length) {
79
- return;
80
- }
81
- else {
82
- // Recursive case: multiple filters
83
- const filterStrings = filter.filters.map((subFilter) => generateQueryString(subFilter));
84
- const logic = filter.logic || 'AND'; // Default logic is 'AND' if not provided
85
- return `${filterStrings.filter((i) => i).join(` ${logic} `)}`;
86
- }
87
- }
88
- let queryString = params?.customFilter ? params.customFilter : '';
89
- if (params?.filter) {
90
- const filter = params.filter;
91
- if (filter.filters && filter.filters.length > 0) {
92
- // Construct filter string from provided filters
93
- const dynamicQueries = generateQueryString(filter);
94
- console.log({ dynamicQueries: dynamicQueries });
95
- // Append dynamic filters to custom filter, if both exist
96
- queryString = queryString ? `${queryString},${dynamicQueries}` : dynamicQueries;
97
- }
98
- }
99
- // Set the $filter parameter if there are any filters
100
- if (queryString) {
101
- httpParams = httpParams.set('$query', queryString);
102
- }
103
- return firstValueFrom(this.http.get(`${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${params?.costumGetter ? params.costumGetter : entity.name}/${params?.sub ? params.sub : ''}`, { params: httpParams })).then((response) => {
104
- return {
105
- total: response.totalCount,
106
- items: response.items,
107
- };
108
- });
109
- }
110
- updateOne(entity, id, data) {
111
- const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}${id ? '/' + id : ''}`;
112
- return firstValueFrom(this.http.put(url, data));
113
- }
114
- deleteOne(entity, id) {
115
- const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}/${id}`;
116
- return firstValueFrom(this.http.delete(url));
117
- }
118
- getFirst(entity) {
119
- // return this.getMany(entity.name).then((res) => res.items[0]);
120
- return new Promise((resolve) => resolve(true));
121
- }
122
- // File uploader function
123
- uploadFile(file, title, customUrl) {
124
- const url = customUrl ? `${this.mainUrl}/${customUrl}` : `${this.mainUrl}/common/files`;
125
- const formData = new FormData();
126
- formData.append('File', file);
127
- formData.append('Title', title);
128
- return firstValueFrom(this.http.post(url, formData));
129
- }
130
- // Function to upload multiple files
131
- uploadMultipleFiles(files, title) {
132
- const uploadPromises = files.map((file) => this.uploadFile(file, title));
133
- return Promise.all(uploadPromises);
134
- }
135
- // Function to view a file
136
- viewFile(id, name) {
137
- const url = `${this.mainUrl}/common/files/${id}/View/${name}`;
138
- return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
139
- }
140
- // Function to download a file
141
- downloadFile(id, name) {
142
- const url = `${this.mainUrl}/common/files/${id}/Download/${name}`;
143
- return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
144
- }
145
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
146
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, providedIn: 'root' }); }
147
- }
148
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendDataProvider, decorators: [{
149
- type: Injectable,
150
- args: [{
151
- providedIn: 'root',
152
- }]
153
- }], ctorParameters: () => [{ type: i1.HttpClient }] });
154
-
155
20
  class AXMOidcApplicationLoader {
156
21
  constructor(http) {
157
22
  this.http = http;
@@ -193,10 +58,10 @@ class AXMOidcApplicationLoader {
193
58
  // features: item.features || [],
194
59
  };
195
60
  }
196
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
197
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader }); }
61
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
62
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcApplicationLoader }); }
198
63
  }
199
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
200
65
  type: Injectable
201
66
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
202
67
 
@@ -236,10 +101,10 @@ class AXMConfigurationService {
236
101
  switchMap(() => of(this.applicationConfig)));
237
102
  }
238
103
  }
239
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
240
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
104
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
105
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
241
106
  }
242
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMConfigurationService, decorators: [{
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMConfigurationService, decorators: [{
243
108
  type: Injectable,
244
109
  args: [{
245
110
  providedIn: 'root',
@@ -266,146 +131,413 @@ class AXMOidcFeatureLoader {
266
131
  }
267
132
  }
268
133
 
269
- // Other imports...
270
- class AXMOidcUserManagerService {
271
- constructor(authConfig) {
272
- this.authConfig = authConfig;
273
- this.selectedTenant = null;
274
- this.selectedApplication = null;
275
- if (!authConfig.oidc_settings) {
276
- throw new Error('OIDC configuration is missing');
277
- }
278
- this.userManager = new UserManager({
279
- ...authConfig.oidc_settings,
280
- userStore: new WebStorageStateStore({ store: window.localStorage }),
281
- });
282
- }
283
- getUserManager() {
284
- return this.userManager;
285
- }
286
- async signinSilentCallback() {
287
- await this.userManager.signinSilentCallback();
288
- }
289
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, deps: [{ token: AXM_AUTH_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
290
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, providedIn: 'root' }); }
291
- }
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcUserManagerService, decorators: [{
293
- type: Injectable,
294
- args: [{
295
- providedIn: 'root',
296
- }]
297
- }], ctorParameters: () => [{ type: undefined, decorators: [{
298
- type: Inject,
299
- args: [AXM_AUTH_CONFIG_TOKEN]
300
- }] }] });
301
-
302
134
  class AXMOidcStrategy {
303
135
  constructor() {
304
- this.injector = inject(Injector);
305
- this.userManagerService = this.injector.get(AXMOidcUserManagerService);
306
- this.userManager = this.userManagerService.getUserManager();
307
- // Log.setLogger(console);
308
- // Log.setLevel(Log.DEBUG);
309
- }
310
- get name() {
311
- return 'user-pass';
136
+ this.aXMAuthConfigs = inject(AXM_AUTH_CONFIG_TOKEN);
137
+ this.oauthService = inject(OAuthService);
138
+ this.http = inject(HttpClient);
139
+ }
140
+ async configureOAuth() {
141
+ if (this.openidConfigurationInfo)
142
+ return;
143
+ if (!this.authConfig) {
144
+ if (!this.aXMAuthConfigs.authConfig) {
145
+ throw new Error('authConfig is missing');
146
+ }
147
+ this.authConfig = this.aXMAuthConfigs.authConfig;
148
+ }
149
+ this.oauthService.configure(this.authConfig);
150
+ this.oauthService.setStorage(localStorage);
151
+ this.openidConfigurationInfo = await this.oauthService.loadDiscoveryDocument();
152
+ if (!this.openidConfigurationInfo) {
153
+ throw new Error('openidConfigurationInfo is missing');
154
+ }
155
+ this.oauthService.events.subscribe(async (event) => {
156
+ // console.log('event', event);
157
+ // if (event.type === 'token_received') {
158
+ // console.log('Token has been refreshed');
159
+ // }
160
+ // if (event.type === 'token_expires') {
161
+ // console.log('Token is about to expire. Triggering silent refresh...');
162
+ // }
163
+ });
164
+ const oidcJson = localStorage.getItem(AXPSessionService.SESSION_KEY);
165
+ if (oidcJson) {
166
+ const authData = JSON.parse(oidcJson);
167
+ if (authData) {
168
+ this.setServiceProps(authData);
169
+ if (authData.expiresIn && new Date(authData.expiresIn) < new Date()) {
170
+ if (authData.expiresIn) {
171
+ // this.refresh();
172
+ }
173
+ else {
174
+ this.logout();
175
+ }
176
+ }
177
+ }
178
+ }
312
179
  }
313
180
  async signin(credentials) {
181
+ await this.configureOAuth();
314
182
  try {
315
- await this.userManager.removeUser();
316
- await this.userManager.clearStaleState();
317
- const oidcUser = await this.userManager.signinSilent({
318
- extraQueryParams: {
319
- username: credentials.username,
320
- password: credentials.password,
321
- },
183
+ const body = new HttpParams()
184
+ .set('grant_type', 'password')
185
+ .set('client_id', this.authConfig.clientId)
186
+ .set('client_secret', this.authConfig.dummyClientSecret)
187
+ .set('username', credentials.username)
188
+ .set('password', credentials.password)
189
+ .set('scope', this.authConfig.scope);
190
+ const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
191
+ const response = await firstValueFrom(this.http.post(this.openidConfigurationInfo.info.discoveryDocument.token_endpoint, body.toString(), { headers }));
192
+ // const authData = new AuthenticationData(response);
193
+ this.setServiceProps({
194
+ accessToken: response.access_token,
195
+ refreshToken: response.refresh_token,
196
+ idToken: response.id_token,
197
+ expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
322
198
  });
323
- if (oidcUser) {
324
- const profile = oidcUser.profile; // Cast to any to access deeply nested properties
325
- const user = {
326
- id: profile.sub,
327
- name: `${profile.email}`,
328
- title: `${profile.name}`,
329
- avatar: `${profile.picture}`,
330
- };
331
- const accessToken = oidcUser.access_token;
332
- const refreshToken = oidcUser.refresh_token ?? '';
199
+ return {
200
+ succeed: true,
201
+ data: {
202
+ accessToken: response.access_token,
203
+ expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
204
+ idToken: response.id_token,
205
+ refreshToken: response.refresh_token,
206
+ user: {
207
+ id: response.sub,
208
+ title: response.fullname,
209
+ name: response.sub,
210
+ avatar: response.picture,
211
+ },
212
+ tenant: {
213
+ id: response.tenantid,
214
+ name: response.tenantname,
215
+ title: response.tenanttitle,
216
+ },
217
+ application: {
218
+ id: response.applicationid,
219
+ name: response.applicationname,
220
+ title: response.applicationtitle,
221
+ },
222
+ },
223
+ };
224
+ }
225
+ catch (error) {
226
+ this.handleError(error);
227
+ }
228
+ }
229
+ async signout() {
230
+ this.logout();
231
+ }
232
+ async refreshToken(context) {
233
+ console.log('context.tenant', context.tenant);
234
+ try {
235
+ await this.configureOAuth();
236
+ const refreshResult = await this.refresh(context.tenant?.id, context.application?.id);
237
+ if (refreshResult) {
333
238
  return {
334
239
  succeed: true,
335
- data: { user, accessToken, refreshToken },
240
+ data: {
241
+ accessToken: this.oauthService.getAccessToken(),
242
+ refreshToken: this.oauthService.getRefreshToken(),
243
+ },
336
244
  };
337
245
  }
338
- return {
339
- succeed: false,
340
- };
246
+ else {
247
+ return { succeed: false };
248
+ }
341
249
  }
342
250
  catch (error) {
343
- if (error?.message)
344
- throw new Error(error.message);
345
- // Depending on the error type, you might want to throw a specific error
251
+ console.error('Error refreshing token', error);
252
+ return { succeed: false };
253
+ }
254
+ }
255
+ async refresh(tenantId, applicationId) {
256
+ await this.configureOAuth();
257
+ const authData = this.loadAuthData();
258
+ if (!authData)
259
+ return false;
260
+ const refreshToken = this.oauthService.getRefreshToken();
261
+ if (!refreshToken)
262
+ return false;
263
+ const body = new HttpParams()
264
+ .set('grant_type', 'refresh_token')
265
+ .set('client_id', this.authConfig.clientId)
266
+ .set('client_secret', this.authConfig.dummyClientSecret)
267
+ .set('refresh_token', refreshToken)
268
+ .set('tenantId', tenantId ?? '')
269
+ .set('applicationId', applicationId ?? '');
270
+ const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
271
+ try {
272
+ const response = await firstValueFrom(this.http.post(this.openidConfigurationInfo.info.discoveryDocument.token_endpoint, body.toString(), { headers }));
273
+ this.setServiceProps({
274
+ accessToken: response.access_token,
275
+ refreshToken: response.refresh_token,
276
+ idToken: response.id_token,
277
+ expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
278
+ });
279
+ return true;
280
+ }
281
+ catch (error) {
282
+ console.error('Token refresh error', error);
283
+ return false;
284
+ }
285
+ }
286
+ expires_in_milisecound(expires_in_date) {
287
+ const now = new Date();
288
+ const expire = new Date(expires_in_date);
289
+ return expire.getTime() - now.getTime();
290
+ }
291
+ setServiceProps(authData) {
292
+ this.oauthService.getAccessToken = () => authData.accessToken;
293
+ this.oauthService.getIdToken = () => authData.idToken ?? '';
294
+ this.oauthService.getRefreshToken = () => authData.refreshToken;
295
+ if (authData.expiresIn) {
296
+ const refreshTime = this.expires_in_milisecound(authData.expiresIn);
297
+ this.oauthService.getAccessTokenExpiration = () => refreshTime;
298
+ // if (refreshTime < 0) {
299
+ // this.refresh();
300
+ // }else{
301
+ // }
302
+ }
303
+ }
304
+ loadAuthData() {
305
+ const authDataJson = localStorage.getItem(AXPSessionService.SESSION_KEY);
306
+ if (!authDataJson)
307
+ return undefined;
308
+ const authData = JSON.parse(authDataJson);
309
+ // return authData ? new AuthenticationData(authData) : undefined;
310
+ return authData;
311
+ }
312
+ async loadUserInfo() {
313
+ return this.oauthService.loadUserProfile();
314
+ }
315
+ calculateExpireInDate(expireInMilisecound) {
316
+ return new Date(Date.now() + expireInMilisecound * 1000).toISOString();
317
+ }
318
+ logout() {
319
+ this.oauthService.logOut({
320
+ noRedirectToLogoutUrl: true
321
+ });
322
+ }
323
+ handleError(error) {
324
+ if (error?.reason) {
325
+ throw new Error(JSON.stringify(error.reason));
326
+ }
327
+ else if (error?.message) {
328
+ throw new Error(error.message);
329
+ }
330
+ else {
346
331
  throw new Error('Network or server error occurred');
347
332
  }
348
333
  }
349
- async signout() {
350
- console.log('User signed out');
351
- this.userManager.removeUser();
352
- this.userManager.clearStaleState();
353
- //this.userManager.signoutSilent();
334
+ //#region getter
335
+ get name() {
336
+ return 'user-pass';
354
337
  }
355
- async refreshToken(context) {
356
- const currentUser = await this.userManager.getUser();
357
- if (currentUser) {
358
- const accessToken = currentUser?.access_token;
359
- const newRefreshToken = currentUser?.refresh_token;
360
- return {
361
- succeed: true,
362
- data: { accessToken, refreshToken: newRefreshToken },
363
- };
338
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
339
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcStrategy }); }
340
+ }
341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcStrategy, decorators: [{
342
+ type: Injectable
343
+ }] });
344
+
345
+ class AXMOidcPermissionLoader {
346
+ constructor(http) {
347
+ this.http = http;
348
+ this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
349
+ this.apiGetConfig = `${this.configs.baseUrl}/abp/application-configuration`;
350
+ }
351
+ getList(context) {
352
+ return this.http.get(this.apiGetConfig).pipe(map((response) => this.mapTo(response)));
353
+ // if (context.user == null)
354
+ // return of([]);
355
+ // else if (context.user.name.toLowerCase() == 'admin')
356
+ // return of(['axp.admin.console', 'asc.admin.message', 'asc.admin.settings', 'asc.admin.gliding', 'asc.user.gliding']);
357
+ // else
358
+ // return of(['asc.user.gliding']);
359
+ // return of(['axp.admin.console', 'asc.admin.message', 'asc.admin.settings', 'asc.admin.gliding', 'asc.user.gliding']);
360
+ }
361
+ mapTo(jsonObj) {
362
+ const policies = jsonObj.auth.grantedPolicies;
363
+ const truePolicies = Object.keys(policies).filter((key) => policies[key] === true);
364
+ return truePolicies;
365
+ }
366
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
367
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcPermissionLoader }); }
368
+ }
369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
370
+ type: Injectable
371
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
372
+
373
+ class AXMOidcTenantLoader {
374
+ constructor(http) {
375
+ this.http = http;
376
+ this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
377
+ this.apiGetTenants = `${this.configs.baseUrl}/user-tenants/Tenants`;
378
+ this.apiSetTenant = `${this.configs.baseUrl}/SetTenant`;
379
+ }
380
+ getList() {
381
+ return this.http.get(this.apiGetTenants).pipe(map((response) => response.items.map((item) => this.mapToAXPTenant(item))));
382
+ }
383
+ async set(tenant) {
384
+ return Promise.resolve();
385
+ }
386
+ mapToAXPTenant(item) {
387
+ return {
388
+ id: item.id,
389
+ name: item.name || 'defaultName',
390
+ title: item.title || 'defaultTitle',
391
+ // Add other fields and defaults as needed, and handle the logo if applicable
392
+ };
393
+ }
394
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
395
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcTenantLoader }); }
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
398
+ type: Injectable
399
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
400
+
401
+ class AXMBackendDataProvider {
402
+ constructor(http) {
403
+ this.http = http;
404
+ this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
405
+ this.mainUrl = this.configs.baseUrl;
406
+ }
407
+ insertOne(entity, entityItem) {
408
+ const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}`;
409
+ return firstValueFrom(this.http.post(url, entityItem));
410
+ }
411
+ insertMany(entity, entityList) {
412
+ const promises = entityList.map((entity) => {
413
+ const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}`;
414
+ return firstValueFrom(this.http.post(url, entity));
415
+ });
416
+ return Promise.all(promises);
417
+ }
418
+ getOne(entity, id) {
419
+ const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}${id ? '/' + id : ''}`;
420
+ return firstValueFrom(this.http.get(url));
421
+ }
422
+ getMany(entity, params) {
423
+ let httpParams = new HttpParams().set('Skip', params?.skip?.toString() ?? '0').set('Take', params?.take?.toString() ?? '10');
424
+ if (params?.sort && params?.sort.length > 0) {
425
+ const sortParam = params?.sort.map((sort) => `${sort.field}:${sort.dir}`).join(',');
426
+ httpParams = httpParams.set('$orderby', sortParam);
427
+ }
428
+ const buildFilterString = (filters) => {
429
+ return filters
430
+ .map((f) => {
431
+ if (f.filters) {
432
+ return buildFilterString(f.filters);
433
+ }
434
+ else {
435
+ return `${f.field} ${f.operator.type} ${f.value}`;
436
+ }
437
+ })
438
+ .join(',');
439
+ };
440
+ let filterString = params?.customFilter ? params.customFilter : '';
441
+ if (params?.filter) {
442
+ const filter = params.filter;
443
+ if (filter.filters) {
444
+ // Construct filter string from provided filters
445
+ const dynamicFilters = buildFilterString(filter.filters);
446
+ // Append dynamic filters to custom filter, if both exist
447
+ filterString = filterString ? `${filterString},${dynamicFilters}` : dynamicFilters;
448
+ }
449
+ }
450
+ // Set the $filter parameter if there are any filters
451
+ if (filterString) {
452
+ httpParams = httpParams.set('$filter', filterString);
453
+ }
454
+ function capitalizeFirstLetter(str) {
455
+ return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
456
+ }
457
+ function generateQueryString(filter) {
458
+ if (!filter.filters) {
459
+ // Base case: single filter
460
+ return `${capitalizeFirstLetter(filter.field)} ${filter.operator.type} ${filter.value}`;
461
+ }
462
+ else if (!filter.filters.length) {
463
+ return;
464
+ }
465
+ else {
466
+ // Recursive case: multiple filters
467
+ const filterStrings = filter.filters.map((subFilter) => generateQueryString(subFilter));
468
+ const logic = filter.logic || 'AND'; // Default logic is 'AND' if not provided
469
+ return `${filterStrings.filter((i) => i).join(` ${logic} `)}`;
470
+ }
471
+ }
472
+ let queryString = params?.customFilter ? params.customFilter : '';
473
+ if (params?.filter) {
474
+ const filter = params.filter;
475
+ if (filter.filters && filter.filters.length > 0) {
476
+ // Construct filter string from provided filters
477
+ const dynamicQueries = generateQueryString(filter);
478
+ console.log({ dynamicQueries: dynamicQueries });
479
+ // Append dynamic filters to custom filter, if both exist
480
+ queryString = queryString ? `${queryString},${dynamicQueries}` : dynamicQueries;
481
+ }
364
482
  }
365
- else {
483
+ // Set the $filter parameter if there are any filters
484
+ if (queryString) {
485
+ httpParams = httpParams.set('$query', queryString);
486
+ }
487
+ return firstValueFrom(this.http.get(`${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${params?.costumGetter ? params.costumGetter : entity.name}/${params?.sub ? params.sub : ''}`, { params: httpParams })).then((response) => {
366
488
  return {
367
- succeed: false,
489
+ total: response.totalCount,
490
+ items: response.items,
368
491
  };
369
- }
492
+ });
370
493
  }
371
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
372
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy }); }
373
- }
374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcStrategy, decorators: [{
375
- type: Injectable
376
- }], ctorParameters: () => [] });
377
-
378
- class AXMOidcPermissionLoader {
379
- constructor(http) {
380
- this.http = http;
381
- this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
382
- this.apiGetConfig = `${this.configs.baseUrl}/abp/application-configuration`;
494
+ updateOne(entity, id, data) {
495
+ const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}${id ? '/' + id : ''}`;
496
+ return firstValueFrom(this.http.put(url, data));
383
497
  }
384
- getList(context) {
385
- return this.http.get(this.apiGetConfig).pipe(map((response) => this.mapTo(response)));
386
- // if (context.user == null)
387
- // return of([]);
388
- // else if (context.user.name.toLowerCase() == 'admin')
389
- // return of(['axp.admin.console', 'asc.admin.message', 'asc.admin.settings', 'asc.admin.gliding', 'asc.user.gliding']);
390
- // else
391
- // return of(['asc.user.gliding']);
392
- // return of(['axp.admin.console', 'asc.admin.message', 'asc.admin.settings', 'asc.admin.gliding', 'asc.user.gliding']);
498
+ deleteOne(entity, id) {
499
+ const url = `${this.mainUrl}${entity.area ? '/' + entity.area : ''}/${entity.module}/${entity.name}/${id}`;
500
+ return firstValueFrom(this.http.delete(url));
393
501
  }
394
- mapTo(jsonObj) {
395
- const policies = jsonObj.auth.grantedPolicies;
396
- const truePolicies = Object.keys(policies).filter((key) => policies[key] === true);
397
- return truePolicies;
502
+ getFirst(entity) {
503
+ // return this.getMany(entity.name).then((res) => res.items[0]);
504
+ return new Promise((resolve) => resolve(true));
505
+ }
506
+ // File uploader function
507
+ uploadFile(file, title, customUrl) {
508
+ const url = customUrl ? `${this.mainUrl}/${customUrl}` : `${this.mainUrl}/common/files`;
509
+ const formData = new FormData();
510
+ formData.append('File', file);
511
+ formData.append('Title', title);
512
+ return firstValueFrom(this.http.post(url, formData));
513
+ }
514
+ // Function to upload multiple files
515
+ uploadMultipleFiles(files, title) {
516
+ const uploadPromises = files.map((file) => this.uploadFile(file, title));
517
+ return Promise.all(uploadPromises);
518
+ }
519
+ // Function to view a file
520
+ viewFile(id, name) {
521
+ const url = `${this.mainUrl}/common/files/${id}/View/${name}`;
522
+ return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
523
+ }
524
+ // Function to download a file
525
+ downloadFile(id, name) {
526
+ const url = `${this.mainUrl}/common/files/${id}/Download/${name}`;
527
+ return firstValueFrom(this.http.get(url, { responseType: 'blob' }));
398
528
  }
399
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
400
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader }); }
529
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendDataProvider, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
530
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendDataProvider, providedIn: 'root' }); }
401
531
  }
402
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
403
- type: Injectable
532
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendDataProvider, decorators: [{
533
+ type: Injectable,
534
+ args: [{
535
+ providedIn: 'root',
536
+ }]
404
537
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
405
538
 
406
539
  class SignincallbackComponent {
407
- constructor(userManagerService, router, route) {
408
- this.userManagerService = userManagerService;
540
+ constructor(router, route) {
409
541
  this.router = router;
410
542
  this.route = route;
411
543
  this.sessionService = inject(AXPSessionService);
@@ -430,122 +562,110 @@ class SignincallbackComponent {
430
562
  };
431
563
  this.sessionService.setApplication(selectedApplication);
432
564
  }
433
- this.userManagerService.signinSilentCallback();
565
+ // this.userManagerService.signinSilentCallback();
434
566
  }
435
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: SignincallbackComponent, deps: [{ token: AXMOidcUserManagerService }, { token: i2.Router }, { token: i2.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); }
436
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.2", type: SignincallbackComponent, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
567
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SignincallbackComponent, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component }); }
568
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: SignincallbackComponent, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
437
569
  }
438
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: SignincallbackComponent, decorators: [{
570
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: SignincallbackComponent, decorators: [{
439
571
  type: Component,
440
572
  args: [{
441
573
  template: '',
442
574
  }]
443
- }], ctorParameters: () => [{ type: AXMOidcUserManagerService }, { type: i2.Router }, { type: i2.ActivatedRoute }] });
575
+ }], ctorParameters: () => [{ type: i1$1.Router }, { type: i1$1.ActivatedRoute }] });
444
576
 
445
- class AXMOidcTenantLoader {
446
- constructor(http) {
447
- this.http = http;
577
+ class AXMFileManagementService {
578
+ constructor() {
448
579
  this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
449
- this.apiGetTenants = `${this.configs.baseUrl}/user-tenants/Tenants`;
450
- this.apiSetTenant = `${this.configs.baseUrl}/SetTenant`;
580
+ this.mainUrl = this.configs.baseUrl;
581
+ this.http = inject(HttpClient);
582
+ this.networkService = inject(AXNetworkService);
583
+ }
584
+ upload(requests) {
585
+ const url = `${this.mainUrl}/common/files`;
586
+ const tasks = requests.map((r) => {
587
+ const formData = new FormData();
588
+ formData.append('File', r.file);
589
+ const task = this.networkService.upload(url, formData);
590
+ return new Promise((resolve, reject) => {
591
+ task.events.subscribe({
592
+ next: (event) => {
593
+ if (event.status == AXUploadStatus.UploadFailed) {
594
+ r.error(event.message || '');
595
+ reject(event.result);
596
+ }
597
+ if (event.status == AXUploadStatus.UploadComplete) {
598
+ r.finish();
599
+ resolve(event.result);
600
+ }
601
+ else {
602
+ r.setTransferredBytes(event.bytesTransferred);
603
+ }
604
+ },
605
+ });
606
+ r.onStart.subscribe(() => {
607
+ task.start();
608
+ });
609
+ r.onCancel.subscribe(() => {
610
+ task.cancel();
611
+ reject({ status: 'cancelled', request: r });
612
+ });
613
+ r.upload();
614
+ });
615
+ });
616
+ return Promise.allSettled(tasks);
451
617
  }
452
- getList() {
453
- return this.http.get(this.apiGetTenants).pipe(map((response) => response.items.map((item) => this.mapToAXPTenant(item))));
618
+ delete(fileId) {
619
+ return new Promise((resolve, reject) => {
620
+ setTimeout(() => resolve({ success: true, fileId }), 1000);
621
+ });
454
622
  }
455
- async set(tenant) {
456
- return Promise.resolve();
623
+ get(fileId, name) {
624
+ return new Observable((observer) => {
625
+ const url = `${this.mainUrl}/common/files/${fileId}/Download/${name}`;
626
+ const downloadTask = this.networkService.download(url);
627
+ downloadTask.events.subscribe((event) => {
628
+ // Emit progress events
629
+ observer.next({
630
+ status: event.status,
631
+ progress: event.progress,
632
+ fileId,
633
+ data: event.data || null, // Assuming `event.data` contains the downloaded file's data when completed
634
+ });
635
+ // Complete the observable if download is finished
636
+ if (event.status === AXDownloadStatus.DownloadComplete) {
637
+ observer.complete();
638
+ }
639
+ }, (error) => {
640
+ console.error('Download failed:', error);
641
+ observer.error({
642
+ status: 'failed',
643
+ fileId,
644
+ error,
645
+ });
646
+ });
647
+ return () => {
648
+ downloadTask.cancel();
649
+ };
650
+ });
457
651
  }
458
- mapToAXPTenant(item) {
459
- return {
460
- id: item.id,
461
- name: item.name || 'defaultName',
462
- title: item.title || 'defaultTitle',
463
- // Add other fields and defaults as needed, and handle the logo if applicable
464
- };
652
+ list() {
653
+ return new Promise((resolve, reject) => {
654
+ setTimeout(() => resolve([{ fileId: '1', data: 'fileData' }]), 1000);
655
+ });
465
656
  }
466
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
467
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader }); }
468
- }
469
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
470
- type: Injectable
471
- }], ctorParameters: () => [{ type: i1.HttpClient }] });
472
-
473
- function routesFactory() {
474
- const routes = [{ path: 'auth/signincallback', component: SignincallbackComponent }];
475
- return routes;
476
- }
477
- class AXMBackendModule {
478
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
479
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, imports: [i1$1.AXMAuthModule, i2$1.AXPAuthModule] }); }
480
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, providers: [
481
- {
482
- provide: AXPDataProvider,
483
- useClass: AXMBackendDataProvider,
484
- },
485
- {
486
- provide: AXP_TENANT_LOADER,
487
- useClass: AXMOidcTenantLoader,
488
- },
489
- {
490
- provide: AXP_APPLICATION_LOADER,
491
- useClass: AXMOidcApplicationLoader,
492
- },
493
- {
494
- provide: AXP_PERMISSION_LOADER,
495
- useClass: AXMOidcPermissionLoader,
496
- },
497
- {
498
- provide: AXP_FEATURE_LOADER,
499
- useClass: AXMOidcFeatureLoader,
500
- },
501
- {
502
- provide: ROUTES,
503
- multi: true,
504
- useFactory: routesFactory,
505
- },
506
- ], imports: [AXMAuthModule.forRoot(),
507
- AXPAuthModule.forRoot({
508
- strategies: [AXMOidcStrategy],
509
- })] }); }
657
+ setMetadata(fileId, metadata) {
658
+ return new Promise((resolve, reject) => {
659
+ setTimeout(() => resolve({ fileId, metadata }), 1000);
660
+ });
661
+ }
662
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMFileManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
663
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMFileManagementService, providedIn: 'root' }); }
510
664
  }
511
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMBackendModule, decorators: [{
512
- type: NgModule,
665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMFileManagementService, decorators: [{
666
+ type: Injectable,
513
667
  args: [{
514
- imports: [
515
- AXMAuthModule.forRoot(),
516
- AXPAuthModule.forRoot({
517
- strategies: [AXMOidcStrategy],
518
- }),
519
- ],
520
- exports: [],
521
- declarations: [],
522
- providers: [
523
- {
524
- provide: AXPDataProvider,
525
- useClass: AXMBackendDataProvider,
526
- },
527
- {
528
- provide: AXP_TENANT_LOADER,
529
- useClass: AXMOidcTenantLoader,
530
- },
531
- {
532
- provide: AXP_APPLICATION_LOADER,
533
- useClass: AXMOidcApplicationLoader,
534
- },
535
- {
536
- provide: AXP_PERMISSION_LOADER,
537
- useClass: AXMOidcPermissionLoader,
538
- },
539
- {
540
- provide: AXP_FEATURE_LOADER,
541
- useClass: AXMOidcFeatureLoader,
542
- },
543
- {
544
- provide: ROUTES,
545
- multi: true,
546
- useFactory: routesFactory,
547
- },
548
- ],
668
+ providedIn: 'root',
549
669
  }]
550
670
  }] });
551
671
 
@@ -755,19 +875,108 @@ class AXMLocalDataProvider {
755
875
  downloadFile(id, name) {
756
876
  return this.viewFile(id, name);
757
877
  }
758
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, deps: [{ token: i1$2.AXPStorageMockService }], target: i0.ɵɵFactoryTarget.Injectable }); }
759
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, providedIn: 'root' }); }
878
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMLocalDataProvider, deps: [{ token: i1$2.AXPStorageMockService }], target: i0.ɵɵFactoryTarget.Injectable }); }
879
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMLocalDataProvider, providedIn: 'root' }); }
760
880
  }
761
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXMLocalDataProvider, decorators: [{
881
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMLocalDataProvider, decorators: [{
762
882
  type: Injectable,
763
883
  args: [{
764
884
  providedIn: 'root',
765
885
  }]
766
886
  }], ctorParameters: () => [{ type: i1$2.AXPStorageMockService }] });
767
887
 
888
+ function routesFactory() {
889
+ const routes = [{ path: 'auth/signincallback', component: SignincallbackComponent }];
890
+ return routes;
891
+ }
892
+ class AXMBackendModule {
893
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
894
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendModule, imports: [i1$3.OAuthModule, i2.AXMAuthModule, i3.AXPAuthModule] }); }
895
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendModule, providers: [
896
+ {
897
+ provide: AXPDataProvider,
898
+ useClass: AXMBackendDataProvider,
899
+ },
900
+ {
901
+ provide: AXP_TENANT_LOADER,
902
+ useClass: AXMOidcTenantLoader,
903
+ },
904
+ {
905
+ provide: AXP_APPLICATION_LOADER,
906
+ useClass: AXMOidcApplicationLoader,
907
+ },
908
+ {
909
+ provide: AXP_PERMISSION_LOADER,
910
+ useClass: AXMOidcPermissionLoader,
911
+ },
912
+ {
913
+ provide: AXP_FEATURE_LOADER,
914
+ useClass: AXMOidcFeatureLoader,
915
+ },
916
+ {
917
+ provide: AXPFileManagementService,
918
+ useClass: AXMFileManagementService,
919
+ },
920
+ {
921
+ provide: ROUTES,
922
+ multi: true,
923
+ useFactory: routesFactory,
924
+ },
925
+ ], imports: [OAuthModule.forRoot(),
926
+ AXMAuthModule.forRoot(),
927
+ AXPAuthModule.forRoot({
928
+ strategies: [AXMOidcStrategy],
929
+ })] }); }
930
+ }
931
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMBackendModule, decorators: [{
932
+ type: NgModule,
933
+ args: [{
934
+ imports: [
935
+ OAuthModule.forRoot(),
936
+ AXMAuthModule.forRoot(),
937
+ AXPAuthModule.forRoot({
938
+ strategies: [AXMOidcStrategy],
939
+ }),
940
+ ],
941
+ exports: [],
942
+ declarations: [],
943
+ providers: [
944
+ {
945
+ provide: AXPDataProvider,
946
+ useClass: AXMBackendDataProvider,
947
+ },
948
+ {
949
+ provide: AXP_TENANT_LOADER,
950
+ useClass: AXMOidcTenantLoader,
951
+ },
952
+ {
953
+ provide: AXP_APPLICATION_LOADER,
954
+ useClass: AXMOidcApplicationLoader,
955
+ },
956
+ {
957
+ provide: AXP_PERMISSION_LOADER,
958
+ useClass: AXMOidcPermissionLoader,
959
+ },
960
+ {
961
+ provide: AXP_FEATURE_LOADER,
962
+ useClass: AXMOidcFeatureLoader,
963
+ },
964
+ {
965
+ provide: AXPFileManagementService,
966
+ useClass: AXMFileManagementService,
967
+ },
968
+ {
969
+ provide: ROUTES,
970
+ multi: true,
971
+ useFactory: routesFactory,
972
+ },
973
+ ],
974
+ }]
975
+ }] });
976
+
768
977
  /**
769
978
  * Generated bundle index. Do not edit.
770
979
  */
771
980
 
772
- export { AXMBackendDataProvider, AXMBackendModule, AXMConfigurationService, AXMLocalDataProvider, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcStrategy, AXMOidcTenantLoader, AXMOidcUserManagerService, SignincallbackComponent, applyFilterArray, applySortArray };
981
+ export { AXMBackendDataProvider, AXMBackendModule, AXMConfigurationService, AXMFileManagementService, AXMLocalDataProvider, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcStrategy, AXMOidcTenantLoader, applyFilterArray, applySortArray };
773
982
  //# sourceMappingURL=acorex-modules-backend.mjs.map