@eui/core 17.0.0-next.12 → 17.0.0-next.13
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/dependencies.html +22 -20
- package/docs/injectables/ApiQueueService.html +2 -10
- package/docs/injectables/EuiAppShellService.html +476 -0
- package/docs/injectables/EuiDynamicComponentService.html +1 -1
- package/docs/injectables/EuiDynamicMenuService.html +2 -2
- package/docs/injectables/I18nService.html +64 -0
- package/docs/injectables/LogService.html +1 -2
- package/docs/injectables/StoreService.html +8 -8
- package/docs/injectables/StoreServiceMock.html +5 -5
- package/docs/injectables/UserService.html +2 -2
- package/docs/injectables/UserServiceMock.html +218 -145
- 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/menu-wc_es5.js +1 -1
- package/docs/js/search/search_index.js +2 -2
- package/docs/miscellaneous/functions.html +42 -0
- package/docs/miscellaneous/variables.html +51 -51
- package/docs/modules/I18nModule.html +1 -1
- package/esm2022/lib/eui-core.module.mjs +7 -7
- 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 +4 -4
- package/esm2022/lib/interceptors/cache-prevention.interceptor.mjs +4 -4
- package/esm2022/lib/interceptors/cors-security.interceptor.mjs +4 -4
- package/esm2022/lib/interceptors/csrf-prevention.interceptor.mjs +4 -4
- package/esm2022/lib/interceptors/eu-login-session-timeout-handling.interceptor.mjs +13 -6
- package/esm2022/lib/interceptors/openid/openid-connect.interceptor.mjs +37 -8
- package/esm2022/lib/interceptors/openid/openid-connect.service.mjs +6 -4
- package/esm2022/lib/interceptors/ux-request-error-model.interceptor.mjs +10 -5
- 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/dynamic-component/dynamic-component.service.mjs +9 -4
- package/esm2022/lib/services/dynamic-menu/dynamic-menu.service.mjs +8 -5
- package/esm2022/lib/services/errors/eui.error.mjs +5 -1
- package/esm2022/lib/services/errors/global-error-handler.mjs +7 -5
- package/esm2022/lib/services/errors/http-error-handler-callback-functions.mjs +2 -2
- package/esm2022/lib/services/errors/http-error-handler.interceptor.mjs +24 -17
- package/esm2022/lib/services/eui-app-shell.service.mjs +123 -12
- package/esm2022/lib/services/eui-timezone.service.mjs +3 -3
- package/esm2022/lib/services/growl/eui-growl.service.mjs +4 -4
- package/esm2022/lib/services/i18n/i18n.loader.mjs +16 -5
- package/esm2022/lib/services/i18n/i18n.resource.mjs +8 -3
- package/esm2022/lib/services/i18n/i18n.service.mjs +17 -19
- package/esm2022/lib/services/i18n/index.mjs +2 -2
- package/esm2022/lib/services/locale/locale.service.mjs +7 -5
- package/esm2022/lib/services/locale/locale.service.mock.mjs +3 -3
- package/esm2022/lib/services/log/log.module.mjs +4 -4
- package/esm2022/lib/services/log/log.service.mjs +4 -4
- package/esm2022/lib/services/log/log.service.mock.mjs +1 -1
- package/esm2022/lib/services/permission/permission.service.mjs +5 -5
- package/esm2022/lib/services/queue/api-queue.service.mjs +20 -8
- 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 +43 -18
- package/esm2022/lib/services/storage/local-storage.service.mjs +8 -4
- package/esm2022/lib/services/storage/session-storage.service.mjs +8 -4
- 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 +14 -6
- package/esm2022/lib/services/store/store.service.mock.mjs +4 -4
- package/esm2022/lib/services/user/user.service.mjs +13 -7
- package/esm2022/lib/services/user/user.service.mock.mjs +11 -17
- package/fesm2022/eui-core.mjs +825 -588
- 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.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/dynamic-component/dynamic-component.service.d.ts +3 -7
- package/lib/services/dynamic-component/dynamic-component.service.d.ts.map +1 -1
- package/lib/services/dynamic-menu/dynamic-menu.service.d.ts +6 -6
- package/lib/services/dynamic-menu/dynamic-menu.service.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/eui-app-shell.service.d.ts +39 -7
- package/lib/services/eui-app-shell.service.d.ts.map +1 -1
- package/lib/services/i18n/i18n.loader.d.ts.map +1 -1
- package/lib/services/i18n/i18n.resource.d.ts +1 -1
- package/lib/services/i18n/i18n.resource.d.ts.map +1 -1
- package/lib/services/i18n/i18n.service.d.ts +4 -4
- package/lib/services/i18n/i18n.service.d.ts.map +1 -1
- package/lib/services/i18n/index.d.ts +0 -1
- package/lib/services/i18n/index.d.ts.map +1 -1
- package/lib/services/locale/locale.service.d.ts.map +1 -1
- package/lib/services/log/log.service.d.ts.map +1 -1
- package/lib/services/log/log.service.mock.d.ts.map +1 -1
- package/lib/services/permission/permission.service.d.ts.map +1 -1
- package/lib/services/queue/api-queue.service.d.ts +2 -2
- package/lib/services/queue/api-queue.service.d.ts.map +1 -1
- package/lib/services/queue/api-queue.service.mock.d.ts.map +1 -1
- package/lib/services/storage/async-storage.service.d.ts.map +1 -1
- package/lib/services/storage/async-storage.service.mock.d.ts.map +1 -1
- package/lib/services/storage/local-forage.service.d.ts +1 -1
- package/lib/services/storage/local-forage.service.d.ts.map +1 -1
- package/lib/services/storage/local-storage.service.d.ts.map +1 -1
- package/lib/services/storage/session-storage.service.d.ts.map +1 -1
- package/lib/services/storage/storage.service.d.ts.map +1 -1
- package/lib/services/storage/storage.service.mock.d.ts +1 -1
- package/lib/services/storage/storage.service.mock.d.ts.map +1 -1
- package/lib/services/store/actions/app.actions.d.ts.map +1 -1
- package/lib/services/store/actions/notifications.actions.d.ts.map +1 -1
- package/lib/services/store/actions/user.actions.d.ts.map +1 -1
- package/lib/services/store/reducers/app.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/core.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/meta.reducers.d.ts +2 -2
- package/lib/services/store/reducers/meta.reducers.d.ts.map +1 -1
- package/lib/services/store/reducers/user.reducers.d.ts.map +1 -1
- package/lib/services/store/store.service.d.ts +8 -8
- package/lib/services/store/store.service.d.ts.map +1 -1
- package/lib/services/store/store.service.mock.d.ts +2 -1
- package/lib/services/store/store.service.mock.d.ts.map +1 -1
- package/lib/services/user/user.service.d.ts +3 -3
- package/lib/services/user/user.service.d.ts.map +1 -1
- package/lib/services/user/user.service.mock.d.ts +10 -12
- package/lib/services/user/user.service.mock.d.ts.map +1 -1
- package/package.json +1 -1
- 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,20 +1,20 @@
|
|
|
1
1
|
import * as i1 from '@eui/base';
|
|
2
|
-
import { LogLevel, ConsoleAppender,
|
|
2
|
+
import { LogLevel, ConsoleAppender, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, Logger, LoggerMock, xhr, getApiQueue, getApiQueueItem, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, EuiEuLanguages, getActiveLang, EuiService, getUserRights, getUserState, 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, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler,
|
|
5
|
+
import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler, PLATFORM_ID, LOCALE_ID } from '@angular/core';
|
|
6
6
|
import * as extendProxy from 'extend';
|
|
7
|
+
import * as i1$1 from '@ngrx/effects';
|
|
8
|
+
import { createEffect, ofType } from '@ngrx/effects';
|
|
9
|
+
import { merge, fromEvent, throwError, of, forkJoin, BehaviorSubject, defer, firstValueFrom, from, Subject, Observable } from 'rxjs';
|
|
10
|
+
import { mapTo, map, mergeMap, tap, debounceTime, distinctUntilChanged, take, switchMap, catchError, concatMap, filter, takeUntil, finalize } from 'rxjs/operators';
|
|
11
|
+
import * as i1$2 from '@ngx-translate/core';
|
|
12
|
+
import { TranslateLoader } from '@ngx-translate/core';
|
|
13
|
+
import * as i1$3 from '@ngrx/store';
|
|
14
|
+
import { createSelector } from '@ngrx/store';
|
|
7
15
|
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
|
8
16
|
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
|
9
17
|
import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
|
|
10
|
-
import { throwError, merge, fromEvent, of, forkJoin, BehaviorSubject, defer, from, Subject, Observable } from 'rxjs';
|
|
11
|
-
import { debounceTime, distinctUntilChanged, mapTo, map, mergeMap, tap, take, switchMap, catchError, concatMap, filter, takeUntil, finalize } from 'rxjs/operators';
|
|
12
|
-
import * as i1$1 from '@ngrx/store';
|
|
13
|
-
import { createSelector } from '@ngrx/store';
|
|
14
|
-
import * as i1$2 from '@ngrx/effects';
|
|
15
|
-
import { createEffect, ofType } from '@ngrx/effects';
|
|
16
|
-
import * as i1$3 from '@ngx-translate/core';
|
|
17
|
-
import { TranslateLoader } from '@ngx-translate/core';
|
|
18
18
|
import * as i1$5 from '@angular/common/http';
|
|
19
19
|
import { HttpErrorResponse, HttpResponse, HttpHeaders, HttpEventType } from '@angular/common/http';
|
|
20
20
|
import * as i1$4 from '@angular/router';
|
|
@@ -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: "17.0.0-rc.0", 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: "17.0.0-rc.0", ngImport: i0, type: LogService }); }
|
|
202
|
-
}
|
|
203
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogService, decorators: [{
|
|
204
|
-
type: Injectable
|
|
205
|
-
}], ctorParameters: () => [{ 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";
|
|
@@ -329,218 +231,17 @@ class AddApiQueueItemAction {
|
|
|
329
231
|
}
|
|
330
232
|
class RemoveApiQueueItemAction {
|
|
331
233
|
constructor(payload) {
|
|
332
|
-
this.payload = payload;
|
|
333
|
-
this.type = CoreAppActionTypes.REMOVE_API_QUEUE_ITEM;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
class EmptyApiQueueAction {
|
|
337
|
-
constructor(payload) {
|
|
338
|
-
this.payload = payload;
|
|
339
|
-
this.type = CoreAppActionTypes.EMPTY_API_QUEUE;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
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: "17.0.0-rc.0", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
375
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule }); }
|
|
376
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule }); }
|
|
377
|
-
}
|
|
378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", 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: "17.0.0-rc.0", 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: "17.0.0-rc.0", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
475
|
-
}
|
|
476
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreService, decorators: [{
|
|
477
|
-
type: Injectable,
|
|
478
|
-
args: [{
|
|
479
|
-
providedIn: 'root',
|
|
480
|
-
}]
|
|
481
|
-
}], ctorParameters: () => [{ 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] }];
|
|
234
|
+
this.payload = payload;
|
|
235
|
+
this.type = CoreAppActionTypes.REMOVE_API_QUEUE_ITEM;
|
|
236
|
+
}
|
|
531
237
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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
|
-
];
|
|
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
|
|
241
|
+
constructor(payload) {
|
|
242
|
+
this.payload = payload;
|
|
243
|
+
this.type = CoreAppActionTypes.EMPTY_API_QUEUE;
|
|
244
|
+
}
|
|
544
245
|
}
|
|
545
246
|
|
|
546
247
|
var CoreI18nActionTypes;
|
|
@@ -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;
|
|
@@ -682,10 +387,10 @@ class EuiGrowlService {
|
|
|
682
387
|
growlInfo(msg, position) {
|
|
683
388
|
this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
|
|
684
389
|
}
|
|
685
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
686
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
390
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiGrowlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
391
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiGrowlService, providedIn: 'root' }); }
|
|
687
392
|
}
|
|
688
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
393
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiGrowlService, decorators: [{
|
|
689
394
|
type: Injectable,
|
|
690
395
|
args: [{
|
|
691
396
|
providedIn: 'root',
|
|
@@ -727,15 +432,15 @@ class CoreAppEffects {
|
|
|
727
432
|
}
|
|
728
433
|
})), { dispatch: false });
|
|
729
434
|
}
|
|
730
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
731
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
435
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$1.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$2.TranslateService }, { token: EuiGrowlService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
436
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreAppEffects }); }
|
|
732
437
|
}
|
|
733
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
438
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreAppEffects, decorators: [{
|
|
734
439
|
type: Injectable
|
|
735
|
-
}], ctorParameters: () => [{ type: i1$
|
|
440
|
+
}], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
|
|
736
441
|
type: Inject,
|
|
737
442
|
args: [SHOW_CONNECTION_STATUS_TOKEN]
|
|
738
|
-
}] }, { type: i1$
|
|
443
|
+
}] }, { type: i1$2.TranslateService }, { type: EuiGrowlService }] });
|
|
739
444
|
|
|
740
445
|
const CoreModuleEffects = [CoreAppEffects];
|
|
741
446
|
|
|
@@ -772,7 +477,6 @@ const removeApiQueueItem = (state, action) => {
|
|
|
772
477
|
}, {});
|
|
773
478
|
return Object.assign({}, state, { apiQueue });
|
|
774
479
|
};
|
|
775
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
776
480
|
const emptyApiQueue = (state, action) =>
|
|
777
481
|
// remove all items in the Api Queue
|
|
778
482
|
Object.assign({}, state, { apiQueue: {} });
|
|
@@ -874,6 +578,8 @@ const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
|
874
578
|
return state;
|
|
875
579
|
};
|
|
876
580
|
|
|
581
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
582
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
877
583
|
const coreReducers = Object.assign({}, {
|
|
878
584
|
app: coreAppReducers,
|
|
879
585
|
user: coreUserReducers,
|
|
@@ -882,6 +588,8 @@ const coreReducers = Object.assign({}, {
|
|
|
882
588
|
locale: coreLocaleReducers,
|
|
883
589
|
});
|
|
884
590
|
|
|
591
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
592
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
885
593
|
const extend = extendProxy.default || extendProxy;
|
|
886
594
|
/**
|
|
887
595
|
* Utility meta-reducer to load the state from the local storage
|
|
@@ -908,66 +616,318 @@ const filterAppState = (app) => {
|
|
|
908
616
|
if (!app) {
|
|
909
617
|
return {};
|
|
910
618
|
}
|
|
911
|
-
return (Object.keys(app)
|
|
912
|
-
// select keys that are present in the allowed list
|
|
913
|
-
.filter((key) => !disallowedKeys.includes(key))
|
|
914
|
-
// build a new object with only the allowed properties
|
|
915
|
-
.reduce((obj, key) => {
|
|
916
|
-
obj[key] = app[key];
|
|
917
|
-
return obj;
|
|
918
|
-
}, {}));
|
|
919
|
-
};
|
|
920
|
-
/**
|
|
921
|
-
*
|
|
922
|
-
* @param
|
|
923
|
-
*/
|
|
924
|
-
const loadState = (storage = localStorage) => {
|
|
925
|
-
try {
|
|
926
|
-
// by default falls back to localStorage
|
|
927
|
-
const serializedState = storage.getItem('state');
|
|
928
|
-
if (serializedState === null) {
|
|
929
|
-
return undefined;
|
|
619
|
+
return (Object.keys(app)
|
|
620
|
+
// select keys that are present in the allowed list
|
|
621
|
+
.filter((key) => !disallowedKeys.includes(key))
|
|
622
|
+
// build a new object with only the allowed properties
|
|
623
|
+
.reduce((obj, key) => {
|
|
624
|
+
obj[key] = app[key];
|
|
625
|
+
return obj;
|
|
626
|
+
}, {}));
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
*
|
|
630
|
+
* @param storage Type of storage to load the state from
|
|
631
|
+
*/
|
|
632
|
+
const loadState = (storage = localStorage) => {
|
|
633
|
+
try {
|
|
634
|
+
// by default falls back to localStorage
|
|
635
|
+
const serializedState = storage.getItem('state');
|
|
636
|
+
if (serializedState === null) {
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
// deserialize state
|
|
640
|
+
let state = JSON.parse(serializedState);
|
|
641
|
+
// filter AppState and replace
|
|
642
|
+
state = { ...state, app: filterAppState(state?.app) };
|
|
643
|
+
return state;
|
|
644
|
+
}
|
|
645
|
+
catch (err) {
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
const cb = (reducer, storage) => (state, action) => {
|
|
650
|
+
if (action.type === CoreAppActionTypes.INIT_STORE) {
|
|
651
|
+
// This action must be dispatched from an app initializer
|
|
652
|
+
// We load the state from a storage and compare the version and userId with the provided ones.
|
|
653
|
+
// If they are the same, we merge the local state into the initial state.
|
|
654
|
+
// If there is a mismatch, we don't merge the local state, but update only the initial state.
|
|
655
|
+
// load the state from the localStorage
|
|
656
|
+
const localState = loadState(storage);
|
|
657
|
+
// extract the details about user and app version from the action payload
|
|
658
|
+
const payload = action.payload;
|
|
659
|
+
const payloadVersion = payload?.version;
|
|
660
|
+
if (localState) {
|
|
661
|
+
// TODO: Why all these checks here? What is the purpose of this code?
|
|
662
|
+
// extract the details about user and app version from the storage state
|
|
663
|
+
const localVersion = localState?.app?.version;
|
|
664
|
+
// const localUserId = localState.user && localState.user.userId;
|
|
665
|
+
const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
|
|
666
|
+
// const isUserIdOK = (localUserId === payloadUserId);
|
|
667
|
+
// update the entire state with deep merge of states, if the version and user are the same
|
|
668
|
+
if (isVersionOK) {
|
|
669
|
+
state = extend(true, {}, state, localState);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
// update the app version, if defined
|
|
673
|
+
if (payloadVersion) {
|
|
674
|
+
state = { ...state, app: { ...state?.app, version: payloadVersion } };
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return reducer(state, action);
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
const BASE_LOGGER_NAME_TOKEN = new InjectionToken('BASE_LOGGER_NAME');
|
|
681
|
+
const LOG_LEVEL_TOKEN = new InjectionToken('LOG_LEVEL');
|
|
682
|
+
const LOG_APPENDERS_TOKEN = new InjectionToken('LOG_APPENDERS');
|
|
683
|
+
/**
|
|
684
|
+
* Log service, responsible for getting or creating loggers. It itself acts as a base logger
|
|
685
|
+
*/
|
|
686
|
+
class LogService extends Logger {
|
|
687
|
+
constructor(name, level, appenders) {
|
|
688
|
+
super(name, level, appenders);
|
|
689
|
+
this.name = name;
|
|
690
|
+
this.level = level;
|
|
691
|
+
this.appenders = appenders;
|
|
692
|
+
/** the list of persistent loggers */
|
|
693
|
+
this.loggers = {};
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Gets a logger by name. If the logger does not exist, it is created
|
|
697
|
+
*
|
|
698
|
+
* @param loggerName logger name
|
|
699
|
+
* @param persist optional parameter. Set it to true if you want to reuse the logger. By default, it is set to false
|
|
700
|
+
* @returns the logger
|
|
701
|
+
*/
|
|
702
|
+
getLogger(loggerName, persist = false) {
|
|
703
|
+
// create the logger, if necessary
|
|
704
|
+
const logger = (persist && this.loggers[loggerName]) || new Logger(loggerName, this.level, this.appenders);
|
|
705
|
+
// if the logger is persistent, add it to the list of persistent loggers
|
|
706
|
+
if (persist) {
|
|
707
|
+
this.loggers[loggerName] = logger;
|
|
708
|
+
}
|
|
709
|
+
return logger;
|
|
710
|
+
}
|
|
711
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
712
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogService }); }
|
|
713
|
+
}
|
|
714
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogService, decorators: [{
|
|
715
|
+
type: Injectable
|
|
716
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
717
|
+
type: Inject,
|
|
718
|
+
args: [BASE_LOGGER_NAME_TOKEN]
|
|
719
|
+
}] }, { type: i1.LogLevel, decorators: [{
|
|
720
|
+
type: Inject,
|
|
721
|
+
args: [LOG_LEVEL_TOKEN]
|
|
722
|
+
}] }, { type: undefined, decorators: [{
|
|
723
|
+
type: Inject,
|
|
724
|
+
args: [LOG_APPENDERS_TOKEN]
|
|
725
|
+
}] }] });
|
|
726
|
+
|
|
727
|
+
class LogServiceMock extends LoggerMock {
|
|
728
|
+
getLogger() {
|
|
729
|
+
return new LoggerMock();
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const LOG_INSTANCES = {};
|
|
734
|
+
/**
|
|
735
|
+
* Helper function to check if the log config is defined.
|
|
736
|
+
* Does not check only for empty object, because the config can have other (non-log) parameters
|
|
737
|
+
* @params config log configuration
|
|
738
|
+
* @returns true/false
|
|
739
|
+
*/
|
|
740
|
+
function isLogConfigDefined(config) {
|
|
741
|
+
return config && ('baseLoggerName' in config || 'logLevel' in config || 'logAppenders' in config);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Helper function to provide a list of log appenders from a log configuration
|
|
745
|
+
*
|
|
746
|
+
* @params config log configuration
|
|
747
|
+
* @returns an array of log appenders
|
|
748
|
+
*/
|
|
749
|
+
function getLogAppendersConfig(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
750
|
+
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
751
|
+
config.logAppenders = config.logAppenders || [];
|
|
752
|
+
config.logAppenders = Array.isArray(config.logAppenders) ? config.logAppenders : [config.logAppenders];
|
|
753
|
+
return config.logAppenders.map((logAppender) => {
|
|
754
|
+
const appenderType = typeof logAppender === 'object' ? logAppender.type : logAppender;
|
|
755
|
+
const appenderParams = typeof logAppender === 'object' ? logAppender : undefined;
|
|
756
|
+
return new appenderType(appenderParams, injector);
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Helper function to provide an instance of LogService from a configuration
|
|
761
|
+
*
|
|
762
|
+
* @params config log configuration
|
|
763
|
+
* @returns an instance of log service
|
|
764
|
+
*/
|
|
765
|
+
function logServiceFactory(config = DEFAULT_LOG_CONFIG, injector = null) {
|
|
766
|
+
// add the default values to config
|
|
767
|
+
config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
|
|
768
|
+
// extract parameters from config
|
|
769
|
+
const logLevel = config.logLevel;
|
|
770
|
+
const logAppenders = getLogAppendersConfig(config, injector);
|
|
771
|
+
// return an instance of LogService
|
|
772
|
+
return new LogService(config.baseLoggerName, logLevel, logAppenders);
|
|
773
|
+
}
|
|
774
|
+
function euiLogServiceFactory(injector, rootBaseLoggerName, rootConfig, childBaseLoggerName = null, childConfig = {}) {
|
|
775
|
+
// determine if the configuration is for non-root modules
|
|
776
|
+
const forChild = isLogConfigDefined(childConfig);
|
|
777
|
+
const baseLoggerName = forChild ? childBaseLoggerName : rootBaseLoggerName;
|
|
778
|
+
// create the proper configuration
|
|
779
|
+
const config = Object.assign({ baseLoggerName }, forChild ? Object.assign({}, rootConfig, childConfig) : rootConfig);
|
|
780
|
+
// re-use the log service or create a new instance
|
|
781
|
+
const logService = LOG_INSTANCES[baseLoggerName] || logServiceFactory(config, injector);
|
|
782
|
+
LOG_INSTANCES[baseLoggerName] = logService;
|
|
783
|
+
return logService;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const LOG_MODULE_CONFIG_TOKEN = new InjectionToken('LOG_CONFIG');
|
|
787
|
+
/**
|
|
788
|
+
* Log Module
|
|
789
|
+
*/
|
|
790
|
+
class LogModule {
|
|
791
|
+
/** method called in your root module to provide the LogService */
|
|
792
|
+
static forRoot(config = DEFAULT_LOG_CONFIG) {
|
|
793
|
+
return {
|
|
794
|
+
ngModule: LogModule,
|
|
795
|
+
providers: [
|
|
796
|
+
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
797
|
+
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
798
|
+
],
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/** method called in your other (non root, lazy loaded) modules to import a different instance of LogService */
|
|
802
|
+
static forChild(config = DEFAULT_LOG_CONFIG) {
|
|
803
|
+
return {
|
|
804
|
+
ngModule: LogModule,
|
|
805
|
+
providers: [
|
|
806
|
+
{ provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
|
|
807
|
+
{ provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
|
|
808
|
+
],
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
812
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogModule }); }
|
|
813
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogModule }); }
|
|
814
|
+
}
|
|
815
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LogModule, decorators: [{
|
|
816
|
+
type: NgModule
|
|
817
|
+
}] });
|
|
818
|
+
|
|
819
|
+
var BrowserStorageType;
|
|
820
|
+
(function (BrowserStorageType) {
|
|
821
|
+
BrowserStorageType[BrowserStorageType["local"] = 0] = "local";
|
|
822
|
+
BrowserStorageType[BrowserStorageType["session"] = 1] = "session";
|
|
823
|
+
})(BrowserStorageType || (BrowserStorageType = {}));
|
|
824
|
+
// todo should stay here but all the store directory should be moved upper level
|
|
825
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
826
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
827
|
+
class StoreService {
|
|
828
|
+
constructor(store, logService) {
|
|
829
|
+
this.store = store;
|
|
830
|
+
this.logService = logService;
|
|
831
|
+
/**
|
|
832
|
+
* autoSave handlers to call before saving in local Storage
|
|
833
|
+
*/
|
|
834
|
+
this._autoSaveHandlers = {};
|
|
835
|
+
/** storage instance e.g. localStorage, sessionStorage */
|
|
836
|
+
this._storage = localStorage;
|
|
837
|
+
}
|
|
838
|
+
// use init with just version info, to update to user state, UserService.updateState
|
|
839
|
+
// initializeStore(version?: string, userDetails?: BaseUserDetails) {
|
|
840
|
+
// this.dispatch(new InitStoreAction({ version, userDetails }));
|
|
841
|
+
// }
|
|
842
|
+
init(version, storageType) {
|
|
843
|
+
this.dispatch(new InitStoreAction({ version }));
|
|
844
|
+
this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
|
|
845
|
+
}
|
|
846
|
+
addAutoSaveHandler(stateSlice, handler) {
|
|
847
|
+
if (!this.store) {
|
|
848
|
+
if (this.logService) {
|
|
849
|
+
this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
|
|
850
|
+
}
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
this._autoSaveHandlers[stateSlice] = handler;
|
|
854
|
+
}
|
|
855
|
+
handleAutoSave() {
|
|
856
|
+
if (!this.store) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
this.store.pipe(debounceTime(1000), distinctUntilChanged()).subscribe((state) => {
|
|
860
|
+
this.saveState(state);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Proxy to NGRX store.dispatch()
|
|
865
|
+
* that allows to intercept if the store is present
|
|
866
|
+
*/
|
|
867
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
868
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
869
|
+
dispatch(action) {
|
|
870
|
+
if (this.store) {
|
|
871
|
+
return this.store.dispatch(action);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
875
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
876
|
+
dispatchAction(state, actionKey, reducer) {
|
|
877
|
+
if (this.store) {
|
|
878
|
+
this.store.addReducer(actionKey, reducer);
|
|
879
|
+
return this.store.dispatch({ type: actionKey, payload: state });
|
|
930
880
|
}
|
|
931
|
-
// deserialize state
|
|
932
|
-
let state = JSON.parse(serializedState);
|
|
933
|
-
// filter AppState and replace
|
|
934
|
-
state = { ...state, app: filterAppState(state?.app) };
|
|
935
|
-
return state;
|
|
936
881
|
}
|
|
937
|
-
|
|
938
|
-
|
|
882
|
+
/**
|
|
883
|
+
* Proxy to NGRX store.select()
|
|
884
|
+
* that allows to intercept if the store is present
|
|
885
|
+
*/
|
|
886
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
887
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
888
|
+
select(key) {
|
|
889
|
+
if (!this.store) {
|
|
890
|
+
return throwError(() => new Error('NGRX Store not configured'));
|
|
891
|
+
}
|
|
892
|
+
return this.store.select(key);
|
|
939
893
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
const payloadVersion = payload?.version;
|
|
952
|
-
if (localState) {
|
|
953
|
-
// TODO: Why all these checks here? What is the purpose of this code?
|
|
954
|
-
// extract the details about user and app version from the storage state
|
|
955
|
-
const localVersion = localState?.app?.version;
|
|
956
|
-
// const localUserId = localState.user && localState.user.userId;
|
|
957
|
-
const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
|
|
958
|
-
// const isUserIdOK = (localUserId === payloadUserId);
|
|
959
|
-
// update the entire state with deep merge of states, if the version and user are the same
|
|
960
|
-
if (isVersionOK) {
|
|
961
|
-
state = extend(true, {}, state, localState);
|
|
962
|
-
}
|
|
894
|
+
/**
|
|
895
|
+
* filters and save the state with the Browser storage
|
|
896
|
+
* @param state type of CoreState
|
|
897
|
+
*/
|
|
898
|
+
saveState(state) {
|
|
899
|
+
let stateToSave = {
|
|
900
|
+
app: state.app,
|
|
901
|
+
};
|
|
902
|
+
if (state.user) {
|
|
903
|
+
const { userId, preferences } = state.user;
|
|
904
|
+
stateToSave.user = { userId, preferences };
|
|
963
905
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
906
|
+
Object.keys(this._autoSaveHandlers).forEach((sliceState) => {
|
|
907
|
+
const handler = this._autoSaveHandlers[sliceState];
|
|
908
|
+
stateToSave = Object.assign(stateToSave, { [sliceState]: handler(state[sliceState]) });
|
|
909
|
+
});
|
|
910
|
+
try {
|
|
911
|
+
const serializedState = JSON.stringify(stateToSave);
|
|
912
|
+
this._storage.setItem('state', serializedState);
|
|
913
|
+
}
|
|
914
|
+
catch (err) {
|
|
915
|
+
// Ignore write errors.
|
|
967
916
|
}
|
|
968
917
|
}
|
|
969
|
-
|
|
970
|
-
};
|
|
918
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreService, deps: [{ token: i1$3.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
919
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
920
|
+
}
|
|
921
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreService, decorators: [{
|
|
922
|
+
type: Injectable,
|
|
923
|
+
args: [{
|
|
924
|
+
providedIn: 'root',
|
|
925
|
+
}]
|
|
926
|
+
}], ctorParameters: () => [{ type: i1$3.Store, decorators: [{
|
|
927
|
+
type: Optional
|
|
928
|
+
}] }, { type: LogService, decorators: [{
|
|
929
|
+
type: Optional
|
|
930
|
+
}] }] });
|
|
971
931
|
|
|
972
932
|
class StoreServiceMock extends StoreService {
|
|
973
933
|
constructor() {
|
|
@@ -980,13 +940,72 @@ class StoreServiceMock extends StoreService {
|
|
|
980
940
|
select() {
|
|
981
941
|
return of({});
|
|
982
942
|
}
|
|
983
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
984
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
943
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
944
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreServiceMock }); }
|
|
985
945
|
}
|
|
986
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
946
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: StoreServiceMock, decorators: [{
|
|
987
947
|
type: Injectable
|
|
988
948
|
}], ctorParameters: () => [] });
|
|
989
949
|
|
|
950
|
+
const euiInitApp = (injector) => () => new Promise((resolve) => {
|
|
951
|
+
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
952
|
+
locationInitialized.then(() => {
|
|
953
|
+
const appConfig = injector.get(CONFIG_TOKEN);
|
|
954
|
+
// necessary config parameters
|
|
955
|
+
let appVersion;
|
|
956
|
+
if (appConfig && appConfig.versions && appConfig.versions.app) {
|
|
957
|
+
appVersion = appConfig.versions.app;
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
appVersion = '0.0.0';
|
|
961
|
+
}
|
|
962
|
+
let storageType;
|
|
963
|
+
if (appConfig && appConfig.saveStateStorage) {
|
|
964
|
+
storageType = appConfig.saveStateStorage;
|
|
965
|
+
}
|
|
966
|
+
else {
|
|
967
|
+
storageType = BrowserStorageType.local;
|
|
968
|
+
}
|
|
969
|
+
const storeService = injector.get(StoreService);
|
|
970
|
+
storeService.init(appVersion, storageType);
|
|
971
|
+
storeService.handleAutoSave();
|
|
972
|
+
resolve(null);
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
function getCoreProviders() {
|
|
977
|
+
return [
|
|
978
|
+
// core config
|
|
979
|
+
...getDependencyProviders(),
|
|
980
|
+
{ provide: BASE_NAME_TOKEN, useValue: 'eui-core' },
|
|
981
|
+
// app config
|
|
982
|
+
{ provide: CONFIG_TOKEN, useFactory: prepareEuiAppConfigToken, deps: [EUI_CONFIG_TOKEN] },
|
|
983
|
+
// global config
|
|
984
|
+
{ provide: GLOBAL_CONFIG_TOKEN, useFactory: getGlobalConfig, deps: [CONFIG_TOKEN] },
|
|
985
|
+
{ provide: ROOT_LOG_CONFIG_TOKEN, useFactory: getRootLogConfig, deps: [CONFIG_TOKEN] },
|
|
986
|
+
{ provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
|
|
987
|
+
{ provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
|
|
988
|
+
{ provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
|
|
989
|
+
{ provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
|
|
990
|
+
];
|
|
991
|
+
}
|
|
992
|
+
function getDependencyProviders() {
|
|
993
|
+
return [{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] }];
|
|
994
|
+
}
|
|
995
|
+
function getCoreChildProviders(moduleName) {
|
|
996
|
+
return [
|
|
997
|
+
// module config
|
|
998
|
+
{ provide: MODULE_NAME_TOKEN, useValue: moduleName },
|
|
999
|
+
{ provide: MODULE_CONFIG_TOKEN, useFactory: getModuleConfig, deps: [CONFIG_TOKEN, MODULE_NAME_TOKEN] },
|
|
1000
|
+
// log config
|
|
1001
|
+
{
|
|
1002
|
+
provide: LogService,
|
|
1003
|
+
useFactory: euiLogServiceFactory,
|
|
1004
|
+
deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN, MODULE_NAME_TOKEN, MODULE_CONFIG_TOKEN],
|
|
1005
|
+
},
|
|
1006
|
+
];
|
|
1007
|
+
}
|
|
1008
|
+
|
|
990
1009
|
const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
|
|
991
1010
|
class CoreModule {
|
|
992
1011
|
/**
|
|
@@ -1027,11 +1046,11 @@ class CoreModule {
|
|
|
1027
1046
|
storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
|
|
1028
1047
|
}
|
|
1029
1048
|
}
|
|
1030
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1031
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.
|
|
1032
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1049
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1050
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreModule }); }
|
|
1051
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreModule }); }
|
|
1033
1052
|
}
|
|
1034
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1053
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CoreModule, decorators: [{
|
|
1035
1054
|
type: NgModule,
|
|
1036
1055
|
args: [{
|
|
1037
1056
|
imports: [
|
|
@@ -1050,7 +1069,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ng
|
|
|
1050
1069
|
}] }, { type: i0.Injector }] });
|
|
1051
1070
|
const createEuiCoreRootGuard = (core) => {
|
|
1052
1071
|
if (core) {
|
|
1053
|
-
throw new TypeError(
|
|
1072
|
+
throw new TypeError('CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.');
|
|
1054
1073
|
}
|
|
1055
1074
|
return 'guarded';
|
|
1056
1075
|
};
|
|
@@ -1110,6 +1129,8 @@ const messages = {
|
|
|
1110
1129
|
// Intermediate "hacky" subclass taken from
|
|
1111
1130
|
// https://www.bennadel.com/blog/3226-experimenting-with-error-sub-classing-using-es5-and-typescript-2-1-5.htm
|
|
1112
1131
|
class ErrorSubClass {
|
|
1132
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1113
1134
|
constructor(code, msg, args) {
|
|
1114
1135
|
if (!msg && code && code in messages) {
|
|
1115
1136
|
if (typeof messages[code] === 'function') {
|
|
@@ -1135,6 +1156,8 @@ class ErrorSubClass {
|
|
|
1135
1156
|
// This replaces the "extends" on the Class
|
|
1136
1157
|
// ErrorSubClass.prototype = <any>Object.create(Error.prototype);
|
|
1137
1158
|
class EuiError extends ErrorSubClass {
|
|
1159
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1160
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1138
1161
|
constructor(code = errorCodes.ERR_GENERIC, msg, args) {
|
|
1139
1162
|
super(code, msg, args);
|
|
1140
1163
|
this.name = 'EuiError';
|
|
@@ -1146,16 +1169,18 @@ class GlobalErrorHandler extends ErrorHandler {
|
|
|
1146
1169
|
super();
|
|
1147
1170
|
this.logService = logService;
|
|
1148
1171
|
}
|
|
1172
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1149
1174
|
handleError(error) {
|
|
1150
1175
|
// log error
|
|
1151
1176
|
this.logService.error(error.message || error.toString());
|
|
1152
1177
|
// throw error;
|
|
1153
1178
|
super.handleError(error);
|
|
1154
1179
|
}
|
|
1155
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1156
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1180
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1181
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' }); }
|
|
1157
1182
|
}
|
|
1158
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: GlobalErrorHandler, decorators: [{
|
|
1159
1184
|
type: Injectable,
|
|
1160
1185
|
args: [{
|
|
1161
1186
|
providedIn: 'root',
|
|
@@ -1168,21 +1193,28 @@ class HttpErrorHandlerInterceptor {
|
|
|
1168
1193
|
this.injector = injector;
|
|
1169
1194
|
this.router = router;
|
|
1170
1195
|
}
|
|
1196
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1171
1198
|
intercept(req, next) {
|
|
1172
|
-
return next.handle(req).pipe(tap(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
this.
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1199
|
+
return next.handle(req).pipe(tap({
|
|
1200
|
+
next: () => { },
|
|
1201
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1202
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1203
|
+
error: (error) => {
|
|
1204
|
+
// in case of http error
|
|
1205
|
+
if (error instanceof HttpErrorResponse) {
|
|
1206
|
+
const routeConfig = this.getRouteConfig(error);
|
|
1207
|
+
const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
|
|
1208
|
+
if (typeof rule === 'string') {
|
|
1209
|
+
// perform a redirect
|
|
1210
|
+
this.router.navigate([rule]);
|
|
1211
|
+
}
|
|
1212
|
+
else if (typeof rule === 'function') {
|
|
1213
|
+
// callback function
|
|
1214
|
+
rule.call(null, error, this.injector);
|
|
1215
|
+
}
|
|
1184
1216
|
}
|
|
1185
|
-
}
|
|
1217
|
+
},
|
|
1186
1218
|
}));
|
|
1187
1219
|
}
|
|
1188
1220
|
/**
|
|
@@ -1200,10 +1232,10 @@ class HttpErrorHandlerInterceptor {
|
|
|
1200
1232
|
// return the first matching route, if any
|
|
1201
1233
|
return routes.length > 0 ? routes[0] : null;
|
|
1202
1234
|
}
|
|
1203
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1204
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1235
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i1$4.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1236
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: HttpErrorHandlerInterceptor }); }
|
|
1205
1237
|
}
|
|
1206
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
|
|
1207
1239
|
type: Injectable
|
|
1208
1240
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1209
1241
|
type: Inject,
|
|
@@ -1289,6 +1321,8 @@ class ApiQueueService {
|
|
|
1289
1321
|
* @param id - id of the item inside the queue
|
|
1290
1322
|
* @return An Observable of type any
|
|
1291
1323
|
*/
|
|
1324
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1292
1326
|
processQueueItem(id) {
|
|
1293
1327
|
return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
1294
1328
|
if (!queue) {
|
|
@@ -1303,6 +1337,8 @@ class ApiQueueService {
|
|
|
1303
1337
|
* @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
|
|
1304
1338
|
* @return An Observable with an array which contains all responses from all items in queue.
|
|
1305
1339
|
*/
|
|
1340
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1341
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1306
1342
|
processAllQueueItems(continueOnError = true) {
|
|
1307
1343
|
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
1308
1344
|
this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
@@ -1310,7 +1346,10 @@ class ApiQueueService {
|
|
|
1310
1346
|
throw error;
|
|
1311
1347
|
}
|
|
1312
1348
|
return of(error);
|
|
1313
|
-
})))),
|
|
1349
|
+
})))),
|
|
1350
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1351
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1352
|
+
switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
|
|
1314
1353
|
}
|
|
1315
1354
|
/**
|
|
1316
1355
|
* Process all items in queue after it order them based on their timestamp. Beware that order
|
|
@@ -1318,6 +1357,8 @@ class ApiQueueService {
|
|
|
1318
1357
|
* or Http response follows order.
|
|
1319
1358
|
* @param [ascending=true] - sets the order of queue items based on timestamp
|
|
1320
1359
|
*/
|
|
1360
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1361
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1321
1362
|
processAllQueueItemsSequential(ascending = true) {
|
|
1322
1363
|
return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
|
|
1323
1364
|
.sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
|
|
@@ -1340,13 +1381,16 @@ class ApiQueueService {
|
|
|
1340
1381
|
* @param item - the item of the queue that matches the id.
|
|
1341
1382
|
* @return An Observable of HttpClient Request
|
|
1342
1383
|
*/
|
|
1384
|
+
// TODO: add type for T and deprecate old function
|
|
1385
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1386
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1343
1387
|
buildHttpRequest(id, item) {
|
|
1344
1388
|
return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
|
|
1345
1389
|
}
|
|
1346
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1347
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1390
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$5.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1391
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
|
|
1348
1392
|
}
|
|
1349
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1393
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: ApiQueueService, decorators: [{
|
|
1350
1394
|
type: Injectable,
|
|
1351
1395
|
args: [{
|
|
1352
1396
|
providedIn: 'root',
|
|
@@ -1364,11 +1408,15 @@ class ApiQueueServiceMock extends ApiQueueService {
|
|
|
1364
1408
|
return of({ uri: id, method: 'GET' });
|
|
1365
1409
|
}
|
|
1366
1410
|
removeAllQueueItem() { }
|
|
1411
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1412
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1367
1413
|
processAllQueueItems() {
|
|
1368
1414
|
return of({});
|
|
1369
1415
|
}
|
|
1370
1416
|
addQueueItem() { }
|
|
1371
1417
|
removeQueueItem() { }
|
|
1418
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1419
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1372
1420
|
processQueueItem() {
|
|
1373
1421
|
return of({});
|
|
1374
1422
|
}
|
|
@@ -1380,9 +1428,12 @@ class I18nResourceImpl {
|
|
|
1380
1428
|
*
|
|
1381
1429
|
* @param prefix the prefix of the resource
|
|
1382
1430
|
* @param suffix the suffix of the resource, optional parameter
|
|
1383
|
-
* @param
|
|
1431
|
+
* @param compileTranslationsFn compiler function, optional parameter
|
|
1384
1432
|
*/
|
|
1385
|
-
constructor(prefix, suffix = '',
|
|
1433
|
+
constructor(prefix, suffix = '',
|
|
1434
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1435
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-function-return-type
|
|
1436
|
+
compileTranslationsFn = (translations) => translations) {
|
|
1386
1437
|
this.prefix = prefix;
|
|
1387
1438
|
this.suffix = suffix;
|
|
1388
1439
|
this.compileTranslationsFn = compileTranslationsFn;
|
|
@@ -1394,6 +1445,8 @@ class I18nResourceImpl {
|
|
|
1394
1445
|
* @param lang the translations language
|
|
1395
1446
|
* @returns the pre-processed translations
|
|
1396
1447
|
*/
|
|
1448
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1449
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1397
1450
|
compileTranslations(translations, lang) {
|
|
1398
1451
|
return this.compileTranslationsFn(translations, lang);
|
|
1399
1452
|
}
|
|
@@ -1435,6 +1488,8 @@ class I18nLoader {
|
|
|
1435
1488
|
* @param lang
|
|
1436
1489
|
* @returns Observable<any>
|
|
1437
1490
|
*/
|
|
1491
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1492
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1438
1493
|
getTranslation(lang) {
|
|
1439
1494
|
return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
|
|
1440
1495
|
this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
|
|
@@ -1470,6 +1525,8 @@ class I18nLoader {
|
|
|
1470
1525
|
* @param lang the resource language to load
|
|
1471
1526
|
* @returns Observable<any>
|
|
1472
1527
|
*/
|
|
1528
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1529
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1473
1530
|
loadResources(resources, lang) {
|
|
1474
1531
|
// if there are resources to load
|
|
1475
1532
|
if (Array.isArray(resources) && resources.length > 0) {
|
|
@@ -1555,13 +1612,20 @@ class I18nLoader {
|
|
|
1555
1612
|
* @param lang the resource language to load
|
|
1556
1613
|
* @returns Observable<any>
|
|
1557
1614
|
*/
|
|
1615
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1616
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1558
1617
|
loadResource(resource, lang) {
|
|
1559
1618
|
// the path to the resource
|
|
1560
1619
|
const path = resource.getPath(lang);
|
|
1561
1620
|
// load the translations from the path
|
|
1562
1621
|
return this.http.get(path).pipe(
|
|
1563
1622
|
// preprocess the translations using the resource compiler
|
|
1564
|
-
|
|
1623
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1624
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1625
|
+
map((translations) => resource.compileTranslations(translations, lang)),
|
|
1626
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1627
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1628
|
+
map((translations) => {
|
|
1565
1629
|
// resource loaded properly, send a info message
|
|
1566
1630
|
if (this.logService) {
|
|
1567
1631
|
this.logService.info(`I18n resource loaded from path ${path}`);
|
|
@@ -1586,10 +1650,10 @@ class I18nLoader {
|
|
|
1586
1650
|
}
|
|
1587
1651
|
return undefined;
|
|
1588
1652
|
}
|
|
1589
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1590
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1653
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nLoader, deps: [{ token: i1$5.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1654
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nLoader }); }
|
|
1591
1655
|
}
|
|
1592
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1656
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nLoader, decorators: [{
|
|
1593
1657
|
type: Injectable
|
|
1594
1658
|
}], ctorParameters: () => [{ type: i1$5.HttpClient }, { type: LogService, decorators: [{
|
|
1595
1659
|
type: Optional
|
|
@@ -1617,7 +1681,9 @@ class I18nService extends EuiLazyService {
|
|
|
1617
1681
|
}
|
|
1618
1682
|
getState(keyOrMapFn) {
|
|
1619
1683
|
let selector = getI18nState;
|
|
1620
|
-
|
|
1684
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1685
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1686
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
1621
1687
|
if (keyOrMapFn) {
|
|
1622
1688
|
switch (typeof keyOrMapFn) {
|
|
1623
1689
|
case 'function':
|
|
@@ -1647,15 +1713,6 @@ class I18nService extends EuiLazyService {
|
|
|
1647
1713
|
}
|
|
1648
1714
|
return of({ success: false, error: 'Initial active lang should be string' });
|
|
1649
1715
|
}
|
|
1650
|
-
/**
|
|
1651
|
-
* A pipe function that could serve as a wrapper of another observable
|
|
1652
|
-
* e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
|
|
1653
|
-
* WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
|
|
1654
|
-
* into another emission.
|
|
1655
|
-
*
|
|
1656
|
-
* @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
|
|
1657
|
-
* fetch module name from the state.
|
|
1658
|
-
*/
|
|
1659
1716
|
onReady(moduleName) {
|
|
1660
1717
|
return this.onModuleLoad.pipe(switchMap((evt) => moduleName
|
|
1661
1718
|
? of(evt)
|
|
@@ -1678,6 +1735,7 @@ class I18nService extends EuiLazyService {
|
|
|
1678
1735
|
* Add resources based of a config loader
|
|
1679
1736
|
*
|
|
1680
1737
|
* @param config I18nLoaderConfig
|
|
1738
|
+
* @param moduleName
|
|
1681
1739
|
* @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
|
|
1682
1740
|
*/
|
|
1683
1741
|
addResources(config, moduleName) {
|
|
@@ -1685,6 +1743,8 @@ class I18nService extends EuiLazyService {
|
|
|
1685
1743
|
this.onModuleLoad.next({ ready: false, name: moduleName });
|
|
1686
1744
|
const loader = this.translateService.currentLoader;
|
|
1687
1745
|
if (loader instanceof I18nLoader) {
|
|
1746
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1747
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1688
1748
|
const langSubscription = [];
|
|
1689
1749
|
const i18nLoader = loader;
|
|
1690
1750
|
// add the resources to the loader
|
|
@@ -1694,10 +1754,10 @@ class I18nService extends EuiLazyService {
|
|
|
1694
1754
|
// add the new set of translations to the current language
|
|
1695
1755
|
this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
|
|
1696
1756
|
})));
|
|
1697
|
-
// if the current language is different
|
|
1757
|
+
// if the current language is different from the DEFAULT language
|
|
1698
1758
|
const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
|
|
1699
1759
|
if (this.translateService.currentLang !== defaultLang) {
|
|
1700
|
-
// manually load the resources for the default language and add them to the
|
|
1760
|
+
// manually load the resources for the default language and add them to the translation service
|
|
1701
1761
|
langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
|
|
1702
1762
|
this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
|
|
1703
1763
|
})));
|
|
@@ -1789,6 +1849,8 @@ class I18nService extends EuiLazyService {
|
|
|
1789
1849
|
* @returns Observable that returns an object contain the object translation for given language after language
|
|
1790
1850
|
* fully loaded.
|
|
1791
1851
|
*/
|
|
1852
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1853
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1792
1854
|
use(lang) {
|
|
1793
1855
|
return this.translateService.use(lang);
|
|
1794
1856
|
}
|
|
@@ -1800,10 +1862,10 @@ class I18nService extends EuiLazyService {
|
|
|
1800
1862
|
updateHTMLDOMLang(lang) {
|
|
1801
1863
|
this.document.documentElement.lang = lang;
|
|
1802
1864
|
}
|
|
1803
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1804
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1865
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$2.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1866
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nService, providedIn: 'root' }); }
|
|
1805
1867
|
}
|
|
1806
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
1868
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: I18nService, decorators: [{
|
|
1807
1869
|
type: Injectable,
|
|
1808
1870
|
args: [{
|
|
1809
1871
|
providedIn: 'root',
|
|
@@ -1811,46 +1873,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ng
|
|
|
1811
1873
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1812
1874
|
type: Inject,
|
|
1813
1875
|
args: [GLOBAL_CONFIG_TOKEN]
|
|
1814
|
-
}] }, { type: i1$
|
|
1876
|
+
}] }, { type: i1$2.TranslateService }, { type: LogService, decorators: [{
|
|
1815
1877
|
type: Optional
|
|
1816
1878
|
}] }, { type: StoreService }, { type: Document, decorators: [{
|
|
1817
1879
|
type: Inject,
|
|
1818
1880
|
args: [DOCUMENT]
|
|
1819
1881
|
}] }] });
|
|
1820
1882
|
|
|
1821
|
-
|
|
1822
|
-
constructor() {
|
|
1823
|
-
super(null, null, null, null, null);
|
|
1824
|
-
this.DEFAULT_LANGUAGE = 'en';
|
|
1825
|
-
}
|
|
1826
|
-
get onLangChange() {
|
|
1827
|
-
return new EventEmitter();
|
|
1828
|
-
}
|
|
1829
|
-
addResources() {
|
|
1830
|
-
return of({ success: true });
|
|
1831
|
-
}
|
|
1832
|
-
get currentLanguage() {
|
|
1833
|
-
return this.DEFAULT_LANGUAGE;
|
|
1834
|
-
}
|
|
1835
|
-
getState() {
|
|
1836
|
-
return of({ activeLang: this.DEFAULT_LANGUAGE });
|
|
1837
|
-
}
|
|
1838
|
-
updateState(i18nState) {
|
|
1839
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1840
|
-
}
|
|
1841
|
-
init(i18nState) {
|
|
1842
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1843
|
-
return of({ success: true });
|
|
1844
|
-
}
|
|
1845
|
-
lazyLoadInit() {
|
|
1846
|
-
return of({ success: true });
|
|
1847
|
-
}
|
|
1848
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1849
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock }); }
|
|
1850
|
-
}
|
|
1851
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock, decorators: [{
|
|
1852
|
-
type: Injectable
|
|
1853
|
-
}], ctorParameters: () => [] });
|
|
1883
|
+
// export * from './i18n.service.mock';
|
|
1854
1884
|
|
|
1855
1885
|
const diffDays = (dateStart, dateEnd) => Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
|
|
1856
1886
|
const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
@@ -1860,15 +1890,15 @@ const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
|
1860
1890
|
* http://api.jquery.com/position/
|
|
1861
1891
|
*/
|
|
1862
1892
|
const position = (nativeEl) => {
|
|
1863
|
-
|
|
1893
|
+
const elBCR = offset(nativeEl);
|
|
1864
1894
|
let offsetParentBCR = { top: 0, left: 0 };
|
|
1865
|
-
|
|
1895
|
+
const offsetParentEl = parentOffsetEl(nativeEl);
|
|
1866
1896
|
if (offsetParentEl !== document) {
|
|
1867
1897
|
offsetParentBCR = offset(offsetParentEl);
|
|
1868
1898
|
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
|
|
1869
1899
|
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
|
|
1870
1900
|
}
|
|
1871
|
-
|
|
1901
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
1872
1902
|
return {
|
|
1873
1903
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
1874
1904
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -1881,7 +1911,7 @@ const position = (nativeEl) => {
|
|
|
1881
1911
|
* http://api.jquery.com/offset/
|
|
1882
1912
|
*/
|
|
1883
1913
|
const offset = (nativeEl) => {
|
|
1884
|
-
|
|
1914
|
+
const boundingClientRect = nativeEl.getBoundingClientRect();
|
|
1885
1915
|
return {
|
|
1886
1916
|
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
1887
1917
|
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
@@ -1890,6 +1920,8 @@ const offset = (nativeEl) => {
|
|
|
1890
1920
|
};
|
|
1891
1921
|
};
|
|
1892
1922
|
// PRIVATE FUNCTIONS
|
|
1923
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
1924
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1893
1925
|
const getStyle = (nativeEl, cssProp) => {
|
|
1894
1926
|
// IE
|
|
1895
1927
|
if (nativeEl.currentStyle) {
|
|
@@ -1917,8 +1949,8 @@ const parentOffsetEl = (nativeEl) => {
|
|
|
1917
1949
|
return offsetParent || document;
|
|
1918
1950
|
};
|
|
1919
1951
|
const getViewElement = (fixture, componentClass, klass) => {
|
|
1920
|
-
let
|
|
1921
|
-
de = fixture.debugElement.query(By.css(componentClass));
|
|
1952
|
+
let el, domElement;
|
|
1953
|
+
const de = fixture.debugElement.query(By.css(componentClass));
|
|
1922
1954
|
if (de) {
|
|
1923
1955
|
el = de.nativeElement;
|
|
1924
1956
|
if (el && klass) {
|
|
@@ -1928,7 +1960,7 @@ const getViewElement = (fixture, componentClass, klass) => {
|
|
|
1928
1960
|
}
|
|
1929
1961
|
}
|
|
1930
1962
|
}
|
|
1931
|
-
return { de, el, domElement };
|
|
1963
|
+
return { de, el, domElement: domElement };
|
|
1932
1964
|
};
|
|
1933
1965
|
const closestMatchingParent = (target, className) => {
|
|
1934
1966
|
let element = target;
|
|
@@ -2014,11 +2046,11 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2014
2046
|
}
|
|
2015
2047
|
if (typeof value === 'string') {
|
|
2016
2048
|
// get all non characters
|
|
2017
|
-
|
|
2049
|
+
const nonChars = value.match(/[^0-9]+/g) || [];
|
|
2018
2050
|
// get all unique chars
|
|
2019
|
-
|
|
2051
|
+
const uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
|
|
2020
2052
|
// get separators
|
|
2021
|
-
|
|
2053
|
+
const separators = Array.from(uniqueChars.keys());
|
|
2022
2054
|
// sense where decimal separator and where thousand separator is
|
|
2023
2055
|
if (separators.length > 1) {
|
|
2024
2056
|
// left detected separator will be thousand and second will be decimal
|
|
@@ -2044,12 +2076,13 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2044
2076
|
return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2045
2077
|
}
|
|
2046
2078
|
// do the replacement of separators and parseInt
|
|
2047
|
-
// Beware! Always replace thousand separator first and then decimal
|
|
2079
|
+
// Beware! Always replace a thousand separator first and then decimal
|
|
2048
2080
|
value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
|
|
2049
2081
|
}
|
|
2050
2082
|
decimalSeparator = inDecimalSeparator;
|
|
2051
2083
|
thousandsSeparator = inThousandSeparator;
|
|
2052
2084
|
const maxFraction = '0'.repeat(fractionSize);
|
|
2085
|
+
// eslint-disable-next-line prefer-const
|
|
2053
2086
|
let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
|
|
2054
2087
|
fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
|
|
2055
2088
|
// this rule makes sense only in number in case fraction is all zero
|
|
@@ -2058,9 +2091,8 @@ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThous
|
|
|
2058
2091
|
};
|
|
2059
2092
|
|
|
2060
2093
|
const handleError = (error) => {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
return throwError(errMsg);
|
|
2094
|
+
const errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
|
2095
|
+
throw new Error(errMsg);
|
|
2064
2096
|
};
|
|
2065
2097
|
|
|
2066
2098
|
/**
|
|
@@ -2156,14 +2188,14 @@ class EuiPermissionService extends EuiService {
|
|
|
2156
2188
|
*/
|
|
2157
2189
|
haveAllRights(rights) {
|
|
2158
2190
|
if (!isDefined(rights)) {
|
|
2159
|
-
throw Error(
|
|
2191
|
+
throw Error('The rights should be an array but instead it\'s not defined!');
|
|
2160
2192
|
}
|
|
2161
2193
|
return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
|
|
2162
2194
|
}
|
|
2163
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2164
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2195
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiPermissionService, deps: [{ token: LogService, optional: true }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2196
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiPermissionService, providedIn: 'root' }); }
|
|
2165
2197
|
}
|
|
2166
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiPermissionService, decorators: [{
|
|
2167
2199
|
type: Injectable,
|
|
2168
2200
|
args: [{
|
|
2169
2201
|
providedIn: 'root',
|
|
@@ -2172,6 +2204,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ng
|
|
|
2172
2204
|
type: Optional
|
|
2173
2205
|
}] }, { type: StoreService }] });
|
|
2174
2206
|
|
|
2207
|
+
// TODO: Type of LINK should be UxLink or something relevant. Do we need that service anymore?
|
|
2208
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2209
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2175
2210
|
class EuiDynamicMenuService {
|
|
2176
2211
|
// TODO: it should be moved euiservice, or it should be static
|
|
2177
2212
|
// TODO: can we moved that service inside the module of the component that's using it?
|
|
@@ -2223,16 +2258,17 @@ class EuiDynamicMenuService {
|
|
|
2223
2258
|
return true;
|
|
2224
2259
|
});
|
|
2225
2260
|
}
|
|
2226
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2227
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2261
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicMenuService, deps: [{ token: EuiPermissionService }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2262
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicMenuService, providedIn: 'root' }); }
|
|
2228
2263
|
}
|
|
2229
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicMenuService, decorators: [{
|
|
2230
2265
|
type: Injectable,
|
|
2231
2266
|
args: [{
|
|
2232
2267
|
providedIn: 'root',
|
|
2233
2268
|
}]
|
|
2234
2269
|
}], ctorParameters: () => [{ type: EuiPermissionService }, { type: StoreService }] });
|
|
2235
2270
|
|
|
2271
|
+
// TODO: Do we need that service anymore? Can we remove it?
|
|
2236
2272
|
const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
|
|
2237
2273
|
class EuiDynamicComponentService {
|
|
2238
2274
|
constructor(componentFactoryResolver, injector, appRef) {
|
|
@@ -2246,6 +2282,8 @@ class EuiDynamicComponentService {
|
|
|
2246
2282
|
* @param el The element reference for the component to be injected
|
|
2247
2283
|
* @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
|
|
2248
2284
|
*/
|
|
2285
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2286
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2249
2287
|
add(component, el, config) {
|
|
2250
2288
|
// TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
|
|
2251
2289
|
// Create a portalHost from a DOM element
|
|
@@ -2281,15 +2319,17 @@ class EuiDynamicComponentService {
|
|
|
2281
2319
|
* creates a custom injector to be used when providing custom injection tokens to components inside a portal
|
|
2282
2320
|
* @param data to be used by DYNAMIC_COMPONENT_CONFIG token
|
|
2283
2321
|
*/
|
|
2322
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2323
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2284
2324
|
createInjector(data) {
|
|
2285
2325
|
const injectorTokens = new WeakMap();
|
|
2286
2326
|
injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
|
|
2287
2327
|
return new PortalInjector(this.injector, injectorTokens);
|
|
2288
2328
|
}
|
|
2289
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2290
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2329
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicComponentService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2330
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicComponentService }); }
|
|
2291
2331
|
}
|
|
2292
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2332
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiDynamicComponentService, decorators: [{
|
|
2293
2333
|
type: Injectable
|
|
2294
2334
|
}], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }] });
|
|
2295
2335
|
|
|
@@ -2355,6 +2395,8 @@ class EuiAppShellService {
|
|
|
2355
2395
|
get breakpoint$() {
|
|
2356
2396
|
return this._breakpoint$.asObservable();
|
|
2357
2397
|
}
|
|
2398
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2399
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2358
2400
|
get breakpoints$() {
|
|
2359
2401
|
return this._breakpoints$.asObservable();
|
|
2360
2402
|
}
|
|
@@ -2437,6 +2479,14 @@ class EuiAppShellService {
|
|
|
2437
2479
|
this.router = router;
|
|
2438
2480
|
this.storeService = storeService;
|
|
2439
2481
|
this.i18nService = i18nService;
|
|
2482
|
+
/**
|
|
2483
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2484
|
+
*/
|
|
2485
|
+
this.openModalId = new BehaviorSubject('');
|
|
2486
|
+
/**
|
|
2487
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2488
|
+
*/
|
|
2489
|
+
this.activeModals = [];
|
|
2440
2490
|
this.cssVars = [];
|
|
2441
2491
|
let stateWithConfig = initialState;
|
|
2442
2492
|
const languages = config?.i18n?.i18nService?.languages || initialState.languages;
|
|
@@ -2461,7 +2511,7 @@ class EuiAppShellService {
|
|
|
2461
2511
|
}
|
|
2462
2512
|
}
|
|
2463
2513
|
setState(nextState, updateI18 = true) {
|
|
2464
|
-
let breakpoint, breakpoints
|
|
2514
|
+
let breakpoint, breakpoints;
|
|
2465
2515
|
let combinedLinks;
|
|
2466
2516
|
const state = this.state;
|
|
2467
2517
|
// check if window width has been updated from previous state
|
|
@@ -2477,7 +2527,7 @@ class EuiAppShellService {
|
|
|
2477
2527
|
breakpoints = state.breakpoints;
|
|
2478
2528
|
}
|
|
2479
2529
|
// finally get the wrapper classes when both the state and breakpoint are known
|
|
2480
|
-
wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
2530
|
+
const wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
2481
2531
|
// check if the menuLinks or sidebarLinks have changed from previous state
|
|
2482
2532
|
if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
|
|
2483
2533
|
combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
|
|
@@ -2504,6 +2554,8 @@ class EuiAppShellService {
|
|
|
2504
2554
|
*
|
|
2505
2555
|
* @param key can be 'key' or 'key.sub.sub'
|
|
2506
2556
|
*/
|
|
2557
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2558
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2507
2559
|
getState(key) {
|
|
2508
2560
|
return defer(() =>
|
|
2509
2561
|
// check if key exists
|
|
@@ -2685,8 +2737,8 @@ class EuiAppShellService {
|
|
|
2685
2737
|
* Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
|
|
2686
2738
|
*/
|
|
2687
2739
|
setAppViewportCssVars() {
|
|
2688
|
-
|
|
2689
|
-
|
|
2740
|
+
const vh = window.innerHeight * 0.01;
|
|
2741
|
+
const vw = window.innerWidth * 0.01;
|
|
2690
2742
|
this._setCssVarValue('--eui-app-vh', `${vh}px`);
|
|
2691
2743
|
this._setCssVarValue('--eui-app-vw', `${vw}px`);
|
|
2692
2744
|
}
|
|
@@ -2706,6 +2758,103 @@ class EuiAppShellService {
|
|
|
2706
2758
|
}, false);
|
|
2707
2759
|
this._setCssVarValue('--eui-base-font-size', newsize);
|
|
2708
2760
|
}
|
|
2761
|
+
/**
|
|
2762
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2763
|
+
*/
|
|
2764
|
+
openModal(modalId) {
|
|
2765
|
+
document.body.classList.add('modal-open');
|
|
2766
|
+
if (!modalId) {
|
|
2767
|
+
modalId = 'single_modal';
|
|
2768
|
+
}
|
|
2769
|
+
this.activeModals.push({
|
|
2770
|
+
id: modalId,
|
|
2771
|
+
isOpen: true,
|
|
2772
|
+
});
|
|
2773
|
+
setTimeout(() => {
|
|
2774
|
+
const el = document.getElementById(modalId + '-close-button');
|
|
2775
|
+
if (el) {
|
|
2776
|
+
el.focus();
|
|
2777
|
+
}
|
|
2778
|
+
}, 100);
|
|
2779
|
+
}
|
|
2780
|
+
/**
|
|
2781
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2782
|
+
*/
|
|
2783
|
+
openMessageBox(messageBoxId) {
|
|
2784
|
+
if (!messageBoxId) {
|
|
2785
|
+
messageBoxId = 'messagebox_modal';
|
|
2786
|
+
}
|
|
2787
|
+
this.openModal(messageBoxId);
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2791
|
+
*/
|
|
2792
|
+
closeMessageBox(messageBoxId) {
|
|
2793
|
+
if (!messageBoxId) {
|
|
2794
|
+
messageBoxId = 'messagebox_modal';
|
|
2795
|
+
}
|
|
2796
|
+
this.closeModal(messageBoxId);
|
|
2797
|
+
}
|
|
2798
|
+
/**
|
|
2799
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2800
|
+
*/
|
|
2801
|
+
isModalOpen(modalId) {
|
|
2802
|
+
if (!modalId) {
|
|
2803
|
+
modalId = 'single_modal';
|
|
2804
|
+
}
|
|
2805
|
+
if (this.activeModals.length) {
|
|
2806
|
+
const modalIndex = this.findModalIndex(modalId);
|
|
2807
|
+
if (modalIndex !== -1) {
|
|
2808
|
+
return this.activeModals[modalIndex].isOpen;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
return false;
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2815
|
+
*/
|
|
2816
|
+
closeModal(modalId) {
|
|
2817
|
+
if (!modalId) {
|
|
2818
|
+
modalId = 'single_modal';
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2821
|
+
* Make sure we find the modal before splicing the activeModals array
|
|
2822
|
+
*/
|
|
2823
|
+
const index = this.findModalIndex(modalId);
|
|
2824
|
+
if (index >= 0) {
|
|
2825
|
+
this.activeModals.splice(index, 1);
|
|
2826
|
+
}
|
|
2827
|
+
if (this.activeModals && this.activeModals.length <= 0) {
|
|
2828
|
+
document.body.classList.remove('modal-open');
|
|
2829
|
+
}
|
|
2830
|
+
else {
|
|
2831
|
+
// If there is still another (parent) modal dialog open, ensure it is focused upon to be able to close is with the ESC key:
|
|
2832
|
+
const lastModalId = this.activeModals[this.activeModals.length - 1].id;
|
|
2833
|
+
if (lastModalId) {
|
|
2834
|
+
setTimeout(() => {
|
|
2835
|
+
const el = document.getElementById(lastModalId + '-close-button');
|
|
2836
|
+
if (el) {
|
|
2837
|
+
el.focus();
|
|
2838
|
+
}
|
|
2839
|
+
}, 100);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
/**
|
|
2844
|
+
* @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
|
|
2845
|
+
*/
|
|
2846
|
+
findModalIndex(modalId) {
|
|
2847
|
+
let index = -1;
|
|
2848
|
+
if (this.activeModals.length) {
|
|
2849
|
+
for (let i = 0; i < this.activeModals.length; i++) {
|
|
2850
|
+
if (this.activeModals[i].id === modalId) {
|
|
2851
|
+
index = i;
|
|
2852
|
+
break;
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
return index;
|
|
2857
|
+
}
|
|
2709
2858
|
// ---------------
|
|
2710
2859
|
// private getters
|
|
2711
2860
|
// ---------------
|
|
@@ -2721,7 +2870,7 @@ class EuiAppShellService {
|
|
|
2721
2870
|
document.documentElement.style.setProperty(varName, varValue);
|
|
2722
2871
|
}
|
|
2723
2872
|
getWrapperClasses(state, breakpoint) {
|
|
2724
|
-
|
|
2873
|
+
const classes = [];
|
|
2725
2874
|
classes.push(breakpoint);
|
|
2726
2875
|
if (state.hasSidebar) {
|
|
2727
2876
|
if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
|
|
@@ -2814,12 +2963,14 @@ class EuiAppShellService {
|
|
|
2814
2963
|
};
|
|
2815
2964
|
}
|
|
2816
2965
|
getJson(url) {
|
|
2817
|
-
return this.http.get(url)
|
|
2966
|
+
return firstValueFrom(this.http.get(url)).then(this.extractData).catch(this.handleError);
|
|
2818
2967
|
}
|
|
2819
2968
|
extractData(res) {
|
|
2820
2969
|
const body = res;
|
|
2821
2970
|
return body || {};
|
|
2822
2971
|
}
|
|
2972
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
2973
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2823
2974
|
handleError(error) {
|
|
2824
2975
|
console.error('An error occurred', error);
|
|
2825
2976
|
return Promise.reject(error.message || error);
|
|
@@ -2834,10 +2985,10 @@ class EuiAppShellService {
|
|
|
2834
2985
|
}
|
|
2835
2986
|
});
|
|
2836
2987
|
}
|
|
2837
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2838
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2988
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$5.HttpClient }, { token: PLATFORM_ID }, { token: i1$4.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2989
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiAppShellService, providedIn: 'root' }); }
|
|
2839
2990
|
}
|
|
2840
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
2991
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiAppShellService, decorators: [{
|
|
2841
2992
|
type: Injectable,
|
|
2842
2993
|
args: [{
|
|
2843
2994
|
providedIn: 'root',
|
|
@@ -3561,10 +3712,10 @@ class EuiTimezoneService {
|
|
|
3561
3712
|
getTimezone(tz) {
|
|
3562
3713
|
return EUI_TIMEZONES.find((item) => item.name === tz);
|
|
3563
3714
|
}
|
|
3564
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3565
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3715
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiTimezoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3716
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiTimezoneService }); }
|
|
3566
3717
|
}
|
|
3567
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3718
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuiTimezoneService, decorators: [{
|
|
3568
3719
|
type: Injectable
|
|
3569
3720
|
}] });
|
|
3570
3721
|
|
|
@@ -3602,18 +3753,26 @@ class AsyncStorageService extends StorageService {
|
|
|
3602
3753
|
}
|
|
3603
3754
|
|
|
3604
3755
|
class AsyncStorageServiceMock extends AsyncStorageService {
|
|
3756
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3757
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3605
3758
|
ready() {
|
|
3606
3759
|
return of({});
|
|
3607
3760
|
}
|
|
3608
3761
|
name() {
|
|
3609
3762
|
return null;
|
|
3610
3763
|
}
|
|
3764
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3765
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3611
3766
|
get() {
|
|
3612
3767
|
return of({});
|
|
3613
3768
|
}
|
|
3769
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3770
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3614
3771
|
set() {
|
|
3615
3772
|
return of({});
|
|
3616
3773
|
}
|
|
3774
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3775
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3617
3776
|
remove() {
|
|
3618
3777
|
return of({});
|
|
3619
3778
|
}
|
|
@@ -3641,6 +3800,8 @@ class LocalStorageService extends StorageService {
|
|
|
3641
3800
|
* @param key the associated key
|
|
3642
3801
|
* @returns the value or undefined, if case of error
|
|
3643
3802
|
*/
|
|
3803
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3804
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3644
3805
|
get(key) {
|
|
3645
3806
|
try {
|
|
3646
3807
|
const serialized = localStorage.getItem(key);
|
|
@@ -3658,6 +3819,8 @@ class LocalStorageService extends StorageService {
|
|
|
3658
3819
|
* @param key the associated key
|
|
3659
3820
|
* @param value the value to set
|
|
3660
3821
|
*/
|
|
3822
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3823
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3661
3824
|
set(key, value) {
|
|
3662
3825
|
try {
|
|
3663
3826
|
const serialized = JSON.stringify(value);
|
|
@@ -3683,10 +3846,10 @@ class LocalStorageService extends StorageService {
|
|
|
3683
3846
|
}
|
|
3684
3847
|
}
|
|
3685
3848
|
}
|
|
3686
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3687
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3849
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3850
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalStorageService }); }
|
|
3688
3851
|
}
|
|
3689
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3852
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalStorageService, decorators: [{
|
|
3690
3853
|
type: Injectable
|
|
3691
3854
|
}], ctorParameters: () => [{ type: LogService, decorators: [{
|
|
3692
3855
|
type: Optional
|
|
@@ -3712,6 +3875,8 @@ class SessionStorageService extends StorageService {
|
|
|
3712
3875
|
* @param key the associated key
|
|
3713
3876
|
* @returns the value or undefined, if case of error
|
|
3714
3877
|
*/
|
|
3878
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3879
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3715
3880
|
get(key) {
|
|
3716
3881
|
try {
|
|
3717
3882
|
const serialized = sessionStorage.getItem(key);
|
|
@@ -3729,6 +3894,8 @@ class SessionStorageService extends StorageService {
|
|
|
3729
3894
|
* @param key the associated key
|
|
3730
3895
|
* @param value the value to set
|
|
3731
3896
|
*/
|
|
3897
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3898
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3732
3899
|
set(key, value) {
|
|
3733
3900
|
try {
|
|
3734
3901
|
const serialized = JSON.stringify(value);
|
|
@@ -3754,17 +3921,21 @@ class SessionStorageService extends StorageService {
|
|
|
3754
3921
|
}
|
|
3755
3922
|
}
|
|
3756
3923
|
}
|
|
3757
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3758
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3924
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: SessionStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3925
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: SessionStorageService }); }
|
|
3759
3926
|
}
|
|
3760
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3927
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: SessionStorageService, decorators: [{
|
|
3761
3928
|
type: Injectable
|
|
3762
3929
|
}], ctorParameters: () => [{ type: LogService, decorators: [{
|
|
3763
3930
|
type: Optional
|
|
3764
3931
|
}] }] });
|
|
3765
3932
|
|
|
3766
3933
|
/** @internal */
|
|
3934
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3935
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3767
3936
|
const localForage = 'defineDriver' in lf ? lf : lf['default'];
|
|
3937
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3938
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3768
3939
|
const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVICE_CONFIG');
|
|
3769
3940
|
/**
|
|
3770
3941
|
* localforage service, using the localForage javascript library
|
|
@@ -3772,7 +3943,10 @@ const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVI
|
|
|
3772
3943
|
*/
|
|
3773
3944
|
class LocalForageService extends AsyncStorageService {
|
|
3774
3945
|
static { this.NAME = 'LocalForageService'; }
|
|
3775
|
-
constructor(
|
|
3946
|
+
constructor(
|
|
3947
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3948
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3949
|
+
config, log) {
|
|
3776
3950
|
super();
|
|
3777
3951
|
this.config = config;
|
|
3778
3952
|
this.log = log;
|
|
@@ -3791,11 +3965,16 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3791
3965
|
* reflects the readiness of the storage
|
|
3792
3966
|
* @returns one time emission Observable<void>
|
|
3793
3967
|
*/
|
|
3968
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3969
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3794
3970
|
ready() {
|
|
3795
|
-
return from(localForage.ready()).pipe(take(1), tap(
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3971
|
+
return from(localForage.ready()).pipe(take(1), tap({
|
|
3972
|
+
next: () => { },
|
|
3973
|
+
error: (err) => {
|
|
3974
|
+
if (this.log) {
|
|
3975
|
+
this.log.error(this.name(), 'ready', err);
|
|
3976
|
+
}
|
|
3977
|
+
},
|
|
3799
3978
|
}));
|
|
3800
3979
|
}
|
|
3801
3980
|
/**
|
|
@@ -3803,6 +3982,8 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3803
3982
|
* @param key the associated key
|
|
3804
3983
|
* @returns one time emission Observable of value
|
|
3805
3984
|
*/
|
|
3985
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
3986
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3806
3987
|
get(key) {
|
|
3807
3988
|
return from(localForage.getItem(key)).pipe(take(1), tap(() => { }, (err) => {
|
|
3808
3989
|
if (this.log) {
|
|
@@ -3816,11 +3997,17 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3816
3997
|
* @param value the value to set
|
|
3817
3998
|
* @returns one time emission Observable
|
|
3818
3999
|
*/
|
|
4000
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4001
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3819
4002
|
set(key, value) {
|
|
3820
|
-
return from(localForage.setItem(key, value)).pipe(take(1), tap(
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
4003
|
+
return from(localForage.setItem(key, value)).pipe(take(1), tap({
|
|
4004
|
+
next: () => {
|
|
4005
|
+
},
|
|
4006
|
+
error: (err) => {
|
|
4007
|
+
if (this.log) {
|
|
4008
|
+
this.log.error(this.name(), 'set', err);
|
|
4009
|
+
}
|
|
4010
|
+
},
|
|
3824
4011
|
}));
|
|
3825
4012
|
}
|
|
3826
4013
|
/**
|
|
@@ -3828,17 +4015,22 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3828
4015
|
* @param key the associated key
|
|
3829
4016
|
* @returns one time emission Observable
|
|
3830
4017
|
*/
|
|
4018
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4019
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3831
4020
|
remove(key) {
|
|
3832
|
-
return from(localForage.removeItem(key)).pipe(take(1), tap(
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
4021
|
+
return from(localForage.removeItem(key)).pipe(take(1), tap({
|
|
4022
|
+
next: () => { },
|
|
4023
|
+
error: (err) => {
|
|
4024
|
+
if (this.log) {
|
|
4025
|
+
this.log.error(this.name(), 'remove', err);
|
|
4026
|
+
}
|
|
4027
|
+
},
|
|
3836
4028
|
}));
|
|
3837
4029
|
}
|
|
3838
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
3839
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4030
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4031
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalForageService }); }
|
|
3840
4032
|
}
|
|
3841
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocalForageService, decorators: [{
|
|
3842
4034
|
type: Injectable
|
|
3843
4035
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3844
4036
|
type: Inject,
|
|
@@ -3886,7 +4078,9 @@ class LocaleService extends EuiService {
|
|
|
3886
4078
|
}
|
|
3887
4079
|
getState(keyOrMapFn) {
|
|
3888
4080
|
let selector = getLocaleState;
|
|
3889
|
-
|
|
4081
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4082
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4083
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
3890
4084
|
if (keyOrMapFn) {
|
|
3891
4085
|
switch (typeof keyOrMapFn) {
|
|
3892
4086
|
case 'function':
|
|
@@ -4045,10 +4239,10 @@ class LocaleService extends EuiService {
|
|
|
4045
4239
|
}
|
|
4046
4240
|
});
|
|
4047
4241
|
}
|
|
4048
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4049
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4242
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleService, deps: [{ token: StoreService }, { token: GLOBAL_CONFIG_TOKEN }, { token: LOCALE_ID }, { token: LOCALE_ID_MAPPER, optional: true }, { token: I18nService, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4243
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
|
|
4050
4244
|
}
|
|
4051
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleService, decorators: [{
|
|
4052
4246
|
type: Injectable,
|
|
4053
4247
|
args: [{
|
|
4054
4248
|
providedIn: 'root',
|
|
@@ -4094,10 +4288,10 @@ class LocaleServiceMock extends LocaleService {
|
|
|
4094
4288
|
this.DEFAULT_LOCALE = state.id || 'en';
|
|
4095
4289
|
return of({ success: true });
|
|
4096
4290
|
}
|
|
4097
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4098
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4291
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleServiceMock, deps: [{ token: LOCALE_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4292
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleServiceMock }); }
|
|
4099
4293
|
}
|
|
4100
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4294
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: LocaleServiceMock, decorators: [{
|
|
4101
4295
|
type: Injectable
|
|
4102
4296
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
4103
4297
|
type: Optional
|
|
@@ -4124,7 +4318,9 @@ class UserService extends EuiService {
|
|
|
4124
4318
|
}
|
|
4125
4319
|
getState(keyOrMapFn) {
|
|
4126
4320
|
let selector = getUserState;
|
|
4127
|
-
|
|
4321
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4322
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4323
|
+
const dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
4128
4324
|
if (keyOrMapFn) {
|
|
4129
4325
|
switch (typeof keyOrMapFn) {
|
|
4130
4326
|
case 'function':
|
|
@@ -4137,6 +4333,8 @@ class UserService extends EuiService {
|
|
|
4137
4333
|
}
|
|
4138
4334
|
return this.store.select(selector);
|
|
4139
4335
|
}
|
|
4336
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4337
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4140
4338
|
updateState(userState, reducer) {
|
|
4141
4339
|
// if (typeof pathOrReducer === 'string') {
|
|
4142
4340
|
// let dotNotationToObject = (obj, key) => key.split('.').reduce((obj, i) => obj[i], obj);
|
|
@@ -4150,13 +4348,15 @@ class UserService extends EuiService {
|
|
|
4150
4348
|
this.store.dispatchAction(userState, 'user', reducer);
|
|
4151
4349
|
}
|
|
4152
4350
|
else {
|
|
4351
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4352
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4153
4353
|
this.store.dispatch(new UpdateUserStateAction(userState));
|
|
4154
4354
|
}
|
|
4155
4355
|
}
|
|
4156
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4157
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4356
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4357
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserService, providedIn: 'root' }); }
|
|
4158
4358
|
}
|
|
4159
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserService, decorators: [{
|
|
4160
4360
|
type: Injectable,
|
|
4161
4361
|
args: [{
|
|
4162
4362
|
providedIn: 'root',
|
|
@@ -4167,27 +4367,21 @@ class UserServiceMock extends UserService {
|
|
|
4167
4367
|
constructor() {
|
|
4168
4368
|
super(null);
|
|
4169
4369
|
}
|
|
4170
|
-
|
|
4171
|
-
return of({
|
|
4172
|
-
}
|
|
4173
|
-
observePreferencesUpdate() { }
|
|
4174
|
-
loadUserPreferences() {
|
|
4175
|
-
return of({});
|
|
4176
|
-
}
|
|
4177
|
-
saveUserPreferences() {
|
|
4178
|
-
return of({});
|
|
4370
|
+
init(userState) {
|
|
4371
|
+
return of({ success: true });
|
|
4179
4372
|
}
|
|
4180
|
-
|
|
4181
|
-
userPreferences() {
|
|
4373
|
+
getState(keyOrMapFn) {
|
|
4182
4374
|
return of({});
|
|
4183
4375
|
}
|
|
4184
|
-
|
|
4185
|
-
|
|
4376
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4377
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4378
|
+
updateState(userState, reducer) {
|
|
4379
|
+
/* empty */
|
|
4186
4380
|
}
|
|
4187
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4188
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4381
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4382
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserServiceMock }); }
|
|
4189
4383
|
}
|
|
4190
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4384
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UserServiceMock, decorators: [{
|
|
4191
4385
|
type: Injectable
|
|
4192
4386
|
}], ctorParameters: () => [] });
|
|
4193
4387
|
|
|
@@ -4216,12 +4410,12 @@ class AddLangParamInterceptor {
|
|
|
4216
4410
|
params: req.params.set(langParam, langValue),
|
|
4217
4411
|
}));
|
|
4218
4412
|
}
|
|
4219
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4220
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4413
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4414
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: AddLangParamInterceptor }); }
|
|
4221
4415
|
}
|
|
4222
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4416
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
|
|
4223
4417
|
type: Injectable
|
|
4224
|
-
}], ctorParameters: () => [{ type: i1$
|
|
4418
|
+
}], ctorParameters: () => [{ type: i1$2.TranslateService }] });
|
|
4225
4419
|
|
|
4226
4420
|
class CachePreventionInterceptor {
|
|
4227
4421
|
intercept(req, next) {
|
|
@@ -4235,10 +4429,10 @@ class CachePreventionInterceptor {
|
|
|
4235
4429
|
headers: req.headers.set('Cache-Control', 'No-Cache'),
|
|
4236
4430
|
}));
|
|
4237
4431
|
}
|
|
4238
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4239
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4432
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CachePreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4433
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CachePreventionInterceptor }); }
|
|
4240
4434
|
}
|
|
4241
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4435
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CachePreventionInterceptor, decorators: [{
|
|
4242
4436
|
type: Injectable
|
|
4243
4437
|
}] });
|
|
4244
4438
|
|
|
@@ -4248,10 +4442,10 @@ class CorsSecurityInterceptor {
|
|
|
4248
4442
|
withCredentials: true,
|
|
4249
4443
|
}));
|
|
4250
4444
|
}
|
|
4251
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4252
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4445
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CorsSecurityInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4446
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CorsSecurityInterceptor }); }
|
|
4253
4447
|
}
|
|
4254
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4448
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CorsSecurityInterceptor, decorators: [{
|
|
4255
4449
|
type: Injectable
|
|
4256
4450
|
}] });
|
|
4257
4451
|
|
|
@@ -4261,10 +4455,10 @@ class CsrfPreventionInterceptor {
|
|
|
4261
4455
|
headers: request.headers.set('X-Requested-With', 'XMLHttpRequest'),
|
|
4262
4456
|
}));
|
|
4263
4457
|
}
|
|
4264
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4265
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4458
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CsrfPreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4459
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CsrfPreventionInterceptor }); }
|
|
4266
4460
|
}
|
|
4267
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4461
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: CsrfPreventionInterceptor, decorators: [{
|
|
4268
4462
|
type: Injectable
|
|
4269
4463
|
}] });
|
|
4270
4464
|
|
|
@@ -4280,17 +4474,24 @@ class EuLoginSessionTimeoutHandlingInterceptor {
|
|
|
4280
4474
|
this.checkRequestErrorForEULoginSessionTimeout(request, error);
|
|
4281
4475
|
}));
|
|
4282
4476
|
}
|
|
4477
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4478
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4283
4479
|
checkRequestSuccessForEULoginSessionTimeout(request, event) {
|
|
4284
4480
|
if (event instanceof HttpResponse) {
|
|
4481
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4482
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4285
4483
|
if (this.isSsoResponse(event.body)) {
|
|
4286
4484
|
this.reauthenticate();
|
|
4287
4485
|
}
|
|
4288
4486
|
}
|
|
4289
4487
|
}
|
|
4290
|
-
//
|
|
4488
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4489
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4291
4490
|
checkRequestErrorForEULoginSessionTimeout(request, response) {
|
|
4292
|
-
|
|
4491
|
+
/* intentionally blank; meant for overriding */
|
|
4293
4492
|
}
|
|
4493
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4494
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4294
4495
|
isSsoResponse(body) {
|
|
4295
4496
|
if (body) {
|
|
4296
4497
|
if (typeof body !== 'string') {
|
|
@@ -4329,10 +4530,10 @@ class EuLoginSessionTimeoutHandlingInterceptor {
|
|
|
4329
4530
|
reauthenticate() {
|
|
4330
4531
|
document.location.reload();
|
|
4331
4532
|
}
|
|
4332
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4333
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4533
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4534
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor }); }
|
|
4334
4535
|
}
|
|
4335
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4536
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, decorators: [{
|
|
4336
4537
|
type: Injectable
|
|
4337
4538
|
}] });
|
|
4338
4539
|
|
|
@@ -4341,8 +4542,13 @@ class UxRequestErrorModelInterceptor {
|
|
|
4341
4542
|
constructor(errorMappingHandler) {
|
|
4342
4543
|
this.errorMappingHandler = errorMappingHandler;
|
|
4343
4544
|
}
|
|
4545
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4546
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4344
4547
|
intercept(req, next) {
|
|
4345
|
-
return next.handle(req).pipe(
|
|
4548
|
+
return next.handle(req).pipe(
|
|
4549
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4550
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4551
|
+
catchError((err) => {
|
|
4346
4552
|
if (this.errorMappingHandler) {
|
|
4347
4553
|
if (err instanceof HttpErrorResponse) {
|
|
4348
4554
|
err = transformToUxHttpResponse(err, this.errorMappingHandler);
|
|
@@ -4351,10 +4557,10 @@ class UxRequestErrorModelInterceptor {
|
|
|
4351
4557
|
return of(err);
|
|
4352
4558
|
}));
|
|
4353
4559
|
}
|
|
4354
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4355
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4560
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UxRequestErrorModelInterceptor, deps: [{ token: UX_ERROR_MAPPING_HANDLER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4561
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UxRequestErrorModelInterceptor }); }
|
|
4356
4562
|
}
|
|
4357
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4563
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: UxRequestErrorModelInterceptor, decorators: [{
|
|
4358
4564
|
type: Injectable
|
|
4359
4565
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
4360
4566
|
type: Inject,
|
|
@@ -4370,14 +4576,25 @@ class OpenIdConnectInterceptor {
|
|
|
4370
4576
|
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.');
|
|
4371
4577
|
}
|
|
4372
4578
|
}
|
|
4373
|
-
intercept(
|
|
4579
|
+
intercept(
|
|
4580
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4581
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4582
|
+
request, next, retryCount = 0,
|
|
4583
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4584
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4585
|
+
retryCallback) {
|
|
4374
4586
|
if (typeof OpenIdConnect !== 'undefined') {
|
|
4375
4587
|
let authorizedRequest = retryCallback;
|
|
4376
4588
|
if (!authorizedRequest) {
|
|
4589
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4590
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4377
4591
|
authorizedRequest = new Subject();
|
|
4378
4592
|
}
|
|
4379
4593
|
let subscription = null;
|
|
4380
|
-
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4594
|
+
OpenIdConnect.getAuthorizationHeaders(request.urlWithParams,
|
|
4595
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4596
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4597
|
+
(headers) => {
|
|
4381
4598
|
let newRequest = request;
|
|
4382
4599
|
if (headers) {
|
|
4383
4600
|
let newHeaders = request.headers;
|
|
@@ -4402,6 +4619,8 @@ class OpenIdConnectInterceptor {
|
|
|
4402
4619
|
subscription = next
|
|
4403
4620
|
.handle(newRequest)
|
|
4404
4621
|
.pipe(catchError((response) => this.handleErrorResponse(response, request, next, retryCount, authorizedRequest, subscription)))
|
|
4622
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4623
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4405
4624
|
.subscribe((httpEvent) => {
|
|
4406
4625
|
if (httpEvent) {
|
|
4407
4626
|
authorizedRequest.next(httpEvent);
|
|
@@ -4414,6 +4633,8 @@ class OpenIdConnectInterceptor {
|
|
|
4414
4633
|
}
|
|
4415
4634
|
});
|
|
4416
4635
|
}, (errorResponse) => {
|
|
4636
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4637
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4417
4638
|
const errorProperties = {
|
|
4418
4639
|
error: errorResponse,
|
|
4419
4640
|
};
|
|
@@ -4434,7 +4655,13 @@ class OpenIdConnectInterceptor {
|
|
|
4434
4655
|
return next.handle(request);
|
|
4435
4656
|
}
|
|
4436
4657
|
}
|
|
4437
|
-
handleErrorResponse(response,
|
|
4658
|
+
handleErrorResponse(response,
|
|
4659
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4660
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4661
|
+
originalRequest, next, retryCount = 0,
|
|
4662
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4663
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4664
|
+
retryCallback, subscription) {
|
|
4438
4665
|
if (response) {
|
|
4439
4666
|
if (response.error && response.error.error === 'invalid_request') {
|
|
4440
4667
|
// The ID token is invalid or incorrect; retrieve another one:
|
|
@@ -4467,7 +4694,13 @@ class OpenIdConnectInterceptor {
|
|
|
4467
4694
|
}
|
|
4468
4695
|
return throwError(response);
|
|
4469
4696
|
}
|
|
4470
|
-
retryRequest(
|
|
4697
|
+
retryRequest(
|
|
4698
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4699
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4700
|
+
originalRequest, response, next, retryCount = 0,
|
|
4701
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4702
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4703
|
+
retryCallback, subscription) {
|
|
4471
4704
|
if (retryCount < this.maximumRequestRetries()) {
|
|
4472
4705
|
this.intercept(originalRequest, next, retryCount + 1, retryCallback);
|
|
4473
4706
|
}
|
|
@@ -4484,6 +4717,8 @@ class OpenIdConnectInterceptor {
|
|
|
4484
4717
|
retryCallback.complete();
|
|
4485
4718
|
}
|
|
4486
4719
|
}
|
|
4720
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4721
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4487
4722
|
return of(null);
|
|
4488
4723
|
}
|
|
4489
4724
|
apiGatewayTokenExpired(response) {
|
|
@@ -4503,10 +4738,10 @@ class OpenIdConnectInterceptor {
|
|
|
4503
4738
|
return this.defaultMaximumRequestRetries;
|
|
4504
4739
|
}
|
|
4505
4740
|
}
|
|
4506
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4507
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4741
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4742
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectInterceptor }); }
|
|
4508
4743
|
}
|
|
4509
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4744
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectInterceptor, decorators: [{
|
|
4510
4745
|
type: Injectable
|
|
4511
4746
|
}], ctorParameters: () => [] });
|
|
4512
4747
|
|
|
@@ -4514,6 +4749,8 @@ class OpenIdConnectService {
|
|
|
4514
4749
|
constructor() {
|
|
4515
4750
|
this.userDetails = new Observable((observer) => {
|
|
4516
4751
|
if (typeof ApiGateway !== 'undefined') {
|
|
4752
|
+
// TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
|
|
4753
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4517
4754
|
ApiGateway.getUser((user) => {
|
|
4518
4755
|
if (user) {
|
|
4519
4756
|
observer.next({
|
|
@@ -4553,10 +4790,10 @@ class OpenIdConnectService {
|
|
|
4553
4790
|
getUserDetails() {
|
|
4554
4791
|
return this.userDetails;
|
|
4555
4792
|
}
|
|
4556
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4557
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4793
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4794
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectService, providedIn: 'root' }); }
|
|
4558
4795
|
}
|
|
4559
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.
|
|
4796
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.1", ngImport: i0, type: OpenIdConnectService, decorators: [{
|
|
4560
4797
|
type: Injectable,
|
|
4561
4798
|
args: [{
|
|
4562
4799
|
providedIn: 'root',
|
|
@@ -4575,5 +4812,5 @@ class OpenIdConnectServiceMock extends OpenIdConnectService {
|
|
|
4575
4812
|
* Generated bundle index. Do not edit.
|
|
4576
4813
|
*/
|
|
4577
4814
|
|
|
4578
|
-
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, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiPermissionService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService,
|
|
4815
|
+
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, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiPermissionService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, InitStoreAction, LANG_PARAM_KEY, LOCALE_ID_MAPPER, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, LOG_APPENDERS_TOKEN, LOG_LEVEL_TOKEN, LocalForageService, LocalStorageService, LocaleService, LocaleServiceMock, LogHttpErrorCallbackFn, LogModule, LogService, LogServiceMock, MODULE_CONFIG_TOKEN, MODULE_NAME_TOKEN, OpenIdConnectInterceptor, OpenIdConnectService, OpenIdConnectServiceMock, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_ERROR_MAPPING_HANDLER_TOKEN, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxRequestErrorModelInterceptor, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, 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 };
|
|
4579
4816
|
//# sourceMappingURL=eui-core.mjs.map
|