@eui/core 19.0.0-next.13 → 19.0.0-next.15
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/docs/classes/ActivatedRouteAction.html +10 -2
- package/docs/classes/AddApiQueueItemAction.html +10 -2
- package/docs/classes/AddAppLoadedConfigModulesAction.html +10 -2
- package/docs/classes/ApiQueueServiceMock.html +27 -3
- package/docs/classes/EmptyApiQueueAction.html +10 -2
- package/docs/classes/InitStoreAction.html +10 -2
- package/docs/classes/RemoveApiQueueItemAction.html +10 -2
- package/docs/classes/UpdateAppConnectionAction.html +10 -2
- package/docs/classes/UpdateAppStatusAction.html +10 -2
- package/docs/classes/UpdateAppVersionAction.html +10 -2
- package/docs/classes/UpdateCurrentModuleAction.html +10 -2
- package/docs/classes/UpdateI18nStateAction.html +10 -2
- package/docs/classes/UpdateLocaleStateAction.html +10 -2
- package/docs/classes/UpdateNotificationsListAction.html +10 -2
- package/docs/classes/UpdateUserDashboardAction.html +10 -2
- package/docs/classes/UpdateUserDetailsAction.html +10 -2
- package/docs/classes/UpdateUserPreferencesAction.html +10 -2
- package/docs/classes/UpdateUserRightsAction.html +10 -2
- package/docs/classes/UpdateUserStateAction.html +10 -2
- package/docs/dependencies.html +2 -2
- package/docs/index.html +2 -2
- package/docs/injectables/ApiQueueService.html +18 -2
- package/docs/injectables/EuiAppShellService.html +9 -1
- package/docs/injectables/GlobalErrorHandler.html +1 -1
- package/docs/injectables/I18nService.html +51 -71
- package/docs/injectables/I18nServiceMock.html +37 -1
- package/docs/injectables/LocaleService.html +88 -47
- package/docs/injectables/LocaleServiceMock.html +8 -41
- package/docs/injectables/StoreService.html +273 -65
- package/docs/injectables/StoreServiceMock.html +8 -30
- package/docs/injectables/UserService.html +97 -21
- package/docs/injectables/UserServiceMock.html +36 -0
- package/docs/interceptors/AddLangParamInterceptor.html +2 -2
- package/docs/interceptors/CachePreventionInterceptor.html +2 -2
- package/docs/interceptors/CorsSecurityInterceptor.html +2 -2
- package/docs/interceptors/CsrfPreventionInterceptor.html +2 -2
- package/docs/interceptors/EuLoginSessionTimeoutHandlingInterceptor.html +2 -2
- package/docs/interceptors/HttpErrorHandlerInterceptor.html +4 -4
- package/docs/interceptors/UxRequestErrorModelInterceptor.html +4 -4
- package/docs/interfaces/Action.html +270 -0
- package/docs/interfaces/ActionReducer.html +269 -0
- package/docs/interfaces/MemoizedSelector.html +407 -0
- package/docs/interfaces/MemoizedSelectorWithProps.html +414 -0
- package/docs/js/menu-wc.js +30 -21
- package/docs/js/menu-wc_es5.js +1 -1
- package/docs/js/search/search_index.js +2 -2
- package/docs/miscellaneous/enumerations.html +35 -10
- package/docs/miscellaneous/functions.html +937 -60
- package/docs/miscellaneous/typealiases.html +232 -13
- package/docs/miscellaneous/variables.html +283 -160
- package/fesm2022/eui-core.mjs +575 -387
- package/fesm2022/eui-core.mjs.map +1 -1
- package/lib/eui-core.module.d.ts.map +1 -1
- package/lib/services/app/eui-init-app.d.ts +10 -1
- package/lib/services/app/eui-init-app.d.ts.map +1 -1
- package/lib/services/app/eui-pre-init-app.d.ts.map +1 -1
- package/lib/services/app/eui-startup.d.ts.map +1 -1
- package/lib/services/app/index.d.ts +1 -0
- package/lib/services/app/index.d.ts.map +1 -1
- package/lib/services/eui-app-shell.service.d.ts +1 -1
- package/lib/services/eui-app-shell.service.d.ts.map +1 -1
- package/lib/services/i18n/i18n.loader.d.ts.map +1 -1
- package/lib/services/i18n/i18n.service.d.ts +20 -7
- package/lib/services/i18n/i18n.service.d.ts.map +1 -1
- package/lib/services/locale/locale.service.d.ts +17 -32
- package/lib/services/locale/locale.service.d.ts.map +1 -1
- package/lib/services/locale/locale.service.mock.d.ts +1 -1
- package/lib/services/locale/locale.service.mock.d.ts.map +1 -1
- package/lib/services/permission/permission.service.d.ts.map +1 -1
- package/lib/services/queue/api-queue.service.d.ts +18 -3
- package/lib/services/queue/api-queue.service.d.ts.map +1 -1
- package/lib/services/queue/api-queue.service.mock.d.ts +2 -2
- package/lib/services/queue/api-queue.service.mock.d.ts.map +1 -1
- package/lib/services/store/actions/app.actions.d.ts +37 -1
- package/lib/services/store/actions/app.actions.d.ts.map +1 -1
- package/lib/services/store/actions/i18n.actions.d.ts +10 -1
- package/lib/services/store/actions/i18n.actions.d.ts.map +1 -1
- package/lib/services/store/actions/locale.actions.d.ts +10 -1
- package/lib/services/store/actions/locale.actions.d.ts.map +1 -1
- package/lib/services/store/actions/notifications.actions.d.ts +10 -1
- package/lib/services/store/actions/notifications.actions.d.ts.map +1 -1
- package/lib/services/store/actions/user.actions.d.ts +22 -1
- package/lib/services/store/actions/user.actions.d.ts.map +1 -1
- package/lib/services/store/index.d.ts +0 -1
- package/lib/services/store/index.d.ts.map +1 -1
- package/lib/services/store/ngrx_kit.d.ts +54 -0
- package/lib/services/store/ngrx_kit.d.ts.map +1 -0
- package/lib/services/store/reducers/app.reducers.d.ts +4 -1
- package/lib/services/store/reducers/app.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/core.reducers.d.ts +4 -1
- package/lib/services/store/reducers/core.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/i18n.reducers.d.ts +4 -1
- package/lib/services/store/reducers/i18n.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/locale.reducers.d.ts +4 -1
- package/lib/services/store/reducers/locale.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/meta.reducers.d.ts +5 -1
- package/lib/services/store/reducers/meta.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/notifications.reducers.d.ts +4 -1
- package/lib/services/store/reducers/notifications.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/user.reducers.d.ts +4 -1
- package/lib/services/store/reducers/user.reducers.d.ts.map +1 -1
- package/lib/services/store/store.service.d.ts +40 -12
- package/lib/services/store/store.service.d.ts.map +1 -1
- package/lib/services/user/user.service.d.ts +32 -6
- package/lib/services/user/user.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/docs/injectables/CoreAppEffects.html +0 -468
- package/lib/services/store/effects/app.effects.d.ts +0 -21
- package/lib/services/store/effects/app.effects.d.ts.map +0 -1
- package/lib/services/store/effects/index.d.ts +0 -4
- package/lib/services/store/effects/index.d.ts.map +0 -1
package/fesm2022/eui-core.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import * as i1 from '@eui/base';
|
|
2
|
-
import { LogLevel, ConsoleAppender, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, Logger, LoggerMock,
|
|
2
|
+
import { LogLevel, ConsoleAppender, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, Logger, LoggerMock, initialCoreState, xhr, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getBrowserDefaultLanguage, EuiEuLanguages, EuiService, getUserState, getLocaleServiceConfigFromBase, transformToUxHttpResponse } from '@eui/base';
|
|
3
3
|
export * from '@eui/base';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { InjectionToken,
|
|
5
|
+
import { InjectionToken, inject, PLATFORM_ID, Injectable, Inject, Injector, NgModule, signal, computed, runInInjectionContext, Optional, SkipSelf, provideAppInitializer, ErrorHandler, LOCALE_ID } from '@angular/core';
|
|
6
6
|
import * as extendProxy from 'extend';
|
|
7
|
-
import * as i1$1 from '@ngrx/effects';
|
|
8
|
-
import { createEffect, ofType } from '@ngrx/effects';
|
|
9
|
-
import { merge, fromEvent, of, throwError, forkJoin, from, BehaviorSubject, defer, firstValueFrom, Subject } from 'rxjs';
|
|
10
|
-
import { map, mergeMap, tap, debounceTime, distinctUntilChanged, take, switchMap, catchError, concatMap, filter, takeUntil } from 'rxjs/operators';
|
|
11
7
|
import { isPlatformBrowser, LOCATION_INITIALIZED, DOCUMENT, isPlatformServer, getLocaleId, registerLocaleData } from '@angular/common';
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
8
|
+
import { filter, debounceTime, distinctUntilChanged, tap, take, map, switchMap, catchError, concatMap, takeUntil } from 'rxjs/operators';
|
|
9
|
+
import { toObservable } from '@angular/core/rxjs-interop';
|
|
10
|
+
import { isEqual } from 'lodash';
|
|
11
|
+
import { of, forkJoin, from, Subject, BehaviorSubject, defer, firstValueFrom } from 'rxjs';
|
|
16
12
|
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
|
17
13
|
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
|
18
|
-
import * as i1$
|
|
14
|
+
import * as i1$2 from '@angular/common/http';
|
|
19
15
|
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
|
|
20
|
-
import * as i1$
|
|
16
|
+
import * as i1$1 from '@angular/router';
|
|
21
17
|
import { NavigationEnd } from '@angular/router';
|
|
18
|
+
import { createSelector } from 'reselect';
|
|
19
|
+
import * as i1$3 from '@ngx-translate/core';
|
|
20
|
+
import { TranslateLoader } from '@ngx-translate/core';
|
|
22
21
|
import { By } from '@angular/platform-browser';
|
|
23
22
|
import { FormGroup, FormArray } from '@angular/forms';
|
|
24
23
|
import { DomPortalOutlet, ComponentPortal, PortalInjector } from '@angular/cdk/portal';
|
|
25
|
-
import isEqual from 'lodash-es/isEqual';
|
|
24
|
+
import isEqual$1 from 'lodash-es/isEqual';
|
|
26
25
|
import get from 'lodash-es/get';
|
|
27
26
|
import * as lf from 'localforage';
|
|
28
27
|
import localeFr from '@angular/common/locales/fr';
|
|
29
28
|
import localeEl from '@angular/common/locales/el';
|
|
29
|
+
import { of as of$1 } from 'rxjs/internal/observable/of';
|
|
30
30
|
|
|
31
31
|
/** default log configuration */
|
|
32
32
|
const DEFAULT_LOG_CONFIG = {
|
|
@@ -158,6 +158,9 @@ function mergeAppJsonConfigToAppConfig(euiAppConfig, envAppJsonConfig, merge, is
|
|
|
158
158
|
return Object.assign({}, euiAppConfig, envAppJsonConfig, deepMerged);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated it will be removed in the next major version
|
|
163
|
+
*/
|
|
161
164
|
var CoreAppActionTypes;
|
|
162
165
|
(function (CoreAppActionTypes) {
|
|
163
166
|
CoreAppActionTypes["INIT_STORE"] = "[App] Init store";
|
|
@@ -171,60 +174,90 @@ var CoreAppActionTypes;
|
|
|
171
174
|
CoreAppActionTypes["REMOVE_API_QUEUE_ITEM"] = "[App] Remove API queue item";
|
|
172
175
|
CoreAppActionTypes["EMPTY_API_QUEUE"] = "[App] empty API queue";
|
|
173
176
|
})(CoreAppActionTypes || (CoreAppActionTypes = {}));
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated it will be removed in the next major version
|
|
179
|
+
*/
|
|
174
180
|
class InitStoreAction {
|
|
175
181
|
constructor(payload) {
|
|
176
182
|
this.payload = payload;
|
|
177
183
|
this.type = CoreAppActionTypes.INIT_STORE;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated it will be removed in the next major version
|
|
188
|
+
*/
|
|
180
189
|
class UpdateAppVersionAction {
|
|
181
190
|
constructor(payload) {
|
|
182
191
|
this.payload = payload;
|
|
183
192
|
this.type = CoreAppActionTypes.UPDATE_APP_VERSION;
|
|
184
193
|
}
|
|
185
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated it will be removed in the next major version
|
|
197
|
+
*/
|
|
186
198
|
class UpdateAppConnectionAction {
|
|
187
199
|
constructor(payload) {
|
|
188
200
|
this.payload = payload;
|
|
189
201
|
this.type = CoreAppActionTypes.UPDATE_APP_CONNECTION;
|
|
190
202
|
}
|
|
191
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated it will be removed in the next major version
|
|
206
|
+
*/
|
|
192
207
|
class AddAppLoadedConfigModulesAction {
|
|
193
208
|
constructor(payload) {
|
|
194
209
|
this.payload = payload;
|
|
195
210
|
this.type = CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES;
|
|
196
211
|
}
|
|
197
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated it will be removed in the next major version
|
|
215
|
+
*/
|
|
198
216
|
class UpdateAppStatusAction {
|
|
199
217
|
constructor(payload) {
|
|
200
218
|
this.payload = payload;
|
|
201
219
|
this.type = CoreAppActionTypes.UPDATE_APP_STATUS;
|
|
202
220
|
}
|
|
203
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* @deprecated it will be removed in the next major version
|
|
224
|
+
*/
|
|
204
225
|
class UpdateCurrentModuleAction {
|
|
205
226
|
constructor(payload) {
|
|
206
227
|
this.payload = payload;
|
|
207
228
|
this.type = CoreAppActionTypes.UPDATE_CURRENT_MODULE;
|
|
208
229
|
}
|
|
209
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated it will be removed in the next major version
|
|
233
|
+
*/
|
|
210
234
|
class ActivatedRouteAction {
|
|
211
235
|
constructor(payload) {
|
|
212
236
|
this.payload = payload;
|
|
213
237
|
this.type = CoreAppActionTypes.ACTIVATED_ROUTE;
|
|
214
238
|
}
|
|
215
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* @deprecated it will be removed in the next major version
|
|
242
|
+
*/
|
|
216
243
|
class AddApiQueueItemAction {
|
|
217
244
|
constructor(payload) {
|
|
218
245
|
this.payload = payload;
|
|
219
246
|
this.type = CoreAppActionTypes.ADD_API_QUEUE_ITEM;
|
|
220
247
|
}
|
|
221
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* @deprecated it will be removed in the next major version
|
|
251
|
+
*/
|
|
222
252
|
class RemoveApiQueueItemAction {
|
|
223
253
|
constructor(payload) {
|
|
224
254
|
this.payload = payload;
|
|
225
255
|
this.type = CoreAppActionTypes.REMOVE_API_QUEUE_ITEM;
|
|
226
256
|
}
|
|
227
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated it will be removed in the next major version
|
|
260
|
+
*/
|
|
228
261
|
class EmptyApiQueueAction {
|
|
229
262
|
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
230
263
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -234,10 +267,16 @@ class EmptyApiQueueAction {
|
|
|
234
267
|
}
|
|
235
268
|
}
|
|
236
269
|
|
|
270
|
+
/**
|
|
271
|
+
* @deprecated it will be removed in the next major version
|
|
272
|
+
*/
|
|
237
273
|
var CoreI18nActionTypes;
|
|
238
274
|
(function (CoreI18nActionTypes) {
|
|
239
275
|
CoreI18nActionTypes["UPDATE_I18N_STATE"] = "[I18n] Update I18n State";
|
|
240
276
|
})(CoreI18nActionTypes || (CoreI18nActionTypes = {}));
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated it will be removed in the next major version
|
|
279
|
+
*/
|
|
241
280
|
class UpdateI18nStateAction {
|
|
242
281
|
constructor(payload) {
|
|
243
282
|
this.payload = payload;
|
|
@@ -245,6 +284,9 @@ class UpdateI18nStateAction {
|
|
|
245
284
|
}
|
|
246
285
|
}
|
|
247
286
|
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated it will be removed in the next major version
|
|
289
|
+
*/
|
|
248
290
|
var CoreUserActionTypes;
|
|
249
291
|
(function (CoreUserActionTypes) {
|
|
250
292
|
CoreUserActionTypes["UPDATE_USER_STATE"] = "[User] Update User state";
|
|
@@ -253,30 +295,45 @@ var CoreUserActionTypes;
|
|
|
253
295
|
CoreUserActionTypes["UPDATE_USER_RIGHTS"] = "[User] Update rights";
|
|
254
296
|
CoreUserActionTypes["UPDATE_USER_DASHBOARD"] = "[User] Update dashboard";
|
|
255
297
|
})(CoreUserActionTypes || (CoreUserActionTypes = {}));
|
|
298
|
+
/**
|
|
299
|
+
* @deprecated it will be removed in the next major version
|
|
300
|
+
*/
|
|
256
301
|
class UpdateUserStateAction {
|
|
257
302
|
constructor(payload) {
|
|
258
303
|
this.payload = payload;
|
|
259
304
|
this.type = CoreUserActionTypes.UPDATE_USER_STATE;
|
|
260
305
|
}
|
|
261
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* @deprecated it will be removed in the next major version
|
|
309
|
+
*/
|
|
262
310
|
class UpdateUserDetailsAction {
|
|
263
311
|
constructor(payload) {
|
|
264
312
|
this.payload = payload;
|
|
265
313
|
this.type = CoreUserActionTypes.UPDATE_USER_DETAILS;
|
|
266
314
|
}
|
|
267
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* @deprecated it will be removed in the next major version
|
|
318
|
+
*/
|
|
268
319
|
class UpdateUserPreferencesAction {
|
|
269
320
|
constructor(payload) {
|
|
270
321
|
this.payload = payload;
|
|
271
322
|
this.type = CoreUserActionTypes.UPDATE_USER_PREFERENCES;
|
|
272
323
|
}
|
|
273
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* @deprecated it will be removed in the next major version
|
|
327
|
+
*/
|
|
274
328
|
class UpdateUserRightsAction {
|
|
275
329
|
constructor(payload) {
|
|
276
330
|
this.payload = payload;
|
|
277
331
|
this.type = CoreUserActionTypes.UPDATE_USER_RIGHTS;
|
|
278
332
|
}
|
|
279
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* @deprecated it will be removed in the next major version
|
|
336
|
+
*/
|
|
280
337
|
class UpdateUserDashboardAction {
|
|
281
338
|
constructor(payload) {
|
|
282
339
|
this.payload = payload;
|
|
@@ -284,10 +341,16 @@ class UpdateUserDashboardAction {
|
|
|
284
341
|
}
|
|
285
342
|
}
|
|
286
343
|
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated it will be removed in the next major version
|
|
346
|
+
*/
|
|
287
347
|
var CoreNotificationsActionTypes;
|
|
288
348
|
(function (CoreNotificationsActionTypes) {
|
|
289
349
|
CoreNotificationsActionTypes["UPDATE_NOTIFICATIONS_LIST"] = "[Notif] Update list";
|
|
290
350
|
})(CoreNotificationsActionTypes || (CoreNotificationsActionTypes = {}));
|
|
351
|
+
/**
|
|
352
|
+
* @deprecated it will be removed in the next major version
|
|
353
|
+
*/
|
|
291
354
|
class UpdateNotificationsListAction {
|
|
292
355
|
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
293
356
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -297,10 +360,16 @@ class UpdateNotificationsListAction {
|
|
|
297
360
|
}
|
|
298
361
|
}
|
|
299
362
|
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated it will be removed in the next major version
|
|
365
|
+
*/
|
|
300
366
|
var CoreLocaleActionTypes;
|
|
301
367
|
(function (CoreLocaleActionTypes) {
|
|
302
368
|
CoreLocaleActionTypes["UPDATE_LOCALE_STATE"] = "[Locale] Update Locale State";
|
|
303
369
|
})(CoreLocaleActionTypes || (CoreLocaleActionTypes = {}));
|
|
370
|
+
/**
|
|
371
|
+
* @deprecated it will be removed in the next major version
|
|
372
|
+
*/
|
|
304
373
|
class UpdateLocaleStateAction {
|
|
305
374
|
constructor(payload) {
|
|
306
375
|
this.payload = payload;
|
|
@@ -308,150 +377,8 @@ class UpdateLocaleStateAction {
|
|
|
308
377
|
}
|
|
309
378
|
}
|
|
310
379
|
|
|
311
|
-
class EuiGrowlService {
|
|
312
|
-
constructor() {
|
|
313
|
-
this.growlMessages = [];
|
|
314
|
-
this.isGrowlSticky = false;
|
|
315
|
-
this.isCloseAllSticky = false;
|
|
316
|
-
this.growlLife = 3000;
|
|
317
|
-
this.growlPosition = 'bottom-right';
|
|
318
|
-
this.growlCallback = null;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* displays a growl UxMessage item, isSticky
|
|
322
|
-
*/
|
|
323
|
-
growl(msg, isSticky, isMultiple, life, position, callback) {
|
|
324
|
-
if (msg.severity !== 'info' && msg.severity !== 'warning' && msg.severity !== 'success' && msg.severity !== 'danger') {
|
|
325
|
-
throw new Error('EuiGrowlService.growl() ERROR : message severity must be either : success, warning, info, danger');
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
if (isMultiple === undefined || !isMultiple) {
|
|
329
|
-
this.growlMessages = [];
|
|
330
|
-
}
|
|
331
|
-
this.growlMessages = this.growlMessages.concat(msg);
|
|
332
|
-
msg.life = life || msg.life;
|
|
333
|
-
msg.sticky = isSticky || msg.sticky;
|
|
334
|
-
if (life === undefined || isNaN(life)) {
|
|
335
|
-
if (msg.severity === 'danger') {
|
|
336
|
-
isSticky = true;
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
this.growlLife = 3000;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
this.growlLife = life;
|
|
344
|
-
}
|
|
345
|
-
if (isSticky) {
|
|
346
|
-
this.isGrowlSticky = isSticky;
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
this.isGrowlSticky = false;
|
|
350
|
-
}
|
|
351
|
-
if (position) {
|
|
352
|
-
this.growlPosition = position;
|
|
353
|
-
}
|
|
354
|
-
if (callback) {
|
|
355
|
-
this.growlCallback = callback;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
clearGrowl() {
|
|
360
|
-
this.growlMessages = [];
|
|
361
|
-
}
|
|
362
|
-
growlSuccess(msg, position) {
|
|
363
|
-
this.growl({ severity: 'success', summary: 'SUCCESS', detail: msg }, false, false, undefined, position);
|
|
364
|
-
}
|
|
365
|
-
growlError(msg, position) {
|
|
366
|
-
this.growl({ severity: 'danger', summary: 'ERROR', detail: msg }, false, false, undefined, position);
|
|
367
|
-
}
|
|
368
|
-
growlWarning(msg, position) {
|
|
369
|
-
this.growl({ severity: 'warning', summary: 'WARNING', detail: msg }, false, false, undefined, position);
|
|
370
|
-
}
|
|
371
|
-
growlInfo(msg, position) {
|
|
372
|
-
this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
|
|
373
|
-
}
|
|
374
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
375
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, providedIn: 'root' }); }
|
|
376
|
-
}
|
|
377
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, decorators: [{
|
|
378
|
-
type: Injectable,
|
|
379
|
-
args: [{
|
|
380
|
-
providedIn: 'root',
|
|
381
|
-
}]
|
|
382
|
-
}] });
|
|
383
|
-
|
|
384
|
-
class CoreAppEffects {
|
|
385
|
-
constructor(actions,
|
|
386
|
-
// TODO: remove on eUI 14
|
|
387
|
-
showConnectionStatus, translateService, asService, platformId) {
|
|
388
|
-
this.actions = actions;
|
|
389
|
-
this.showConnectionStatus = showConnectionStatus;
|
|
390
|
-
this.translateService = translateService;
|
|
391
|
-
this.asService = asService;
|
|
392
|
-
this.platformId = platformId;
|
|
393
|
-
this.getAppConnectionInformation = createEffect(() => {
|
|
394
|
-
if (isPlatformBrowser(this.platformId)) {
|
|
395
|
-
return merge(fromEvent(window, 'online').pipe(map(() => true)), fromEvent(window, 'offline').pipe(map(() => false))).pipe(map((connected) => new UpdateAppConnectionAction(connected)));
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
return of(new UpdateAppConnectionAction(false));
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
this.activatedRoute = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap((route) => {
|
|
402
|
-
// extract the module name, if defined
|
|
403
|
-
const module = route.snapshot.data['module'] || 'undefined';
|
|
404
|
-
return [new UpdateCurrentModuleAction(module)];
|
|
405
|
-
})));
|
|
406
|
-
this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
|
|
407
|
-
// check if feature is enabled
|
|
408
|
-
const isFeatureEnabled = this.showConnectionStatus?.enabled;
|
|
409
|
-
// extract lifespan if any
|
|
410
|
-
const lifespan = this.showConnectionStatus?.messageBox?.lifespan || 0;
|
|
411
|
-
// if the user needs to be informed about the connection status
|
|
412
|
-
if (isFeatureEnabled) {
|
|
413
|
-
if (connected) {
|
|
414
|
-
this.translateService.get('eui.CONNECTED').subscribe((translation) => {
|
|
415
|
-
this.asService.growl({ severity: 'success', summary: 'MESSAGE', detail: translation, life: lifespan }, lifespan < 1, false);
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
this.translateService.get('eui.NOTCONNECTED').subscribe((translation) => {
|
|
420
|
-
this.asService.growl({ severity: 'danger', summary: 'ERROR', detail: translation, life: lifespan }, lifespan < 1, false);
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
})), { dispatch: false });
|
|
425
|
-
}
|
|
426
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$1.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$2.TranslateService }, { token: EuiGrowlService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
427
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CoreAppEffects }); }
|
|
428
|
-
}
|
|
429
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CoreAppEffects, decorators: [{
|
|
430
|
-
type: Injectable
|
|
431
|
-
}], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
|
|
432
|
-
type: Inject,
|
|
433
|
-
args: [SHOW_CONNECTION_STATUS_TOKEN]
|
|
434
|
-
}] }, { type: i1$2.TranslateService }, { type: EuiGrowlService }, { type: undefined, decorators: [{
|
|
435
|
-
type: Inject,
|
|
436
|
-
args: [PLATFORM_ID]
|
|
437
|
-
}] }] });
|
|
438
|
-
|
|
439
|
-
const CoreModuleEffects = [CoreAppEffects];
|
|
440
|
-
|
|
441
380
|
const updateAppVersion = (state, action) => ({ ...state, version: action.payload });
|
|
442
381
|
const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
|
|
443
|
-
const AddAppLoadedConfigModules = (state, action) => ({
|
|
444
|
-
...state,
|
|
445
|
-
loadedConfigModules: {
|
|
446
|
-
lastAddedModule: action.payload.moduleName,
|
|
447
|
-
modulesConfig: {
|
|
448
|
-
...state.loadedConfigModules.modulesConfig,
|
|
449
|
-
[action.payload.moduleName]: {
|
|
450
|
-
...action.payload.moduleConfig,
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
});
|
|
455
382
|
const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
|
|
456
383
|
const updateCurrentModule = (state, action) => Object.assign({}, state, { currentModule: action.payload });
|
|
457
384
|
const addApiQueueItem = (state, action) => {
|
|
@@ -477,13 +404,15 @@ Object.assign({}, state, { apiQueue: {} });
|
|
|
477
404
|
const actionToReducerMap$4 = {
|
|
478
405
|
[CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
|
|
479
406
|
[CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
|
|
480
|
-
[CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
|
|
481
407
|
[CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
|
|
482
408
|
[CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
|
|
483
409
|
[CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
|
|
484
410
|
[CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
|
|
485
411
|
[CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
|
|
486
412
|
};
|
|
413
|
+
/**
|
|
414
|
+
* @deprecated it will be removed in the next major version
|
|
415
|
+
*/
|
|
487
416
|
const coreAppReducers = (state = initialAppState, action) => {
|
|
488
417
|
if (actionToReducerMap$4[action.type]) {
|
|
489
418
|
return actionToReducerMap$4[action.type](state, action);
|
|
@@ -526,6 +455,9 @@ const actionToReducerMap$3 = {
|
|
|
526
455
|
[CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
|
|
527
456
|
[CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
|
|
528
457
|
};
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated it will be removed in the next major version
|
|
460
|
+
*/
|
|
529
461
|
const coreUserReducers = (state = initialUserState, action) => {
|
|
530
462
|
if (actionToReducerMap$3[action.type]) {
|
|
531
463
|
return actionToReducerMap$3[action.type](state, action);
|
|
@@ -537,6 +469,9 @@ const updateNotificationsList = (state, action) => Object.assign({}, state, { li
|
|
|
537
469
|
const actionToReducerMap$2 = {
|
|
538
470
|
[CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST]: updateNotificationsList,
|
|
539
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* @deprecated it will be removed in the next major version
|
|
474
|
+
*/
|
|
540
475
|
const coreNotificationsReducers = (state = initialNotificationsState, action) => {
|
|
541
476
|
if (actionToReducerMap$2[action.type]) {
|
|
542
477
|
return actionToReducerMap$2[action.type](state, action);
|
|
@@ -544,13 +479,22 @@ const coreNotificationsReducers = (state = initialNotificationsState, action) =>
|
|
|
544
479
|
return state;
|
|
545
480
|
};
|
|
546
481
|
|
|
482
|
+
/**
|
|
483
|
+
* @deprecated it will be removed in the next major version
|
|
484
|
+
*/
|
|
547
485
|
const updateI18nState = (state, action) => ({
|
|
548
486
|
...state,
|
|
549
487
|
...action.payload,
|
|
550
488
|
});
|
|
489
|
+
/**
|
|
490
|
+
* @deprecated it will be removed in the next major version
|
|
491
|
+
*/
|
|
551
492
|
const actionToReducerMap$1 = {
|
|
552
493
|
[CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
|
|
553
494
|
};
|
|
495
|
+
/**
|
|
496
|
+
* @deprecated it will be removed in the next major version
|
|
497
|
+
*/
|
|
554
498
|
const corI18nReducers = (state = initialI18nState, action) => {
|
|
555
499
|
if (actionToReducerMap$1[action.type]) {
|
|
556
500
|
return actionToReducerMap$1[action.type](state, action);
|
|
@@ -558,13 +502,22 @@ const corI18nReducers = (state = initialI18nState, action) => {
|
|
|
558
502
|
return state;
|
|
559
503
|
};
|
|
560
504
|
|
|
505
|
+
/**
|
|
506
|
+
* @deprecated it will be removed in the next major version
|
|
507
|
+
*/
|
|
561
508
|
const updateLocaleState = (state, action) => ({
|
|
562
509
|
...state,
|
|
563
510
|
...action.payload,
|
|
564
511
|
});
|
|
512
|
+
/**
|
|
513
|
+
* @deprecated it will be removed in the next major version
|
|
514
|
+
*/
|
|
565
515
|
const actionToReducerMap = {
|
|
566
516
|
[CoreLocaleActionTypes.UPDATE_LOCALE_STATE]: updateLocaleState,
|
|
567
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* @deprecated it will be removed in the next major version
|
|
520
|
+
*/
|
|
568
521
|
const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
569
522
|
if (actionToReducerMap[action.type]) {
|
|
570
523
|
return actionToReducerMap[action.type](state, action);
|
|
@@ -572,6 +525,9 @@ const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
|
572
525
|
return state;
|
|
573
526
|
};
|
|
574
527
|
|
|
528
|
+
/**
|
|
529
|
+
* @deprecated it will be removed in the next major version
|
|
530
|
+
*/
|
|
575
531
|
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
576
532
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
577
533
|
const coreReducers = Object.assign({}, {
|
|
@@ -612,6 +568,7 @@ const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'stat
|
|
|
612
568
|
/**
|
|
613
569
|
* filters the AppState by removing those keys from the state and return a new state Object
|
|
614
570
|
* @param app the AppState
|
|
571
|
+
* @deprecated it will be removed in the next major version
|
|
615
572
|
*/
|
|
616
573
|
const filterAppState = (app) => {
|
|
617
574
|
// in case app is undefined or null it should return empty object
|
|
@@ -630,6 +587,7 @@ const filterAppState = (app) => {
|
|
|
630
587
|
/**
|
|
631
588
|
*
|
|
632
589
|
* @param storage Type of storage to load the state from
|
|
590
|
+
* @deprecated it will be removed in the next major version
|
|
633
591
|
*/
|
|
634
592
|
const loadState = (storage = localStorage) => {
|
|
635
593
|
if (!storage) {
|
|
@@ -831,77 +789,99 @@ var BrowserStorageType;
|
|
|
831
789
|
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
832
790
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
833
791
|
class StoreService {
|
|
834
|
-
constructor(
|
|
835
|
-
this.store = store;
|
|
792
|
+
constructor(logService, platformId) {
|
|
836
793
|
this.logService = logService;
|
|
837
794
|
this.platformId = platformId;
|
|
838
795
|
/**
|
|
839
796
|
* autoSave handlers to call before saving in local Storage
|
|
840
797
|
*/
|
|
841
|
-
// eslint-disable-next-line
|
|
842
798
|
this._autoSaveHandlers = {};
|
|
799
|
+
this.isHandlingAutoSave = false;
|
|
800
|
+
this.injector = inject(Injector);
|
|
843
801
|
if (isPlatformBrowser(this.platformId)) {
|
|
844
802
|
this._storage = localStorage;
|
|
845
803
|
}
|
|
804
|
+
this.state = signal({});
|
|
805
|
+
toObservable(this.state)
|
|
806
|
+
.pipe(filter(() => this.isHandlingAutoSave), debounceTime(1000), distinctUntilChanged())
|
|
807
|
+
.subscribe((state) => {
|
|
808
|
+
this.saveState(state);
|
|
809
|
+
});
|
|
846
810
|
}
|
|
847
|
-
// use init with just version info, to update to user state, UserService.updateState
|
|
848
|
-
// initializeStore(version?: string, userDetails?: BaseUserDetails) {
|
|
849
|
-
// this.dispatch(new InitStoreAction({ version, userDetails }));
|
|
850
|
-
// }
|
|
851
811
|
init(version, storageType) {
|
|
852
812
|
if (isPlatformBrowser(this.platformId)) {
|
|
853
|
-
|
|
813
|
+
// This action must be dispatched from an app initializer
|
|
814
|
+
// We load the state from a storage and compare the version and userId with the provided ones.
|
|
815
|
+
// If they are the same, we merge the local state into the initial state.
|
|
816
|
+
// If there is a mismatch, we don't merge the local state, but update only the initial state.
|
|
854
817
|
this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
|
|
818
|
+
// load the state from the localStorage
|
|
819
|
+
let localState = loadState(this._storage);
|
|
820
|
+
localState = { ...localState, app: { ...localState?.app, version } };
|
|
821
|
+
this.updateState(this.deepMerge(localState, { ...initialCoreState }));
|
|
855
822
|
}
|
|
856
823
|
}
|
|
857
|
-
|
|
824
|
+
/**
|
|
825
|
+
* Add an autoSave handler for a specific state slice
|
|
826
|
+
* @param stateSlice
|
|
827
|
+
* @param handler
|
|
828
|
+
* @deprecated it will be removed in the next major version
|
|
829
|
+
*/
|
|
858
830
|
addAutoSaveHandler(stateSlice, handler) {
|
|
859
|
-
if (!this.store) {
|
|
860
|
-
if (this.logService) {
|
|
861
|
-
this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
|
|
862
|
-
}
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
831
|
this._autoSaveHandlers[stateSlice] = handler;
|
|
866
832
|
}
|
|
867
833
|
handleAutoSave() {
|
|
868
|
-
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
this.store.pipe(debounceTime(1000), distinctUntilChanged()).subscribe((state) => {
|
|
872
|
-
this.saveState(state);
|
|
873
|
-
});
|
|
834
|
+
this.isHandlingAutoSave = true;
|
|
874
835
|
}
|
|
875
836
|
/**
|
|
876
837
|
* Proxy to NGRX store.dispatch()
|
|
877
838
|
* that allows to intercept if the store is present
|
|
839
|
+
*
|
|
840
|
+
* @deprecated it will be removed in the next version support of NGRX will cease
|
|
878
841
|
*/
|
|
879
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
880
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
881
842
|
dispatch(action) {
|
|
882
|
-
|
|
883
|
-
return this.store.dispatch(action);
|
|
884
|
-
}
|
|
843
|
+
console.warn('eUI does not PROXY to NGRX store.dispatch() anymore');
|
|
885
844
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
845
|
+
updateState(state, reducer) {
|
|
846
|
+
if (reducer) {
|
|
847
|
+
this.state.update(currentState => {
|
|
848
|
+
const newState = reducer(currentState, state);
|
|
849
|
+
return {
|
|
850
|
+
...newState,
|
|
851
|
+
};
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
this.state.update(currentState => this.deepMerge(currentState, { ...state }));
|
|
892
856
|
}
|
|
893
857
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
858
|
+
select(keyOrMapFn) {
|
|
859
|
+
let computedState = computed(() => this.state());
|
|
860
|
+
if (keyOrMapFn) {
|
|
861
|
+
switch (typeof keyOrMapFn) {
|
|
862
|
+
case 'function':
|
|
863
|
+
computedState = computed(() => {
|
|
864
|
+
const state = this.state();
|
|
865
|
+
return keyOrMapFn(state);
|
|
866
|
+
});
|
|
867
|
+
break;
|
|
868
|
+
case 'string':
|
|
869
|
+
computedState = computed(() => {
|
|
870
|
+
const state = this.state();
|
|
871
|
+
if (!keyOrMapFn) {
|
|
872
|
+
return state;
|
|
873
|
+
}
|
|
874
|
+
const keys = keyOrMapFn.split('.');
|
|
875
|
+
// Traverse the object based on the dot notation
|
|
876
|
+
return keys.reduce((acc, currKey) => {
|
|
877
|
+
return acc && acc[currKey] !== undefined ? acc[currKey] : undefined;
|
|
878
|
+
}, state);
|
|
879
|
+
});
|
|
880
|
+
break;
|
|
881
|
+
}
|
|
903
882
|
}
|
|
904
|
-
|
|
883
|
+
// Use `runInInjectionContext` to ensure `toObservable` is within Angular injection context
|
|
884
|
+
return runInInjectionContext(this.injector, () => toObservable(computedState).pipe(distinctUntilChanged((x, y) => isEqual(x, y))));
|
|
905
885
|
}
|
|
906
886
|
/**
|
|
907
887
|
* filters and save the state with the Browser storage
|
|
@@ -927,7 +907,38 @@ class StoreService {
|
|
|
927
907
|
// Ignore write errors.
|
|
928
908
|
}
|
|
929
909
|
}
|
|
930
|
-
|
|
910
|
+
/**
|
|
911
|
+
* deep merge two objects
|
|
912
|
+
* @param target the object that will be merged into
|
|
913
|
+
* @param source the object that will be merged from
|
|
914
|
+
*/
|
|
915
|
+
deepMerge(target, source) {
|
|
916
|
+
const output = Object.assign({}, target);
|
|
917
|
+
if (this.isObject(target) && this.isObject(source)) {
|
|
918
|
+
Object.keys(source).forEach(key => {
|
|
919
|
+
if (this.isObject(source[key])) {
|
|
920
|
+
if (!(key in target)) {
|
|
921
|
+
Object.assign(output, { [key]: source[key] });
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
output[key] = this.deepMerge(target[key], source[key]);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
Object.assign(output, { [key]: source[key] });
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
return output;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* checks if the given item is an object
|
|
936
|
+
* @param item the item that will be checked
|
|
937
|
+
*/
|
|
938
|
+
isObject(item) {
|
|
939
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
940
|
+
}
|
|
941
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StoreService, deps: [{ token: LogService, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
931
942
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
932
943
|
}
|
|
933
944
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StoreService, decorators: [{
|
|
@@ -935,9 +946,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
935
946
|
args: [{
|
|
936
947
|
providedIn: 'root',
|
|
937
948
|
}]
|
|
938
|
-
}], ctorParameters: () => [{ type:
|
|
939
|
-
type: Optional
|
|
940
|
-
}] }, { type: LogService, decorators: [{
|
|
949
|
+
}], ctorParameters: () => [{ type: LogService, decorators: [{
|
|
941
950
|
type: Optional
|
|
942
951
|
}] }, { type: undefined, decorators: [{
|
|
943
952
|
type: Inject,
|
|
@@ -947,7 +956,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
947
956
|
const PLATFORM_BROWSER_ID = 'browser';
|
|
948
957
|
class StoreServiceMock extends StoreService {
|
|
949
958
|
constructor() {
|
|
950
|
-
super(null,
|
|
959
|
+
super(null, PLATFORM_BROWSER_ID);
|
|
951
960
|
}
|
|
952
961
|
init() { }
|
|
953
962
|
addAutoSaveHandler() { }
|
|
@@ -963,32 +972,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
963
972
|
type: Injectable
|
|
964
973
|
}], ctorParameters: () => [] });
|
|
965
974
|
|
|
966
|
-
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
967
|
-
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
968
|
-
locationInitialized.then(() => {
|
|
969
|
-
const appConfig = injector.get(CONFIG_TOKEN);
|
|
970
|
-
// necessary config parameters
|
|
971
|
-
let appVersion;
|
|
972
|
-
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
973
|
-
appVersion = appConfig.versions.app;
|
|
974
|
-
}
|
|
975
|
-
else {
|
|
976
|
-
appVersion = '0.0.0';
|
|
977
|
-
}
|
|
978
|
-
let storageType;
|
|
979
|
-
if (appConfig && appConfig['saveStateStorage']) {
|
|
980
|
-
storageType = appConfig['saveStateStorage'];
|
|
981
|
-
}
|
|
982
|
-
else {
|
|
983
|
-
storageType = BrowserStorageType.local;
|
|
984
|
-
}
|
|
985
|
-
const storeService = injector.get(StoreService);
|
|
986
|
-
storeService.init(appVersion, storageType);
|
|
987
|
-
storeService.handleAutoSave();
|
|
988
|
-
resolve(null);
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
|
|
992
975
|
function getCoreProviders() {
|
|
993
976
|
return [
|
|
994
977
|
// core config
|
|
@@ -1002,7 +985,6 @@ function getCoreProviders() {
|
|
|
1002
985
|
{ provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
|
|
1003
986
|
{ provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
|
|
1004
987
|
{ provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
|
|
1005
|
-
{ provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
|
|
1006
988
|
];
|
|
1007
989
|
}
|
|
1008
990
|
function getDependencyProviders() {
|
|
@@ -1022,6 +1004,21 @@ function getCoreChildProviders(moduleName) {
|
|
|
1022
1004
|
];
|
|
1023
1005
|
}
|
|
1024
1006
|
|
|
1007
|
+
const AddAppLoadedConfigModules = (state, action) => ({
|
|
1008
|
+
...state,
|
|
1009
|
+
app: {
|
|
1010
|
+
...state.app,
|
|
1011
|
+
loadedConfigModules: {
|
|
1012
|
+
lastAddedModule: action.moduleName,
|
|
1013
|
+
modulesConfig: {
|
|
1014
|
+
...state.app.loadedConfigModules.modulesConfig,
|
|
1015
|
+
[action.moduleName]: {
|
|
1016
|
+
...action.moduleConfig,
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
},
|
|
1021
|
+
});
|
|
1025
1022
|
const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
|
|
1026
1023
|
class CoreModule {
|
|
1027
1024
|
/**
|
|
@@ -1059,7 +1056,7 @@ class CoreModule {
|
|
|
1059
1056
|
const storeService = injector.get(StoreService);
|
|
1060
1057
|
const moduleName = injector.get(MODULE_NAME_TOKEN);
|
|
1061
1058
|
const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
|
|
1062
|
-
storeService.
|
|
1059
|
+
storeService.updateState({ moduleName, moduleConfig }, AddAppLoadedConfigModules);
|
|
1063
1060
|
}
|
|
1064
1061
|
}
|
|
1065
1062
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -1099,8 +1096,7 @@ async function preInitApp(envConfig) {
|
|
|
1099
1096
|
const envDynamicConfig = envConfig && envConfig.envDynamicConfig;
|
|
1100
1097
|
if (envDynamicConfig) {
|
|
1101
1098
|
// load the local configuration file, if defined
|
|
1102
|
-
|
|
1103
|
-
envConfig.loadedEnvDynamicConfig = euiAppJsonConfig;
|
|
1099
|
+
envConfig.loadedEnvDynamicConfig = await loadEuiDynamicEnvironmentConfig(envDynamicConfig.uri, envDynamicConfig.configTimeout || 2000);
|
|
1104
1100
|
return envConfig;
|
|
1105
1101
|
}
|
|
1106
1102
|
return envConfig;
|
|
@@ -1131,6 +1127,70 @@ async function loadEuiDynamicEnvironmentConfig(url, timeout) {
|
|
|
1131
1127
|
return null;
|
|
1132
1128
|
}
|
|
1133
1129
|
|
|
1130
|
+
const init = () => {
|
|
1131
|
+
const locationInitialized = inject(LOCATION_INITIALIZED, { optional: true }) || Promise.resolve(null);
|
|
1132
|
+
const appConfig = inject(CONFIG_TOKEN);
|
|
1133
|
+
const storeService = inject(StoreService);
|
|
1134
|
+
return new Promise(resolve => {
|
|
1135
|
+
locationInitialized.then(() => {
|
|
1136
|
+
// necessary config parameters
|
|
1137
|
+
let appVersion;
|
|
1138
|
+
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
1139
|
+
appVersion = appConfig.versions.app;
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
appVersion = '0.0.0';
|
|
1143
|
+
}
|
|
1144
|
+
let storageType;
|
|
1145
|
+
if (appConfig && appConfig['saveStateStorage']) {
|
|
1146
|
+
storageType = appConfig['saveStateStorage'];
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
storageType = BrowserStorageType.local;
|
|
1150
|
+
}
|
|
1151
|
+
storeService.init(appVersion, storageType);
|
|
1152
|
+
storeService.handleAutoSave();
|
|
1153
|
+
resolve(null);
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
};
|
|
1157
|
+
/**
|
|
1158
|
+
* Initializes the app with the necessary configurations. Use this in combination with `provideAppInitializer(euiInitApp_Env)`
|
|
1159
|
+
*/
|
|
1160
|
+
function provideEuiInitializer() {
|
|
1161
|
+
return provideAppInitializer(init);
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Initializes the app with the necessary configurations
|
|
1165
|
+
* @param injector
|
|
1166
|
+
* @deprecated Use `provideEuiInitializer()` instead. Beware that this should be declared as Environment providers.
|
|
1167
|
+
*/
|
|
1168
|
+
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
1169
|
+
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
1170
|
+
locationInitialized.then(() => {
|
|
1171
|
+
const appConfig = injector.get(CONFIG_TOKEN);
|
|
1172
|
+
// necessary config parameters
|
|
1173
|
+
let appVersion;
|
|
1174
|
+
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
1175
|
+
appVersion = appConfig.versions.app;
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
appVersion = '0.0.0';
|
|
1179
|
+
}
|
|
1180
|
+
let storageType;
|
|
1181
|
+
if (appConfig && appConfig['saveStateStorage']) {
|
|
1182
|
+
storageType = appConfig['saveStateStorage'];
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
storageType = BrowserStorageType.local;
|
|
1186
|
+
}
|
|
1187
|
+
const storeService = injector.get(StoreService);
|
|
1188
|
+
storeService.init(appVersion, storageType);
|
|
1189
|
+
storeService.handleAutoSave();
|
|
1190
|
+
resolve(null);
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1134
1194
|
const errorCodes = {
|
|
1135
1195
|
ERR_GENERIC: 'ERR_GENERIC',
|
|
1136
1196
|
};
|
|
@@ -1243,7 +1303,7 @@ class HttpErrorHandlerInterceptor {
|
|
|
1243
1303
|
// return the first matching route, if any
|
|
1244
1304
|
return routes.length > 0 ? routes[0] : null;
|
|
1245
1305
|
}
|
|
1246
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i1$
|
|
1306
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1247
1307
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: HttpErrorHandlerInterceptor }); }
|
|
1248
1308
|
}
|
|
1249
1309
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
|
|
@@ -1251,7 +1311,80 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
1251
1311
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1252
1312
|
type: Inject,
|
|
1253
1313
|
args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
|
|
1254
|
-
}] }, { type: i0.Injector }, { type: i1$
|
|
1314
|
+
}] }, { type: i0.Injector }, { type: i1$1.Router }] });
|
|
1315
|
+
|
|
1316
|
+
class EuiGrowlService {
|
|
1317
|
+
constructor() {
|
|
1318
|
+
this.growlMessages = [];
|
|
1319
|
+
this.isGrowlSticky = false;
|
|
1320
|
+
this.isCloseAllSticky = false;
|
|
1321
|
+
this.growlLife = 3000;
|
|
1322
|
+
this.growlPosition = 'bottom-right';
|
|
1323
|
+
this.growlCallback = null;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* displays a growl UxMessage item, isSticky
|
|
1327
|
+
*/
|
|
1328
|
+
growl(msg, isSticky, isMultiple, life, position, callback) {
|
|
1329
|
+
if (msg.severity !== 'info' && msg.severity !== 'warning' && msg.severity !== 'success' && msg.severity !== 'danger') {
|
|
1330
|
+
throw new Error('EuiGrowlService.growl() ERROR : message severity must be either : success, warning, info, danger');
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
if (isMultiple === undefined || !isMultiple) {
|
|
1334
|
+
this.growlMessages = [];
|
|
1335
|
+
}
|
|
1336
|
+
this.growlMessages = this.growlMessages.concat(msg);
|
|
1337
|
+
msg.life = life || msg.life;
|
|
1338
|
+
msg.sticky = isSticky || msg.sticky;
|
|
1339
|
+
if (life === undefined || isNaN(life)) {
|
|
1340
|
+
if (msg.severity === 'danger') {
|
|
1341
|
+
isSticky = true;
|
|
1342
|
+
}
|
|
1343
|
+
else {
|
|
1344
|
+
this.growlLife = 3000;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
else {
|
|
1348
|
+
this.growlLife = life;
|
|
1349
|
+
}
|
|
1350
|
+
if (isSticky) {
|
|
1351
|
+
this.isGrowlSticky = isSticky;
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
this.isGrowlSticky = false;
|
|
1355
|
+
}
|
|
1356
|
+
if (position) {
|
|
1357
|
+
this.growlPosition = position;
|
|
1358
|
+
}
|
|
1359
|
+
if (callback) {
|
|
1360
|
+
this.growlCallback = callback;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
clearGrowl() {
|
|
1365
|
+
this.growlMessages = [];
|
|
1366
|
+
}
|
|
1367
|
+
growlSuccess(msg, position) {
|
|
1368
|
+
this.growl({ severity: 'success', summary: 'SUCCESS', detail: msg }, false, false, undefined, position);
|
|
1369
|
+
}
|
|
1370
|
+
growlError(msg, position) {
|
|
1371
|
+
this.growl({ severity: 'danger', summary: 'ERROR', detail: msg }, false, false, undefined, position);
|
|
1372
|
+
}
|
|
1373
|
+
growlWarning(msg, position) {
|
|
1374
|
+
this.growl({ severity: 'warning', summary: 'WARNING', detail: msg }, false, false, undefined, position);
|
|
1375
|
+
}
|
|
1376
|
+
growlInfo(msg, position) {
|
|
1377
|
+
this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
|
|
1378
|
+
}
|
|
1379
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1380
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, providedIn: 'root' }); }
|
|
1381
|
+
}
|
|
1382
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiGrowlService, decorators: [{
|
|
1383
|
+
type: Injectable,
|
|
1384
|
+
args: [{
|
|
1385
|
+
providedIn: 'root',
|
|
1386
|
+
}]
|
|
1387
|
+
}] });
|
|
1255
1388
|
|
|
1256
1389
|
function AlertHttpErrorCallbackFn(error) {
|
|
1257
1390
|
alert(error.statusText);
|
|
@@ -1307,9 +1440,39 @@ class ApiQueueService {
|
|
|
1307
1440
|
this.store = store;
|
|
1308
1441
|
this.http = http;
|
|
1309
1442
|
this.logService = logService;
|
|
1443
|
+
/**
|
|
1444
|
+
* A state reducer that adds an item to the API queue.
|
|
1445
|
+
* @param state
|
|
1446
|
+
* @param action
|
|
1447
|
+
*/
|
|
1448
|
+
this.addApiQueueItem = (state, action) => {
|
|
1449
|
+
// apply the timestamp to the queue item
|
|
1450
|
+
action.item.timestamp = new Date().getTime();
|
|
1451
|
+
// update the queue
|
|
1452
|
+
const apiQueue = Object.assign({}, state.app?.apiQueue, { [action.id]: action.item });
|
|
1453
|
+
return Object.assign({}, state, { app: { ...state.app, apiQueue } });
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* A state reducer that removes an item from the API queue.
|
|
1457
|
+
* @param state
|
|
1458
|
+
* @param action
|
|
1459
|
+
*/
|
|
1460
|
+
this.removeApiQueueItem = (state, action) => {
|
|
1461
|
+
// remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
|
|
1462
|
+
const apiQueue = Object.keys(state.app.apiQueue)
|
|
1463
|
+
.filter((id) => id !== action.payload)
|
|
1464
|
+
.reduce((queue, key) => {
|
|
1465
|
+
queue[key] = state.app.apiQueue[key];
|
|
1466
|
+
return queue;
|
|
1467
|
+
}, {});
|
|
1468
|
+
return Object.assign({}, state, { app: { ...state.app, apiQueue } });
|
|
1469
|
+
};
|
|
1310
1470
|
if (logService) {
|
|
1311
1471
|
this.logger = logService.getLogger('core.ApiQueueService');
|
|
1312
1472
|
}
|
|
1473
|
+
this.getAppState = (state) => state.app;
|
|
1474
|
+
this.getApiQueue = createSelector(this.getAppState, (state) => state.apiQueue);
|
|
1475
|
+
this.getApiQueueItem = (itemId) => createSelector(this.getAppState, (state) => state.apiQueue[itemId]);
|
|
1313
1476
|
}
|
|
1314
1477
|
/**
|
|
1315
1478
|
* Adds an item to the queue by dispatching an action to the store.
|
|
@@ -1338,7 +1501,7 @@ class ApiQueueService {
|
|
|
1338
1501
|
if (allowedMethods.indexOf(item.method) < 0) {
|
|
1339
1502
|
throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
|
|
1340
1503
|
}
|
|
1341
|
-
this.store.
|
|
1504
|
+
this.store.updateState({ id, item }, this.addApiQueueItem);
|
|
1342
1505
|
}
|
|
1343
1506
|
/**
|
|
1344
1507
|
* Retrieves the current state of the API queue and converts it into an array of Observables.
|
|
@@ -1362,7 +1525,7 @@ class ApiQueueService {
|
|
|
1362
1525
|
* });
|
|
1363
1526
|
*/
|
|
1364
1527
|
getQueue() {
|
|
1365
|
-
return this.store.select(getApiQueue).pipe(take(1), map((queue) => {
|
|
1528
|
+
return this.store.select(this.getApiQueue).pipe(take(1), map((queue) => {
|
|
1366
1529
|
const queueArray = queue && Object.values(queue);
|
|
1367
1530
|
if (!queueArray || queueArray.length < 1) {
|
|
1368
1531
|
this.logger?.warn('No items in the queue exist.');
|
|
@@ -1396,7 +1559,7 @@ class ApiQueueService {
|
|
|
1396
1559
|
* });
|
|
1397
1560
|
*/
|
|
1398
1561
|
getQueueItem(id) {
|
|
1399
|
-
return this.store.select(getApiQueueItem(id)).pipe(take(1), map((queue) => {
|
|
1562
|
+
return this.store.select(this.getApiQueueItem(id)).pipe(take(1), map((queue) => {
|
|
1400
1563
|
if (!queue) {
|
|
1401
1564
|
this.logger?.warn(`Queue item with id "${id}" does not exist`);
|
|
1402
1565
|
return null;
|
|
@@ -1423,7 +1586,7 @@ class ApiQueueService {
|
|
|
1423
1586
|
* // The item with ID 'item123' will be dispatched for removal from the queue.
|
|
1424
1587
|
*/
|
|
1425
1588
|
removeQueueItem(id) {
|
|
1426
|
-
this.store.
|
|
1589
|
+
this.store.updateState({ payload: id }, this.removeApiQueueItem);
|
|
1427
1590
|
}
|
|
1428
1591
|
/**
|
|
1429
1592
|
* Clears all items from the API queue.
|
|
@@ -1441,7 +1604,7 @@ class ApiQueueService {
|
|
|
1441
1604
|
* // This will dispatch an action to empty the entire API queue.
|
|
1442
1605
|
*/
|
|
1443
1606
|
removeAllQueueItem() {
|
|
1444
|
-
this.store.
|
|
1607
|
+
this.store.updateState({ app: { apiQueue: {} } });
|
|
1445
1608
|
}
|
|
1446
1609
|
/**
|
|
1447
1610
|
* Processes an item from the API queue identified by its ID.
|
|
@@ -1463,10 +1626,8 @@ class ApiQueueService {
|
|
|
1463
1626
|
* }
|
|
1464
1627
|
* });
|
|
1465
1628
|
*/
|
|
1466
|
-
// TODO: Replace `any` with a more specific type or make the method generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1467
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1468
1629
|
processQueueItem(id) {
|
|
1469
|
-
return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
1630
|
+
return this.store.select(this.getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
1470
1631
|
if (!queue) {
|
|
1471
1632
|
this.logger?.warn(`Queue item with id "${id}" does not exist`);
|
|
1472
1633
|
return of(null);
|
|
@@ -1494,10 +1655,8 @@ class ApiQueueService {
|
|
|
1494
1655
|
* // Handle the array of responses or errors
|
|
1495
1656
|
* });
|
|
1496
1657
|
*/
|
|
1497
|
-
// TODO: Refine the return type to be more specific or implement generics, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1498
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1499
1658
|
processAllQueueItems(continueOnError = true) {
|
|
1500
|
-
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
1659
|
+
return this.store.select(this.getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
1501
1660
|
this.logger?.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
1502
1661
|
if (!continueOnError) {
|
|
1503
1662
|
throw error;
|
|
@@ -1526,10 +1685,8 @@ class ApiQueueService {
|
|
|
1526
1685
|
* // Handle each response in the order of queue processing
|
|
1527
1686
|
* });
|
|
1528
1687
|
*/
|
|
1529
|
-
// TODO: Refine the return type for more specific or implement generics, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1530
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1531
1688
|
processAllQueueItemsSequential(ascending = true) {
|
|
1532
|
-
return this.store.select(getApiQueue).pipe(switchMap((queue) => from(Object.entries(queue)
|
|
1689
|
+
return this.store.select(this.getApiQueue).pipe(switchMap((queue) => from(Object.entries(queue)
|
|
1533
1690
|
.sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
|
|
1534
1691
|
.map(([id, item]) => this.buildHttpRequest(id, item)))
|
|
1535
1692
|
.pipe(concatMap(x => x))));
|
|
@@ -1578,13 +1735,10 @@ class ApiQueueService {
|
|
|
1578
1735
|
*
|
|
1579
1736
|
* @template T - The expected type of the HTTP response. Defaults to `any`.
|
|
1580
1737
|
*/
|
|
1581
|
-
// TODO: add type for T and deprecate old function
|
|
1582
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1583
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1584
1738
|
buildHttpRequest(id, item) {
|
|
1585
1739
|
return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
|
|
1586
1740
|
}
|
|
1587
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$
|
|
1741
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$2.HttpClient }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1588
1742
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
|
|
1589
1743
|
}
|
|
1590
1744
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ApiQueueService, decorators: [{
|
|
@@ -1592,7 +1746,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
1592
1746
|
args: [{
|
|
1593
1747
|
providedIn: 'root',
|
|
1594
1748
|
}]
|
|
1595
|
-
}], ctorParameters: () => [{ type: StoreService }, { type: i1$
|
|
1749
|
+
}], ctorParameters: () => [{ type: StoreService }, { type: i1$2.HttpClient }, { type: LogService, decorators: [{
|
|
1596
1750
|
type: Optional
|
|
1597
1751
|
}] }] });
|
|
1598
1752
|
|
|
@@ -1607,15 +1761,11 @@ class ApiQueueServiceMock extends ApiQueueService {
|
|
|
1607
1761
|
return of({ uri: id, method: 'GET' });
|
|
1608
1762
|
}
|
|
1609
1763
|
removeAllQueueItem() { }
|
|
1610
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1611
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1612
1764
|
processAllQueueItems() {
|
|
1613
1765
|
return of({});
|
|
1614
1766
|
}
|
|
1615
1767
|
addQueueItem() { }
|
|
1616
1768
|
removeQueueItem() { }
|
|
1617
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1618
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1619
1769
|
processQueueItem() {
|
|
1620
1770
|
return of({});
|
|
1621
1771
|
}
|
|
@@ -1839,12 +1989,12 @@ class I18nLoader {
|
|
|
1839
1989
|
}
|
|
1840
1990
|
return undefined;
|
|
1841
1991
|
}
|
|
1842
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nLoader, deps: [{ token: i1$
|
|
1992
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nLoader, deps: [{ token: i1$2.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1843
1993
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nLoader }); }
|
|
1844
1994
|
}
|
|
1845
1995
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nLoader, decorators: [{
|
|
1846
1996
|
type: Injectable
|
|
1847
|
-
}], ctorParameters: () => [{ type: i1$
|
|
1997
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }, { type: LogService, decorators: [{
|
|
1848
1998
|
type: Optional
|
|
1849
1999
|
}] }, { type: undefined, decorators: [{
|
|
1850
2000
|
type: Inject,
|
|
@@ -1857,7 +2007,9 @@ const translateConfig = {
|
|
|
1857
2007
|
},
|
|
1858
2008
|
};
|
|
1859
2009
|
|
|
2010
|
+
const getLastAddedModule = (state) => state.app.loadedConfigModules.lastAddedModule;
|
|
1860
2011
|
class I18nService extends EuiLazyService {
|
|
2012
|
+
static { this.DEFAULT_STATE = { activeLang: 'en' }; }
|
|
1861
2013
|
constructor(baseGlobalConfig, translateService, logService, store, document) {
|
|
1862
2014
|
super({ activeLang: 'en' });
|
|
1863
2015
|
this.baseGlobalConfig = baseGlobalConfig;
|
|
@@ -1865,29 +2017,56 @@ class I18nService extends EuiLazyService {
|
|
|
1865
2017
|
this.logService = logService;
|
|
1866
2018
|
this.store = store;
|
|
1867
2019
|
this.document = document;
|
|
2020
|
+
/**
|
|
2021
|
+
* a single signal holding the state - initial state is null
|
|
2022
|
+
*/
|
|
2023
|
+
this.state = signal(I18nService.DEFAULT_STATE);
|
|
2024
|
+
this.injector = inject(Injector);
|
|
2025
|
+
this.subNotifier = new Subject();
|
|
1868
2026
|
this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
|
|
1869
2027
|
this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
|
|
1870
2028
|
}
|
|
2029
|
+
ngOnDestroy() {
|
|
2030
|
+
this.subNotifier.next(void 0);
|
|
2031
|
+
this.subNotifier.complete();
|
|
2032
|
+
}
|
|
1871
2033
|
getState(keyOrMapFn) {
|
|
1872
|
-
let
|
|
1873
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1874
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1875
|
-
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
2034
|
+
let computedState = computed(() => this.state());
|
|
1876
2035
|
if (keyOrMapFn) {
|
|
1877
2036
|
switch (typeof keyOrMapFn) {
|
|
1878
2037
|
case 'function':
|
|
1879
|
-
|
|
2038
|
+
computedState = computed(() => {
|
|
2039
|
+
const state = this.state();
|
|
2040
|
+
return keyOrMapFn(state);
|
|
2041
|
+
});
|
|
1880
2042
|
break;
|
|
1881
2043
|
case 'string':
|
|
1882
|
-
|
|
2044
|
+
computedState = computed(() => {
|
|
2045
|
+
const state = this.state();
|
|
2046
|
+
if (!keyOrMapFn) {
|
|
2047
|
+
return state;
|
|
2048
|
+
}
|
|
2049
|
+
const keys = keyOrMapFn.split('.');
|
|
2050
|
+
// Traverse the object based on the dot notation
|
|
2051
|
+
return keys.reduce((acc, currKey) => {
|
|
2052
|
+
return acc && acc[currKey] !== undefined ? acc[currKey] : undefined;
|
|
2053
|
+
}, state);
|
|
2054
|
+
});
|
|
1883
2055
|
break;
|
|
1884
2056
|
}
|
|
1885
2057
|
}
|
|
1886
|
-
|
|
2058
|
+
// Use `runInInjectionContext` to ensure `toObservable` is within Angular injection context
|
|
2059
|
+
return runInInjectionContext(this.injector, () => toObservable(computedState).pipe(takeUntil(this.subNotifier), distinctUntilChanged((x, y) => isEqual(x, y))));
|
|
1887
2060
|
}
|
|
1888
|
-
updateState(
|
|
1889
|
-
this.updateHTMLDOMLang(
|
|
1890
|
-
this.
|
|
2061
|
+
updateState(state) {
|
|
2062
|
+
this.updateHTMLDOMLang(state.activeLang);
|
|
2063
|
+
this.state.update(currentState => super.deepMerge(currentState, { ...state }));
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* This method is used to get the state as readonly signal.
|
|
2067
|
+
*/
|
|
2068
|
+
getSignal() {
|
|
2069
|
+
return this.state.asReadonly();
|
|
1891
2070
|
}
|
|
1892
2071
|
init(langState) {
|
|
1893
2072
|
const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
|
|
@@ -1902,6 +2081,15 @@ class I18nService extends EuiLazyService {
|
|
|
1902
2081
|
}
|
|
1903
2082
|
return of({ success: false, error: 'Initial active lang should be string' });
|
|
1904
2083
|
}
|
|
2084
|
+
/**
|
|
2085
|
+
* A pipe function that could serve as a wrapper of another observable
|
|
2086
|
+
* e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
|
|
2087
|
+
* WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
|
|
2088
|
+
* into another emission.
|
|
2089
|
+
*
|
|
2090
|
+
* @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
|
|
2091
|
+
* fetch module name from the state.
|
|
2092
|
+
*/
|
|
1905
2093
|
onReady(moduleName) {
|
|
1906
2094
|
return this.onModuleLoad.pipe(switchMap((evt) => moduleName
|
|
1907
2095
|
? of(evt)
|
|
@@ -1976,13 +2164,13 @@ class I18nService extends EuiLazyService {
|
|
|
1976
2164
|
return this.config.defaultLanguage;
|
|
1977
2165
|
}
|
|
1978
2166
|
/**
|
|
1979
|
-
* @param
|
|
2167
|
+
* @param initLanguage if given default language to override default language coming from the
|
|
1980
2168
|
* configuration token.
|
|
1981
2169
|
*/
|
|
1982
2170
|
setup(initLanguage) {
|
|
1983
2171
|
// use the default config as a reference base
|
|
1984
2172
|
this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
|
|
1985
|
-
// configure the
|
|
2173
|
+
// configure the translation config service
|
|
1986
2174
|
if (this.config.languages) {
|
|
1987
2175
|
this.translateService.addLangs(EuiEuLanguages.getLanguageCodes(this.config.languages));
|
|
1988
2176
|
if (this.logService) {
|
|
@@ -2007,7 +2195,9 @@ class I18nService extends EuiLazyService {
|
|
|
2007
2195
|
}), catchError((error) => of({ success: false, error })));
|
|
2008
2196
|
}
|
|
2009
2197
|
bindActiveLangStateToTranslateService() {
|
|
2010
|
-
this.
|
|
2198
|
+
this.getState((s) => s.activeLang)
|
|
2199
|
+
.pipe(takeUntil(this.subNotifier))
|
|
2200
|
+
.subscribe((lang) => {
|
|
2011
2201
|
if (lang !== null && this.translateService.currentLang !== lang) {
|
|
2012
2202
|
this.use(lang);
|
|
2013
2203
|
}
|
|
@@ -2051,7 +2241,7 @@ class I18nService extends EuiLazyService {
|
|
|
2051
2241
|
updateHTMLDOMLang(lang) {
|
|
2052
2242
|
this.document.documentElement.lang = lang;
|
|
2053
2243
|
}
|
|
2054
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$
|
|
2244
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$3.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2055
2245
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nService, providedIn: 'root' }); }
|
|
2056
2246
|
}
|
|
2057
2247
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: I18nService, decorators: [{
|
|
@@ -2062,7 +2252,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
2062
2252
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2063
2253
|
type: Inject,
|
|
2064
2254
|
args: [GLOBAL_CONFIG_TOKEN]
|
|
2065
|
-
}] }, { type: i1$
|
|
2255
|
+
}] }, { type: i1$3.TranslateService }, { type: LogService, decorators: [{
|
|
2066
2256
|
type: Optional
|
|
2067
2257
|
}] }, { type: StoreService }, { type: Document, decorators: [{
|
|
2068
2258
|
type: Inject,
|
|
@@ -2541,6 +2731,8 @@ class EuiPermissionService extends EuiService {
|
|
|
2541
2731
|
* });
|
|
2542
2732
|
*/
|
|
2543
2733
|
getState() {
|
|
2734
|
+
const getUserState = (state) => state.user;
|
|
2735
|
+
const getUserRights = createSelector(getUserState, (state) => state.rights);
|
|
2544
2736
|
return this.store.select(getUserRights);
|
|
2545
2737
|
}
|
|
2546
2738
|
/**
|
|
@@ -2561,7 +2753,7 @@ class EuiPermissionService extends EuiService {
|
|
|
2561
2753
|
* permissionService.updateState(newUserRights);
|
|
2562
2754
|
*/
|
|
2563
2755
|
updateState(rights) {
|
|
2564
|
-
this.store.
|
|
2756
|
+
this.store.updateState({ user: { rights: rights || [] } });
|
|
2565
2757
|
}
|
|
2566
2758
|
/**
|
|
2567
2759
|
* Checks if the user has the specified attribute permission.
|
|
@@ -2990,7 +3182,7 @@ class EuiAppShellService {
|
|
|
2990
3182
|
key
|
|
2991
3183
|
? this.state$.pipe(map((state) => get(state, key)),
|
|
2992
3184
|
// filter((state) => state),
|
|
2993
|
-
distinctUntilChanged((x, y) => isEqual(x, y)))
|
|
3185
|
+
distinctUntilChanged((x, y) => isEqual$1(x, y)))
|
|
2994
3186
|
: this.state$);
|
|
2995
3187
|
}
|
|
2996
3188
|
sidebarToggle() {
|
|
@@ -3157,13 +3349,12 @@ class EuiAppShellService {
|
|
|
3157
3349
|
const body = res;
|
|
3158
3350
|
return body || {};
|
|
3159
3351
|
}
|
|
3160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3161
3352
|
handleError(error) {
|
|
3162
3353
|
console.error('An error occurred', error);
|
|
3163
3354
|
return Promise.reject(error.message || error);
|
|
3164
3355
|
}
|
|
3165
3356
|
bindActiveLanguageToAppShellState() {
|
|
3166
|
-
this.
|
|
3357
|
+
this.i18nService.getState((s) => s.activeLang).subscribe((activeLang) => {
|
|
3167
3358
|
if (activeLang !== this.state.activeLanguage) {
|
|
3168
3359
|
this.setState({
|
|
3169
3360
|
...this.state,
|
|
@@ -3172,7 +3363,7 @@ class EuiAppShellService {
|
|
|
3172
3363
|
}
|
|
3173
3364
|
});
|
|
3174
3365
|
}
|
|
3175
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$
|
|
3366
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$2.HttpClient }, { token: PLATFORM_ID }, { token: DOCUMENT }, { token: i1$1.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3176
3367
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiAppShellService, providedIn: 'root' }); }
|
|
3177
3368
|
}
|
|
3178
3369
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: EuiAppShellService, decorators: [{
|
|
@@ -3185,13 +3376,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
3185
3376
|
}, {
|
|
3186
3377
|
type: Inject,
|
|
3187
3378
|
args: [GLOBAL_CONFIG_TOKEN]
|
|
3188
|
-
}] }, { type: i1$
|
|
3379
|
+
}] }, { type: i1$2.HttpClient }, { type: undefined, decorators: [{
|
|
3189
3380
|
type: Inject,
|
|
3190
3381
|
args: [PLATFORM_ID]
|
|
3191
3382
|
}] }, { type: Document, decorators: [{
|
|
3192
3383
|
type: Inject,
|
|
3193
3384
|
args: [DOCUMENT]
|
|
3194
|
-
}] }, { type: i1$
|
|
3385
|
+
}] }, { type: i1$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
|
|
3195
3386
|
type: Optional
|
|
3196
3387
|
}] }] });
|
|
3197
3388
|
|
|
@@ -4457,8 +4648,9 @@ const LOCALE_ID_MAPPER = new InjectionToken('localeIdMapper');
|
|
|
4457
4648
|
* @extends EuiService<T | LocaleState>
|
|
4458
4649
|
*/
|
|
4459
4650
|
class LocaleService extends EuiService {
|
|
4651
|
+
static { this.DEFAULT_STATE = { id: 'en-US' }; }
|
|
4460
4652
|
constructor(store, baseGlobalConfig, locale_id, localeMapper, i18n, log) {
|
|
4461
|
-
super({ id:
|
|
4653
|
+
super({ id: locale_id || Intl.DateTimeFormat().resolvedOptions().locale });
|
|
4462
4654
|
this.store = store;
|
|
4463
4655
|
this.baseGlobalConfig = baseGlobalConfig;
|
|
4464
4656
|
this.locale_id = locale_id;
|
|
@@ -4466,6 +4658,11 @@ class LocaleService extends EuiService {
|
|
|
4466
4658
|
this.i18n = i18n;
|
|
4467
4659
|
this.log = log;
|
|
4468
4660
|
this.subNotifier = new Subject();
|
|
4661
|
+
/**
|
|
4662
|
+
* a single signal holding the state - initial state is null
|
|
4663
|
+
*/
|
|
4664
|
+
this.state = signal(LocaleService.DEFAULT_STATE);
|
|
4665
|
+
this.injector = inject(Injector);
|
|
4469
4666
|
if (log) {
|
|
4470
4667
|
this.logger = log.getLogger('core.LocaleService');
|
|
4471
4668
|
}
|
|
@@ -4482,45 +4679,55 @@ class LocaleService extends EuiService {
|
|
|
4482
4679
|
/**
|
|
4483
4680
|
* @param {((state: T) => K) | string} [keyOrMapFn] - Either a mapping function or a string key.
|
|
4484
4681
|
* If a string is provided, it uses dot notation to access nested properties.
|
|
4485
|
-
* @returns {Observable<K
|
|
4682
|
+
* @returns {Observable<Partial<K>>} - An observable that emits the selected or transformed state.
|
|
4486
4683
|
*
|
|
4487
4684
|
* If no parameter is provided, the method returns the entire state.
|
|
4488
4685
|
* @param keyOrMapFn
|
|
4489
4686
|
*/
|
|
4490
4687
|
getState(keyOrMapFn) {
|
|
4491
|
-
let
|
|
4492
|
-
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4493
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4494
|
-
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4688
|
+
let computedState = computed(() => this.state());
|
|
4495
4689
|
if (keyOrMapFn) {
|
|
4496
4690
|
switch (typeof keyOrMapFn) {
|
|
4497
4691
|
case 'function':
|
|
4498
|
-
|
|
4692
|
+
computedState = computed(() => {
|
|
4693
|
+
const state = this.state();
|
|
4694
|
+
return keyOrMapFn(state);
|
|
4695
|
+
});
|
|
4499
4696
|
break;
|
|
4500
4697
|
case 'string':
|
|
4501
|
-
|
|
4698
|
+
computedState = computed(() => {
|
|
4699
|
+
const state = this.state();
|
|
4700
|
+
if (!keyOrMapFn) {
|
|
4701
|
+
return state;
|
|
4702
|
+
}
|
|
4703
|
+
const keys = keyOrMapFn.split('.');
|
|
4704
|
+
// Traverse the object based on the dot notation
|
|
4705
|
+
return keys.reduce((acc, currKey) => {
|
|
4706
|
+
return acc && acc[currKey] !== undefined ? acc[currKey] : undefined;
|
|
4707
|
+
}, state);
|
|
4708
|
+
});
|
|
4502
4709
|
break;
|
|
4503
4710
|
}
|
|
4504
4711
|
}
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
map((state) => (state ? state : this.stateInstance ? this.stateInstance : this.locale_id)));
|
|
4712
|
+
// Use `runInInjectionContext` to ensure `toObservable` is within Angular injection context
|
|
4713
|
+
return runInInjectionContext(this.injector, () => toObservable(computedState).pipe(distinctUntilChanged((x, y) => isEqual(x, y))));
|
|
4508
4714
|
}
|
|
4509
4715
|
/**
|
|
4510
4716
|
* Initializes the LocaleService with necessary configurations and state.
|
|
4511
4717
|
* Binds language changes to the state and dynamically loads the appropriate locales.
|
|
4512
4718
|
*
|
|
4513
|
-
* @param {LocaleState
|
|
4719
|
+
* @param {LocaleState} [state] - Optional initial state for the locale service.
|
|
4514
4720
|
* @returns {Observable<EuiServiceStatus>} - Observable emitting the status of the initialization.
|
|
4515
4721
|
*/
|
|
4516
4722
|
init(state) {
|
|
4517
4723
|
super.initEuiService();
|
|
4724
|
+
state = state || { id: this.currentLocale };
|
|
4518
4725
|
// bind language changes to locale changes
|
|
4519
4726
|
if (this.config?.bindWithTranslate) {
|
|
4520
4727
|
this.bindTranslateServiceLangChangeToState();
|
|
4521
4728
|
}
|
|
4522
|
-
|
|
4523
|
-
|
|
4729
|
+
return of({ success: true })
|
|
4730
|
+
.pipe(tap(() => this.updateState(state)));
|
|
4524
4731
|
}
|
|
4525
4732
|
/**
|
|
4526
4733
|
* Updates the locale state within the application. If the new state is not available,
|
|
@@ -4530,26 +4737,30 @@ class LocaleService extends EuiService {
|
|
|
4530
4737
|
* @throws Will throw an error if the locale for the given state id is not available.
|
|
4531
4738
|
*/
|
|
4532
4739
|
updateState(state) {
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4740
|
+
if (state?.id) {
|
|
4741
|
+
// check if locale is available otherwise throw error
|
|
4742
|
+
try {
|
|
4743
|
+
const id = this.localeMapper(state.id);
|
|
4744
|
+
this.state.update(currentState => super.deepMerge(currentState, { ...state, id }));
|
|
4745
|
+
}
|
|
4746
|
+
catch (e) {
|
|
4747
|
+
const message = `Locale for '${state.id}' is not available.\n` +
|
|
4748
|
+
`Please use addLocale('${state.id}') first`;
|
|
4749
|
+
if (this.log) {
|
|
4750
|
+
this.logger.info(message, e);
|
|
4751
|
+
}
|
|
4752
|
+
throw new Error(message);
|
|
4542
4753
|
}
|
|
4543
|
-
|
|
4754
|
+
}
|
|
4755
|
+
else {
|
|
4756
|
+
this.state.update(currentState => this.deepMerge(currentState, { ...state }));
|
|
4544
4757
|
}
|
|
4545
4758
|
}
|
|
4546
4759
|
/**
|
|
4547
|
-
*
|
|
4548
|
-
*
|
|
4549
|
-
* @param id
|
|
4760
|
+
* This method is used to get the state as readonly signal.
|
|
4550
4761
|
*/
|
|
4551
|
-
|
|
4552
|
-
return this.
|
|
4762
|
+
getSignal() {
|
|
4763
|
+
return this.state.asReadonly();
|
|
4553
4764
|
}
|
|
4554
4765
|
/**
|
|
4555
4766
|
* Retrieves the previous locale used in the application.
|
|
@@ -4567,19 +4778,6 @@ class LocaleService extends EuiService {
|
|
|
4567
4778
|
get currentLocale() {
|
|
4568
4779
|
return this.stateInstance?.id;
|
|
4569
4780
|
}
|
|
4570
|
-
/**
|
|
4571
|
-
* @deprecated eui does not offer a way to dynamically add locale it will be removed in future versions
|
|
4572
|
-
*
|
|
4573
|
-
* Dynamically loads and registers locale data based on the given locale identifiers.
|
|
4574
|
-
*
|
|
4575
|
-
* @param {string[] | string} locale - An array of locale identifiers or a single locale identifier.
|
|
4576
|
-
* @returns {Observable<EuiServiceStatus>} - Observable emitting the status of the loading process.
|
|
4577
|
-
* @private
|
|
4578
|
-
*/
|
|
4579
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4580
|
-
loadLocale(locale) {
|
|
4581
|
-
return of({ success: true });
|
|
4582
|
-
}
|
|
4583
4781
|
/**
|
|
4584
4782
|
* Listens for language changes and dynamically sets the locale accordingly.
|
|
4585
4783
|
*
|
|
@@ -4589,54 +4787,25 @@ class LocaleService extends EuiService {
|
|
|
4589
4787
|
if (this.i18n) {
|
|
4590
4788
|
this.i18n.onStateChange
|
|
4591
4789
|
.pipe(takeUntil(this.subNotifier),
|
|
4592
|
-
//
|
|
4593
|
-
|
|
4594
|
-
//
|
|
4595
|
-
|
|
4596
|
-
|
|
4790
|
+
// Only processes state changes when the language actually changes
|
|
4791
|
+
// Example: With activeLang='en', ignores changes between 'en-US' and 'en-GB'
|
|
4792
|
+
// Checks: activeLang exists, has 2+ chars, and differs from current locale's primary language
|
|
4793
|
+
filter((state) => state?.activeLang !== null &&
|
|
4794
|
+
state?.activeLang !== undefined &&
|
|
4795
|
+
state?.activeLang.length > 1 &&
|
|
4796
|
+
state.activeLang.toLowerCase() !== this.stateInstance?.id.slice(0, 2).toLowerCase()),
|
|
4597
4797
|
// to check if registration of locale otherwise register it
|
|
4598
|
-
|
|
4599
|
-
// getLocaleId may throw Error(`Missing locale data for the locale "${locale}".`);
|
|
4600
|
-
switchMap((i18state) => {
|
|
4601
|
-
// check if activeLang is null or undefined
|
|
4602
|
-
if (!i18state.activeLang) {
|
|
4603
|
-
return throwError('Has i18nService initialized? If not make sure i18nService.init().subscribe(..)');
|
|
4604
|
-
}
|
|
4605
|
-
return of(this.localeMapper(i18state.activeLang));
|
|
4606
|
-
}), catchError((error) => {
|
|
4607
|
-
if (this.log) {
|
|
4608
|
-
this.logger.debug(error);
|
|
4609
|
-
}
|
|
4610
|
-
return this.loadLocale(value?.activeLang).pipe(filter((s) => s.success), map(() => this.localeMapper(value?.activeLang)), catchError((e) => {
|
|
4611
|
-
if (this.log) {
|
|
4612
|
-
this.logger.debug('Something went terribly really wrong during locale loading', e.err.message);
|
|
4613
|
-
}
|
|
4614
|
-
return of(e);
|
|
4615
|
-
}));
|
|
4616
|
-
}))),
|
|
4798
|
+
map((state) => this.localeMapper(state.activeLang)),
|
|
4617
4799
|
// update the "available" array attribute with newly registered
|
|
4618
4800
|
switchMap((id) => this.getState().pipe(take(1), map((state) => {
|
|
4619
4801
|
const available = state['available'] ? state['available'] : [];
|
|
4620
4802
|
return { ...state, id, available: Array.from(new Set([...available, id])) };
|
|
4621
4803
|
}))))
|
|
4622
4804
|
.subscribe((state) => {
|
|
4623
|
-
this.updateState(state);
|
|
4805
|
+
return this.updateState(state);
|
|
4624
4806
|
});
|
|
4625
4807
|
}
|
|
4626
4808
|
}
|
|
4627
|
-
/**
|
|
4628
|
-
* Retrieves an array of locale identifiers supported by the browser.
|
|
4629
|
-
*
|
|
4630
|
-
* @returns {string[] | undefined} - An array of browser locale identifiers or undefined if not available.
|
|
4631
|
-
* @private
|
|
4632
|
-
*/
|
|
4633
|
-
getBrowserLocales() {
|
|
4634
|
-
const browserLocales = navigator.languages === undefined ? [navigator.language] : navigator.languages;
|
|
4635
|
-
if (!browserLocales) {
|
|
4636
|
-
return undefined;
|
|
4637
|
-
}
|
|
4638
|
-
return browserLocales.map((locale) => locale.trim());
|
|
4639
|
-
}
|
|
4640
4809
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LocaleService, deps: [{ token: StoreService }, { token: GLOBAL_CONFIG_TOKEN }, { token: LOCALE_ID }, { token: LOCALE_ID_MAPPER, optional: true }, { token: I18nService, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4641
4810
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
|
|
4642
4811
|
}
|
|
@@ -4994,49 +5163,68 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
4994
5163
|
}] });
|
|
4995
5164
|
|
|
4996
5165
|
class UserService extends EuiService {
|
|
5166
|
+
static { this.DEFAULT_STATE = { userId: 'annonymous' }; }
|
|
4997
5167
|
constructor(store) {
|
|
4998
|
-
super(
|
|
5168
|
+
super(UserService.DEFAULT_STATE);
|
|
4999
5169
|
this.store = store;
|
|
5170
|
+
/**
|
|
5171
|
+
* a single signal holding the state - initial state is null
|
|
5172
|
+
*/
|
|
5173
|
+
this.state = signal(UserService.DEFAULT_STATE);
|
|
5174
|
+
this.injector = inject(Injector);
|
|
5000
5175
|
}
|
|
5001
|
-
init(
|
|
5176
|
+
init(state) {
|
|
5002
5177
|
super.initEuiService();
|
|
5003
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
5004
|
-
this.updateState(
|
|
5005
|
-
return of({ success: true });
|
|
5178
|
+
if (Object.prototype.hasOwnProperty.call(state, 'userId')) {
|
|
5179
|
+
this.updateState(state);
|
|
5180
|
+
return of$1({ success: true });
|
|
5006
5181
|
}
|
|
5007
|
-
return of({ success: false, error: 'Init object should be instance of BaseUserState' });
|
|
5182
|
+
return of$1({ success: false, error: 'Init object should be instance of BaseUserState' });
|
|
5008
5183
|
}
|
|
5009
5184
|
getState(keyOrMapFn) {
|
|
5010
|
-
let
|
|
5011
|
-
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
5185
|
+
let computedState = computed(() => this.state());
|
|
5012
5186
|
if (keyOrMapFn) {
|
|
5013
5187
|
switch (typeof keyOrMapFn) {
|
|
5014
5188
|
case 'function':
|
|
5015
|
-
|
|
5189
|
+
computedState = computed(() => {
|
|
5190
|
+
const state = this.state();
|
|
5191
|
+
return keyOrMapFn(state);
|
|
5192
|
+
});
|
|
5016
5193
|
break;
|
|
5017
5194
|
case 'string':
|
|
5018
|
-
|
|
5195
|
+
computedState = computed(() => {
|
|
5196
|
+
const state = this.state();
|
|
5197
|
+
const keys = keyOrMapFn.split('.');
|
|
5198
|
+
// Traverse the object based on the dot notation
|
|
5199
|
+
return keys.reduce((acc, currKey) => {
|
|
5200
|
+
return acc && acc[currKey] !== undefined ? acc[currKey] : undefined;
|
|
5201
|
+
}, state);
|
|
5202
|
+
});
|
|
5019
5203
|
break;
|
|
5020
5204
|
}
|
|
5021
5205
|
}
|
|
5022
|
-
|
|
5206
|
+
// Use `runInInjectionContext` to ensure `toObservable` is within Angular injection context
|
|
5207
|
+
return runInInjectionContext(this.injector, () => toObservable(computedState).pipe(distinctUntilChanged((x, y) => isEqual(x, y))));
|
|
5023
5208
|
}
|
|
5024
|
-
updateState(
|
|
5025
|
-
// if (typeof pathOrReducer === 'string') {
|
|
5026
|
-
// let dotNotationToObject = (obj, key) => key.split('.').reduce((obj, i) => obj[i], obj);
|
|
5027
|
-
//
|
|
5028
|
-
// const customReducer = (state: UserState, action: UpdateUserDetailsAction): UserState => {
|
|
5029
|
-
// return Object.assign({}, dotNotationToObject(state, pathOrReducer), action.payload);
|
|
5030
|
-
// };
|
|
5031
|
-
// this.store.dispatchAction(userState, 'user', customReducer);
|
|
5032
|
-
// }
|
|
5209
|
+
updateState(state, reducer) {
|
|
5033
5210
|
if (reducer) {
|
|
5034
|
-
this.
|
|
5211
|
+
this.state.update(currentState => {
|
|
5212
|
+
const newState = reducer(currentState, state);
|
|
5213
|
+
return {
|
|
5214
|
+
...newState,
|
|
5215
|
+
};
|
|
5216
|
+
});
|
|
5035
5217
|
}
|
|
5036
5218
|
else {
|
|
5037
|
-
this.
|
|
5219
|
+
this.state.update(currentState => this.deepMerge(currentState, { ...state }));
|
|
5038
5220
|
}
|
|
5039
5221
|
}
|
|
5222
|
+
/**
|
|
5223
|
+
* This method is used to get the signal of the service.
|
|
5224
|
+
*/
|
|
5225
|
+
getSignal() {
|
|
5226
|
+
return this.state.asReadonly();
|
|
5227
|
+
}
|
|
5040
5228
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5041
5229
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: UserService, providedIn: 'root' }); }
|
|
5042
5230
|
}
|
|
@@ -5092,12 +5280,12 @@ class AddLangParamInterceptor {
|
|
|
5092
5280
|
params: req.params.set(langParam, langValue),
|
|
5093
5281
|
}));
|
|
5094
5282
|
}
|
|
5095
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$
|
|
5283
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$3.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5096
5284
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: AddLangParamInterceptor }); }
|
|
5097
5285
|
}
|
|
5098
5286
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
|
|
5099
5287
|
type: Injectable
|
|
5100
|
-
}], ctorParameters: () => [{ type: i1$
|
|
5288
|
+
}], ctorParameters: () => [{ type: i1$3.TranslateService }] });
|
|
5101
5289
|
|
|
5102
5290
|
class CachePreventionInterceptor {
|
|
5103
5291
|
intercept(req, next) {
|
|
@@ -5250,5 +5438,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
|
|
|
5250
5438
|
* Generated bundle index. Do not edit.
|
|
5251
5439
|
*/
|
|
5252
5440
|
|
|
5253
|
-
export { ActivatedRouteAction, AddApiQueueItemAction, AddAppLoadedConfigModulesAction, AddLangParamInterceptor, AlertHttpErrorCallbackFn, ApiQueueService, ApiQueueServiceMock, AsyncStorageService, AsyncStorageServiceMock, BASE_LOGGER_NAME_TOKEN, BASE_NAME_TOKEN, BrowserStorageType, CONFIG_TOKEN, CORE_ROOT_GUARD, CachePreventionInterceptor, ConsoleHttpErrorCallbackFn, CoreAppActionTypes,
|
|
5441
|
+
export { ActivatedRouteAction, AddApiQueueItemAction, AddAppLoadedConfigModulesAction, AddLangParamInterceptor, AlertHttpErrorCallbackFn, ApiQueueService, ApiQueueServiceMock, AsyncStorageService, AsyncStorageServiceMock, BASE_LOGGER_NAME_TOKEN, BASE_NAME_TOKEN, BrowserStorageType, CONFIG_TOKEN, CORE_ROOT_GUARD, CachePreventionInterceptor, ConsoleHttpErrorCallbackFn, CoreAppActionTypes, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, CssUtils, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiLoaderService, EuiPermissionService, EuiTheme, EuiThemeService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, InitStoreAction, LANG_PARAM_KEY, LOCALE_ID_MAPPER, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, LOG_APPENDERS_TOKEN, LOG_LEVEL_TOKEN, LocalForageService, LocalStorageService, LocaleService, LocaleServiceMock, LogHttpErrorCallbackFn, LogModule, LogService, LogServiceMock, MODULE_CONFIG_TOKEN, MODULE_NAME_TOKEN, PLATFORM_BROWSER_ID, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, Status, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_ERROR_MAPPING_HANDLER_TOKEN, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxRequestErrorModelInterceptor, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, euiInitApp, formatNumber, getGlobalConfig, getHttpErrorHandlingConfig, getModuleConfig, getRootLogConfig, getShowConnectionStatus, getViewElement, handleError, isDefined, loadEuiDynamicEnvironmentConfig, loadState, localForage, localStorageSync, markControlsTouched, markFormGroupTouched, mergeAppHandlerConfigToAppConfig, mergeAppJsonConfigToAppConfig, offset, parentOffsetEl, position, preInitApp, prepareEuiAppConfigToken, provideEuiInitializer, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail };
|
|
5254
5442
|
//# sourceMappingURL=eui-core.mjs.map
|