@eui/core 16.2.4 → 16.2.5-snapshot-1697815040873
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 +1 -1
- package/docs/injectables/I18nServiceMock.html +1 -1
- 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 -7
- 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 -458
- 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 -3
- 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':
|
|
@@ -919,6 +781,7 @@ class I18nService extends EuiLazyService {
|
|
|
919
781
|
* Add resources based of a config loader
|
|
920
782
|
*
|
|
921
783
|
* @param config I18nLoaderConfig
|
|
784
|
+
* @param moduleName
|
|
922
785
|
* @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
|
|
923
786
|
*/
|
|
924
787
|
addResources(config, moduleName) {
|
|
@@ -926,6 +789,8 @@ class I18nService extends EuiLazyService {
|
|
|
926
789
|
this.onModuleLoad.next({ ready: false, name: moduleName });
|
|
927
790
|
const loader = this.translateService.currentLoader;
|
|
928
791
|
if (loader instanceof I18nLoader) {
|
|
792
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
793
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
929
794
|
const langSubscription = [];
|
|
930
795
|
const i18nLoader = loader;
|
|
931
796
|
// add the resources to the loader
|
|
@@ -935,10 +800,10 @@ class I18nService extends EuiLazyService {
|
|
|
935
800
|
// add the new set of translations to the current language
|
|
936
801
|
this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
|
|
937
802
|
})));
|
|
938
|
-
// if the current language is different
|
|
803
|
+
// if the current language is different from the DEFAULT language
|
|
939
804
|
const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
|
|
940
805
|
if (this.translateService.currentLang !== defaultLang) {
|
|
941
|
-
// manually load the resources for the default language and add them to the
|
|
806
|
+
// manually load the resources for the default language and add them to the translation service
|
|
942
807
|
langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
|
|
943
808
|
this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
|
|
944
809
|
})));
|
|
@@ -1030,6 +895,8 @@ class I18nService extends EuiLazyService {
|
|
|
1030
895
|
* @returns Observable that returns an object contain the object translation for given language after language
|
|
1031
896
|
* fully loaded.
|
|
1032
897
|
*/
|
|
898
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
899
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1033
900
|
use(lang) {
|
|
1034
901
|
return this.translateService.use(lang);
|
|
1035
902
|
}
|
|
@@ -1059,39 +926,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
1059
926
|
args: [DOCUMENT]
|
|
1060
927
|
}] }]; } });
|
|
1061
928
|
|
|
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 []; } });
|
|
929
|
+
// export * from './i18n.service.mock';
|
|
1095
930
|
|
|
1096
931
|
const initialState = {
|
|
1097
932
|
appName: '',
|
|
@@ -1156,6 +991,8 @@ class UxAppShellService {
|
|
|
1156
991
|
get breakpoint$() {
|
|
1157
992
|
return this._breakpoint$.asObservable();
|
|
1158
993
|
}
|
|
994
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
995
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1159
996
|
get breakpoints$() {
|
|
1160
997
|
return this._breakpoints$.asObservable();
|
|
1161
998
|
}
|
|
@@ -1243,6 +1080,8 @@ class UxAppShellService {
|
|
|
1243
1080
|
this.isCloseAllSticky = false;
|
|
1244
1081
|
this.growlLife = 3000;
|
|
1245
1082
|
this.growlPosition = 'bottom-right';
|
|
1083
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1084
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1246
1085
|
this.growlCallback = null;
|
|
1247
1086
|
this.activeModals = [];
|
|
1248
1087
|
this.openModalId = new BehaviorSubject('');
|
|
@@ -1270,7 +1109,7 @@ class UxAppShellService {
|
|
|
1270
1109
|
}
|
|
1271
1110
|
}
|
|
1272
1111
|
setState(nextState, updateI18 = true) {
|
|
1273
|
-
let breakpoint, breakpoints
|
|
1112
|
+
let breakpoint, breakpoints;
|
|
1274
1113
|
let combinedLinks;
|
|
1275
1114
|
const state = this.state;
|
|
1276
1115
|
// check if window width has been updated from previous state
|
|
@@ -1286,7 +1125,7 @@ class UxAppShellService {
|
|
|
1286
1125
|
breakpoints = state.breakpoints;
|
|
1287
1126
|
}
|
|
1288
1127
|
// finally get the wrapper classes when both the state and breakpoint are known
|
|
1289
|
-
wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
1128
|
+
const wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
1290
1129
|
// check if the menuLinks or sidebarLinks have changed from previous state
|
|
1291
1130
|
if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
|
|
1292
1131
|
combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
|
|
@@ -1313,6 +1152,8 @@ class UxAppShellService {
|
|
|
1313
1152
|
*
|
|
1314
1153
|
* @param key can be 'key' or 'key.sub.sub'
|
|
1315
1154
|
*/
|
|
1155
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1316
1157
|
getState(key) {
|
|
1317
1158
|
return defer(() =>
|
|
1318
1159
|
// check if key exists
|
|
@@ -1494,8 +1335,8 @@ class UxAppShellService {
|
|
|
1494
1335
|
* Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
|
|
1495
1336
|
*/
|
|
1496
1337
|
setAppViewportCssVars() {
|
|
1497
|
-
|
|
1498
|
-
|
|
1338
|
+
const vh = window.innerHeight * 0.01;
|
|
1339
|
+
const vw = window.innerWidth * 0.01;
|
|
1499
1340
|
this._setCssVarValue('--eui-app-vh', `${vh}px`);
|
|
1500
1341
|
this._setCssVarValue('--eui-app-vw', `${vw}px`);
|
|
1501
1342
|
}
|
|
@@ -1606,7 +1447,7 @@ class UxAppShellService {
|
|
|
1606
1447
|
modalId = 'single_modal';
|
|
1607
1448
|
}
|
|
1608
1449
|
if (this.activeModals.length) {
|
|
1609
|
-
|
|
1450
|
+
const modalIndex = this.findModalIndex(modalId);
|
|
1610
1451
|
if (modalIndex !== -1) {
|
|
1611
1452
|
return this.activeModals[modalIndex].isOpen;
|
|
1612
1453
|
}
|
|
@@ -1668,7 +1509,7 @@ class UxAppShellService {
|
|
|
1668
1509
|
document.documentElement.style.setProperty(varName, varValue);
|
|
1669
1510
|
}
|
|
1670
1511
|
getWrapperClasses(state, breakpoint) {
|
|
1671
|
-
|
|
1512
|
+
const classes = [];
|
|
1672
1513
|
classes.push(breakpoint);
|
|
1673
1514
|
if (state.hasSidebar) {
|
|
1674
1515
|
if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
|
|
@@ -1761,12 +1602,14 @@ class UxAppShellService {
|
|
|
1761
1602
|
};
|
|
1762
1603
|
}
|
|
1763
1604
|
getJson(url) {
|
|
1764
|
-
return this.http.get(url)
|
|
1605
|
+
return firstValueFrom(this.http.get(url)).then(this.extractData).catch(this.handleError);
|
|
1765
1606
|
}
|
|
1766
1607
|
extractData(res) {
|
|
1767
1608
|
const body = res;
|
|
1768
1609
|
return body || {};
|
|
1769
1610
|
}
|
|
1611
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1612
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1770
1613
|
handleError(error) {
|
|
1771
1614
|
console.error('An error occurred', error);
|
|
1772
1615
|
return Promise.reject(error.message || error);
|
|
@@ -1781,7 +1624,7 @@ class UxAppShellService {
|
|
|
1781
1624
|
}
|
|
1782
1625
|
});
|
|
1783
1626
|
}
|
|
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$
|
|
1627
|
+
/** @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
1628
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, providedIn: 'root' }); }
|
|
1786
1629
|
}
|
|
1787
1630
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UxAppShellService, decorators: [{
|
|
@@ -1794,7 +1637,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
1794
1637
|
}, {
|
|
1795
1638
|
type: Inject,
|
|
1796
1639
|
args: [GLOBAL_CONFIG_TOKEN]
|
|
1797
|
-
}] }, { type: i1$
|
|
1640
|
+
}] }, { type: i1$1.HttpClient }, { type: undefined, decorators: [{
|
|
1798
1641
|
type: Inject,
|
|
1799
1642
|
args: [PLATFORM_ID]
|
|
1800
1643
|
}] }, { type: i2$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
|
|
@@ -1818,9 +1661,9 @@ class CoreAppEffects {
|
|
|
1818
1661
|
this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
|
|
1819
1662
|
// TODO: for eUI 14, drop boolean support and refactor
|
|
1820
1663
|
// check if feature is enabled
|
|
1821
|
-
|
|
1664
|
+
const isFeatureEnabled = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.enabled : this.showConnectionStatus;
|
|
1822
1665
|
// extract lifespan if any
|
|
1823
|
-
|
|
1666
|
+
const lifespan = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.messageBox?.lifespan || 0 : 0;
|
|
1824
1667
|
// if the user needs to be informed about the connection status
|
|
1825
1668
|
if (isFeatureEnabled) {
|
|
1826
1669
|
if (connected) {
|
|
@@ -1836,12 +1679,12 @@ class CoreAppEffects {
|
|
|
1836
1679
|
}
|
|
1837
1680
|
})), { dispatch: false });
|
|
1838
1681
|
}
|
|
1839
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$
|
|
1682
|
+
/** @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
1683
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects }); }
|
|
1841
1684
|
}
|
|
1842
1685
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: CoreAppEffects, decorators: [{
|
|
1843
1686
|
type: Injectable
|
|
1844
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
1687
|
+
}], ctorParameters: function () { return [{ type: i1$2.Actions }, { type: undefined, decorators: [{
|
|
1845
1688
|
type: Inject,
|
|
1846
1689
|
args: [SHOW_CONNECTION_STATUS_TOKEN]
|
|
1847
1690
|
}] }, { type: i2.TranslateService }, { type: UxAppShellService }]; } });
|
|
@@ -1881,7 +1724,6 @@ const removeApiQueueItem = (state, action) => {
|
|
|
1881
1724
|
}, {});
|
|
1882
1725
|
return Object.assign({}, state, { apiQueue });
|
|
1883
1726
|
};
|
|
1884
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1885
1727
|
const emptyApiQueue = (state, action) =>
|
|
1886
1728
|
// remove all items in the Api Queue
|
|
1887
1729
|
Object.assign({}, state, { apiQueue: {} });
|
|
@@ -1983,6 +1825,8 @@ const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
|
1983
1825
|
return state;
|
|
1984
1826
|
};
|
|
1985
1827
|
|
|
1828
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1829
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1986
1830
|
const coreReducers = Object.assign({}, {
|
|
1987
1831
|
app: coreAppReducers,
|
|
1988
1832
|
user: coreUserReducers,
|
|
@@ -1991,6 +1835,8 @@ const coreReducers = Object.assign({}, {
|
|
|
1991
1835
|
locale: coreLocaleReducers,
|
|
1992
1836
|
});
|
|
1993
1837
|
|
|
1838
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1839
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1994
1840
|
const extend = extendProxy.default || extendProxy;
|
|
1995
1841
|
/**
|
|
1996
1842
|
* Utility meta-reducer to load the state from the local storage
|
|
@@ -2028,7 +1874,7 @@ const filterAppState = (app) => {
|
|
|
2028
1874
|
};
|
|
2029
1875
|
/**
|
|
2030
1876
|
*
|
|
2031
|
-
* @param
|
|
1877
|
+
* @param storage Type of storage to load the state from
|
|
2032
1878
|
*/
|
|
2033
1879
|
const loadState = (storage = localStorage) => {
|
|
2034
1880
|
try {
|
|
@@ -2078,6 +1924,119 @@ const cb = (reducer, storage) => (state, action) => {
|
|
|
2078
1924
|
return reducer(state, action);
|
|
2079
1925
|
};
|
|
2080
1926
|
|
|
1927
|
+
var BrowserStorageType;
|
|
1928
|
+
(function (BrowserStorageType) {
|
|
1929
|
+
BrowserStorageType[BrowserStorageType["local"] = 0] = "local";
|
|
1930
|
+
BrowserStorageType[BrowserStorageType["session"] = 1] = "session";
|
|
1931
|
+
})(BrowserStorageType || (BrowserStorageType = {}));
|
|
1932
|
+
// todo should stay here but all the store directory should be moved upper level
|
|
1933
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1934
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1935
|
+
class StoreService {
|
|
1936
|
+
constructor(store, logService) {
|
|
1937
|
+
this.store = store;
|
|
1938
|
+
this.logService = logService;
|
|
1939
|
+
/**
|
|
1940
|
+
* autoSave handlers to call before saving in local Storage
|
|
1941
|
+
*/
|
|
1942
|
+
this._autoSaveHandlers = {};
|
|
1943
|
+
/** storage instance e.g. localStorage, sessionStorage */
|
|
1944
|
+
this._storage = localStorage;
|
|
1945
|
+
}
|
|
1946
|
+
// use init with just version info, to update to user state, UserService.updateState
|
|
1947
|
+
// initializeStore(version?: string, userDetails?: BaseUserDetails) {
|
|
1948
|
+
// this.dispatch(new InitStoreAction({ version, userDetails }));
|
|
1949
|
+
// }
|
|
1950
|
+
init(version, storageType) {
|
|
1951
|
+
this.dispatch(new InitStoreAction({ version }));
|
|
1952
|
+
this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
|
|
1953
|
+
}
|
|
1954
|
+
addAutoSaveHandler(stateSlice, handler) {
|
|
1955
|
+
if (!this.store) {
|
|
1956
|
+
if (this.logService) {
|
|
1957
|
+
this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
|
|
1958
|
+
}
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
this._autoSaveHandlers[stateSlice] = handler;
|
|
1962
|
+
}
|
|
1963
|
+
handleAutoSave() {
|
|
1964
|
+
if (!this.store) {
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1967
|
+
this.store.pipe(debounceTime(1000), distinctUntilChanged()).subscribe((state) => {
|
|
1968
|
+
this.saveState(state);
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Proxy to NGRX store.dispatch()
|
|
1973
|
+
* that allows to intercept if the store is present
|
|
1974
|
+
*/
|
|
1975
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1976
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1977
|
+
dispatch(action) {
|
|
1978
|
+
if (this.store) {
|
|
1979
|
+
return this.store.dispatch(action);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1983
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1984
|
+
dispatchAction(state, actionKey, reducer) {
|
|
1985
|
+
if (this.store) {
|
|
1986
|
+
this.store.addReducer(actionKey, reducer);
|
|
1987
|
+
return this.store.dispatch({ type: actionKey, payload: state });
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Proxy to NGRX store.select()
|
|
1992
|
+
* that allows to intercept if the store is present
|
|
1993
|
+
*/
|
|
1994
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1995
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1996
|
+
select(key) {
|
|
1997
|
+
if (!this.store) {
|
|
1998
|
+
return throwError(() => new Error('NGRX Store not configured'));
|
|
1999
|
+
}
|
|
2000
|
+
return this.store.select(key);
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* filters and save the state with the Browser storage
|
|
2004
|
+
* @param state type of CoreState
|
|
2005
|
+
*/
|
|
2006
|
+
saveState(state) {
|
|
2007
|
+
let stateToSave = {
|
|
2008
|
+
app: state.app,
|
|
2009
|
+
};
|
|
2010
|
+
if (state.user) {
|
|
2011
|
+
const { userId, preferences } = state.user;
|
|
2012
|
+
stateToSave.user = { userId, preferences };
|
|
2013
|
+
}
|
|
2014
|
+
Object.keys(this._autoSaveHandlers).forEach((sliceState) => {
|
|
2015
|
+
const handler = this._autoSaveHandlers[sliceState];
|
|
2016
|
+
stateToSave = Object.assign(stateToSave, { [sliceState]: handler(state[sliceState]) });
|
|
2017
|
+
});
|
|
2018
|
+
try {
|
|
2019
|
+
const serializedState = JSON.stringify(stateToSave);
|
|
2020
|
+
this._storage.setItem('state', serializedState);
|
|
2021
|
+
}
|
|
2022
|
+
catch (err) {
|
|
2023
|
+
// Ignore write errors.
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
/** @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 }); }
|
|
2027
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
2028
|
+
}
|
|
2029
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: StoreService, decorators: [{
|
|
2030
|
+
type: Injectable,
|
|
2031
|
+
args: [{
|
|
2032
|
+
providedIn: 'root',
|
|
2033
|
+
}]
|
|
2034
|
+
}], ctorParameters: function () { return [{ type: i1$3.Store, decorators: [{
|
|
2035
|
+
type: Optional
|
|
2036
|
+
}] }, { type: LogService, decorators: [{
|
|
2037
|
+
type: Optional
|
|
2038
|
+
}] }]; } });
|
|
2039
|
+
|
|
2081
2040
|
class StoreServiceMock extends StoreService {
|
|
2082
2041
|
constructor() {
|
|
2083
2042
|
super(null, null);
|
|
@@ -2096,6 +2055,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2096
2055
|
type: Injectable
|
|
2097
2056
|
}], ctorParameters: function () { return []; } });
|
|
2098
2057
|
|
|
2058
|
+
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
2059
|
+
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
2060
|
+
locationInitialized.then(() => {
|
|
2061
|
+
const appConfig = injector.get(CONFIG_TOKEN);
|
|
2062
|
+
// necessary config parameters
|
|
2063
|
+
let appVersion;
|
|
2064
|
+
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
2065
|
+
appVersion = appConfig.versions.app;
|
|
2066
|
+
}
|
|
2067
|
+
else {
|
|
2068
|
+
appVersion = '0.0.0';
|
|
2069
|
+
}
|
|
2070
|
+
let storageType;
|
|
2071
|
+
if (appConfig && appConfig.saveStateStorage) {
|
|
2072
|
+
storageType = appConfig.saveStateStorage;
|
|
2073
|
+
}
|
|
2074
|
+
else {
|
|
2075
|
+
storageType = BrowserStorageType.local;
|
|
2076
|
+
}
|
|
2077
|
+
const storeService = injector.get(StoreService);
|
|
2078
|
+
storeService.init(appVersion, storageType);
|
|
2079
|
+
storeService.handleAutoSave();
|
|
2080
|
+
resolve(null);
|
|
2081
|
+
});
|
|
2082
|
+
});
|
|
2083
|
+
|
|
2084
|
+
function getCoreProviders() {
|
|
2085
|
+
return [
|
|
2086
|
+
// core config
|
|
2087
|
+
...getDependencyProviders(),
|
|
2088
|
+
{ provide: BASE_NAME_TOKEN, useValue: 'eui-core' },
|
|
2089
|
+
// app config
|
|
2090
|
+
{ provide: CONFIG_TOKEN, useFactory: prepareEuiAppConfigToken, deps: [EUI_CONFIG_TOKEN] },
|
|
2091
|
+
// global config
|
|
2092
|
+
{ provide: GLOBAL_CONFIG_TOKEN, useFactory: getGlobalConfig, deps: [CONFIG_TOKEN] },
|
|
2093
|
+
{ provide: ROOT_LOG_CONFIG_TOKEN, useFactory: getRootLogConfig, deps: [CONFIG_TOKEN] },
|
|
2094
|
+
{ provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
|
|
2095
|
+
{ provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
|
|
2096
|
+
{ provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
|
|
2097
|
+
{ provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
|
|
2098
|
+
];
|
|
2099
|
+
}
|
|
2100
|
+
function getDependencyProviders() {
|
|
2101
|
+
return [{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] }];
|
|
2102
|
+
}
|
|
2103
|
+
function getCoreChildProviders(moduleName) {
|
|
2104
|
+
return [
|
|
2105
|
+
// module config
|
|
2106
|
+
{ provide: MODULE_NAME_TOKEN, useValue: moduleName },
|
|
2107
|
+
{ provide: MODULE_CONFIG_TOKEN, useFactory: getModuleConfig, deps: [CONFIG_TOKEN, MODULE_NAME_TOKEN] },
|
|
2108
|
+
// log config
|
|
2109
|
+
{
|
|
2110
|
+
provide: LogService,
|
|
2111
|
+
useFactory: euiLogServiceFactory,
|
|
2112
|
+
deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN, MODULE_NAME_TOKEN, MODULE_CONFIG_TOKEN],
|
|
2113
|
+
},
|
|
2114
|
+
];
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2099
2117
|
const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
|
|
2100
2118
|
class CoreModule {
|
|
2101
2119
|
/**
|
|
@@ -2159,7 +2177,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2159
2177
|
}] }, { type: i0.Injector }]; } });
|
|
2160
2178
|
const createEuiCoreRootGuard = (core) => {
|
|
2161
2179
|
if (core) {
|
|
2162
|
-
throw new TypeError(
|
|
2180
|
+
throw new TypeError('CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.');
|
|
2163
2181
|
}
|
|
2164
2182
|
return 'guarded';
|
|
2165
2183
|
};
|
|
@@ -2219,6 +2237,8 @@ const messages = {
|
|
|
2219
2237
|
// Intermediate "hacky" subclass taken from
|
|
2220
2238
|
// https://www.bennadel.com/blog/3226-experimenting-with-error-sub-classing-using-es5-and-typescript-2-1-5.htm
|
|
2221
2239
|
class ErrorSubClass {
|
|
2240
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2222
2242
|
constructor(code, msg, args) {
|
|
2223
2243
|
if (!msg && code && code in messages) {
|
|
2224
2244
|
if (typeof messages[code] === 'function') {
|
|
@@ -2244,6 +2264,8 @@ class ErrorSubClass {
|
|
|
2244
2264
|
// This replaces the "extends" on the Class
|
|
2245
2265
|
// ErrorSubClass.prototype = <any>Object.create(Error.prototype);
|
|
2246
2266
|
class EuiError extends ErrorSubClass {
|
|
2267
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2268
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2247
2269
|
constructor(code = errorCodes.ERR_GENERIC, msg, args) {
|
|
2248
2270
|
super(code, msg, args);
|
|
2249
2271
|
this.name = 'EuiError';
|
|
@@ -2255,6 +2277,8 @@ class GlobalErrorHandler extends ErrorHandler {
|
|
|
2255
2277
|
super();
|
|
2256
2278
|
this.logService = logService;
|
|
2257
2279
|
}
|
|
2280
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2258
2282
|
handleError(error) {
|
|
2259
2283
|
// log error
|
|
2260
2284
|
this.logService.error(error.message || error.toString());
|
|
@@ -2277,21 +2301,28 @@ class HttpErrorHandlerInterceptor {
|
|
|
2277
2301
|
this.injector = injector;
|
|
2278
2302
|
this.router = router;
|
|
2279
2303
|
}
|
|
2304
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2305
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2280
2306
|
intercept(req, next) {
|
|
2281
|
-
return next.handle(req).pipe(tap(
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
this.
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2307
|
+
return next.handle(req).pipe(tap({
|
|
2308
|
+
next: () => { },
|
|
2309
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2310
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2311
|
+
error: (error) => {
|
|
2312
|
+
// in case of http error
|
|
2313
|
+
if (error instanceof HttpErrorResponse) {
|
|
2314
|
+
const routeConfig = this.getRouteConfig(error);
|
|
2315
|
+
const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
|
|
2316
|
+
if (typeof rule === 'string') {
|
|
2317
|
+
// perform a redirect
|
|
2318
|
+
this.router.navigate([rule]);
|
|
2319
|
+
}
|
|
2320
|
+
else if (typeof rule === 'function') {
|
|
2321
|
+
// callback function
|
|
2322
|
+
rule.call(null, error, this.injector);
|
|
2323
|
+
}
|
|
2293
2324
|
}
|
|
2294
|
-
}
|
|
2325
|
+
},
|
|
2295
2326
|
}));
|
|
2296
2327
|
}
|
|
2297
2328
|
/**
|
|
@@ -2398,6 +2429,8 @@ class ApiQueueService {
|
|
|
2398
2429
|
* @param id - id of the item inside the queue
|
|
2399
2430
|
* @return An Observable of type any
|
|
2400
2431
|
*/
|
|
2432
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2433
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2401
2434
|
processQueueItem(id) {
|
|
2402
2435
|
return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
2403
2436
|
if (!queue) {
|
|
@@ -2412,6 +2445,8 @@ class ApiQueueService {
|
|
|
2412
2445
|
* @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
|
|
2413
2446
|
* @return An Observable with an array which contains all responses from all items in queue.
|
|
2414
2447
|
*/
|
|
2448
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2449
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2415
2450
|
processAllQueueItems(continueOnError = true) {
|
|
2416
2451
|
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
2417
2452
|
this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
@@ -2419,7 +2454,10 @@ class ApiQueueService {
|
|
|
2419
2454
|
throw error;
|
|
2420
2455
|
}
|
|
2421
2456
|
return of(error);
|
|
2422
|
-
})))),
|
|
2457
|
+
})))),
|
|
2458
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2459
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2460
|
+
switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
|
|
2423
2461
|
}
|
|
2424
2462
|
/**
|
|
2425
2463
|
* Process all items in queue after it order them based on their timestamp. Beware that order
|
|
@@ -2427,6 +2465,8 @@ class ApiQueueService {
|
|
|
2427
2465
|
* or Http response follows order.
|
|
2428
2466
|
* @param [ascending=true] - sets the order of queue items based on timestamp
|
|
2429
2467
|
*/
|
|
2468
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2469
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2430
2470
|
processAllQueueItemsSequential(ascending = true) {
|
|
2431
2471
|
return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
|
|
2432
2472
|
.sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
|
|
@@ -2449,10 +2489,13 @@ class ApiQueueService {
|
|
|
2449
2489
|
* @param item - the item of the queue that matches the id.
|
|
2450
2490
|
* @return An Observable of HttpClient Request
|
|
2451
2491
|
*/
|
|
2492
|
+
// TODO: add type for T and deprecate old function
|
|
2493
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2494
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2452
2495
|
buildHttpRequest(id, item) {
|
|
2453
2496
|
return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
|
|
2454
2497
|
}
|
|
2455
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$
|
|
2498
|
+
/** @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
2499
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
|
|
2457
2500
|
}
|
|
2458
2501
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: ApiQueueService, decorators: [{
|
|
@@ -2460,7 +2503,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2460
2503
|
args: [{
|
|
2461
2504
|
providedIn: 'root',
|
|
2462
2505
|
}]
|
|
2463
|
-
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$
|
|
2506
|
+
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$1.HttpClient }, { type: LogService }]; } });
|
|
2464
2507
|
|
|
2465
2508
|
class ApiQueueServiceMock extends ApiQueueService {
|
|
2466
2509
|
constructor() {
|
|
@@ -2473,11 +2516,15 @@ class ApiQueueServiceMock extends ApiQueueService {
|
|
|
2473
2516
|
return of({ uri: id, method: 'GET' });
|
|
2474
2517
|
}
|
|
2475
2518
|
removeAllQueueItem() { }
|
|
2519
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2520
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2476
2521
|
processAllQueueItems() {
|
|
2477
2522
|
return of({});
|
|
2478
2523
|
}
|
|
2479
2524
|
addQueueItem() { }
|
|
2480
2525
|
removeQueueItem() { }
|
|
2526
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2527
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2481
2528
|
processQueueItem() {
|
|
2482
2529
|
return of({});
|
|
2483
2530
|
}
|
|
@@ -2491,15 +2538,15 @@ const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
|
2491
2538
|
* http://api.jquery.com/position/
|
|
2492
2539
|
*/
|
|
2493
2540
|
const position = (nativeEl) => {
|
|
2494
|
-
|
|
2541
|
+
const elBCR = offset(nativeEl);
|
|
2495
2542
|
let offsetParentBCR = { top: 0, left: 0 };
|
|
2496
|
-
|
|
2543
|
+
const offsetParentEl = parentOffsetEl(nativeEl);
|
|
2497
2544
|
if (offsetParentEl !== document) {
|
|
2498
2545
|
offsetParentBCR = offset(offsetParentEl);
|
|
2499
2546
|
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
|
|
2500
2547
|
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
|
|
2501
2548
|
}
|
|
2502
|
-
|
|
2549
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
2503
2550
|
return {
|
|
2504
2551
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
2505
2552
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -2512,7 +2559,7 @@ const position = (nativeEl) => {
|
|
|
2512
2559
|
* http://api.jquery.com/offset/
|
|
2513
2560
|
*/
|
|
2514
2561
|
const offset = (nativeEl) => {
|
|
2515
|
-
|
|
2562
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
2516
2563
|
return {
|
|
2517
2564
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
2518
2565
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -2521,6 +2568,8 @@ const offset = (nativeEl) => {
|
|
|
2521
2568
|
};
|
|
2522
2569
|
};
|
|
2523
2570
|
// PRIVATE FUNCTIONS
|
|
2571
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2572
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2524
2573
|
const getStyle = (nativeEl, cssProp) => {
|
|
2525
2574
|
// IE
|
|
2526
2575
|
if (nativeEl.currentStyle) {
|
|
@@ -2548,8 +2597,8 @@ const parentOffsetEl = (nativeEl) => {
|
|
|
2548
2597
|
return offsetParent || document;
|
|
2549
2598
|
};
|
|
2550
2599
|
const getViewElement = (fixture, componentClass, klass) => {
|
|
2551
|
-
let
|
|
2552
|
-
de = fixture.debugElement.query(By.css(componentClass));
|
|
2600
|
+
let el, domElement;
|
|
2601
|
+
const de = fixture.debugElement.query(By.css(componentClass));
|
|
2553
2602
|
if (de) {
|
|
2554
2603
|
el = de.nativeElement;
|
|
2555
2604
|
if (el && klass) {
|
|
@@ -2559,7 +2608,7 @@ const getViewElement = (fixture, componentClass, klass) => {
|
|
|
2559
2608
|
}
|
|
2560
2609
|
}
|
|
2561
2610
|
}
|
|
2562
|
-
return { de, el, domElement };
|
|
2611
|
+
return { de, el, domElement: domElement };
|
|
2563
2612
|
};
|
|
2564
2613
|
const closestMatchingParent = (target, className) => {
|
|
2565
2614
|
let element = target;
|
|
@@ -2645,11 +2694,11 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2645
2694
|
}
|
|
2646
2695
|
if (typeof value === 'string') {
|
|
2647
2696
|
// get all non characters
|
|
2648
|
-
|
|
2697
|
+
const nonChars = value.match(/[^0-9]+/g) || [];
|
|
2649
2698
|
// get all unique chars
|
|
2650
|
-
|
|
2699
|
+
const uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
|
|
2651
2700
|
// get separators
|
|
2652
|
-
|
|
2701
|
+
const separators = Array.from(uniqueChars.keys());
|
|
2653
2702
|
// sense where decimal separator and where thousand separator is
|
|
2654
2703
|
if (separators.length > 1) {
|
|
2655
2704
|
// left detected separator will be thousand and second will be decimal
|
|
@@ -2675,12 +2724,13 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2675
2724
|
return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2676
2725
|
}
|
|
2677
2726
|
// do the replacement of separators and parseInt
|
|
2678
|
-
// Beware! Always replace thousand separator first and then decimal
|
|
2727
|
+
// Beware! Always replace a thousand separator first and then decimal
|
|
2679
2728
|
value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
|
|
2680
2729
|
}
|
|
2681
2730
|
decimalSeparator = inDecimalSeparator;
|
|
2682
2731
|
thousandsSeparator = inThousandSeparator;
|
|
2683
2732
|
const maxFraction = '0'.repeat(fractionSize);
|
|
2733
|
+
// eslint-disable-next-line prefer-const
|
|
2684
2734
|
let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
|
|
2685
2735
|
fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
|
|
2686
2736
|
// this rule makes sense only in number in case fraction is all zero
|
|
@@ -2689,9 +2739,8 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2689
2739
|
};
|
|
2690
2740
|
|
|
2691
2741
|
const handleError = (error) => {
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
return throwError(errMsg);
|
|
2742
|
+
const errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
|
2743
|
+
throw new Error(errMsg);
|
|
2695
2744
|
};
|
|
2696
2745
|
|
|
2697
2746
|
/**
|
|
@@ -2787,7 +2836,7 @@ class EuiPermissionService extends EuiService {
|
|
|
2787
2836
|
*/
|
|
2788
2837
|
haveAllRights(rights) {
|
|
2789
2838
|
if (!isDefined(rights)) {
|
|
2790
|
-
throw Error(
|
|
2839
|
+
throw Error('The rights should be an array but instead it\'s not defined!');
|
|
2791
2840
|
}
|
|
2792
2841
|
return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
|
|
2793
2842
|
}
|
|
@@ -2803,6 +2852,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
2803
2852
|
type: Optional
|
|
2804
2853
|
}] }, { type: StoreService }]; } });
|
|
2805
2854
|
|
|
2855
|
+
// TODO: Type of LINK should be UxLink or something relevant. Do we need that service anymore?
|
|
2856
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2857
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2806
2858
|
class UxDynamicMenuService {
|
|
2807
2859
|
// TODO: it should be moved euiservice, or it should be static
|
|
2808
2860
|
// TODO: can we moved that service inside the module of the component that's using it?
|
|
@@ -2970,6 +3022,7 @@ class UxErrorManager {
|
|
|
2970
3022
|
}
|
|
2971
3023
|
}
|
|
2972
3024
|
|
|
3025
|
+
// TODO: Do we need that service anymore? Can we remove it?
|
|
2973
3026
|
const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
|
|
2974
3027
|
class UxDynamicComponentService {
|
|
2975
3028
|
constructor(componentFactoryResolver, injector, appRef) {
|
|
@@ -2983,6 +3036,8 @@ class UxDynamicComponentService {
|
|
|
2983
3036
|
* @param el The element reference for the component to be injected
|
|
2984
3037
|
* @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
|
|
2985
3038
|
*/
|
|
3039
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3040
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2986
3041
|
add(component, el, config) {
|
|
2987
3042
|
// TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
|
|
2988
3043
|
// Create a portalHost from a DOM element
|
|
@@ -3018,6 +3073,8 @@ class UxDynamicComponentService {
|
|
|
3018
3073
|
* creates a custom injector to be used when providing custom injection tokens to components inside a portal
|
|
3019
3074
|
* @param data to be used by DYNAMIC_COMPONENT_CONFIG token
|
|
3020
3075
|
*/
|
|
3076
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3077
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3021
3078
|
createInjector(data) {
|
|
3022
3079
|
const injectorTokens = new WeakMap();
|
|
3023
3080
|
injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
|
|
@@ -3779,18 +3836,26 @@ class AsyncStorageService extends StorageService {
|
|
|
3779
3836
|
}
|
|
3780
3837
|
|
|
3781
3838
|
class AsyncStorageServiceMock extends AsyncStorageService {
|
|
3839
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3840
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3782
3841
|
ready() {
|
|
3783
3842
|
return of({});
|
|
3784
3843
|
}
|
|
3785
3844
|
name() {
|
|
3786
3845
|
return null;
|
|
3787
3846
|
}
|
|
3847
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3848
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3788
3849
|
get() {
|
|
3789
3850
|
return of({});
|
|
3790
3851
|
}
|
|
3852
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3853
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3791
3854
|
set() {
|
|
3792
3855
|
return of({});
|
|
3793
3856
|
}
|
|
3857
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3858
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3794
3859
|
remove() {
|
|
3795
3860
|
return of({});
|
|
3796
3861
|
}
|
|
@@ -3818,6 +3883,8 @@ class LocalStorageService extends StorageService {
|
|
|
3818
3883
|
* @param key the associated key
|
|
3819
3884
|
* @returns the value or undefined, if case of error
|
|
3820
3885
|
*/
|
|
3886
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3887
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3821
3888
|
get(key) {
|
|
3822
3889
|
try {
|
|
3823
3890
|
const serialized = localStorage.getItem(key);
|
|
@@ -3835,6 +3902,8 @@ class LocalStorageService extends StorageService {
|
|
|
3835
3902
|
* @param key the associated key
|
|
3836
3903
|
* @param value the value to set
|
|
3837
3904
|
*/
|
|
3905
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3906
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3838
3907
|
set(key, value) {
|
|
3839
3908
|
try {
|
|
3840
3909
|
const serialized = JSON.stringify(value);
|
|
@@ -3889,6 +3958,8 @@ class SessionStorageService extends StorageService {
|
|
|
3889
3958
|
* @param key the associated key
|
|
3890
3959
|
* @returns the value or undefined, if case of error
|
|
3891
3960
|
*/
|
|
3961
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3962
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3892
3963
|
get(key) {
|
|
3893
3964
|
try {
|
|
3894
3965
|
const serialized = sessionStorage.getItem(key);
|
|
@@ -3906,6 +3977,8 @@ class SessionStorageService extends StorageService {
|
|
|
3906
3977
|
* @param key the associated key
|
|
3907
3978
|
* @param value the value to set
|
|
3908
3979
|
*/
|
|
3980
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3981
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3909
3982
|
set(key, value) {
|
|
3910
3983
|
try {
|
|
3911
3984
|
const serialized = JSON.stringify(value);
|
|
@@ -3941,7 +4014,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImpo
|
|
|
3941
4014
|
}] }]; } });
|
|
3942
4015
|
|
|
3943
4016
|
/** @internal */
|
|
4017
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4018
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3944
4019
|
const localForage = 'defineDriver' in lf ? lf : lf['default'];
|
|
4020
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4021
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3945
4022
|
const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVICE_CONFIG');
|
|
3946
4023
|
/**
|
|
3947
4024
|
* localforage service, using the localForage javascript library
|
|
@@ -3949,7 +4026,10 @@ const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVI
|
|
|
3949
4026
|
*/
|
|
3950
4027
|
class LocalForageService extends AsyncStorageService {
|
|
3951
4028
|
static { this.NAME = 'LocalForageService'; }
|
|
3952
|
-
constructor(
|
|
4029
|
+
constructor(
|
|
4030
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4031
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4032
|
+
config, log) {
|
|
3953
4033
|
super();
|
|
3954
4034
|
this.config = config;
|
|
3955
4035
|
this.log = log;
|
|
@@ -3968,11 +4048,16 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3968
4048
|
* reflects the readiness of the storage
|
|
3969
4049
|
* @returns one time emission Observable<void>
|
|
3970
4050
|
*/
|
|
4051
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4052
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3971
4053
|
ready() {
|
|
3972
|
-
return from(localForage.ready()).pipe(take(1), tap(
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
4054
|
+
return from(localForage.ready()).pipe(take(1), tap({
|
|
4055
|
+
next: () => { },
|
|
4056
|
+
error: (err) => {
|
|
4057
|
+
if (this.log) {
|
|
4058
|
+
this.log.error(this.name(), 'ready', err);
|
|
4059
|
+
}
|
|
4060
|
+
},
|
|
3976
4061
|
}));
|
|
3977
4062
|
}
|
|
3978
4063
|
/**
|
|
@@ -3980,6 +4065,8 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3980
4065
|
* @param key the associated key
|
|
3981
4066
|
* @returns one time emission Observable of value
|
|
3982
4067
|
*/
|
|
4068
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4069
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3983
4070
|
get(key) {
|
|
3984
4071
|
return from(localForage.getItem(key)).pipe(take(1), tap(() => { }, (err) => {
|
|
3985
4072
|
if (this.log) {
|
|
@@ -3993,11 +4080,17 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3993
4080
|
* @param value the value to set
|
|
3994
4081
|
* @returns one time emission Observable
|
|
3995
4082
|
*/
|
|
4083
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4084
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3996
4085
|
set(key, value) {
|
|
3997
|
-
return from(localForage.setItem(key, value)).pipe(take(1), tap(
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4086
|
+
return from(localForage.setItem(key, value)).pipe(take(1), tap({
|
|
4087
|
+
next: () => {
|
|
4088
|
+
},
|
|
4089
|
+
error: (err) => {
|
|
4090
|
+
if (this.log) {
|
|
4091
|
+
this.log.error(this.name(), 'set', err);
|
|
4092
|
+
}
|
|
4093
|
+
},
|
|
4001
4094
|
}));
|
|
4002
4095
|
}
|
|
4003
4096
|
/**
|
|
@@ -4005,11 +4098,16 @@ class LocalForageService extends AsyncStorageService {
|
|
|
4005
4098
|
* @param key the associated key
|
|
4006
4099
|
* @returns one time emission Observable
|
|
4007
4100
|
*/
|
|
4101
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4008
4103
|
remove(key) {
|
|
4009
|
-
return from(localForage.removeItem(key)).pipe(take(1), tap(
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4104
|
+
return from(localForage.removeItem(key)).pipe(take(1), tap({
|
|
4105
|
+
next: () => { },
|
|
4106
|
+
error: (err) => {
|
|
4107
|
+
if (this.log) {
|
|
4108
|
+
this.log.error(this.name(), 'remove', err);
|
|
4109
|
+
}
|
|
4110
|
+
},
|
|
4013
4111
|
}));
|
|
4014
4112
|
}
|
|
4015
4113
|
/** @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 +4161,9 @@ class LocaleService extends EuiService {
|
|
|
4063
4161
|
}
|
|
4064
4162
|
getState(keyOrMapFn) {
|
|
4065
4163
|
let selector = getLocaleState;
|
|
4066
|
-
|
|
4164
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4166
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4067
4167
|
if (keyOrMapFn) {
|
|
4068
4168
|
switch (typeof keyOrMapFn) {
|
|
4069
4169
|
case 'function':
|
|
@@ -4301,7 +4401,9 @@ class UserService extends EuiService {
|
|
|
4301
4401
|
}
|
|
4302
4402
|
getState(keyOrMapFn) {
|
|
4303
4403
|
let selector = getUserState;
|
|
4304
|
-
|
|
4404
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4405
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4406
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4305
4407
|
if (keyOrMapFn) {
|
|
4306
4408
|
switch (typeof keyOrMapFn) {
|
|
4307
4409
|
case 'function':
|
|
@@ -4314,6 +4416,8 @@ class UserService extends EuiService {
|
|
|
4314
4416
|
}
|
|
4315
4417
|
return this.store.select(selector);
|
|
4316
4418
|
}
|
|
4419
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4420
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4317
4421
|
updateState(userState, reducer) {
|
|
4318
4422
|
// if (typeof pathOrReducer === 'string') {
|
|
4319
4423
|
// let dotNotationToObject = (obj, key) => key.split('.').reduce((obj, i) => obj[i], obj);
|
|
@@ -4327,6 +4431,8 @@ class UserService extends EuiService {
|
|
|
4327
4431
|
this.store.dispatchAction(userState, 'user', reducer);
|
|
4328
4432
|
}
|
|
4329
4433
|
else {
|
|
4434
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4435
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4330
4436
|
this.store.dispatch(new UpdateUserStateAction(userState));
|
|
4331
4437
|
}
|
|
4332
4438
|
}
|
|
@@ -4344,22 +4450,16 @@ class UserServiceMock extends UserService {
|
|
|
4344
4450
|
constructor() {
|
|
4345
4451
|
super(null);
|
|
4346
4452
|
}
|
|
4347
|
-
|
|
4348
|
-
return of({
|
|
4349
|
-
}
|
|
4350
|
-
observePreferencesUpdate() { }
|
|
4351
|
-
loadUserPreferences() {
|
|
4352
|
-
return of({});
|
|
4353
|
-
}
|
|
4354
|
-
saveUserPreferences() {
|
|
4355
|
-
return of({});
|
|
4453
|
+
init(userState) {
|
|
4454
|
+
return of({ success: true });
|
|
4356
4455
|
}
|
|
4357
|
-
|
|
4358
|
-
userPreferences() {
|
|
4456
|
+
getState(keyOrMapFn) {
|
|
4359
4457
|
return of({});
|
|
4360
4458
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4459
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4460
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4461
|
+
updateState(userState, reducer) {
|
|
4462
|
+
/* empty */
|
|
4363
4463
|
}
|
|
4364
4464
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4365
4465
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: UserServiceMock }); }
|
|
@@ -4457,17 +4557,24 @@ class EuLoginSessionTimeoutHandlingInterceptor {
|
|
|
4457
4557
|
this.checkRequestErrorForEULoginSessionTimeout(request, error);
|
|
4458
4558
|
}));
|
|
4459
4559
|
}
|
|
4560
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4561
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4460
4562
|
checkRequestSuccessForEULoginSessionTimeout(request, event) {
|
|
4461
4563
|
if (event instanceof HttpResponse) {
|
|
4564
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4565
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4462
4566
|
if (this.isSsoResponse(event.body)) {
|
|
4463
4567
|
this.reauthenticate();
|
|
4464
4568
|
}
|
|
4465
4569
|
}
|
|
4466
4570
|
}
|
|
4467
|
-
//
|
|
4571
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4572
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4468
4573
|
checkRequestErrorForEULoginSessionTimeout(request, response) {
|
|
4469
|
-
|
|
4574
|
+
/* intentionally blank; meant for overriding */
|
|
4470
4575
|
}
|
|
4576
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4577
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4471
4578
|
isSsoResponse(body) {
|
|
4472
4579
|
if (body) {
|
|
4473
4580
|
if (typeof body !== 'string') {
|
|
@@ -4518,8 +4625,13 @@ class UxRequestErrorModelInterceptor {
|
|
|
4518
4625
|
constructor(errorMappingHandler) {
|
|
4519
4626
|
this.errorMappingHandler = errorMappingHandler;
|
|
4520
4627
|
}
|
|
4628
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4629
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4521
4630
|
intercept(req, next) {
|
|
4522
|
-
return next.handle(req).pipe(
|
|
4631
|
+
return next.handle(req).pipe(
|
|
4632
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4633
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4634
|
+
catchError((err) => {
|
|
4523
4635
|
if (this.errorMappingHandler) {
|
|
4524
4636
|
if (err instanceof HttpErrorResponse) {
|
|
4525
4637
|
err = transformToUxHttpResponse(err, this.errorMappingHandler);
|
|
@@ -4547,14 +4659,25 @@ class OpenIdConnectInterceptor {
|
|
|
4547
4659
|
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
4660
|
}
|
|
4549
4661
|
}
|
|
4550
|
-
intercept(
|
|
4662
|
+
intercept(
|
|
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
|
|
4665
|
+
request, next, retryCount = 0,
|
|
4666
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4667
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4668
|
+
retryCallback) {
|
|
4551
4669
|
if (typeof OpenIdConnect !== 'undefined') {
|
|
4552
4670
|
let authorizedRequest = retryCallback;
|
|
4553
4671
|
if (!authorizedRequest) {
|
|
4672
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4673
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4554
4674
|
authorizedRequest = new Subject();
|
|
4555
4675
|
}
|
|
4556
4676
|
let subscription = null;
|
|
4557
|
-
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4677
|
+
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4678
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4679
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4680
|
+
(headers) => {
|
|
4558
4681
|
let newRequest = request;
|
|
4559
4682
|
if (headers) {
|
|
4560
4683
|
let newHeaders = request.headers;
|
|
@@ -4579,6 +4702,8 @@ class OpenIdConnectInterceptor {
|
|
|
4579
4702
|
subscription = next
|
|
4580
4703
|
.handle(newRequest)
|
|
4581
4704
|
.pipe(catchError((response) => this.handleErrorResponse(response, request, next, retryCount, authorizedRequest, subscription)))
|
|
4705
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4706
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4582
4707
|
.subscribe((httpEvent) => {
|
|
4583
4708
|
if (httpEvent) {
|
|
4584
4709
|
authorizedRequest.next(httpEvent);
|
|
@@ -4591,6 +4716,8 @@ class OpenIdConnectInterceptor {
|
|
|
4591
4716
|
}
|
|
4592
4717
|
});
|
|
4593
4718
|
}, (errorResponse) => {
|
|
4719
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4720
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4594
4721
|
const errorProperties = {
|
|
4595
4722
|
error: errorResponse,
|
|
4596
4723
|
};
|
|
@@ -4611,7 +4738,13 @@ class OpenIdConnectInterceptor {
|
|
|
4611
4738
|
return next.handle(request);
|
|
4612
4739
|
}
|
|
4613
4740
|
}
|
|
4614
|
-
handleErrorResponse(response,
|
|
4741
|
+
handleErrorResponse(response,
|
|
4742
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4743
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4744
|
+
originalRequest, next, retryCount = 0,
|
|
4745
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4746
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4747
|
+
retryCallback, subscription) {
|
|
4615
4748
|
if (response) {
|
|
4616
4749
|
if (response.error && response.error.error === 'invalid_request') {
|
|
4617
4750
|
// The ID token is invalid or incorrect; retrieve another one:
|
|
@@ -4644,7 +4777,13 @@ class OpenIdConnectInterceptor {
|
|
|
4644
4777
|
}
|
|
4645
4778
|
return throwError(response);
|
|
4646
4779
|
}
|
|
4647
|
-
retryRequest(
|
|
4780
|
+
retryRequest(
|
|
4781
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4782
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4783
|
+
originalRequest, response, next, retryCount = 0,
|
|
4784
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4785
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4786
|
+
retryCallback, subscription) {
|
|
4648
4787
|
if (retryCount < this.maximumRequestRetries()) {
|
|
4649
4788
|
this.intercept(originalRequest, next, retryCount + 1, retryCallback);
|
|
4650
4789
|
}
|
|
@@ -4661,6 +4800,8 @@ class OpenIdConnectInterceptor {
|
|
|
4661
4800
|
retryCallback.complete();
|
|
4662
4801
|
}
|
|
4663
4802
|
}
|
|
4803
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4804
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4664
4805
|
return of(null);
|
|
4665
4806
|
}
|
|
4666
4807
|
apiGatewayTokenExpired(response) {
|
|
@@ -4691,6 +4832,8 @@ class OpenIdConnectService {
|
|
|
4691
4832
|
constructor() {
|
|
4692
4833
|
this.userDetails = new Observable((observer) => {
|
|
4693
4834
|
if (typeof ApiGateway !== 'undefined') {
|
|
4835
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4836
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4694
4837
|
ApiGateway.getUser((user) => {
|
|
4695
4838
|
if (user) {
|
|
4696
4839
|
observer.next({
|
|
@@ -4752,5 +4895,5 @@ class OpenIdConnectServiceMock extends OpenIdConnectService {
|
|
|
4752
4895
|
* Generated bundle index. Do not edit.
|
|
4753
4896
|
*/
|
|
4754
4897
|
|
|
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,
|
|
4898
|
+
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
4899
|
//# sourceMappingURL=eui-core.mjs.map
|