@eui/core 16.2.4 → 16.2.5-snapshot-1698024715233
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/ApiQueueServiceMock.html +1 -5
- package/docs/classes/I18nResourceImpl.html +2 -0
- package/docs/classes/LogServiceMock.html +1 -1
- package/docs/classes/RouterMock.html +1 -14
- package/docs/classes/StorageServiceMock.html +0 -9
- package/docs/classes/StoreMock.html +4 -17
- package/docs/classes/UxRootInjectorGuard.html +2 -2
- package/docs/dependencies.html +2 -2
- package/docs/injectables/ApiQueueService.html +2 -10
- package/docs/injectables/CoreAppEffects.html +10 -10
- package/docs/injectables/I18nService.html +66 -0
- package/docs/injectables/LogService.html +1 -2
- package/docs/injectables/StoreService.html +8 -8
- package/docs/injectables/StoreServiceMock.html +5 -5
- package/docs/injectables/UserService.html +2 -2
- package/docs/injectables/UserServiceMock.html +217 -136
- package/docs/injectables/UxAppShellService.html +1 -1
- package/docs/injectables/UxDynamicComponentService.html +1 -1
- package/docs/injectables/UxDynamicMenuService.html +2 -2
- package/docs/interceptors/AddLangParamInterceptor.html +11 -3
- package/docs/interceptors/CachePreventionInterceptor.html +11 -3
- package/docs/interceptors/CorsSecurityInterceptor.html +11 -3
- package/docs/interceptors/CsrfPreventionInterceptor.html +11 -3
- package/docs/interceptors/EuLoginSessionTimeoutHandlingInterceptor.html +11 -3
- package/docs/interfaces/UIState.html +6 -6
- package/docs/js/menu-wc.js +6 -6
- package/docs/js/search/search_index.js +2 -2
- package/docs/miscellaneous/functions.html +42 -0
- package/docs/miscellaneous/variables.html +49 -49
- package/docs/modules/I18nModule.html +1 -1
- package/esm2022/lib/eui-core.module.mjs +3 -3
- package/esm2022/lib/helpers/date-helpers.mjs +1 -1
- package/esm2022/lib/helpers/dom-helpers.mjs +10 -8
- package/esm2022/lib/helpers/event-helpers.mjs +1 -1
- package/esm2022/lib/helpers/form-helpers.mjs +1 -1
- package/esm2022/lib/helpers/format-helpers.mjs +6 -5
- package/esm2022/lib/helpers/http-helpers.mjs +3 -5
- package/esm2022/lib/interceptors/add-lang-param.interceptor.mjs +1 -1
- package/esm2022/lib/interceptors/cache-prevention.interceptor.mjs +1 -1
- package/esm2022/lib/interceptors/cors-security.interceptor.mjs +1 -1
- package/esm2022/lib/interceptors/csrf-prevention.interceptor.mjs +1 -1
- package/esm2022/lib/interceptors/eu-login-session-timeout-handling.interceptor.mjs +10 -3
- package/esm2022/lib/interceptors/openid/openid-connect.interceptor.mjs +34 -5
- package/esm2022/lib/interceptors/openid/openid-connect.service.mjs +3 -1
- package/esm2022/lib/interceptors/ux-request-error-model.interceptor.mjs +7 -2
- package/esm2022/lib/services/app/eui-init-app.mjs +2 -2
- package/esm2022/lib/services/app/eui-pre-init-app.mjs +1 -1
- package/esm2022/lib/services/app/factories/log.mjs +1 -1
- package/esm2022/lib/services/config/tokens.mjs +3 -1
- package/esm2022/lib/services/errors/eui.error.mjs +5 -1
- package/esm2022/lib/services/errors/global-error-handler.mjs +4 -2
- package/esm2022/lib/services/errors/http-error-handler-callback-functions.mjs +2 -2
- package/esm2022/lib/services/errors/http-error-handler.interceptor.mjs +21 -14
- package/esm2022/lib/services/i18n/i18n.loader.mjs +13 -2
- package/esm2022/lib/services/i18n/i18n.resource.mjs +8 -3
- package/esm2022/lib/services/i18n/i18n.service.mjs +14 -16
- package/esm2022/lib/services/i18n/index.mjs +2 -2
- package/esm2022/lib/services/locale/locale.service.mjs +4 -2
- package/esm2022/lib/services/log/log.service.mjs +1 -1
- package/esm2022/lib/services/log/log.service.mock.mjs +1 -1
- package/esm2022/lib/services/permission/permission.service.mjs +2 -2
- package/esm2022/lib/services/queue/api-queue.service.mjs +17 -5
- package/esm2022/lib/services/queue/api-queue.service.mock.mjs +5 -1
- package/esm2022/lib/services/storage/async-storage.service.mjs +1 -1
- package/esm2022/lib/services/storage/async-storage.service.mock.mjs +9 -1
- package/esm2022/lib/services/storage/local-forage.service.mjs +40 -15
- package/esm2022/lib/services/storage/local-storage.service.mjs +5 -1
- package/esm2022/lib/services/storage/session-storage.service.mjs +5 -1
- package/esm2022/lib/services/storage/storage.service.mjs +1 -1
- package/esm2022/lib/services/storage/storage.service.mock.mjs +1 -1
- package/esm2022/lib/services/store/actions/app.actions.mjs +3 -1
- package/esm2022/lib/services/store/actions/notifications.actions.mjs +3 -1
- package/esm2022/lib/services/store/actions/user.actions.mjs +3 -1
- package/esm2022/lib/services/store/effects/app.effects.mjs +3 -3
- package/esm2022/lib/services/store/reducers/app.reducers.mjs +2 -3
- package/esm2022/lib/services/store/reducers/core.reducers.mjs +3 -1
- package/esm2022/lib/services/store/reducers/i18n.reducers.mjs +2 -2
- package/esm2022/lib/services/store/reducers/locale.reducers.mjs +1 -1
- package/esm2022/lib/services/store/reducers/meta.reducers.mjs +4 -2
- package/esm2022/lib/services/store/reducers/notifications.reducers.mjs +2 -2
- package/esm2022/lib/services/store/reducers/user.reducers.mjs +2 -2
- package/esm2022/lib/services/store/store.service.mjs +11 -3
- package/esm2022/lib/services/store/store.service.mock.mjs +1 -1
- package/esm2022/lib/services/user/user.service.mjs +10 -4
- package/esm2022/lib/services/user/user.service.mock.mjs +8 -14
- package/esm2022/lib/services/ux-app-shell.service.mjs +18 -10
- package/esm2022/lib/services/ux-dynamic-component/ux-dynamic-component.service.mjs +6 -1
- package/esm2022/lib/services/ux-dynamic-menu/ux-dynamic-menu.service.mjs +5 -2
- package/esm2022/lib/services/ux-error-feedback/ux-error-feedback.service.mjs +1 -1
- package/esm2022/lib/services/ux-error-feedback/ux-error-handler.operator.mjs +1 -1
- package/fesm2022/eui-core.mjs +601 -467
- package/fesm2022/eui-core.mjs.map +1 -1
- package/lib/eui-core.module.d.ts +1 -1
- package/lib/eui-core.module.d.ts.map +1 -1
- package/lib/helpers/date-helpers.d.ts.map +1 -1
- package/lib/helpers/dom-helpers.d.ts +9 -7
- package/lib/helpers/dom-helpers.d.ts.map +1 -1
- package/lib/helpers/event-helpers.d.ts.map +1 -1
- package/lib/helpers/form-helpers.d.ts.map +1 -1
- package/lib/helpers/format-helpers.d.ts.map +1 -1
- package/lib/helpers/http-helpers.d.ts +2 -1
- package/lib/helpers/http-helpers.d.ts.map +1 -1
- package/lib/interceptors/add-lang-param.interceptor.d.ts +1 -1
- package/lib/interceptors/add-lang-param.interceptor.d.ts.map +1 -1
- package/lib/interceptors/cache-prevention.interceptor.d.ts +1 -1
- package/lib/interceptors/cache-prevention.interceptor.d.ts.map +1 -1
- package/lib/interceptors/cors-security.interceptor.d.ts +1 -1
- package/lib/interceptors/cors-security.interceptor.d.ts.map +1 -1
- package/lib/interceptors/csrf-prevention.interceptor.d.ts +1 -1
- package/lib/interceptors/csrf-prevention.interceptor.d.ts.map +1 -1
- package/lib/interceptors/eu-login-session-timeout-handling.interceptor.d.ts +1 -1
- package/lib/interceptors/eu-login-session-timeout-handling.interceptor.d.ts.map +1 -1
- package/lib/interceptors/openid/openid-connect.interceptor.d.ts.map +1 -1
- package/lib/interceptors/openid/openid-connect.service.d.ts.map +1 -1
- package/lib/interceptors/ux-request-error-model.interceptor.d.ts +1 -1
- package/lib/interceptors/ux-request-error-model.interceptor.d.ts.map +1 -1
- package/lib/services/app/eui-init-app.d.ts +1 -1
- package/lib/services/app/eui-init-app.d.ts.map +1 -1
- package/lib/services/config/tokens.d.ts +2 -2
- package/lib/services/config/tokens.d.ts.map +1 -1
- package/lib/services/errors/eui.error.d.ts.map +1 -1
- package/lib/services/errors/global-error-handler.d.ts +1 -1
- package/lib/services/errors/global-error-handler.d.ts.map +1 -1
- package/lib/services/errors/http-error-handler-callback-functions.d.ts.map +1 -1
- package/lib/services/errors/http-error-handler.interceptor.d.ts.map +1 -1
- package/lib/services/i18n/i18n.loader.d.ts.map +1 -1
- package/lib/services/i18n/i18n.resource.d.ts +1 -1
- package/lib/services/i18n/i18n.resource.d.ts.map +1 -1
- package/lib/services/i18n/i18n.service.d.ts +4 -4
- package/lib/services/i18n/i18n.service.d.ts.map +1 -1
- package/lib/services/i18n/index.d.ts +0 -1
- package/lib/services/i18n/index.d.ts.map +1 -1
- package/lib/services/locale/locale.service.d.ts.map +1 -1
- package/lib/services/log/log.service.d.ts.map +1 -1
- package/lib/services/log/log.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 +2 -2
- package/lib/services/queue/api-queue.service.d.ts.map +1 -1
- package/lib/services/queue/api-queue.service.mock.d.ts.map +1 -1
- package/lib/services/storage/async-storage.service.d.ts.map +1 -1
- package/lib/services/storage/async-storage.service.mock.d.ts.map +1 -1
- package/lib/services/storage/local-forage.service.d.ts +1 -1
- package/lib/services/storage/local-forage.service.d.ts.map +1 -1
- package/lib/services/storage/local-storage.service.d.ts.map +1 -1
- package/lib/services/storage/session-storage.service.d.ts.map +1 -1
- package/lib/services/storage/storage.service.d.ts.map +1 -1
- package/lib/services/storage/storage.service.mock.d.ts +1 -1
- package/lib/services/storage/storage.service.mock.d.ts.map +1 -1
- package/lib/services/store/actions/app.actions.d.ts.map +1 -1
- package/lib/services/store/actions/notifications.actions.d.ts.map +1 -1
- package/lib/services/store/actions/user.actions.d.ts.map +1 -1
- package/lib/services/store/reducers/app.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/core.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/meta.reducers.d.ts +2 -2
- package/lib/services/store/reducers/meta.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/user.reducers.d.ts.map +1 -1
- package/lib/services/store/store.service.d.ts +8 -8
- package/lib/services/store/store.service.d.ts.map +1 -1
- package/lib/services/store/store.service.mock.d.ts +2 -1
- package/lib/services/store/store.service.mock.d.ts.map +1 -1
- package/lib/services/user/user.service.d.ts +3 -3
- package/lib/services/user/user.service.d.ts.map +1 -1
- package/lib/services/user/user.service.mock.d.ts +10 -12
- package/lib/services/user/user.service.mock.d.ts.map +1 -1
- package/lib/services/ux-app-shell.service.d.ts +5 -5
- package/lib/services/ux-app-shell.service.d.ts.map +1 -1
- package/lib/services/ux-dynamic-component/ux-dynamic-component.service.d.ts +3 -7
- package/lib/services/ux-dynamic-component/ux-dynamic-component.service.d.ts.map +1 -1
- package/lib/services/ux-dynamic-menu/ux-dynamic-menu.service.d.ts +6 -6
- package/lib/services/ux-dynamic-menu/ux-dynamic-menu.service.d.ts.map +1 -1
- package/lib/services/ux-error-feedback/ux-error-feedback.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/esm2022/lib/services/i18n/i18n.service.mock.mjs +0 -38
- package/lib/services/i18n/i18n.service.mock.d.ts +0 -20
- package/lib/services/i18n/i18n.service.mock.d.ts.map +0 -1
package/fesm2022/eui-core.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import * as i1 from '@eui/base';
|
|
2
|
-
import { LogLevel, ConsoleAppender, Logger,
|
|
2
|
+
import { LogLevel, ConsoleAppender, Logger, mergeAll, getI18nLoaderConfig, LoggerMock, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, UxEuLanguages, getActiveLang, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, xhr, getApiQueue, getApiQueueItem, EuiService, getUserRights, getUserState, UxPublishErrorFeedbackEvent, UxClearErrorFeedbackEvent, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
|
|
3
3
|
export * from '@eui/base';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { InjectionToken, Injectable, Inject, Injector, NgModule,
|
|
5
|
+
import { InjectionToken, Injectable, Inject, Optional, Injector, NgModule, PLATFORM_ID, APP_INITIALIZER, SkipSelf, ErrorHandler, LOCALE_ID } from '@angular/core';
|
|
6
6
|
import * as extendProxy from 'extend';
|
|
7
|
-
import
|
|
8
|
-
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
|
9
|
-
import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
|
|
10
|
-
import { throwError, forkJoin, of, BehaviorSubject, defer, merge, fromEvent, Observable, Subject, from } from 'rxjs';
|
|
11
|
-
import { debounceTime, distinctUntilChanged, map, catchError, switchMap, tap, filter, take, mapTo, mergeMap, concatMap, takeUntil, finalize } from 'rxjs/operators';
|
|
12
|
-
import * as i1$1 from '@ngrx/store';
|
|
13
|
-
import { createSelector } from '@ngrx/store';
|
|
14
|
-
import * as i1$3 from '@ngrx/effects';
|
|
7
|
+
import * as i1$2 from '@ngrx/effects';
|
|
15
8
|
import { createEffect, ofType } from '@ngrx/effects';
|
|
9
|
+
import { forkJoin, of, BehaviorSubject, defer, firstValueFrom, merge, fromEvent, throwError, Observable, Subject, from } from 'rxjs';
|
|
10
|
+
import { map, catchError, switchMap, tap, filter, take, distinctUntilChanged, mapTo, mergeMap, debounceTime, concatMap, takeUntil, finalize } from 'rxjs/operators';
|
|
16
11
|
import * as i2 from '@ngx-translate/core';
|
|
17
12
|
import { TranslateLoader } from '@ngx-translate/core';
|
|
13
|
+
import { DOCUMENT, isPlatformBrowser, LOCATION_INITIALIZED, getLocaleId, registerLocaleData } from '@angular/common';
|
|
18
14
|
import * as i2$1 from '@angular/router';
|
|
19
15
|
import { NavigationEnd } from '@angular/router';
|
|
20
16
|
import isEqual from 'lodash-es/isEqual';
|
|
21
17
|
import get from 'lodash-es/get';
|
|
22
|
-
import * as i1$
|
|
18
|
+
import * as i1$1 from '@angular/common/http';
|
|
23
19
|
import { HttpErrorResponse, HttpResponse, HttpHeaders, HttpEventType } from '@angular/common/http';
|
|
20
|
+
import * as i1$3 from '@ngrx/store';
|
|
21
|
+
import { createSelector } from '@ngrx/store';
|
|
22
|
+
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
|
23
|
+
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
|
24
24
|
import { By } from '@angular/platform-browser';
|
|
25
25
|
import { FormGroup, FormArray } from '@angular/forms';
|
|
26
26
|
import { DomPortalOutlet, ComponentPortal, PortalInjector } from '@angular/cdk/portal';
|
|
@@ -95,6 +95,8 @@ const DEFAULT_EUI_CONFIG = {
|
|
|
95
95
|
},
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
100
|
const extend$1 = extendProxy.default || extendProxy;
|
|
99
101
|
const EUI_CONFIG_TOKEN = new InjectionToken('EuiConfig');
|
|
100
102
|
const MODULE_NAME_TOKEN = new InjectionToken('moduleName');
|
|
@@ -166,106 +168,6 @@ function mergeAppJsonConfigToAppConfig(euiAppConfig, envAppJsonConfig, merge, is
|
|
|
166
168
|
return Object.assign({}, euiAppConfig, envAppJsonConfig, deepMerged);
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
const BASE_LOGGER_NAME_TOKEN = new InjectionToken('BASE_LOGGER_NAME');
|
|
170
|
-
const LOG_LEVEL_TOKEN = new InjectionToken('LOG_LEVEL');
|
|
171
|
-
const LOG_APPENDERS_TOKEN = new InjectionToken('LOG_APPENDERS');
|
|
172
|
-
/**
|
|
173
|
-
* Log service, responsible for getting or creating loggers. It itself acts as a base logger
|
|
174
|
-
*/
|
|
175
|
-
class LogService extends Logger {
|
|
176
|
-
constructor(name, level, appenders) {
|
|
177
|
-
super(name, level, appenders);
|
|
178
|
-
this.name = name;
|
|
179
|
-
this.level = level;
|
|
180
|
-
this.appenders = appenders;
|
|
181
|
-
/** the list of persistent loggers */
|
|
182
|
-
this.loggers = {};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Gets a logger by name. If the logger does not exist, it is created
|
|
186
|
-
*
|
|
187
|
-
* @param loggerName logger name
|
|
188
|
-
* @param persist optional parameter. Set it to true if you want to reuse the logger. By default, it is set to false
|
|
189
|
-
* @returns the logger
|
|
190
|
-
*/
|
|
191
|
-
getLogger(loggerName, persist = false) {
|
|
192
|
-
// create the logger, if necessary
|
|
193
|
-
const logger = (persist && this.loggers[loggerName]) || new Logger(loggerName, this.level, this.appenders);
|
|
194
|
-
// if the logger is persistent, add it to the list of persistent loggers
|
|
195
|
-
if (persist) {
|
|
196
|
-
this.loggers[loggerName] = logger;
|
|
197
|
-
}
|
|
198
|
-
return logger;
|
|
199
|
-
}
|
|
200
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
201
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService }); }
|
|
202
|
-
}
|
|
203
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService, decorators: [{
|
|
204
|
-
type: Injectable
|
|
205
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
206
|
-
type: Inject,
|
|
207
|
-
args: [BASE_LOGGER_NAME_TOKEN]
|
|
208
|
-
}] }, { type: i1.LogLevel, decorators: [{
|
|
209
|
-
type: Inject,
|
|
210
|
-
args: [LOG_LEVEL_TOKEN]
|
|
211
|
-
}] }, { type: undefined, decorators: [{
|
|
212
|
-
type: Inject,
|
|
213
|
-
args: [LOG_APPENDERS_TOKEN]
|
|
214
|
-
}] }]; } });
|
|
215
|
-
|
|
216
|
-
const LOG_INSTANCES = {};
|
|
217
|
-
/**
|
|
218
|
-
* Helper function to check if the log config is defined.
|
|
219
|
-
* Does not check only for empty object, because the config can have other (non-log) parameters
|
|
220
|
-
* @params config log configuration
|
|
221
|
-
* @returns true/false
|
|
222
|
-
*/
|
|
223
|
-
function isLogConfigDefined(config) {
|
|
224
|
-
return config && ('baseLoggerName' in config || 'logLevel' in config || 'logAppenders' in config);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Helper function to provide a list of log appenders from a log configuration
|
|
228
|
-
*
|
|
229
|
-
* @params config log configuration
|
|
230
|
-
* @returns an array of log appenders
|
|
231
|
-
*/
|
|
232
|
-
function getLogAppendersConfig(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
233
|
-
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
234
|
-
config.logAppenders = config.logAppenders || [];
|
|
235
|
-
config.logAppenders = Array.isArray(config.logAppenders) ? config.logAppenders : [config.logAppenders];
|
|
236
|
-
return config.logAppenders.map((logAppender) => {
|
|
237
|
-
const appenderType = typeof logAppender === 'object' ? logAppender.type : logAppender;
|
|
238
|
-
const appenderParams = typeof logAppender === 'object' ? logAppender : undefined;
|
|
239
|
-
return new appenderType(appenderParams, injector);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Helper function to provide an instance of LogService from a configuration
|
|
244
|
-
*
|
|
245
|
-
* @params config log configuration
|
|
246
|
-
* @returns an instance of log service
|
|
247
|
-
*/
|
|
248
|
-
function logServiceFactory(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
249
|
-
// add the default values to config
|
|
250
|
-
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
251
|
-
// extract parameters from config
|
|
252
|
-
const logLevel = config.logLevel;
|
|
253
|
-
const logAppenders = getLogAppendersConfig(config, injector);
|
|
254
|
-
// return an instance of LogService
|
|
255
|
-
return new LogService(config.baseLoggerName, logLevel, logAppenders);
|
|
256
|
-
}
|
|
257
|
-
function euiLogServiceFactory(injector, rootBaseLoggerName, rootConfig, childBaseLoggerName = null, childConfig = {}) {
|
|
258
|
-
// determine if the configuration is for non-root modules
|
|
259
|
-
const forChild = isLogConfigDefined(childConfig);
|
|
260
|
-
const baseLoggerName = forChild ? childBaseLoggerName : rootBaseLoggerName;
|
|
261
|
-
// create the proper configuration
|
|
262
|
-
const config = Object.assign({ baseLoggerName }, forChild ? Object.assign({}, rootConfig, childConfig) : rootConfig);
|
|
263
|
-
// re-use the log service or create a new instance
|
|
264
|
-
const logService = LOG_INSTANCES[baseLoggerName] || logServiceFactory(config, injector);
|
|
265
|
-
LOG_INSTANCES[baseLoggerName] = logService;
|
|
266
|
-
return logService;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
171
|
var CoreAppActionTypes;
|
|
270
172
|
(function (CoreAppActionTypes) {
|
|
271
173
|
CoreAppActionTypes["INIT_STORE"] = "[App] Init store";
|
|
@@ -334,215 +236,14 @@ class RemoveApiQueueItemAction {
|
|
|
334
236
|
}
|
|
335
237
|
}
|
|
336
238
|
class EmptyApiQueueAction {
|
|
239
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
241
|
constructor(payload) {
|
|
338
242
|
this.payload = payload;
|
|
339
243
|
this.type = CoreAppActionTypes.EMPTY_API_QUEUE;
|
|
340
244
|
}
|
|
341
245
|
}
|
|
342
246
|
|
|
343
|
-
class LogServiceMock extends LoggerMock {
|
|
344
|
-
getLogger() {
|
|
345
|
-
return new LoggerMock();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const LOG_MODULE_CONFIG_TOKEN = new InjectionToken('LOG_CONFIG');
|
|
350
|
-
/**
|
|
351
|
-
* Log Module
|
|
352
|
-
*/
|
|
353
|
-
class LogModule {
|
|
354
|
-
/** method called in your root module to provide the LogService */
|
|
355
|
-
static forRoot(config = DEFAULT_LOG_CONFIG) {
|
|
356
|
-
return {
|
|
357
|
-
ngModule: LogModule,
|
|
358
|
-
providers: [
|
|
359
|
-
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
360
|
-
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
361
|
-
],
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
/** method called in your other (non root, lazy loaded) modules to import a different instance of LogService */
|
|
365
|
-
static forChild(config = DEFAULT_LOG_CONFIG) {
|
|
366
|
-
return {
|
|
367
|
-
ngModule: LogModule,
|
|
368
|
-
providers: [
|
|
369
|
-
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
370
|
-
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
371
|
-
],
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
375
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.10", ngImport: i0, type: LogModule }); }
|
|
376
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule }); }
|
|
377
|
-
}
|
|
378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule, decorators: [{
|
|
379
|
-
type: NgModule
|
|
380
|
-
}] });
|
|
381
|
-
|
|
382
|
-
var BrowserStorageType;
|
|
383
|
-
(function (BrowserStorageType) {
|
|
384
|
-
BrowserStorageType[BrowserStorageType["local"] = 0] = "local";
|
|
385
|
-
BrowserStorageType[BrowserStorageType["session"] = 1] = "session";
|
|
386
|
-
})(BrowserStorageType || (BrowserStorageType = {}));
|
|
387
|
-
// todo should stay here but all the store directory should be moved upper level
|
|
388
|
-
class StoreService {
|
|
389
|
-
constructor(store, logService) {
|
|
390
|
-
this.store = store;
|
|
391
|
-
this.logService = logService;
|
|
392
|
-
/**
|
|
393
|
-
* autoSave handlers to call before saving in local Storage
|
|
394
|
-
*/
|
|
395
|
-
this._autoSaveHandlers = {};
|
|
396
|
-
/** storage instance e.g. localStorage, sessionStorage */
|
|
397
|
-
this._storage = localStorage;
|
|
398
|
-
}
|
|
399
|
-
// use init with just version info, to update to user state, UserService.updateState
|
|
400
|
-
// initializeStore(version?: string, userDetails?: BaseUserDetails) {
|
|
401
|
-
// this.dispatch(new InitStoreAction({ version, userDetails }));
|
|
402
|
-
// }
|
|
403
|
-
init(version, storageType) {
|
|
404
|
-
this.dispatch(new InitStoreAction({ version }));
|
|
405
|
-
this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
|
|
406
|
-
}
|
|
407
|
-
addAutoSaveHandler(stateSlice, handler) {
|
|
408
|
-
if (!this.store) {
|
|
409
|
-
if (this.logService) {
|
|
410
|
-
this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
|
|
411
|
-
}
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
this._autoSaveHandlers[stateSlice] = handler;
|
|
415
|
-
}
|
|
416
|
-
handleAutoSave() {
|
|
417
|
-
if (!this.store) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
this.store.pipe(debounceTime(1000), distinctUntilChanged()).subscribe((state) => {
|
|
421
|
-
this.saveState(state);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Proxy to NGRX store.dispatch()
|
|
426
|
-
* that allows to intercept if the store is present
|
|
427
|
-
*/
|
|
428
|
-
dispatch(action) {
|
|
429
|
-
if (this.store) {
|
|
430
|
-
return this.store.dispatch(action);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
dispatchAction(state, actionKey, reducer) {
|
|
434
|
-
if (this.store) {
|
|
435
|
-
this.store.addReducer(actionKey, reducer);
|
|
436
|
-
return this.store.dispatch({ type: actionKey, payload: state });
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Proxy to NGRX store.select()
|
|
441
|
-
* that allows to intercept if the store is present
|
|
442
|
-
*/
|
|
443
|
-
select(key) {
|
|
444
|
-
if (!this.store) {
|
|
445
|
-
return throwError(() => new Error('NGRX Store not configured'));
|
|
446
|
-
}
|
|
447
|
-
return this.store.select(key);
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* filters and save the state with the Browser storage
|
|
451
|
-
* @param state type of CoreState
|
|
452
|
-
*/
|
|
453
|
-
saveState(state) {
|
|
454
|
-
let stateToSave = {
|
|
455
|
-
app: state.app,
|
|
456
|
-
};
|
|
457
|
-
if (state.user) {
|
|
458
|
-
const { userId, preferences } = state.user;
|
|
459
|
-
stateToSave.user = { userId, preferences };
|
|
460
|
-
}
|
|
461
|
-
Object.keys(this._autoSaveHandlers).forEach((sliceState) => {
|
|
462
|
-
const handler = this._autoSaveHandlers[sliceState];
|
|
463
|
-
stateToSave = Object.assign(stateToSave, { [sliceState]: handler(state[sliceState]) });
|
|
464
|
-
});
|
|
465
|
-
try {
|
|
466
|
-
const serializedState = JSON.stringify(stateToSave);
|
|
467
|
-
this._storage.setItem('state', serializedState);
|
|
468
|
-
}
|
|
469
|
-
catch (err) {
|
|
470
|
-
// Ignore write errors.
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, deps: [{ token: i1$1.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
474
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
475
|
-
}
|
|
476
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, decorators: [{
|
|
477
|
-
type: Injectable,
|
|
478
|
-
args: [{
|
|
479
|
-
providedIn: 'root',
|
|
480
|
-
}]
|
|
481
|
-
}], ctorParameters: function () { return [{ type: i1$1.Store, decorators: [{
|
|
482
|
-
type: Optional
|
|
483
|
-
}] }, { type: LogService, decorators: [{
|
|
484
|
-
type: Optional
|
|
485
|
-
}] }]; } });
|
|
486
|
-
|
|
487
|
-
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
488
|
-
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
489
|
-
locationInitialized.then(() => {
|
|
490
|
-
const appConfig = injector.get(CONFIG_TOKEN);
|
|
491
|
-
// necessary config parameters
|
|
492
|
-
let appVersion;
|
|
493
|
-
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
494
|
-
appVersion = appConfig.versions.app;
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
appVersion = '0.0.0';
|
|
498
|
-
}
|
|
499
|
-
let storageType;
|
|
500
|
-
if (appConfig && appConfig.saveStateStorage) {
|
|
501
|
-
storageType = appConfig.saveStateStorage;
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
storageType = BrowserStorageType.local;
|
|
505
|
-
}
|
|
506
|
-
const storeService = injector.get(StoreService);
|
|
507
|
-
storeService.init(appVersion, storageType);
|
|
508
|
-
storeService.handleAutoSave();
|
|
509
|
-
resolve(null);
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
function getCoreProviders() {
|
|
514
|
-
return [
|
|
515
|
-
// core config
|
|
516
|
-
...getDependencyProviders(),
|
|
517
|
-
{ provide: BASE_NAME_TOKEN, useValue: 'eui-core' },
|
|
518
|
-
// app config
|
|
519
|
-
{ provide: CONFIG_TOKEN, useFactory: prepareEuiAppConfigToken, deps: [EUI_CONFIG_TOKEN] },
|
|
520
|
-
// global config
|
|
521
|
-
{ provide: GLOBAL_CONFIG_TOKEN, useFactory: getGlobalConfig, deps: [CONFIG_TOKEN] },
|
|
522
|
-
{ provide: ROOT_LOG_CONFIG_TOKEN, useFactory: getRootLogConfig, deps: [CONFIG_TOKEN] },
|
|
523
|
-
{ provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
|
|
524
|
-
{ provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
|
|
525
|
-
{ provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
|
|
526
|
-
{ provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
|
|
527
|
-
];
|
|
528
|
-
}
|
|
529
|
-
function getDependencyProviders() {
|
|
530
|
-
return [{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] }];
|
|
531
|
-
}
|
|
532
|
-
function getCoreChildProviders(moduleName) {
|
|
533
|
-
return [
|
|
534
|
-
// module config
|
|
535
|
-
{ provide: MODULE_NAME_TOKEN, useValue: moduleName },
|
|
536
|
-
{ provide: MODULE_CONFIG_TOKEN, useFactory: getModuleConfig, deps: [CONFIG_TOKEN, MODULE_NAME_TOKEN] },
|
|
537
|
-
// log config
|
|
538
|
-
{
|
|
539
|
-
provide: LogService,
|
|
540
|
-
useFactory: euiLogServiceFactory,
|
|
541
|
-
deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN, MODULE_NAME_TOKEN, MODULE_CONFIG_TOKEN],
|
|
542
|
-
},
|
|
543
|
-
];
|
|
544
|
-
}
|
|
545
|
-
|
|
546
247
|
var CoreI18nActionTypes;
|
|
547
248
|
(function (CoreI18nActionTypes) {
|
|
548
249
|
CoreI18nActionTypes["UPDATE_I18N_STATE"] = "[I18n] Update I18n State";
|
|
@@ -587,6 +288,8 @@ class UpdateUserRightsAction {
|
|
|
587
288
|
}
|
|
588
289
|
}
|
|
589
290
|
class UpdateUserDashboardAction {
|
|
291
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
590
293
|
constructor(payload) {
|
|
591
294
|
this.payload = payload;
|
|
592
295
|
this.type = CoreUserActionTypes.UPDATE_USER_DASHBOARD;
|
|
@@ -598,6 +301,8 @@ var CoreNotificationsActionTypes;
|
|
|
598
301
|
CoreNotificationsActionTypes["UPDATE_NOTIFICATIONS_LIST"] = "[Notif] Update list";
|
|
599
302
|
})(CoreNotificationsActionTypes || (CoreNotificationsActionTypes = {}));
|
|
600
303
|
class UpdateNotificationsListAction {
|
|
304
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
601
306
|
constructor(payload) {
|
|
602
307
|
this.payload = payload;
|
|
603
308
|
this.type = CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST;
|
|
@@ -621,9 +326,12 @@ class I18nResourceImpl {
|
|
|
621
326
|
*
|
|
622
327
|
* @param prefix the prefix of the resource
|
|
623
328
|
* @param suffix the suffix of the resource, optional parameter
|
|
624
|
-
* @param
|
|
329
|
+
* @param compileTranslationsFn compiler function, optional parameter
|
|
625
330
|
*/
|
|
626
|
-
constructor(prefix, suffix = '',
|
|
331
|
+
constructor(prefix, suffix = '',
|
|
332
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
333
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-function-return-type
|
|
334
|
+
compileTranslationsFn = (translations) => translations) {
|
|
627
335
|
this.prefix = prefix;
|
|
628
336
|
this.suffix = suffix;
|
|
629
337
|
this.compileTranslationsFn = compileTranslationsFn;
|
|
@@ -635,6 +343,8 @@ class I18nResourceImpl {
|
|
|
635
343
|
* @param lang the translations language
|
|
636
344
|
* @returns the pre-processed translations
|
|
637
345
|
*/
|
|
346
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
638
348
|
compileTranslations(translations, lang) {
|
|
639
349
|
return this.compileTranslationsFn(translations, lang);
|
|
640
350
|
}
|
|
@@ -658,6 +368,53 @@ class I18nResourceImpl {
|
|
|
658
368
|
}
|
|
659
369
|
}
|
|
660
370
|
|
|
371
|
+
const BASE_LOGGER_NAME_TOKEN = new InjectionToken('BASE_LOGGER_NAME');
|
|
372
|
+
const LOG_LEVEL_TOKEN = new InjectionToken('LOG_LEVEL');
|
|
373
|
+
const LOG_APPENDERS_TOKEN = new InjectionToken('LOG_APPENDERS');
|
|
374
|
+
/**
|
|
375
|
+
* Log service, responsible for getting or creating loggers. It itself acts as a base logger
|
|
376
|
+
*/
|
|
377
|
+
class LogService extends Logger {
|
|
378
|
+
constructor(name, level, appenders) {
|
|
379
|
+
super(name, level, appenders);
|
|
380
|
+
this.name = name;
|
|
381
|
+
this.level = level;
|
|
382
|
+
this.appenders = appenders;
|
|
383
|
+
/** the list of persistent loggers */
|
|
384
|
+
this.loggers = {};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Gets a logger by name. If the logger does not exist, it is created
|
|
388
|
+
*
|
|
389
|
+
* @param loggerName logger name
|
|
390
|
+
* @param persist optional parameter. Set it to true if you want to reuse the logger. By default, it is set to false
|
|
391
|
+
* @returns the logger
|
|
392
|
+
*/
|
|
393
|
+
getLogger(loggerName, persist = false) {
|
|
394
|
+
// create the logger, if necessary
|
|
395
|
+
const logger = (persist && this.loggers[loggerName]) || new Logger(loggerName, this.level, this.appenders);
|
|
396
|
+
// if the logger is persistent, add it to the list of persistent loggers
|
|
397
|
+
if (persist) {
|
|
398
|
+
this.loggers[loggerName] = logger;
|
|
399
|
+
}
|
|
400
|
+
return logger;
|
|
401
|
+
}
|
|
402
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
403
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService }); }
|
|
404
|
+
}
|
|
405
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogService, decorators: [{
|
|
406
|
+
type: Injectable
|
|
407
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
408
|
+
type: Inject,
|
|
409
|
+
args: [BASE_LOGGER_NAME_TOKEN]
|
|
410
|
+
}] }, { type: i1.LogLevel, decorators: [{
|
|
411
|
+
type: Inject,
|
|
412
|
+
args: [LOG_LEVEL_TOKEN]
|
|
413
|
+
}] }, { type: undefined, decorators: [{
|
|
414
|
+
type: Inject,
|
|
415
|
+
args: [LOG_APPENDERS_TOKEN]
|
|
416
|
+
}] }]; } });
|
|
417
|
+
|
|
661
418
|
class I18nLoader {
|
|
662
419
|
constructor(http, logService, euiAppConfig) {
|
|
663
420
|
this.http = http;
|
|
@@ -676,6 +433,8 @@ class I18nLoader {
|
|
|
676
433
|
* @param lang
|
|
677
434
|
* @returns Observable<any>
|
|
678
435
|
*/
|
|
436
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
679
438
|
getTranslation(lang) {
|
|
680
439
|
return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
|
|
681
440
|
this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
|
|
@@ -711,6 +470,8 @@ class I18nLoader {
|
|
|
711
470
|
* @param lang the resource language to load
|
|
712
471
|
* @returns Observable<any>
|
|
713
472
|
*/
|
|
473
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
474
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
714
475
|
loadResources(resources, lang) {
|
|
715
476
|
// if there are resources to load
|
|
716
477
|
if (Array.isArray(resources) && resources.length > 0) {
|
|
@@ -796,13 +557,20 @@ class I18nLoader {
|
|
|
796
557
|
* @param lang the resource language to load
|
|
797
558
|
* @returns Observable<any>
|
|
798
559
|
*/
|
|
560
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
561
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
799
562
|
loadResource(resource, lang) {
|
|
800
563
|
// the path to the resource
|
|
801
564
|
const path = resource.getPath(lang);
|
|
802
565
|
// load the translations from the path
|
|
803
566
|
return this.http.get(path).pipe(
|
|
804
567
|
// preprocess the translations using the resource compiler
|
|
805
|
-
|
|
568
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
569
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
570
|
+
map((translations) => resource.compileTranslations(translations, lang)),
|
|
571
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
572
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
573
|
+
map((translations) => {
|
|
806
574
|
// resource loaded properly, send a info message
|
|
807
575
|
if (this.logService) {
|
|
808
576
|
this.logService.info(`I18n resource loaded from path ${path}`);
|
|
@@ -820,30 +588,122 @@ class I18nLoader {
|
|
|
820
588
|
return of(resourceError);
|
|
821
589
|
}));
|
|
822
590
|
}
|
|
823
|
-
getResourceCompileFunction(id) {
|
|
824
|
-
const customHandlers = this.euiAppConfig.customHandler;
|
|
825
|
-
if (customHandlers && typeof customHandlers[id] === 'function') {
|
|
826
|
-
return customHandlers[id];
|
|
827
|
-
}
|
|
828
|
-
return undefined;
|
|
591
|
+
getResourceCompileFunction(id) {
|
|
592
|
+
const customHandlers = this.euiAppConfig.customHandler;
|
|
593
|
+
if (customHandlers && typeof customHandlers[id] === 'function') {
|
|
594
|
+
return customHandlers[id];
|
|
595
|
+
}
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nLoader, deps: [{ token: i1$1.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
599
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nLoader }); }
|
|
600
|
+
}
|
|
601
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nLoader, decorators: [{
|
|
602
|
+
type: Injectable
|
|
603
|
+
}], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: LogService, decorators: [{
|
|
604
|
+
type: Optional
|
|
605
|
+
}] }, { type: undefined, decorators: [{
|
|
606
|
+
type: Inject,
|
|
607
|
+
args: [CONFIG_TOKEN]
|
|
608
|
+
}] }]; } });
|
|
609
|
+
const translateConfig = {
|
|
610
|
+
loader: {
|
|
611
|
+
provide: TranslateLoader,
|
|
612
|
+
useClass: I18nLoader,
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
class LogServiceMock extends LoggerMock {
|
|
617
|
+
getLogger() {
|
|
618
|
+
return new LoggerMock();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const LOG_INSTANCES = {};
|
|
623
|
+
/**
|
|
624
|
+
* Helper function to check if the log config is defined.
|
|
625
|
+
* Does not check only for empty object, because the config can have other (non-log) parameters
|
|
626
|
+
* @params config log configuration
|
|
627
|
+
* @returns true/false
|
|
628
|
+
*/
|
|
629
|
+
function isLogConfigDefined(config) {
|
|
630
|
+
return config && ('baseLoggerName' in config || 'logLevel' in config || 'logAppenders' in config);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Helper function to provide a list of log appenders from a log configuration
|
|
634
|
+
*
|
|
635
|
+
* @params config log configuration
|
|
636
|
+
* @returns an array of log appenders
|
|
637
|
+
*/
|
|
638
|
+
function getLogAppendersConfig(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
639
|
+
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
640
|
+
config.logAppenders = config.logAppenders || [];
|
|
641
|
+
config.logAppenders = Array.isArray(config.logAppenders) ? config.logAppenders : [config.logAppenders];
|
|
642
|
+
return config.logAppenders.map((logAppender) => {
|
|
643
|
+
const appenderType = typeof logAppender === 'object' ? logAppender.type : logAppender;
|
|
644
|
+
const appenderParams = typeof logAppender === 'object' ? logAppender : undefined;
|
|
645
|
+
return new appenderType(appenderParams, injector);
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Helper function to provide an instance of LogService from a configuration
|
|
650
|
+
*
|
|
651
|
+
* @params config log configuration
|
|
652
|
+
* @returns an instance of log service
|
|
653
|
+
*/
|
|
654
|
+
function logServiceFactory(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
655
|
+
// add the default values to config
|
|
656
|
+
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
657
|
+
// extract parameters from config
|
|
658
|
+
const logLevel = config.logLevel;
|
|
659
|
+
const logAppenders = getLogAppendersConfig(config, injector);
|
|
660
|
+
// return an instance of LogService
|
|
661
|
+
return new LogService(config.baseLoggerName, logLevel, logAppenders);
|
|
662
|
+
}
|
|
663
|
+
function euiLogServiceFactory(injector, rootBaseLoggerName, rootConfig, childBaseLoggerName = null, childConfig = {}) {
|
|
664
|
+
// determine if the configuration is for non-root modules
|
|
665
|
+
const forChild = isLogConfigDefined(childConfig);
|
|
666
|
+
const baseLoggerName = forChild ? childBaseLoggerName : rootBaseLoggerName;
|
|
667
|
+
// create the proper configuration
|
|
668
|
+
const config = Object.assign({ baseLoggerName }, forChild ? Object.assign({}, rootConfig, childConfig) : rootConfig);
|
|
669
|
+
// re-use the log service or create a new instance
|
|
670
|
+
const logService = LOG_INSTANCES[baseLoggerName] || logServiceFactory(config, injector);
|
|
671
|
+
LOG_INSTANCES[baseLoggerName] = logService;
|
|
672
|
+
return logService;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const LOG_MODULE_CONFIG_TOKEN = new InjectionToken('LOG_CONFIG');
|
|
676
|
+
/**
|
|
677
|
+
* Log Module
|
|
678
|
+
*/
|
|
679
|
+
class LogModule {
|
|
680
|
+
/** method called in your root module to provide the LogService */
|
|
681
|
+
static forRoot(config = DEFAULT_LOG_CONFIG) {
|
|
682
|
+
return {
|
|
683
|
+
ngModule: LogModule,
|
|
684
|
+
providers: [
|
|
685
|
+
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
686
|
+
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
687
|
+
],
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
/** method called in your other (non root, lazy loaded) modules to import a different instance of LogService */
|
|
691
|
+
static forChild(config = DEFAULT_LOG_CONFIG) {
|
|
692
|
+
return {
|
|
693
|
+
ngModule: LogModule,
|
|
694
|
+
providers: [
|
|
695
|
+
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
696
|
+
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
697
|
+
],
|
|
698
|
+
};
|
|
829
699
|
}
|
|
830
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type:
|
|
831
|
-
/** @nocollapse */ static { this.ɵ
|
|
700
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
701
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.10", ngImport: i0, type: LogModule }); }
|
|
702
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule }); }
|
|
832
703
|
}
|
|
833
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type:
|
|
834
|
-
type:
|
|
835
|
-
}]
|
|
836
|
-
type: Optional
|
|
837
|
-
}] }, { type: undefined, decorators: [{
|
|
838
|
-
type: Inject,
|
|
839
|
-
args: [CONFIG_TOKEN]
|
|
840
|
-
}] }]; } });
|
|
841
|
-
const translateConfig = {
|
|
842
|
-
loader: {
|
|
843
|
-
provide: TranslateLoader,
|
|
844
|
-
useClass: I18nLoader,
|
|
845
|
-
},
|
|
846
|
-
};
|
|
704
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LogModule, decorators: [{
|
|
705
|
+
type: NgModule
|
|
706
|
+
}] });
|
|
847
707
|
|
|
848
708
|
class I18nService extends EuiLazyService {
|
|
849
709
|
constructor(baseGlobalConfig, translateService, logService, store, document) {
|
|
@@ -858,7 +718,9 @@ class I18nService extends EuiLazyService {
|
|
|
858
718
|
}
|
|
859
719
|
getState(keyOrMapFn) {
|
|
860
720
|
let selector = getI18nState;
|
|
861
|
-
|
|
721
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
722
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
723
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
862
724
|
if (keyOrMapFn) {
|
|
863
725
|
switch (typeof keyOrMapFn) {
|
|
864
726
|
case 'function':
|
|
@@ -888,15 +750,6 @@ class I18nService extends EuiLazyService {
|
|
|
888
750
|
}
|
|
889
751
|
return of({ success: false, error: 'Initial active lang should be string' });
|
|
890
752
|
}
|
|
891
|
-
/**
|
|
892
|
-
* A pipe function that could serve as a wrapper of another observable
|
|
893
|
-
* e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
|
|
894
|
-
* WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
|
|
895
|
-
* into another emission.
|
|
896
|
-
*
|
|
897
|
-
* @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
|
|
898
|
-
* fetch module name from the state.
|
|
899
|
-
*/
|
|
900
753
|
onReady(moduleName) {
|
|
901
754
|
return this.onModuleLoad.pipe(switchMap((evt) => moduleName
|
|
902
755
|
? of(evt)
|
|
@@ -919,6 +772,7 @@ class I18nService extends EuiLazyService {
|
|
|
919
772
|
* Add resources based of a config loader
|
|
920
773
|
*
|
|
921
774
|
* @param config I18nLoaderConfig
|
|
775
|
+
* @param moduleName
|
|
922
776
|
* @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
|
|
923
777
|
*/
|
|
924
778
|
addResources(config, moduleName) {
|
|
@@ -926,6 +780,8 @@ class I18nService extends EuiLazyService {
|
|
|
926
780
|
this.onModuleLoad.next({ ready: false, name: moduleName });
|
|
927
781
|
const loader = this.translateService.currentLoader;
|
|
928
782
|
if (loader instanceof I18nLoader) {
|
|
783
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
784
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
929
785
|
const langSubscription = [];
|
|
930
786
|
const i18nLoader = loader;
|
|
931
787
|
// add the resources to the loader
|
|
@@ -935,10 +791,10 @@ class I18nService extends EuiLazyService {
|
|
|
935
791
|
// add the new set of translations to the current language
|
|
936
792
|
this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
|
|
937
793
|
})));
|
|
938
|
-
// if the current language is different
|
|
794
|
+
// if the current language is different from the DEFAULT language
|
|
939
795
|
const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
|
|
940
796
|
if (this.translateService.currentLang !== defaultLang) {
|
|
941
|
-
// manually load the resources for the default language and add them to the
|
|
797
|
+
// manually load the resources for the default language and add them to the translation service
|
|
942
798
|
langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
|
|
943
799
|
this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
|
|
944
800
|
})));
|
|
@@ -1030,6 +886,8 @@ class I18nService extends EuiLazyService {
|
|
|
1030
886
|
* @returns Observable that returns an object contain the object translation for given language after language
|
|
1031
887
|
* fully loaded.
|
|
1032
888
|
*/
|
|
889
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
890
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1033
891
|
use(lang) {
|
|
1034
892
|
return this.translateService.use(lang);
|
|
1035
893
|
}
|
|
@@ -1059,39 +917,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
1059
917
|
args: [DOCUMENT]
|
|
1060
918
|
}] }]; } });
|
|
1061
919
|
|
|
1062
|
-
|
|
1063
|
-
constructor() {
|
|
1064
|
-
super(null, null, null, null, null);
|
|
1065
|
-
this.DEFAULT_LANGUAGE = 'en';
|
|
1066
|
-
}
|
|
1067
|
-
get onLangChange() {
|
|
1068
|
-
return new EventEmitter();
|
|
1069
|
-
}
|
|
1070
|
-
addResources() {
|
|
1071
|
-
return of({ success: true });
|
|
1072
|
-
}
|
|
1073
|
-
get currentLanguage() {
|
|
1074
|
-
return this.DEFAULT_LANGUAGE;
|
|
1075
|
-
}
|
|
1076
|
-
getState() {
|
|
1077
|
-
return of({ activeLang: this.DEFAULT_LANGUAGE });
|
|
1078
|
-
}
|
|
1079
|
-
updateState(i18nState) {
|
|
1080
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1081
|
-
}
|
|
1082
|
-
init(i18nState) {
|
|
1083
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1084
|
-
return of({ success: true });
|
|
1085
|
-
}
|
|
1086
|
-
lazyLoadInit() {
|
|
1087
|
-
return of({ success: true });
|
|
1088
|
-
}
|
|
1089
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1090
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nServiceMock }); }
|
|
1091
|
-
}
|
|
1092
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: I18nServiceMock, decorators: [{
|
|
1093
|
-
type: Injectable
|
|
1094
|
-
}], ctorParameters: function () { return []; } });
|
|
920
|
+
// export * from './i18n.service.mock';
|
|
1095
921
|
|
|
1096
922
|
const initialState = {
|
|
1097
923
|
appName: '',
|
|
@@ -1156,6 +982,8 @@ class UxAppShellService {
|
|
|
1156
982
|
get breakpoint$() {
|
|
1157
983
|
return this._breakpoint$.asObservable();
|
|
1158
984
|
}
|
|
985
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
986
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1159
987
|
get breakpoints$() {
|
|
1160
988
|
return this._breakpoints$.asObservable();
|
|
1161
989
|
}
|
|
@@ -1243,6 +1071,8 @@ class UxAppShellService {
|
|
|
1243
1071
|
this.isCloseAllSticky = false;
|
|
1244
1072
|
this.growlLife = 3000;
|
|
1245
1073
|
this.growlPosition = 'bottom-right';
|
|
1074
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1075
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1246
1076
|
this.growlCallback = null;
|
|
1247
1077
|
this.activeModals = [];
|
|
1248
1078
|
this.openModalId = new BehaviorSubject('');
|
|
@@ -1270,7 +1100,7 @@ class UxAppShellService {
|
|
|
1270
1100
|
}
|
|
1271
1101
|
}
|
|
1272
1102
|
setState(nextState, updateI18 = true) {
|
|
1273
|
-
let breakpoint, breakpoints
|
|
1103
|
+
let breakpoint, breakpoints;
|
|
1274
1104
|
let combinedLinks;
|
|
1275
1105
|
const state = this.state;
|
|
1276
1106
|
// check if window width has been updated from previous state
|
|
@@ -1286,7 +1116,7 @@ class UxAppShellService {
|
|
|
1286
1116
|
breakpoints = state.breakpoints;
|
|
1287
1117
|
}
|
|
1288
1118
|
// finally get the wrapper classes when both the state and breakpoint are known
|
|
1289
|
-
wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
1119
|
+
const wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
1290
1120
|
// check if the menuLinks or sidebarLinks have changed from previous state
|
|
1291
1121
|
if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
|
|
1292
1122
|
combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
|
|
@@ -1313,6 +1143,8 @@ class UxAppShellService {
|
|
|
1313
1143
|
*
|
|
1314
1144
|
* @param key can be 'key' or 'key.sub.sub'
|
|
1315
1145
|
*/
|
|
1146
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1147
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1316
1148
|
getState(key) {
|
|
1317
1149
|
return defer(() =>
|
|
1318
1150
|
// check if key exists
|
|
@@ -1494,8 +1326,8 @@ class UxAppShellService {
|
|
|
1494
1326
|
* Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
|
|
1495
1327
|
*/
|
|
1496
1328
|
setAppViewportCssVars() {
|
|
1497
|
-
|
|
1498
|
-
|
|
1329
|
+
const vh = window.innerHeight * 0.01;
|
|
1330
|
+
const vw = window.innerWidth * 0.01;
|
|
1499
1331
|
this._setCssVarValue('--eui-app-vh', `${vh}px`);
|
|
1500
1332
|
this._setCssVarValue('--eui-app-vw', `${vw}px`);
|
|
1501
1333
|
}
|
|
@@ -1606,7 +1438,7 @@ class UxAppShellService {
|
|
|
1606
1438
|
modalId = 'single_modal';
|
|
1607
1439
|
}
|
|
1608
1440
|
if (this.activeModals.length) {
|
|
1609
|
-
|
|
1441
|
+
const modalIndex = this.findModalIndex(modalId);
|
|
1610
1442
|
if (modalIndex !== -1) {
|
|
1611
1443
|
return this.activeModals[modalIndex].isOpen;
|
|
1612
1444
|
}
|
|
@@ -1668,7 +1500,7 @@ class UxAppShellService {
|
|
|
1668
1500
|
document.documentElement.style.setProperty(varName, varValue);
|
|
1669
1501
|
}
|
|
1670
1502
|
getWrapperClasses(state, breakpoint) {
|
|
1671
|
-
|
|
1503
|
+
const classes = [];
|
|
1672
1504
|
classes.push(breakpoint);
|
|
1673
1505
|
if (state.hasSidebar) {
|
|
1674
1506
|
if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
|
|
@@ -1761,12 +1593,14 @@ class UxAppShellService {
|
|
|
1761
1593
|
};
|
|
1762
1594
|
}
|
|
1763
1595
|
getJson(url) {
|
|
1764
|
-
return this.http.get(url)
|
|
1596
|
+
return firstValueFrom(this.http.get(url)).then(this.extractData).catch(this.handleError);
|
|
1765
1597
|
}
|
|
1766
1598
|
extractData(res) {
|
|
1767
1599
|
const body = res;
|
|
1768
1600
|
return body || {};
|
|
1769
1601
|
}
|
|
1602
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1603
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1770
1604
|
handleError(error) {
|
|
1771
1605
|
console.error('An error occurred', error);
|
|
1772
1606
|
return Promise.reject(error.message || error);
|
|
@@ -1781,7 +1615,7 @@ class UxAppShellService {
|
|
|
1781
1615
|
}
|
|
1782
1616
|
});
|
|
1783
1617
|
}
|
|
1784
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$
|
|
1618
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$1.HttpClient }, { token: PLATFORM_ID }, { token: i2$1.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1785
1619
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, providedIn: 'root' }); }
|
|
1786
1620
|
}
|
|
1787
1621
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, decorators: [{
|
|
@@ -1794,7 +1628,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
1794
1628
|
}, {
|
|
1795
1629
|
type: Inject,
|
|
1796
1630
|
args: [GLOBAL_CONFIG_TOKEN]
|
|
1797
|
-
}] }, { type: i1$
|
|
1631
|
+
}] }, { type: i1$1.HttpClient }, { type: undefined, decorators: [{
|
|
1798
1632
|
type: Inject,
|
|
1799
1633
|
args: [PLATFORM_ID]
|
|
1800
1634
|
}] }, { type: i2$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
|
|
@@ -1818,9 +1652,9 @@ class CoreAppEffects {
|
|
|
1818
1652
|
this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
|
|
1819
1653
|
// TODO: for eUI 14, drop boolean support and refactor
|
|
1820
1654
|
// check if feature is enabled
|
|
1821
|
-
|
|
1655
|
+
const isFeatureEnabled = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.enabled : this.showConnectionStatus;
|
|
1822
1656
|
// extract lifespan if any
|
|
1823
|
-
|
|
1657
|
+
const lifespan = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.messageBox?.lifespan || 0 : 0;
|
|
1824
1658
|
// if the user needs to be informed about the connection status
|
|
1825
1659
|
if (isFeatureEnabled) {
|
|
1826
1660
|
if (connected) {
|
|
@@ -1836,12 +1670,12 @@ class CoreAppEffects {
|
|
|
1836
1670
|
}
|
|
1837
1671
|
})), { dispatch: false });
|
|
1838
1672
|
}
|
|
1839
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$
|
|
1673
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$2.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i2.TranslateService }, { token: UxAppShellService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1840
1674
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects }); }
|
|
1841
1675
|
}
|
|
1842
1676
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects, decorators: [{
|
|
1843
1677
|
type: Injectable
|
|
1844
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
1678
|
+
}], ctorParameters: function () { return [{ type: i1$2.Actions }, { type: undefined, decorators: [{
|
|
1845
1679
|
type: Inject,
|
|
1846
1680
|
args: [SHOW_CONNECTION_STATUS_TOKEN]
|
|
1847
1681
|
}] }, { type: i2.TranslateService }, { type: UxAppShellService }]; } });
|
|
@@ -1881,7 +1715,6 @@ const removeApiQueueItem = (state, action) => {
|
|
|
1881
1715
|
}, {});
|
|
1882
1716
|
return Object.assign({}, state, { apiQueue });
|
|
1883
1717
|
};
|
|
1884
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1885
1718
|
const emptyApiQueue = (state, action) =>
|
|
1886
1719
|
// remove all items in the Api Queue
|
|
1887
1720
|
Object.assign({}, state, { apiQueue: {} });
|
|
@@ -1983,6 +1816,8 @@ const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
|
1983
1816
|
return state;
|
|
1984
1817
|
};
|
|
1985
1818
|
|
|
1819
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1820
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1986
1821
|
const coreReducers = Object.assign({}, {
|
|
1987
1822
|
app: coreAppReducers,
|
|
1988
1823
|
user: coreUserReducers,
|
|
@@ -1991,6 +1826,8 @@ const coreReducers = Object.assign({}, {
|
|
|
1991
1826
|
locale: coreLocaleReducers,
|
|
1992
1827
|
});
|
|
1993
1828
|
|
|
1829
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1830
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1994
1831
|
const extend = extendProxy.default || extendProxy;
|
|
1995
1832
|
/**
|
|
1996
1833
|
* Utility meta-reducer to load the state from the local storage
|
|
@@ -2028,7 +1865,7 @@ const filterAppState = (app) => {
|
|
|
2028
1865
|
};
|
|
2029
1866
|
/**
|
|
2030
1867
|
*
|
|
2031
|
-
* @param
|
|
1868
|
+
* @param storage Type of storage to load the state from
|
|
2032
1869
|
*/
|
|
2033
1870
|
const loadState = (storage = localStorage) => {
|
|
2034
1871
|
try {
|
|
@@ -2078,6 +1915,119 @@ const cb = (reducer, storage) => (state, action) => {
|
|
|
2078
1915
|
return reducer(state, action);
|
|
2079
1916
|
};
|
|
2080
1917
|
|
|
1918
|
+
var BrowserStorageType;
|
|
1919
|
+
(function (BrowserStorageType) {
|
|
1920
|
+
BrowserStorageType[BrowserStorageType["local"] = 0] = "local";
|
|
1921
|
+
BrowserStorageType[BrowserStorageType["session"] = 1] = "session";
|
|
1922
|
+
})(BrowserStorageType || (BrowserStorageType = {}));
|
|
1923
|
+
// todo should stay here but all the store directory should be moved upper level
|
|
1924
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1925
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1926
|
+
class StoreService {
|
|
1927
|
+
constructor(store, logService) {
|
|
1928
|
+
this.store = store;
|
|
1929
|
+
this.logService = logService;
|
|
1930
|
+
/**
|
|
1931
|
+
* autoSave handlers to call before saving in local Storage
|
|
1932
|
+
*/
|
|
1933
|
+
this._autoSaveHandlers = {};
|
|
1934
|
+
/** storage instance e.g. localStorage, sessionStorage */
|
|
1935
|
+
this._storage = localStorage;
|
|
1936
|
+
}
|
|
1937
|
+
// use init with just version info, to update to user state, UserService.updateState
|
|
1938
|
+
// initializeStore(version?: string, userDetails?: BaseUserDetails) {
|
|
1939
|
+
// this.dispatch(new InitStoreAction({ version, userDetails }));
|
|
1940
|
+
// }
|
|
1941
|
+
init(version, storageType) {
|
|
1942
|
+
this.dispatch(new InitStoreAction({ version }));
|
|
1943
|
+
this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
|
|
1944
|
+
}
|
|
1945
|
+
addAutoSaveHandler(stateSlice, handler) {
|
|
1946
|
+
if (!this.store) {
|
|
1947
|
+
if (this.logService) {
|
|
1948
|
+
this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
|
|
1949
|
+
}
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
this._autoSaveHandlers[stateSlice] = handler;
|
|
1953
|
+
}
|
|
1954
|
+
handleAutoSave() {
|
|
1955
|
+
if (!this.store) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
this.store.pipe(debounceTime(1000), distinctUntilChanged()).subscribe((state) => {
|
|
1959
|
+
this.saveState(state);
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Proxy to NGRX store.dispatch()
|
|
1964
|
+
* that allows to intercept if the store is present
|
|
1965
|
+
*/
|
|
1966
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1967
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1968
|
+
dispatch(action) {
|
|
1969
|
+
if (this.store) {
|
|
1970
|
+
return this.store.dispatch(action);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1974
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1975
|
+
dispatchAction(state, actionKey, reducer) {
|
|
1976
|
+
if (this.store) {
|
|
1977
|
+
this.store.addReducer(actionKey, reducer);
|
|
1978
|
+
return this.store.dispatch({ type: actionKey, payload: state });
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Proxy to NGRX store.select()
|
|
1983
|
+
* that allows to intercept if the store is present
|
|
1984
|
+
*/
|
|
1985
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1986
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1987
|
+
select(key) {
|
|
1988
|
+
if (!this.store) {
|
|
1989
|
+
return throwError(() => new Error('NGRX Store not configured'));
|
|
1990
|
+
}
|
|
1991
|
+
return this.store.select(key);
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* filters and save the state with the Browser storage
|
|
1995
|
+
* @param state type of CoreState
|
|
1996
|
+
*/
|
|
1997
|
+
saveState(state) {
|
|
1998
|
+
let stateToSave = {
|
|
1999
|
+
app: state.app,
|
|
2000
|
+
};
|
|
2001
|
+
if (state.user) {
|
|
2002
|
+
const { userId, preferences } = state.user;
|
|
2003
|
+
stateToSave.user = { userId, preferences };
|
|
2004
|
+
}
|
|
2005
|
+
Object.keys(this._autoSaveHandlers).forEach((sliceState) => {
|
|
2006
|
+
const handler = this._autoSaveHandlers[sliceState];
|
|
2007
|
+
stateToSave = Object.assign(stateToSave, { [sliceState]: handler(state[sliceState]) });
|
|
2008
|
+
});
|
|
2009
|
+
try {
|
|
2010
|
+
const serializedState = JSON.stringify(stateToSave);
|
|
2011
|
+
this._storage.setItem('state', serializedState);
|
|
2012
|
+
}
|
|
2013
|
+
catch (err) {
|
|
2014
|
+
// Ignore write errors.
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, deps: [{ token: i1$3.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2018
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
2019
|
+
}
|
|
2020
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, decorators: [{
|
|
2021
|
+
type: Injectable,
|
|
2022
|
+
args: [{
|
|
2023
|
+
providedIn: 'root',
|
|
2024
|
+
}]
|
|
2025
|
+
}], ctorParameters: function () { return [{ type: i1$3.Store, decorators: [{
|
|
2026
|
+
type: Optional
|
|
2027
|
+
}] }, { type: LogService, decorators: [{
|
|
2028
|
+
type: Optional
|
|
2029
|
+
}] }]; } });
|
|
2030
|
+
|
|
2081
2031
|
class StoreServiceMock extends StoreService {
|
|
2082
2032
|
constructor() {
|
|
2083
2033
|
super(null, null);
|
|
@@ -2096,6 +2046,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2096
2046
|
type: Injectable
|
|
2097
2047
|
}], ctorParameters: function () { return []; } });
|
|
2098
2048
|
|
|
2049
|
+
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
2050
|
+
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
2051
|
+
locationInitialized.then(() => {
|
|
2052
|
+
const appConfig = injector.get(CONFIG_TOKEN);
|
|
2053
|
+
// necessary config parameters
|
|
2054
|
+
let appVersion;
|
|
2055
|
+
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
2056
|
+
appVersion = appConfig.versions.app;
|
|
2057
|
+
}
|
|
2058
|
+
else {
|
|
2059
|
+
appVersion = '0.0.0';
|
|
2060
|
+
}
|
|
2061
|
+
let storageType;
|
|
2062
|
+
if (appConfig && appConfig.saveStateStorage) {
|
|
2063
|
+
storageType = appConfig.saveStateStorage;
|
|
2064
|
+
}
|
|
2065
|
+
else {
|
|
2066
|
+
storageType = BrowserStorageType.local;
|
|
2067
|
+
}
|
|
2068
|
+
const storeService = injector.get(StoreService);
|
|
2069
|
+
storeService.init(appVersion, storageType);
|
|
2070
|
+
storeService.handleAutoSave();
|
|
2071
|
+
resolve(null);
|
|
2072
|
+
});
|
|
2073
|
+
});
|
|
2074
|
+
|
|
2075
|
+
function getCoreProviders() {
|
|
2076
|
+
return [
|
|
2077
|
+
// core config
|
|
2078
|
+
...getDependencyProviders(),
|
|
2079
|
+
{ provide: BASE_NAME_TOKEN, useValue: 'eui-core' },
|
|
2080
|
+
// app config
|
|
2081
|
+
{ provide: CONFIG_TOKEN, useFactory: prepareEuiAppConfigToken, deps: [EUI_CONFIG_TOKEN] },
|
|
2082
|
+
// global config
|
|
2083
|
+
{ provide: GLOBAL_CONFIG_TOKEN, useFactory: getGlobalConfig, deps: [CONFIG_TOKEN] },
|
|
2084
|
+
{ provide: ROOT_LOG_CONFIG_TOKEN, useFactory: getRootLogConfig, deps: [CONFIG_TOKEN] },
|
|
2085
|
+
{ provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
|
|
2086
|
+
{ provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
|
|
2087
|
+
{ provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
|
|
2088
|
+
{ provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
|
|
2089
|
+
];
|
|
2090
|
+
}
|
|
2091
|
+
function getDependencyProviders() {
|
|
2092
|
+
return [{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] }];
|
|
2093
|
+
}
|
|
2094
|
+
function getCoreChildProviders(moduleName) {
|
|
2095
|
+
return [
|
|
2096
|
+
// module config
|
|
2097
|
+
{ provide: MODULE_NAME_TOKEN, useValue: moduleName },
|
|
2098
|
+
{ provide: MODULE_CONFIG_TOKEN, useFactory: getModuleConfig, deps: [CONFIG_TOKEN, MODULE_NAME_TOKEN] },
|
|
2099
|
+
// log config
|
|
2100
|
+
{
|
|
2101
|
+
provide: LogService,
|
|
2102
|
+
useFactory: euiLogServiceFactory,
|
|
2103
|
+
deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN, MODULE_NAME_TOKEN, MODULE_CONFIG_TOKEN],
|
|
2104
|
+
},
|
|
2105
|
+
];
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2099
2108
|
const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
|
|
2100
2109
|
class CoreModule {
|
|
2101
2110
|
/**
|
|
@@ -2159,7 +2168,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2159
2168
|
}] }, { type: i0.Injector }]; } });
|
|
2160
2169
|
const createEuiCoreRootGuard = (core) => {
|
|
2161
2170
|
if (core) {
|
|
2162
|
-
throw new TypeError(
|
|
2171
|
+
throw new TypeError('CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.');
|
|
2163
2172
|
}
|
|
2164
2173
|
return 'guarded';
|
|
2165
2174
|
};
|
|
@@ -2219,6 +2228,8 @@ const messages = {
|
|
|
2219
2228
|
// Intermediate "hacky" subclass taken from
|
|
2220
2229
|
// https://www.bennadel.com/blog/3226-experimenting-with-error-sub-classing-using-es5-and-typescript-2-1-5.htm
|
|
2221
2230
|
class ErrorSubClass {
|
|
2231
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2222
2233
|
constructor(code, msg, args) {
|
|
2223
2234
|
if (!msg && code && code in messages) {
|
|
2224
2235
|
if (typeof messages[code] === 'function') {
|
|
@@ -2244,6 +2255,8 @@ class ErrorSubClass {
|
|
|
2244
2255
|
// This replaces the "extends" on the Class
|
|
2245
2256
|
// ErrorSubClass.prototype = <any>Object.create(Error.prototype);
|
|
2246
2257
|
class EuiError extends ErrorSubClass {
|
|
2258
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2259
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2247
2260
|
constructor(code = errorCodes.ERR_GENERIC, msg, args) {
|
|
2248
2261
|
super(code, msg, args);
|
|
2249
2262
|
this.name = 'EuiError';
|
|
@@ -2255,6 +2268,8 @@ class GlobalErrorHandler extends ErrorHandler {
|
|
|
2255
2268
|
super();
|
|
2256
2269
|
this.logService = logService;
|
|
2257
2270
|
}
|
|
2271
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2258
2273
|
handleError(error) {
|
|
2259
2274
|
// log error
|
|
2260
2275
|
this.logService.error(error.message || error.toString());
|
|
@@ -2277,21 +2292,28 @@ class HttpErrorHandlerInterceptor {
|
|
|
2277
2292
|
this.injector = injector;
|
|
2278
2293
|
this.router = router;
|
|
2279
2294
|
}
|
|
2295
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2280
2297
|
intercept(req, next) {
|
|
2281
|
-
return next.handle(req).pipe(tap(
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
this.
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2298
|
+
return next.handle(req).pipe(tap({
|
|
2299
|
+
next: () => { },
|
|
2300
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2301
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2302
|
+
error: (error) => {
|
|
2303
|
+
// in case of http error
|
|
2304
|
+
if (error instanceof HttpErrorResponse) {
|
|
2305
|
+
const routeConfig = this.getRouteConfig(error);
|
|
2306
|
+
const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
|
|
2307
|
+
if (typeof rule === 'string') {
|
|
2308
|
+
// perform a redirect
|
|
2309
|
+
this.router.navigate([rule]);
|
|
2310
|
+
}
|
|
2311
|
+
else if (typeof rule === 'function') {
|
|
2312
|
+
// callback function
|
|
2313
|
+
rule.call(null, error, this.injector);
|
|
2314
|
+
}
|
|
2293
2315
|
}
|
|
2294
|
-
}
|
|
2316
|
+
},
|
|
2295
2317
|
}));
|
|
2296
2318
|
}
|
|
2297
2319
|
/**
|
|
@@ -2398,6 +2420,8 @@ class ApiQueueService {
|
|
|
2398
2420
|
* @param id - id of the item inside the queue
|
|
2399
2421
|
* @return An Observable of type any
|
|
2400
2422
|
*/
|
|
2423
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2424
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2401
2425
|
processQueueItem(id) {
|
|
2402
2426
|
return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
2403
2427
|
if (!queue) {
|
|
@@ -2412,6 +2436,8 @@ class ApiQueueService {
|
|
|
2412
2436
|
* @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
|
|
2413
2437
|
* @return An Observable with an array which contains all responses from all items in queue.
|
|
2414
2438
|
*/
|
|
2439
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2440
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2415
2441
|
processAllQueueItems(continueOnError = true) {
|
|
2416
2442
|
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
2417
2443
|
this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
@@ -2419,7 +2445,10 @@ class ApiQueueService {
|
|
|
2419
2445
|
throw error;
|
|
2420
2446
|
}
|
|
2421
2447
|
return of(error);
|
|
2422
|
-
})))),
|
|
2448
|
+
})))),
|
|
2449
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2450
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2451
|
+
switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
|
|
2423
2452
|
}
|
|
2424
2453
|
/**
|
|
2425
2454
|
* Process all items in queue after it order them based on their timestamp. Beware that order
|
|
@@ -2427,6 +2456,8 @@ class ApiQueueService {
|
|
|
2427
2456
|
* or Http response follows order.
|
|
2428
2457
|
* @param [ascending=true] - sets the order of queue items based on timestamp
|
|
2429
2458
|
*/
|
|
2459
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2460
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2430
2461
|
processAllQueueItemsSequential(ascending = true) {
|
|
2431
2462
|
return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
|
|
2432
2463
|
.sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
|
|
@@ -2449,10 +2480,13 @@ class ApiQueueService {
|
|
|
2449
2480
|
* @param item - the item of the queue that matches the id.
|
|
2450
2481
|
* @return An Observable of HttpClient Request
|
|
2451
2482
|
*/
|
|
2483
|
+
// TODO: add type for T and deprecate old function
|
|
2484
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2485
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2452
2486
|
buildHttpRequest(id, item) {
|
|
2453
2487
|
return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
|
|
2454
2488
|
}
|
|
2455
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$
|
|
2489
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$1.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2456
2490
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
|
|
2457
2491
|
}
|
|
2458
2492
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, decorators: [{
|
|
@@ -2460,7 +2494,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2460
2494
|
args: [{
|
|
2461
2495
|
providedIn: 'root',
|
|
2462
2496
|
}]
|
|
2463
|
-
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$
|
|
2497
|
+
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$1.HttpClient }, { type: LogService }]; } });
|
|
2464
2498
|
|
|
2465
2499
|
class ApiQueueServiceMock extends ApiQueueService {
|
|
2466
2500
|
constructor() {
|
|
@@ -2473,11 +2507,15 @@ class ApiQueueServiceMock extends ApiQueueService {
|
|
|
2473
2507
|
return of({ uri: id, method: 'GET' });
|
|
2474
2508
|
}
|
|
2475
2509
|
removeAllQueueItem() { }
|
|
2510
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2511
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2476
2512
|
processAllQueueItems() {
|
|
2477
2513
|
return of({});
|
|
2478
2514
|
}
|
|
2479
2515
|
addQueueItem() { }
|
|
2480
2516
|
removeQueueItem() { }
|
|
2517
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2518
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2481
2519
|
processQueueItem() {
|
|
2482
2520
|
return of({});
|
|
2483
2521
|
}
|
|
@@ -2491,15 +2529,15 @@ const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
|
2491
2529
|
* http://api.jquery.com/position/
|
|
2492
2530
|
*/
|
|
2493
2531
|
const position = (nativeEl) => {
|
|
2494
|
-
|
|
2532
|
+
const elBCR = offset(nativeEl);
|
|
2495
2533
|
let offsetParentBCR = { top: 0, left: 0 };
|
|
2496
|
-
|
|
2534
|
+
const offsetParentEl = parentOffsetEl(nativeEl);
|
|
2497
2535
|
if (offsetParentEl !== document) {
|
|
2498
2536
|
offsetParentBCR = offset(offsetParentEl);
|
|
2499
2537
|
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
|
|
2500
2538
|
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
|
|
2501
2539
|
}
|
|
2502
|
-
|
|
2540
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
2503
2541
|
return {
|
|
2504
2542
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
2505
2543
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -2512,7 +2550,7 @@ const position = (nativeEl) => {
|
|
|
2512
2550
|
* http://api.jquery.com/offset/
|
|
2513
2551
|
*/
|
|
2514
2552
|
const offset = (nativeEl) => {
|
|
2515
|
-
|
|
2553
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
2516
2554
|
return {
|
|
2517
2555
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
2518
2556
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -2521,6 +2559,8 @@ const offset = (nativeEl) => {
|
|
|
2521
2559
|
};
|
|
2522
2560
|
};
|
|
2523
2561
|
// PRIVATE FUNCTIONS
|
|
2562
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2563
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2524
2564
|
const getStyle = (nativeEl, cssProp) => {
|
|
2525
2565
|
// IE
|
|
2526
2566
|
if (nativeEl.currentStyle) {
|
|
@@ -2548,8 +2588,8 @@ const parentOffsetEl = (nativeEl) => {
|
|
|
2548
2588
|
return offsetParent || document;
|
|
2549
2589
|
};
|
|
2550
2590
|
const getViewElement = (fixture, componentClass, klass) => {
|
|
2551
|
-
let
|
|
2552
|
-
de = fixture.debugElement.query(By.css(componentClass));
|
|
2591
|
+
let el, domElement;
|
|
2592
|
+
const de = fixture.debugElement.query(By.css(componentClass));
|
|
2553
2593
|
if (de) {
|
|
2554
2594
|
el = de.nativeElement;
|
|
2555
2595
|
if (el && klass) {
|
|
@@ -2559,7 +2599,7 @@ const getViewElement = (fixture, componentClass, klass) => {
|
|
|
2559
2599
|
}
|
|
2560
2600
|
}
|
|
2561
2601
|
}
|
|
2562
|
-
return { de, el, domElement };
|
|
2602
|
+
return { de, el, domElement: domElement };
|
|
2563
2603
|
};
|
|
2564
2604
|
const closestMatchingParent = (target, className) => {
|
|
2565
2605
|
let element = target;
|
|
@@ -2645,11 +2685,11 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2645
2685
|
}
|
|
2646
2686
|
if (typeof value === 'string') {
|
|
2647
2687
|
// get all non characters
|
|
2648
|
-
|
|
2688
|
+
const nonChars = value.match(/[^0-9]+/g) || [];
|
|
2649
2689
|
// get all unique chars
|
|
2650
|
-
|
|
2690
|
+
const uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
|
|
2651
2691
|
// get separators
|
|
2652
|
-
|
|
2692
|
+
const separators = Array.from(uniqueChars.keys());
|
|
2653
2693
|
// sense where decimal separator and where thousand separator is
|
|
2654
2694
|
if (separators.length > 1) {
|
|
2655
2695
|
// left detected separator will be thousand and second will be decimal
|
|
@@ -2675,12 +2715,13 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2675
2715
|
return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2676
2716
|
}
|
|
2677
2717
|
// do the replacement of separators and parseInt
|
|
2678
|
-
// Beware! Always replace thousand separator first and then decimal
|
|
2718
|
+
// Beware! Always replace a thousand separator first and then decimal
|
|
2679
2719
|
value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
|
|
2680
2720
|
}
|
|
2681
2721
|
decimalSeparator = inDecimalSeparator;
|
|
2682
2722
|
thousandsSeparator = inThousandSeparator;
|
|
2683
2723
|
const maxFraction = '0'.repeat(fractionSize);
|
|
2724
|
+
// eslint-disable-next-line prefer-const
|
|
2684
2725
|
let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
|
|
2685
2726
|
fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
|
|
2686
2727
|
// this rule makes sense only in number in case fraction is all zero
|
|
@@ -2689,9 +2730,8 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2689
2730
|
};
|
|
2690
2731
|
|
|
2691
2732
|
const handleError = (error) => {
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
return throwError(errMsg);
|
|
2733
|
+
const errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
|
2734
|
+
throw new Error(errMsg);
|
|
2695
2735
|
};
|
|
2696
2736
|
|
|
2697
2737
|
/**
|
|
@@ -2787,7 +2827,7 @@ class EuiPermissionService extends EuiService {
|
|
|
2787
2827
|
*/
|
|
2788
2828
|
haveAllRights(rights) {
|
|
2789
2829
|
if (!isDefined(rights)) {
|
|
2790
|
-
throw Error(
|
|
2830
|
+
throw Error('The rights should be an array but instead it\'s not defined!');
|
|
2791
2831
|
}
|
|
2792
2832
|
return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
|
|
2793
2833
|
}
|
|
@@ -2803,6 +2843,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2803
2843
|
type: Optional
|
|
2804
2844
|
}] }, { type: StoreService }]; } });
|
|
2805
2845
|
|
|
2846
|
+
// TODO: Type of LINK should be UxLink or something relevant. Do we need that service anymore?
|
|
2847
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2848
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2806
2849
|
class UxDynamicMenuService {
|
|
2807
2850
|
// TODO: it should be moved euiservice, or it should be static
|
|
2808
2851
|
// TODO: can we moved that service inside the module of the component that's using it?
|
|
@@ -2970,6 +3013,7 @@ class UxErrorManager {
|
|
|
2970
3013
|
}
|
|
2971
3014
|
}
|
|
2972
3015
|
|
|
3016
|
+
// TODO: Do we need that service anymore? Can we remove it?
|
|
2973
3017
|
const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
|
|
2974
3018
|
class UxDynamicComponentService {
|
|
2975
3019
|
constructor(componentFactoryResolver, injector, appRef) {
|
|
@@ -2983,6 +3027,8 @@ class UxDynamicComponentService {
|
|
|
2983
3027
|
* @param el The element reference for the component to be injected
|
|
2984
3028
|
* @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
|
|
2985
3029
|
*/
|
|
3030
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3031
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2986
3032
|
add(component, el, config) {
|
|
2987
3033
|
// TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
|
|
2988
3034
|
// Create a portalHost from a DOM element
|
|
@@ -3018,6 +3064,8 @@ class UxDynamicComponentService {
|
|
|
3018
3064
|
* creates a custom injector to be used when providing custom injection tokens to components inside a portal
|
|
3019
3065
|
* @param data to be used by DYNAMIC_COMPONENT_CONFIG token
|
|
3020
3066
|
*/
|
|
3067
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3068
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3021
3069
|
createInjector(data) {
|
|
3022
3070
|
const injectorTokens = new WeakMap();
|
|
3023
3071
|
injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
|
|
@@ -3779,18 +3827,26 @@ class AsyncStorageService extends StorageService {
|
|
|
3779
3827
|
}
|
|
3780
3828
|
|
|
3781
3829
|
class AsyncStorageServiceMock extends AsyncStorageService {
|
|
3830
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3831
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3782
3832
|
ready() {
|
|
3783
3833
|
return of({});
|
|
3784
3834
|
}
|
|
3785
3835
|
name() {
|
|
3786
3836
|
return null;
|
|
3787
3837
|
}
|
|
3838
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3839
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3788
3840
|
get() {
|
|
3789
3841
|
return of({});
|
|
3790
3842
|
}
|
|
3843
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3844
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3791
3845
|
set() {
|
|
3792
3846
|
return of({});
|
|
3793
3847
|
}
|
|
3848
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3849
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3794
3850
|
remove() {
|
|
3795
3851
|
return of({});
|
|
3796
3852
|
}
|
|
@@ -3818,6 +3874,8 @@ class LocalStorageService extends StorageService {
|
|
|
3818
3874
|
* @param key the associated key
|
|
3819
3875
|
* @returns the value or undefined, if case of error
|
|
3820
3876
|
*/
|
|
3877
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3878
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3821
3879
|
get(key) {
|
|
3822
3880
|
try {
|
|
3823
3881
|
const serialized = localStorage.getItem(key);
|
|
@@ -3835,6 +3893,8 @@ class LocalStorageService extends StorageService {
|
|
|
3835
3893
|
* @param key the associated key
|
|
3836
3894
|
* @param value the value to set
|
|
3837
3895
|
*/
|
|
3896
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3897
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3838
3898
|
set(key, value) {
|
|
3839
3899
|
try {
|
|
3840
3900
|
const serialized = JSON.stringify(value);
|
|
@@ -3889,6 +3949,8 @@ class SessionStorageService extends StorageService {
|
|
|
3889
3949
|
* @param key the associated key
|
|
3890
3950
|
* @returns the value or undefined, if case of error
|
|
3891
3951
|
*/
|
|
3952
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3953
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3892
3954
|
get(key) {
|
|
3893
3955
|
try {
|
|
3894
3956
|
const serialized = sessionStorage.getItem(key);
|
|
@@ -3906,6 +3968,8 @@ class SessionStorageService extends StorageService {
|
|
|
3906
3968
|
* @param key the associated key
|
|
3907
3969
|
* @param value the value to set
|
|
3908
3970
|
*/
|
|
3971
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3972
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3909
3973
|
set(key, value) {
|
|
3910
3974
|
try {
|
|
3911
3975
|
const serialized = JSON.stringify(value);
|
|
@@ -3941,7 +4005,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
3941
4005
|
}] }]; } });
|
|
3942
4006
|
|
|
3943
4007
|
/** @internal */
|
|
4008
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4009
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3944
4010
|
const localForage = 'defineDriver' in lf ? lf : lf['default'];
|
|
4011
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4012
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3945
4013
|
const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVICE_CONFIG');
|
|
3946
4014
|
/**
|
|
3947
4015
|
* localforage service, using the localForage javascript library
|
|
@@ -3949,7 +4017,10 @@ const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVI
|
|
|
3949
4017
|
*/
|
|
3950
4018
|
class LocalForageService extends AsyncStorageService {
|
|
3951
4019
|
static { this.NAME = 'LocalForageService'; }
|
|
3952
|
-
constructor(
|
|
4020
|
+
constructor(
|
|
4021
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4022
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4023
|
+
config, log) {
|
|
3953
4024
|
super();
|
|
3954
4025
|
this.config = config;
|
|
3955
4026
|
this.log = log;
|
|
@@ -3968,11 +4039,16 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3968
4039
|
* reflects the readiness of the storage
|
|
3969
4040
|
* @returns one time emission Observable<void>
|
|
3970
4041
|
*/
|
|
4042
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4043
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3971
4044
|
ready() {
|
|
3972
|
-
return from(localForage.ready()).pipe(take(1), tap(
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
4045
|
+
return from(localForage.ready()).pipe(take(1), tap({
|
|
4046
|
+
next: () => { },
|
|
4047
|
+
error: (err) => {
|
|
4048
|
+
if (this.log) {
|
|
4049
|
+
this.log.error(this.name(), 'ready', err);
|
|
4050
|
+
}
|
|
4051
|
+
},
|
|
3976
4052
|
}));
|
|
3977
4053
|
}
|
|
3978
4054
|
/**
|
|
@@ -3980,6 +4056,8 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3980
4056
|
* @param key the associated key
|
|
3981
4057
|
* @returns one time emission Observable of value
|
|
3982
4058
|
*/
|
|
4059
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4060
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3983
4061
|
get(key) {
|
|
3984
4062
|
return from(localForage.getItem(key)).pipe(take(1), tap(() => { }, (err) => {
|
|
3985
4063
|
if (this.log) {
|
|
@@ -3993,11 +4071,17 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3993
4071
|
* @param value the value to set
|
|
3994
4072
|
* @returns one time emission Observable
|
|
3995
4073
|
*/
|
|
4074
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4075
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3996
4076
|
set(key, value) {
|
|
3997
|
-
return from(localForage.setItem(key, value)).pipe(take(1), tap(
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4077
|
+
return from(localForage.setItem(key, value)).pipe(take(1), tap({
|
|
4078
|
+
next: () => {
|
|
4079
|
+
},
|
|
4080
|
+
error: (err) => {
|
|
4081
|
+
if (this.log) {
|
|
4082
|
+
this.log.error(this.name(), 'set', err);
|
|
4083
|
+
}
|
|
4084
|
+
},
|
|
4001
4085
|
}));
|
|
4002
4086
|
}
|
|
4003
4087
|
/**
|
|
@@ -4005,11 +4089,16 @@ class LocalForageService extends AsyncStorageService {
|
|
|
4005
4089
|
* @param key the associated key
|
|
4006
4090
|
* @returns one time emission Observable
|
|
4007
4091
|
*/
|
|
4092
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4093
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4008
4094
|
remove(key) {
|
|
4009
|
-
return from(localForage.removeItem(key)).pipe(take(1), tap(
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4095
|
+
return from(localForage.removeItem(key)).pipe(take(1), tap({
|
|
4096
|
+
next: () => { },
|
|
4097
|
+
error: (err) => {
|
|
4098
|
+
if (this.log) {
|
|
4099
|
+
this.log.error(this.name(), 'remove', err);
|
|
4100
|
+
}
|
|
4101
|
+
},
|
|
4013
4102
|
}));
|
|
4014
4103
|
}
|
|
4015
4104
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -4063,7 +4152,9 @@ class LocaleService extends EuiService {
|
|
|
4063
4152
|
}
|
|
4064
4153
|
getState(keyOrMapFn) {
|
|
4065
4154
|
let selector = getLocaleState;
|
|
4066
|
-
|
|
4155
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4157
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4067
4158
|
if (keyOrMapFn) {
|
|
4068
4159
|
switch (typeof keyOrMapFn) {
|
|
4069
4160
|
case 'function':
|
|
@@ -4301,7 +4392,9 @@ class UserService extends EuiService {
|
|
|
4301
4392
|
}
|
|
4302
4393
|
getState(keyOrMapFn) {
|
|
4303
4394
|
let selector = getUserState;
|
|
4304
|
-
|
|
4395
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4397
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4305
4398
|
if (keyOrMapFn) {
|
|
4306
4399
|
switch (typeof keyOrMapFn) {
|
|
4307
4400
|
case 'function':
|
|
@@ -4314,6 +4407,8 @@ class UserService extends EuiService {
|
|
|
4314
4407
|
}
|
|
4315
4408
|
return this.store.select(selector);
|
|
4316
4409
|
}
|
|
4410
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4317
4412
|
updateState(userState, reducer) {
|
|
4318
4413
|
// if (typeof pathOrReducer === 'string') {
|
|
4319
4414
|
// let dotNotationToObject = (obj, key) => key.split('.').reduce((obj, i) => obj[i], obj);
|
|
@@ -4327,6 +4422,8 @@ class UserService extends EuiService {
|
|
|
4327
4422
|
this.store.dispatchAction(userState, 'user', reducer);
|
|
4328
4423
|
}
|
|
4329
4424
|
else {
|
|
4425
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4426
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4330
4427
|
this.store.dispatch(new UpdateUserStateAction(userState));
|
|
4331
4428
|
}
|
|
4332
4429
|
}
|
|
@@ -4344,22 +4441,16 @@ class UserServiceMock extends UserService {
|
|
|
4344
4441
|
constructor() {
|
|
4345
4442
|
super(null);
|
|
4346
4443
|
}
|
|
4347
|
-
|
|
4348
|
-
return of({
|
|
4349
|
-
}
|
|
4350
|
-
observePreferencesUpdate() { }
|
|
4351
|
-
loadUserPreferences() {
|
|
4352
|
-
return of({});
|
|
4353
|
-
}
|
|
4354
|
-
saveUserPreferences() {
|
|
4355
|
-
return of({});
|
|
4444
|
+
init(userState) {
|
|
4445
|
+
return of({ success: true });
|
|
4356
4446
|
}
|
|
4357
|
-
|
|
4358
|
-
userPreferences() {
|
|
4447
|
+
getState(keyOrMapFn) {
|
|
4359
4448
|
return of({});
|
|
4360
4449
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4450
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4451
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4452
|
+
updateState(userState, reducer) {
|
|
4453
|
+
/* empty */
|
|
4363
4454
|
}
|
|
4364
4455
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4365
4456
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UserServiceMock }); }
|
|
@@ -4457,17 +4548,24 @@ class EuLoginSessionTimeoutHandlingInterceptor {
|
|
|
4457
4548
|
this.checkRequestErrorForEULoginSessionTimeout(request, error);
|
|
4458
4549
|
}));
|
|
4459
4550
|
}
|
|
4551
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4552
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4460
4553
|
checkRequestSuccessForEULoginSessionTimeout(request, event) {
|
|
4461
4554
|
if (event instanceof HttpResponse) {
|
|
4555
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4556
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4462
4557
|
if (this.isSsoResponse(event.body)) {
|
|
4463
4558
|
this.reauthenticate();
|
|
4464
4559
|
}
|
|
4465
4560
|
}
|
|
4466
4561
|
}
|
|
4467
|
-
//
|
|
4562
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4563
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4468
4564
|
checkRequestErrorForEULoginSessionTimeout(request, response) {
|
|
4469
|
-
|
|
4565
|
+
/* intentionally blank; meant for overriding */
|
|
4470
4566
|
}
|
|
4567
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4568
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4471
4569
|
isSsoResponse(body) {
|
|
4472
4570
|
if (body) {
|
|
4473
4571
|
if (typeof body !== 'string') {
|
|
@@ -4518,8 +4616,13 @@ class UxRequestErrorModelInterceptor {
|
|
|
4518
4616
|
constructor(errorMappingHandler) {
|
|
4519
4617
|
this.errorMappingHandler = errorMappingHandler;
|
|
4520
4618
|
}
|
|
4619
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4620
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4521
4621
|
intercept(req, next) {
|
|
4522
|
-
return next.handle(req).pipe(
|
|
4622
|
+
return next.handle(req).pipe(
|
|
4623
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4624
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4625
|
+
catchError((err) => {
|
|
4523
4626
|
if (this.errorMappingHandler) {
|
|
4524
4627
|
if (err instanceof HttpErrorResponse) {
|
|
4525
4628
|
err = transformToUxHttpResponse(err, this.errorMappingHandler);
|
|
@@ -4547,14 +4650,25 @@ class OpenIdConnectInterceptor {
|
|
|
4547
4650
|
console.error('Please include the script openid-login.js in your index.html file.', 'For more details, please consult the documentation regarding the Http Interceptors and OpenID Connect configuration.');
|
|
4548
4651
|
}
|
|
4549
4652
|
}
|
|
4550
|
-
intercept(
|
|
4653
|
+
intercept(
|
|
4654
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4655
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4656
|
+
request, next, retryCount = 0,
|
|
4657
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4658
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4659
|
+
retryCallback) {
|
|
4551
4660
|
if (typeof OpenIdConnect !== 'undefined') {
|
|
4552
4661
|
let authorizedRequest = retryCallback;
|
|
4553
4662
|
if (!authorizedRequest) {
|
|
4663
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4664
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4554
4665
|
authorizedRequest = new Subject();
|
|
4555
4666
|
}
|
|
4556
4667
|
let subscription = null;
|
|
4557
|
-
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4668
|
+
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4669
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4670
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4671
|
+
(headers) => {
|
|
4558
4672
|
let newRequest = request;
|
|
4559
4673
|
if (headers) {
|
|
4560
4674
|
let newHeaders = request.headers;
|
|
@@ -4579,6 +4693,8 @@ class OpenIdConnectInterceptor {
|
|
|
4579
4693
|
subscription = next
|
|
4580
4694
|
.handle(newRequest)
|
|
4581
4695
|
.pipe(catchError((response) => this.handleErrorResponse(response, request, next, retryCount, authorizedRequest, subscription)))
|
|
4696
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4697
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4582
4698
|
.subscribe((httpEvent) => {
|
|
4583
4699
|
if (httpEvent) {
|
|
4584
4700
|
authorizedRequest.next(httpEvent);
|
|
@@ -4591,6 +4707,8 @@ class OpenIdConnectInterceptor {
|
|
|
4591
4707
|
}
|
|
4592
4708
|
});
|
|
4593
4709
|
}, (errorResponse) => {
|
|
4710
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4711
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4594
4712
|
const errorProperties = {
|
|
4595
4713
|
error: errorResponse,
|
|
4596
4714
|
};
|
|
@@ -4611,7 +4729,13 @@ class OpenIdConnectInterceptor {
|
|
|
4611
4729
|
return next.handle(request);
|
|
4612
4730
|
}
|
|
4613
4731
|
}
|
|
4614
|
-
handleErrorResponse(response,
|
|
4732
|
+
handleErrorResponse(response,
|
|
4733
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4734
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4735
|
+
originalRequest, next, retryCount = 0,
|
|
4736
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4737
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4738
|
+
retryCallback, subscription) {
|
|
4615
4739
|
if (response) {
|
|
4616
4740
|
if (response.error && response.error.error === 'invalid_request') {
|
|
4617
4741
|
// The ID token is invalid or incorrect; retrieve another one:
|
|
@@ -4644,7 +4768,13 @@ class OpenIdConnectInterceptor {
|
|
|
4644
4768
|
}
|
|
4645
4769
|
return throwError(response);
|
|
4646
4770
|
}
|
|
4647
|
-
retryRequest(
|
|
4771
|
+
retryRequest(
|
|
4772
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4773
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4774
|
+
originalRequest, response, next, retryCount = 0,
|
|
4775
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4776
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4777
|
+
retryCallback, subscription) {
|
|
4648
4778
|
if (retryCount < this.maximumRequestRetries()) {
|
|
4649
4779
|
this.intercept(originalRequest, next, retryCount + 1, retryCallback);
|
|
4650
4780
|
}
|
|
@@ -4661,6 +4791,8 @@ class OpenIdConnectInterceptor {
|
|
|
4661
4791
|
retryCallback.complete();
|
|
4662
4792
|
}
|
|
4663
4793
|
}
|
|
4794
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4795
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4664
4796
|
return of(null);
|
|
4665
4797
|
}
|
|
4666
4798
|
apiGatewayTokenExpired(response) {
|
|
@@ -4691,6 +4823,8 @@ class OpenIdConnectService {
|
|
|
4691
4823
|
constructor() {
|
|
4692
4824
|
this.userDetails = new Observable((observer) => {
|
|
4693
4825
|
if (typeof ApiGateway !== 'undefined') {
|
|
4826
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4827
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4694
4828
|
ApiGateway.getUser((user) => {
|
|
4695
4829
|
if (user) {
|
|
4696
4830
|
observer.next({
|
|
@@ -4752,5 +4886,5 @@ class OpenIdConnectServiceMock extends OpenIdConnectService {
|
|
|
4752
4886
|
* Generated bundle index. Do not edit.
|
|
4753
4887
|
*/
|
|
4754
4888
|
|
|
4755
|
-
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, CoreAppEffects, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreModuleEffects, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiCoreRootGuardClass, EuiError, EuiPermissionService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService,
|
|
4889
|
+
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, CoreAppEffects, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreModuleEffects, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiCoreRootGuardClass, EuiError, EuiPermissionService, 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, OpenIdConnectInterceptor, OpenIdConnectService, OpenIdConnectServiceMock, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_COUNTRIES, UX_ERROR_MAPPING_HANDLER_TOKEN, UX_TIMEZONES, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxAppShellService, UxDynamicComponentService, UxDynamicMenuService, UxErrorFeedbackService, UxErrorManager, UxRequestErrorModelInterceptor, UxTimezoneService, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, formatNumber, getGlobalConfig, getHttpErrorHandlingConfig, getModuleConfig, getRootLogConfig, getShowConnectionStatus, getViewElement, handleError, isDefined, loadEuiDynamicEnvironmentConfig, loadState, localForage, localStorageSync, markControlsTouched, markFormGroupTouched, mergeAppHandlerConfigToAppConfig, mergeAppJsonConfigToAppConfig, offset, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail, withUxErrorManager };
|
|
4756
4890
|
//# sourceMappingURL=eui-core.mjs.map
|