@eui/core 17.0.0-next.4 → 17.0.0-next.6
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/esm2022/lib/eui-core.module.mjs +4 -4
- package/esm2022/lib/interceptors/add-lang-param.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/cache-prevention.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/cors-security.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/csrf-prevention.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/eu-login-session-timeout-handling.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/openid/openid-connect.interceptor.mjs +3 -3
- package/esm2022/lib/interceptors/openid/openid-connect.service.mjs +3 -3
- package/esm2022/lib/interceptors/ux-request-error-model.interceptor.mjs +3 -3
- package/esm2022/lib/services/dynamic-component/dynamic-component.service.mjs +63 -0
- package/esm2022/lib/services/dynamic-menu/dynamic-menu.service.mjs +10 -10
- package/esm2022/lib/services/errors/eui.error.mjs +3 -1
- package/esm2022/lib/services/errors/global-error-handler.mjs +3 -3
- package/esm2022/lib/services/errors/http-error-handler-callback-functions.mjs +4 -5
- package/esm2022/lib/services/errors/http-error-handler.interceptor.mjs +3 -3
- package/esm2022/lib/services/eui-app-shell.service.mjs +576 -0
- package/esm2022/lib/services/eui-timezone.service.mjs +3 -3
- package/esm2022/lib/services/growl/eui-growl.service.mjs +79 -0
- package/esm2022/lib/services/growl/index.mjs +2 -0
- package/esm2022/lib/services/i18n/i18n.loader.mjs +3 -3
- package/esm2022/lib/services/i18n/i18n.service.mjs +3 -3
- package/esm2022/lib/services/i18n/i18n.service.mock.mjs +3 -3
- package/esm2022/lib/services/index.mjs +4 -5
- package/esm2022/lib/services/locale/locale.service.mjs +3 -3
- 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 +3 -3
- package/esm2022/lib/services/permission/permission.service.mjs +4 -4
- package/esm2022/lib/services/queue/api-queue.service.mjs +4 -4
- package/esm2022/lib/services/storage/local-forage.service.mjs +4 -4
- package/esm2022/lib/services/storage/local-storage.service.mjs +3 -3
- package/esm2022/lib/services/storage/session-storage.service.mjs +3 -3
- package/esm2022/lib/services/store/effects/app.effects.mjs +10 -20
- package/esm2022/lib/services/store/store.service.mjs +4 -4
- package/esm2022/lib/services/store/store.service.mock.mjs +3 -3
- package/esm2022/lib/services/user/user.service.mjs +3 -3
- package/esm2022/lib/services/user/user.service.mock.mjs +3 -3
- package/fesm2022/eui-core.mjs +2092 -2120
- package/fesm2022/eui-core.mjs.map +1 -1
- package/lib/services/{ux-dynamic-component/ux-dynamic-component.service.d.ts → dynamic-component/dynamic-component.service.d.ts} +4 -4
- package/lib/services/dynamic-component/dynamic-component.service.d.ts.map +1 -0
- package/lib/services/dynamic-menu/dynamic-menu.service.d.ts +2 -2
- package/lib/services/dynamic-menu/dynamic-menu.service.d.ts.map +1 -1
- package/lib/services/errors/eui.error.d.ts +0 -2
- package/lib/services/errors/eui.error.d.ts.map +1 -1
- package/lib/services/errors/http-error-handler-callback-functions.d.ts.map +1 -1
- package/lib/services/{ux-app-shell.service.d.ts → eui-app-shell.service.d.ts} +13 -4
- package/lib/services/eui-app-shell.service.d.ts.map +1 -0
- package/lib/services/growl/eui-growl.service.d.ts +22 -0
- package/lib/services/growl/eui-growl.service.d.ts.map +1 -0
- package/lib/services/growl/index.d.ts +2 -0
- package/lib/services/growl/index.d.ts.map +1 -0
- package/lib/services/index.d.ts +3 -4
- package/lib/services/index.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.map +1 -1
- package/lib/services/storage/local-forage.service.d.ts.map +1 -1
- package/lib/services/store/effects/app.effects.d.ts +3 -3
- package/lib/services/store/effects/app.effects.d.ts.map +1 -1
- package/lib/services/store/store.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/esm2022/lib/services/ux-app-shell.service.mjs +0 -556
- package/esm2022/lib/services/ux-dynamic-component/ux-dynamic-component.service.mjs +0 -63
- package/esm2022/lib/services/ux-error-feedback/ux-error-feedback.service.mjs +0 -108
- package/esm2022/lib/services/ux-error-feedback/ux-error-handler.operator.mjs +0 -16
- package/lib/services/ux-app-shell.service.d.ts.map +0 -1
- package/lib/services/ux-dynamic-component/ux-dynamic-component.service.d.ts.map +0 -1
- package/lib/services/ux-error-feedback/ux-error-feedback.service.d.ts +0 -36
- package/lib/services/ux-error-feedback/ux-error-feedback.service.d.ts.map +0 -1
- package/lib/services/ux-error-feedback/ux-error-handler.operator.d.ts +0 -4
- package/lib/services/ux-error-feedback/ux-error-handler.operator.d.ts.map +0 -1
package/fesm2022/eui-core.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import * as i1 from '@eui/base';
|
|
2
|
-
import { LogLevel, ConsoleAppender, Logger, LoggerMock,
|
|
2
|
+
import { LogLevel, ConsoleAppender, Logger, LoggerMock, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, 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,
|
|
5
|
+
import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler, EventEmitter, PLATFORM_ID, LOCALE_ID } from '@angular/core';
|
|
6
6
|
import * as extendProxy from 'extend';
|
|
7
7
|
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
|
8
8
|
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
|
9
9
|
import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
|
|
10
|
-
import { throwError,
|
|
11
|
-
import { debounceTime, distinctUntilChanged,
|
|
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
12
|
import * as i1$1 from '@ngrx/store';
|
|
13
13
|
import { createSelector } from '@ngrx/store';
|
|
14
|
-
import * as i1$
|
|
14
|
+
import * as i1$2 from '@ngrx/effects';
|
|
15
15
|
import { createEffect, ofType } from '@ngrx/effects';
|
|
16
|
-
import * as
|
|
16
|
+
import * as i1$3 from '@ngx-translate/core';
|
|
17
17
|
import { TranslateLoader } from '@ngx-translate/core';
|
|
18
|
-
import * as
|
|
19
|
-
import { NavigationEnd } from '@angular/router';
|
|
20
|
-
import isEqual from 'lodash-es/isEqual';
|
|
21
|
-
import get from 'lodash-es/get';
|
|
22
|
-
import * as i1$2 from '@angular/common/http';
|
|
18
|
+
import * as i1$5 from '@angular/common/http';
|
|
23
19
|
import { HttpErrorResponse, HttpResponse, HttpHeaders, HttpEventType } from '@angular/common/http';
|
|
20
|
+
import * as i1$4 from '@angular/router';
|
|
21
|
+
import { NavigationEnd } from '@angular/router';
|
|
24
22
|
import { By } from '@angular/platform-browser';
|
|
25
23
|
import { FormGroup, FormArray } from '@angular/forms';
|
|
26
24
|
import { DomPortalOutlet, ComponentPortal, PortalInjector } from '@angular/cdk/portal';
|
|
25
|
+
import isEqual from 'lodash-es/isEqual';
|
|
26
|
+
import get from 'lodash-es/get';
|
|
27
27
|
import * as lf from 'localforage';
|
|
28
28
|
import localeFr from '@angular/common/locales/fr';
|
|
29
29
|
import localeEl from '@angular/common/locales/el';
|
|
@@ -197,10 +197,10 @@ class LogService extends Logger {
|
|
|
197
197
|
}
|
|
198
198
|
return logger;
|
|
199
199
|
}
|
|
200
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
201
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
200
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", 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-next.4", ngImport: i0, type: LogService }); }
|
|
202
202
|
}
|
|
203
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
203
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LogService, decorators: [{
|
|
204
204
|
type: Injectable
|
|
205
205
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
206
206
|
type: Inject,
|
|
@@ -371,11 +371,11 @@ class LogModule {
|
|
|
371
371
|
],
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
375
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-next.
|
|
376
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
374
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
375
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-next.4", ngImport: i0, type: LogModule }); }
|
|
376
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LogModule }); }
|
|
377
377
|
}
|
|
378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
378
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LogModule, decorators: [{
|
|
379
379
|
type: NgModule
|
|
380
380
|
}] });
|
|
381
381
|
|
|
@@ -470,10 +470,10 @@ class StoreService {
|
|
|
470
470
|
// Ignore write errors.
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
474
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
473
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", 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-next.4", ngImport: i0, type: StoreService, providedIn: 'root' }); }
|
|
475
475
|
}
|
|
476
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: StoreService, decorators: [{
|
|
477
477
|
type: Injectable,
|
|
478
478
|
args: [{
|
|
479
479
|
providedIn: 'root',
|
|
@@ -615,2273 +615,2245 @@ class UpdateLocaleStateAction {
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
class
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
constructor(prefix, suffix = '', compileTranslationsFn = (translations) => translations) {
|
|
627
|
-
this.prefix = prefix;
|
|
628
|
-
this.suffix = suffix;
|
|
629
|
-
this.compileTranslationsFn = compileTranslationsFn;
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Translations pre-processor
|
|
633
|
-
*
|
|
634
|
-
* @param translations the object to be pre-processed
|
|
635
|
-
* @param lang the translations language
|
|
636
|
-
* @returns the pre-processed translations
|
|
637
|
-
*/
|
|
638
|
-
compileTranslations(translations, lang) {
|
|
639
|
-
return this.compileTranslationsFn(translations, lang);
|
|
618
|
+
class EuiGrowlService {
|
|
619
|
+
constructor() {
|
|
620
|
+
this.growlMessages = [];
|
|
621
|
+
this.isGrowlSticky = false;
|
|
622
|
+
this.isCloseAllSticky = false;
|
|
623
|
+
this.growlLife = 3000;
|
|
624
|
+
this.growlPosition = 'bottom-right';
|
|
625
|
+
this.growlCallback = null;
|
|
640
626
|
}
|
|
641
627
|
/**
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
* @param obj the reference object with which to compare
|
|
645
|
-
* @returns true if this object is the same as obj, false otherwise
|
|
628
|
+
* displays a growl UxMessage item, isSticky
|
|
646
629
|
*/
|
|
647
|
-
|
|
648
|
-
|
|
630
|
+
growl(msg, isSticky, isMultiple, life, position, callback) {
|
|
631
|
+
if (msg.severity !== 'info' && msg.severity !== 'warning' && msg.severity !== 'success' && msg.severity !== 'danger') {
|
|
632
|
+
throw new Error('EuiGrowlService.growl() ERROR : message severity must be either : success, warning, info, danger');
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
if (isMultiple === undefined || !isMultiple) {
|
|
636
|
+
this.growlMessages = [];
|
|
637
|
+
}
|
|
638
|
+
this.growlMessages = this.growlMessages.concat(msg);
|
|
639
|
+
msg.life = life || msg.life;
|
|
640
|
+
msg.sticky = isSticky || msg.sticky;
|
|
641
|
+
if (life === undefined || isNaN(life)) {
|
|
642
|
+
if (msg.severity === 'danger') {
|
|
643
|
+
isSticky = true;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
this.growlLife = 3000;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
this.growlLife = life;
|
|
651
|
+
}
|
|
652
|
+
if (isSticky) {
|
|
653
|
+
this.isGrowlSticky = isSticky;
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
this.isGrowlSticky = false;
|
|
657
|
+
}
|
|
658
|
+
if (position) {
|
|
659
|
+
this.growlPosition = position;
|
|
660
|
+
}
|
|
661
|
+
if (callback) {
|
|
662
|
+
this.growlCallback = callback;
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
this.growlCallback = () => { };
|
|
666
|
+
}
|
|
667
|
+
}
|
|
649
668
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
*
|
|
653
|
-
* @param lang the resource language
|
|
654
|
-
* @returns the path
|
|
655
|
-
*/
|
|
656
|
-
getPath(lang) {
|
|
657
|
-
return `${this.prefix}${lang}${this.suffix}`;
|
|
669
|
+
clearGrowl() {
|
|
670
|
+
this.growlMessages = [];
|
|
658
671
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
class I18nLoader {
|
|
662
|
-
constructor(http, logService, euiAppConfig) {
|
|
663
|
-
this.http = http;
|
|
664
|
-
this.logService = logService;
|
|
665
|
-
this.euiAppConfig = euiAppConfig;
|
|
666
|
-
this.resources = [];
|
|
667
|
-
this.failedResources = [];
|
|
668
|
-
// create the resources from the config object
|
|
669
|
-
const i18nConfig = this.euiAppConfig.global && this.euiAppConfig.global.i18n;
|
|
670
|
-
const i18nLoaderConfig = i18nConfig && i18nConfig.i18nLoader;
|
|
671
|
-
this.resources.push(...this.createResources(i18nLoaderConfig));
|
|
672
|
+
growlSuccess(msg, position) {
|
|
673
|
+
this.growl({ severity: 'success', summary: 'SUCCESS', detail: msg }, false, false, undefined, position);
|
|
672
674
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
*
|
|
676
|
-
* @param lang
|
|
677
|
-
* @returns Observable<any>
|
|
678
|
-
*/
|
|
679
|
-
getTranslation(lang) {
|
|
680
|
-
return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
|
|
681
|
-
this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
|
|
682
|
-
return loadedResources.translations;
|
|
683
|
-
}));
|
|
675
|
+
growlError(msg, position) {
|
|
676
|
+
this.growl({ severity: 'danger', summary: 'ERROR', detail: msg }, false, false, undefined, position);
|
|
684
677
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
* @param config loader configuration
|
|
689
|
-
* @returns Observable<any> | false
|
|
690
|
-
*/
|
|
691
|
-
addResources(config) {
|
|
692
|
-
// create the resources
|
|
693
|
-
let resources = this.createResources(config);
|
|
694
|
-
// filter the resources first, to avoid duplicates
|
|
695
|
-
resources = resources.filter((resource) => !this.resources.some((res) => res.equals(resource)));
|
|
696
|
-
// add the new resources to the list of existing resources
|
|
697
|
-
this.resources.push(...resources);
|
|
698
|
-
// return the filtered resources
|
|
699
|
-
return resources;
|
|
678
|
+
// date helpers
|
|
679
|
+
growlWarning(msg, position) {
|
|
680
|
+
this.growl({ severity: 'warning', summary: 'WARNING', detail: msg }, false, false, undefined, position);
|
|
700
681
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
*/
|
|
704
|
-
removeResources(removedResources) {
|
|
705
|
-
this.resources = this.resources.filter((res) => !removedResources.some((removedResource) => removedResource.equals(res)));
|
|
682
|
+
growlInfo(msg, position) {
|
|
683
|
+
this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
|
|
706
684
|
}
|
|
707
|
-
/**
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
685
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiGrowlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
686
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiGrowlService, providedIn: 'root' }); }
|
|
687
|
+
}
|
|
688
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiGrowlService, decorators: [{
|
|
689
|
+
type: Injectable,
|
|
690
|
+
args: [{
|
|
691
|
+
providedIn: 'root',
|
|
692
|
+
}]
|
|
693
|
+
}] });
|
|
694
|
+
|
|
695
|
+
class CoreAppEffects {
|
|
696
|
+
constructor(actions,
|
|
697
|
+
// TODO: remove on eUI 14
|
|
698
|
+
showConnectionStatus, translateService, asService) {
|
|
699
|
+
this.actions = actions;
|
|
700
|
+
this.showConnectionStatus = showConnectionStatus;
|
|
701
|
+
this.translateService = translateService;
|
|
702
|
+
this.asService = asService;
|
|
703
|
+
this.getAppConnectionInformation = createEffect(() => merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map((connected) => new UpdateAppConnectionAction(connected))));
|
|
704
|
+
this.activatedRoute = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap((route) => {
|
|
705
|
+
// extract the module name, if defined
|
|
706
|
+
const module = route.snapshot.data['module'] || 'undefined';
|
|
707
|
+
return [new UpdateCurrentModuleAction(module)];
|
|
708
|
+
})));
|
|
709
|
+
this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
|
|
710
|
+
// TODO: for eUI 14, drop boolean support and refactor
|
|
711
|
+
// check if feature is enabled
|
|
712
|
+
const isFeatureEnabled = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.enabled : this.showConnectionStatus;
|
|
713
|
+
// extract lifespan if any
|
|
714
|
+
const lifespan = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.messageBox?.lifespan || 0 : 0;
|
|
715
|
+
// if the user needs to be informed about the connection status
|
|
716
|
+
if (isFeatureEnabled) {
|
|
717
|
+
if (connected) {
|
|
718
|
+
this.translateService.get('eui.CONNECTED').subscribe((translation) => {
|
|
719
|
+
this.asService.growl({ severity: 'success', summary: 'MESSAGE', detail: translation, life: lifespan }, lifespan < 1, false);
|
|
720
|
+
});
|
|
733
721
|
}
|
|
734
722
|
else {
|
|
735
|
-
|
|
723
|
+
this.translateService.get('eui.NOTCONNECTED').subscribe((translation) => {
|
|
724
|
+
this.asService.growl({ severity: 'danger', summary: 'ERROR', detail: translation, life: lifespan }, lifespan < 1, false);
|
|
725
|
+
});
|
|
736
726
|
}
|
|
737
|
-
}));
|
|
738
|
-
}
|
|
739
|
-
else {
|
|
740
|
-
// no resources to load
|
|
741
|
-
return of({ hasError: false, translations: {} });
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Returns resources that failed
|
|
746
|
-
*/
|
|
747
|
-
getFailedResources() {
|
|
748
|
-
return this.failedResources;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Create resources from a config file
|
|
752
|
-
*
|
|
753
|
-
* @param config loader configuration
|
|
754
|
-
* @returns I18nResourceImpl[] resources
|
|
755
|
-
*/
|
|
756
|
-
createResources(config) {
|
|
757
|
-
// use the default config as a reference base
|
|
758
|
-
config = getI18nLoaderConfig(config);
|
|
759
|
-
const resources = [];
|
|
760
|
-
// extract the i18n folders from config
|
|
761
|
-
const i18nFolders = Array.isArray(config.i18nFolders)
|
|
762
|
-
? config.i18nFolders
|
|
763
|
-
: config.i18nFolders
|
|
764
|
-
? [config.i18nFolders]
|
|
765
|
-
: [];
|
|
766
|
-
if (i18nFolders) {
|
|
767
|
-
// add the i18n folders to resources
|
|
768
|
-
resources.push(...i18nFolders.map((folder) => new I18nResourceImpl(`assets/${folder}/`, '.json')));
|
|
769
|
-
}
|
|
770
|
-
// extract the i18n services from config
|
|
771
|
-
const i18nServices = Array.isArray(config.i18nServices)
|
|
772
|
-
? config.i18nServices
|
|
773
|
-
: config.i18nServices
|
|
774
|
-
? [config.i18nServices]
|
|
775
|
-
: [];
|
|
776
|
-
if (i18nServices) {
|
|
777
|
-
// add the i18n services to resources
|
|
778
|
-
resources.push(...i18nServices.map((service) => new I18nResourceImpl(service)));
|
|
779
|
-
}
|
|
780
|
-
// extract the i18n resources from config
|
|
781
|
-
const i18nResources = Array.isArray(config.i18nResources)
|
|
782
|
-
? config.i18nResources
|
|
783
|
-
: config.i18nResources
|
|
784
|
-
? [config.i18nResources]
|
|
785
|
-
: [];
|
|
786
|
-
if (i18nResources) {
|
|
787
|
-
// add the i18n resources to resources
|
|
788
|
-
resources.push(...i18nResources.map((resource) => new I18nResourceImpl(resource.prefix, resource.suffix, this.getResourceCompileFunction(resource.compileTranslations))));
|
|
789
|
-
}
|
|
790
|
-
return resources;
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Loads a resource, by language
|
|
794
|
-
*
|
|
795
|
-
* @param resource the definition of the resource
|
|
796
|
-
* @param lang the resource language to load
|
|
797
|
-
* @returns Observable<any>
|
|
798
|
-
*/
|
|
799
|
-
loadResource(resource, lang) {
|
|
800
|
-
// the path to the resource
|
|
801
|
-
const path = resource.getPath(lang);
|
|
802
|
-
// load the translations from the path
|
|
803
|
-
return this.http.get(path).pipe(
|
|
804
|
-
// preprocess the translations using the resource compiler
|
|
805
|
-
map((translations) => resource.compileTranslations(translations, lang)), map((translations) => {
|
|
806
|
-
// resource loaded properly, send a info message
|
|
807
|
-
if (this.logService) {
|
|
808
|
-
this.logService.info(`I18n resource loaded from path ${path}`);
|
|
809
|
-
}
|
|
810
|
-
// return the translations
|
|
811
|
-
return translations;
|
|
812
|
-
}), catchError((err) => {
|
|
813
|
-
// remove failed resource from loaded resource array
|
|
814
|
-
this.removeResources([resource]);
|
|
815
|
-
// resource not loaded properly, send a warning message
|
|
816
|
-
if (this.logService) {
|
|
817
|
-
this.logService.warn(`I18n resource NOT loaded from path ${path}`, err);
|
|
818
727
|
}
|
|
819
|
-
|
|
820
|
-
return of(resourceError);
|
|
821
|
-
}));
|
|
822
|
-
}
|
|
823
|
-
getResourceCompileFunction(id) {
|
|
824
|
-
const customHandlers = this.euiAppConfig.customHandler;
|
|
825
|
-
if (customHandlers && typeof customHandlers[id] === 'function') {
|
|
826
|
-
return customHandlers[id];
|
|
827
|
-
}
|
|
828
|
-
return undefined;
|
|
728
|
+
})), { dispatch: false });
|
|
829
729
|
}
|
|
830
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
831
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
730
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$2.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$3.TranslateService }, { token: EuiGrowlService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
731
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreAppEffects }); }
|
|
832
732
|
}
|
|
833
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
733
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreAppEffects, decorators: [{
|
|
834
734
|
type: Injectable
|
|
835
|
-
}], ctorParameters: function () { return [{ type: i1$2.
|
|
836
|
-
type: Optional
|
|
837
|
-
}] }, { type: undefined, decorators: [{
|
|
838
|
-
type: Inject,
|
|
839
|
-
args: [CONFIG_TOKEN]
|
|
840
|
-
}] }]; } });
|
|
841
|
-
const translateConfig = {
|
|
842
|
-
loader: {
|
|
843
|
-
provide: TranslateLoader,
|
|
844
|
-
useClass: I18nLoader,
|
|
845
|
-
},
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
class I18nService extends EuiLazyService {
|
|
849
|
-
constructor(baseGlobalConfig, translateService, logService, store, document) {
|
|
850
|
-
super({ activeLang: 'en' });
|
|
851
|
-
this.baseGlobalConfig = baseGlobalConfig;
|
|
852
|
-
this.translateService = translateService;
|
|
853
|
-
this.logService = logService;
|
|
854
|
-
this.store = store;
|
|
855
|
-
this.document = document;
|
|
856
|
-
this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
|
|
857
|
-
this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
|
|
858
|
-
}
|
|
859
|
-
getState(keyOrMapFn) {
|
|
860
|
-
let selector = getI18nState;
|
|
861
|
-
let dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
862
|
-
if (keyOrMapFn) {
|
|
863
|
-
switch (typeof keyOrMapFn) {
|
|
864
|
-
case 'function':
|
|
865
|
-
selector = createSelector(getI18nState, keyOrMapFn);
|
|
866
|
-
break;
|
|
867
|
-
case 'string':
|
|
868
|
-
selector = createSelector(getI18nState, (state) => dotNotationToObject(state, keyOrMapFn));
|
|
869
|
-
break;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return this.store.select(selector);
|
|
873
|
-
}
|
|
874
|
-
updateState(langState) {
|
|
875
|
-
this.updateHTMLDOMLang(langState.activeLang);
|
|
876
|
-
this.store.dispatch(new UpdateI18nStateAction(langState));
|
|
877
|
-
}
|
|
878
|
-
init(langState) {
|
|
879
|
-
const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
|
|
880
|
-
const initState = {
|
|
881
|
-
...langState,
|
|
882
|
-
activeLang: initLang,
|
|
883
|
-
};
|
|
884
|
-
if (typeof initLang === 'string') {
|
|
885
|
-
super.initEuiService(this.store);
|
|
886
|
-
this.updateState(initState);
|
|
887
|
-
return this.setup(initLang);
|
|
888
|
-
}
|
|
889
|
-
return of({ success: false, error: 'Initial active lang should be string' });
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* A pipe function that could serve as a wrapper of another observable
|
|
893
|
-
* e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
|
|
894
|
-
* WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
|
|
895
|
-
* into another emission.
|
|
896
|
-
*
|
|
897
|
-
* @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
|
|
898
|
-
* fetch module name from the state.
|
|
899
|
-
*/
|
|
900
|
-
onReady(moduleName) {
|
|
901
|
-
return this.onModuleLoad.pipe(switchMap((evt) => moduleName
|
|
902
|
-
? of(evt)
|
|
903
|
-
: this.store.select(getLastAddedModule).pipe(tap((m) => (moduleName = m)), map(() => evt))),
|
|
904
|
-
// emit only if event emitted matches the module name and is ready
|
|
905
|
-
filter((evt) => evt.ready === true && evt.name === moduleName),
|
|
906
|
-
// make sure that observable completes
|
|
907
|
-
take(1));
|
|
908
|
-
}
|
|
909
|
-
lazyLoad(config) {
|
|
910
|
-
const moduleId = Math.floor(Math.random() * 100000 + 1).toLocaleString();
|
|
911
|
-
return this.addResources(config, moduleId);
|
|
912
|
-
}
|
|
913
|
-
lazyLoadInit(moduleConfig, moduleName) {
|
|
914
|
-
const i18nLoaderConfig = moduleConfig;
|
|
915
|
-
// add resources
|
|
916
|
-
return this.addResources(i18nLoaderConfig, moduleName);
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Add resources based of a config loader
|
|
920
|
-
*
|
|
921
|
-
* @param config I18nLoaderConfig
|
|
922
|
-
* @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
|
|
923
|
-
*/
|
|
924
|
-
addResources(config, moduleName) {
|
|
925
|
-
// emit that module is loading
|
|
926
|
-
this.onModuleLoad.next({ ready: false, name: moduleName });
|
|
927
|
-
const loader = this.translateService.currentLoader;
|
|
928
|
-
if (loader instanceof I18nLoader) {
|
|
929
|
-
const langSubscription = [];
|
|
930
|
-
const i18nLoader = loader;
|
|
931
|
-
// add the resources to the loader
|
|
932
|
-
const resources = i18nLoader.addResources(config);
|
|
933
|
-
// manually load the resources for the CURRENT language and add them to the translate service
|
|
934
|
-
langSubscription.push(i18nLoader.loadResources(resources, this.translateService.currentLang).pipe(take(1), tap((loadedResources) => {
|
|
935
|
-
// add the new set of translations to the current language
|
|
936
|
-
this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
|
|
937
|
-
})));
|
|
938
|
-
// if the current language is different than the DEFAULT language
|
|
939
|
-
const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
|
|
940
|
-
if (this.translateService.currentLang !== defaultLang) {
|
|
941
|
-
// manually load the resources for the default language and add them to the translate service
|
|
942
|
-
langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
|
|
943
|
-
this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
|
|
944
|
-
})));
|
|
945
|
-
}
|
|
946
|
-
return forkJoin(langSubscription).pipe(map((loadedResourcesArr) => !loadedResourcesArr[0].hasError ? { success: true } : { success: false, error: loadedResourcesArr[0].errors }), tap(() => {
|
|
947
|
-
// emit status of module loading progress
|
|
948
|
-
this.onModuleLoad.next({ ready: true, name: moduleName });
|
|
949
|
-
}), catchError((error) => {
|
|
950
|
-
// emit status of module loading progress
|
|
951
|
-
this.onModuleLoad.next({ ready: true, name: moduleName, error });
|
|
952
|
-
return of({ success: false, error });
|
|
953
|
-
}));
|
|
954
|
-
}
|
|
955
|
-
else {
|
|
956
|
-
return of({ success: false, error: 'currentLoader is not an I18nLoader.' });
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* Prepares the default language
|
|
961
|
-
*/
|
|
962
|
-
preparedDefaultLanguage() {
|
|
963
|
-
const browserPref = getBrowserDefaultLanguage();
|
|
964
|
-
// If user has browser preferred lang, and that language is part of the languages array
|
|
965
|
-
if (browserPref && this.config.languages && EuiEuLanguages.getLanguageCodes(this.config.languages).includes(browserPref)) {
|
|
966
|
-
return browserPref;
|
|
967
|
-
}
|
|
968
|
-
return this.config.defaultLanguage;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* @param default_language if given default language to override default language coming from the
|
|
972
|
-
* configuration token.
|
|
973
|
-
*/
|
|
974
|
-
setup(initLanguage) {
|
|
975
|
-
// use the default config as a reference base
|
|
976
|
-
this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
|
|
977
|
-
// configure the translate config service
|
|
978
|
-
if (this.config.languages) {
|
|
979
|
-
this.translateService.addLangs(EuiEuLanguages.getLanguageCodes(this.config.languages));
|
|
980
|
-
if (this.logService) {
|
|
981
|
-
this.logService.info(`I18n accepted languages set to ${EuiEuLanguages.getLanguageCodes(this.config.languages)}`);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
// set the current language, causing to load translations
|
|
985
|
-
return this.translateService.use(initLanguage).pipe(tap(() => {
|
|
986
|
-
this.bindActiveLangStateToTranslateService();
|
|
987
|
-
this.bindTranslateServiceLangChangeToState();
|
|
988
|
-
if (this.config.defaultLanguage) {
|
|
989
|
-
this.setDefaultLanguage(this.config.defaultLanguage);
|
|
990
|
-
}
|
|
991
|
-
}), map(() => {
|
|
992
|
-
if (this.translateService.currentLoader instanceof I18nLoader) {
|
|
993
|
-
const failedResources = this.translateService.currentLoader.getFailedResources();
|
|
994
|
-
if (failedResources.length > 0) {
|
|
995
|
-
return { success: false, error: failedResources };
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
return { success: true };
|
|
999
|
-
}), catchError((error) => of({ success: false, error })));
|
|
1000
|
-
}
|
|
1001
|
-
bindActiveLangStateToTranslateService() {
|
|
1002
|
-
this.store.select(getActiveLang).subscribe((lang) => {
|
|
1003
|
-
if (lang !== null && this.translateService.currentLang !== lang) {
|
|
1004
|
-
this.use(lang);
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
bindTranslateServiceLangChangeToState() {
|
|
1009
|
-
this.translateService.onLangChange.subscribe((event) => {
|
|
1010
|
-
if (this.stateInstance.activeLang !== event.lang) {
|
|
1011
|
-
this.updateState({ activeLang: event.lang });
|
|
1012
|
-
}
|
|
1013
|
-
if (this.logService) {
|
|
1014
|
-
this.logService.info(`I18n current language set to ${event.lang}`);
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
setDefaultLanguage(defaultLanguage) {
|
|
1019
|
-
// removed, current language is already calculated in init, setup function fill use it directly, not default
|
|
1020
|
-
// this.translateService.currentLang = default_language || this.config.defaultLanguage;
|
|
1021
|
-
this.translateService.setDefaultLang(defaultLanguage);
|
|
1022
|
-
if (this.logService) {
|
|
1023
|
-
this.logService.info(`I18n default language set to ${defaultLanguage}`);
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* change the currently used language
|
|
1028
|
-
*
|
|
1029
|
-
* @param lang is the language code based on the convention you used e.g. (en or en-EN)
|
|
1030
|
-
* @returns Observable that returns an object contain the object translation for given language after language
|
|
1031
|
-
* fully loaded.
|
|
1032
|
-
*/
|
|
1033
|
-
use(lang) {
|
|
1034
|
-
return this.translateService.use(lang);
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* updates the HTML element lang attribute
|
|
1038
|
-
*
|
|
1039
|
-
* @private
|
|
1040
|
-
*/
|
|
1041
|
-
updateHTMLDOMLang(lang) {
|
|
1042
|
-
this.document.documentElement.lang = lang;
|
|
1043
|
-
}
|
|
1044
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i2.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1045
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nService, providedIn: 'root' }); }
|
|
1046
|
-
}
|
|
1047
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nService, decorators: [{
|
|
1048
|
-
type: Injectable,
|
|
1049
|
-
args: [{
|
|
1050
|
-
providedIn: 'root',
|
|
1051
|
-
}]
|
|
1052
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1053
|
-
type: Inject,
|
|
1054
|
-
args: [GLOBAL_CONFIG_TOKEN]
|
|
1055
|
-
}] }, { type: i2.TranslateService }, { type: LogService, decorators: [{
|
|
1056
|
-
type: Optional
|
|
1057
|
-
}] }, { type: StoreService }, { type: Document, decorators: [{
|
|
735
|
+
}], ctorParameters: function () { return [{ type: i1$2.Actions }, { type: undefined, decorators: [{
|
|
1058
736
|
type: Inject,
|
|
1059
|
-
args: [
|
|
1060
|
-
}] }]; } });
|
|
737
|
+
args: [SHOW_CONNECTION_STATUS_TOKEN]
|
|
738
|
+
}] }, { type: i1$3.TranslateService }, { type: EuiGrowlService }]; } });
|
|
1061
739
|
|
|
1062
|
-
|
|
1063
|
-
constructor() {
|
|
1064
|
-
super(null, null, null, null, null);
|
|
1065
|
-
this.DEFAULT_LANGUAGE = 'en';
|
|
1066
|
-
}
|
|
1067
|
-
get onLangChange() {
|
|
1068
|
-
return new EventEmitter();
|
|
1069
|
-
}
|
|
1070
|
-
addResources() {
|
|
1071
|
-
return of({ success: true });
|
|
1072
|
-
}
|
|
1073
|
-
get currentLanguage() {
|
|
1074
|
-
return this.DEFAULT_LANGUAGE;
|
|
1075
|
-
}
|
|
1076
|
-
getState() {
|
|
1077
|
-
return of({ activeLang: this.DEFAULT_LANGUAGE });
|
|
1078
|
-
}
|
|
1079
|
-
updateState(i18nState) {
|
|
1080
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1081
|
-
}
|
|
1082
|
-
init(i18nState) {
|
|
1083
|
-
this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
|
|
1084
|
-
return of({ success: true });
|
|
1085
|
-
}
|
|
1086
|
-
lazyLoadInit() {
|
|
1087
|
-
return of({ success: true });
|
|
1088
|
-
}
|
|
1089
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1090
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nServiceMock }); }
|
|
1091
|
-
}
|
|
1092
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: I18nServiceMock, decorators: [{
|
|
1093
|
-
type: Injectable
|
|
1094
|
-
}], ctorParameters: function () { return []; } });
|
|
740
|
+
const CoreModuleEffects = [CoreAppEffects];
|
|
1095
741
|
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
isSidebarExpandOnHover: true,
|
|
1109
|
-
hasSidebar: false,
|
|
1110
|
-
hasHeader: false,
|
|
1111
|
-
hasBreadcrumb: false,
|
|
1112
|
-
hasHeaderLogo: false,
|
|
1113
|
-
hasHeaderEnvironment: false,
|
|
1114
|
-
hasToolbar: false,
|
|
1115
|
-
hasToolbarMenu: false,
|
|
1116
|
-
environmentValue: '',
|
|
1117
|
-
isSidebarHidden: false,
|
|
1118
|
-
hasTopMessage: false,
|
|
1119
|
-
windowWidth: 0,
|
|
1120
|
-
windowHeight: 0,
|
|
1121
|
-
mainContentHeight: 0,
|
|
1122
|
-
pageHeaderHeight: 0,
|
|
1123
|
-
wrapperClasses: '',
|
|
1124
|
-
breakpoint: '',
|
|
1125
|
-
breakpoints: {
|
|
1126
|
-
isMobile: false,
|
|
1127
|
-
isTablet: false,
|
|
1128
|
-
isLtDesktop: false,
|
|
1129
|
-
isDesktop: false,
|
|
1130
|
-
isXL: false,
|
|
1131
|
-
isXXL: false,
|
|
742
|
+
const updateAppVersion = (state, action) => ({ ...state, version: action.payload });
|
|
743
|
+
const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
|
|
744
|
+
const AddAppLoadedConfigModules = (state, action) => ({
|
|
745
|
+
...state,
|
|
746
|
+
loadedConfigModules: {
|
|
747
|
+
lastAddedModule: action.payload.moduleName,
|
|
748
|
+
modulesConfig: {
|
|
749
|
+
...state.loadedConfigModules.modulesConfig,
|
|
750
|
+
[action.payload.moduleName]: {
|
|
751
|
+
...action.payload.moduleConfig,
|
|
752
|
+
},
|
|
753
|
+
},
|
|
1132
754
|
},
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
isDimmerActive: false,
|
|
755
|
+
});
|
|
756
|
+
const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
|
|
757
|
+
const updateCurrentModule = (state, action) => Object.assign({}, state, { currentModule: action.payload });
|
|
758
|
+
const addApiQueueItem = (state, action) => {
|
|
759
|
+
// apply the timestamp to the queue item
|
|
760
|
+
const apiQueueItem = Object.assign({}, action.payload.item, { timestamp: new Date().getTime() });
|
|
761
|
+
// update the queue
|
|
762
|
+
const apiQueue = Object.assign({}, state.apiQueue, { [action.payload.id]: apiQueueItem });
|
|
763
|
+
return Object.assign({}, state, { apiQueue });
|
|
1143
764
|
};
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
get isSidebarOpen() {
|
|
1174
|
-
return this.state.isSidebarOpen;
|
|
1175
|
-
}
|
|
1176
|
-
set isSidebarHover(isHover) {
|
|
1177
|
-
if (this.state.isSidebarExpandOnHover) {
|
|
1178
|
-
this.setState({
|
|
1179
|
-
...this.state,
|
|
1180
|
-
isSidebarHover: isHover,
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
get isSidebarHover() {
|
|
1185
|
-
return this.state.isSidebarHover;
|
|
1186
|
-
}
|
|
1187
|
-
set isSidebarActive(isActive) {
|
|
1188
|
-
this.setState({
|
|
1189
|
-
...this.state,
|
|
1190
|
-
isSidebarActive: isActive,
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
set isSidebarInnerActive(isOpen) {
|
|
1194
|
-
this.setState({
|
|
1195
|
-
...this.state,
|
|
1196
|
-
isSidebarInnerActive: isOpen,
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
set sidebarLinks(links) {
|
|
1200
|
-
this.setState({
|
|
1201
|
-
...this.state,
|
|
1202
|
-
sidebarLinks: links,
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
set menuLinks(links) {
|
|
1206
|
-
this.setState({
|
|
1207
|
-
...this.state,
|
|
1208
|
-
menuLinks: links,
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
set isBlockDocumentActive(isActive) {
|
|
1212
|
-
this.setState({
|
|
1213
|
-
...this.state,
|
|
1214
|
-
isBlockDocumentActive: isActive,
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
get hasHeader() {
|
|
1218
|
-
return this.state.hasHeader;
|
|
1219
|
-
}
|
|
1220
|
-
// Edit mode
|
|
1221
|
-
get isDimmerActive() {
|
|
1222
|
-
return this.state.isDimmerActive;
|
|
1223
|
-
}
|
|
1224
|
-
set isDimmerActive(isActive) {
|
|
1225
|
-
this.setState({
|
|
1226
|
-
...this.state,
|
|
1227
|
-
isDimmerActive: isActive,
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
constructor(config, http, platformId, router, storeService, i18nService) {
|
|
1231
|
-
this.config = config;
|
|
1232
|
-
this.http = http;
|
|
1233
|
-
this.platformId = platformId;
|
|
1234
|
-
this.router = router;
|
|
1235
|
-
this.storeService = storeService;
|
|
1236
|
-
this.i18nService = i18nService;
|
|
1237
|
-
this.cssVars = [];
|
|
1238
|
-
let stateWithConfig = initialState;
|
|
1239
|
-
const languages = config?.i18n?.i18nService?.languages || initialState.languages;
|
|
1240
|
-
const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
|
|
1241
|
-
stateWithConfig = {
|
|
1242
|
-
...stateWithConfig,
|
|
1243
|
-
...{
|
|
1244
|
-
languages,
|
|
1245
|
-
activeLanguage: defaultLanguage,
|
|
1246
|
-
},
|
|
1247
|
-
};
|
|
1248
|
-
this._state$ = new BehaviorSubject(stateWithConfig);
|
|
1249
|
-
this._breakpoint$ = new BehaviorSubject('');
|
|
1250
|
-
this._breakpoints$ = new BehaviorSubject({});
|
|
1251
|
-
this.bindActiveLanguageToAppShellState();
|
|
1252
|
-
if (isPlatformBrowser(this.platformId)) {
|
|
1253
|
-
router.events.subscribe((event) => {
|
|
1254
|
-
if (event instanceof NavigationEnd) {
|
|
1255
|
-
window.scrollTo(0, 0);
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
setState(nextState, updateI18 = true) {
|
|
1261
|
-
let breakpoint, breakpoints, wrapperClasses;
|
|
1262
|
-
let combinedLinks;
|
|
1263
|
-
const state = this.state;
|
|
1264
|
-
// check if window width has been updated from previous state
|
|
1265
|
-
if (this.state.windowWidth !== nextState.windowWidth) {
|
|
1266
|
-
breakpoint = this.getBreakpoint(nextState.windowWidth);
|
|
1267
|
-
breakpoints = this.getBreakpoints(breakpoint);
|
|
1268
|
-
this._breakpoint$.next(breakpoint);
|
|
1269
|
-
this._breakpoints$.next(breakpoints);
|
|
1270
|
-
// if not propagate the old ones without doing any calculations
|
|
1271
|
-
}
|
|
1272
|
-
else {
|
|
1273
|
-
breakpoint = state.breakpoint;
|
|
1274
|
-
breakpoints = state.breakpoints;
|
|
1275
|
-
}
|
|
1276
|
-
// finally get the wrapper classes when both the state and breakpoint are known
|
|
1277
|
-
wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
1278
|
-
// check if the menuLinks or sidebarLinks have changed from previous state
|
|
1279
|
-
if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
|
|
1280
|
-
combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
|
|
1281
|
-
}
|
|
1282
|
-
else {
|
|
1283
|
-
combinedLinks = this.state.combinedLinks;
|
|
1284
|
-
}
|
|
1285
|
-
const stateBeforeUpdate = { ...this.state };
|
|
1286
|
-
// we put it all together with the calculated properties
|
|
1287
|
-
this._state$.next({
|
|
1288
|
-
...nextState,
|
|
1289
|
-
wrapperClasses,
|
|
1290
|
-
breakpoint,
|
|
1291
|
-
breakpoints,
|
|
1292
|
-
combinedLinks,
|
|
1293
|
-
});
|
|
1294
|
-
// update the Store Language
|
|
1295
|
-
if (updateI18 && nextState.activeLanguage !== stateBeforeUpdate.activeLanguage) {
|
|
1296
|
-
this.i18nService.updateState({ activeLang: nextState.activeLanguage });
|
|
1297
|
-
}
|
|
765
|
+
const removeApiQueueItem = (state, action) => {
|
|
766
|
+
// remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
|
|
767
|
+
const apiQueue = Object.keys(state.apiQueue)
|
|
768
|
+
.filter((id) => id !== action.payload)
|
|
769
|
+
.reduce((queue, key) => {
|
|
770
|
+
queue[key] = state.apiQueue[key];
|
|
771
|
+
return queue;
|
|
772
|
+
}, {});
|
|
773
|
+
return Object.assign({}, state, { apiQueue });
|
|
774
|
+
};
|
|
775
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
776
|
+
const emptyApiQueue = (state, action) =>
|
|
777
|
+
// remove all items in the Api Queue
|
|
778
|
+
Object.assign({}, state, { apiQueue: {} });
|
|
779
|
+
const actionToReducerMap$4 = {
|
|
780
|
+
[CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
|
|
781
|
+
[CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
|
|
782
|
+
[CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
|
|
783
|
+
[CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
|
|
784
|
+
[CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
|
|
785
|
+
[CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
|
|
786
|
+
[CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
|
|
787
|
+
[CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
|
|
788
|
+
};
|
|
789
|
+
const coreAppReducers = (state = initialAppState, action) => {
|
|
790
|
+
if (actionToReducerMap$4[action.type]) {
|
|
791
|
+
return actionToReducerMap$4[action.type](state, action);
|
|
1298
792
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
key
|
|
1308
|
-
? this.state$.pipe(map((state) => get(state, key)),
|
|
1309
|
-
// filter((state) => state),
|
|
1310
|
-
distinctUntilChanged((x, y) => isEqual(x, y)))
|
|
1311
|
-
: this.state$);
|
|
793
|
+
// if the action type is not in the map, call the base reducers method
|
|
794
|
+
return state;
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
const updateUser = (state, action) => {
|
|
798
|
+
let fullName = action.payload.fullName;
|
|
799
|
+
if (!fullName) {
|
|
800
|
+
fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
|
|
1312
801
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
802
|
+
return Object.assign({}, state, action.payload, { fullName });
|
|
803
|
+
};
|
|
804
|
+
const updateUserDetails = (state, action) => {
|
|
805
|
+
let fullName = action.payload.fullName;
|
|
806
|
+
if (!fullName) {
|
|
807
|
+
fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
|
|
1315
808
|
}
|
|
1316
|
-
//
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
809
|
+
// todo should be checked if state.details is really there
|
|
810
|
+
const details = Object.assign({}, state.details, action.payload, { fullName });
|
|
811
|
+
return Object.assign({}, state, details);
|
|
812
|
+
};
|
|
813
|
+
const updateUserPreferences = (state, action) => {
|
|
814
|
+
const preferences = Object.assign({}, state.preferences, action.payload);
|
|
815
|
+
return Object.assign({}, state, { preferences });
|
|
816
|
+
};
|
|
817
|
+
const updateUserRights = (state, action) => Object.assign({}, state, { rights: [...action.payload] });
|
|
818
|
+
const updateUserDashboard = (state, action) => {
|
|
819
|
+
// apply the dashboard to preferences
|
|
820
|
+
const preferences = Object.assign({}, state.preferences, { dashboard: action.payload });
|
|
821
|
+
// update the state
|
|
822
|
+
return { ...state, preferences };
|
|
823
|
+
};
|
|
824
|
+
const actionToReducerMap$3 = {
|
|
825
|
+
[CoreUserActionTypes.UPDATE_USER_DETAILS]: updateUserDetails,
|
|
826
|
+
[CoreUserActionTypes.UPDATE_USER_PREFERENCES]: updateUserPreferences,
|
|
827
|
+
[CoreUserActionTypes.UPDATE_USER_STATE]: updateUser,
|
|
828
|
+
[CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
|
|
829
|
+
[CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
|
|
830
|
+
};
|
|
831
|
+
const coreUserReducers = (state = initialUserState, action) => {
|
|
832
|
+
if (actionToReducerMap$3[action.type]) {
|
|
833
|
+
return actionToReducerMap$3[action.type](state, action);
|
|
1324
834
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
835
|
+
return state;
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
const updateNotificationsList = (state, action) => Object.assign({}, state, { list: [...action.payload] });
|
|
839
|
+
const actionToReducerMap$2 = {
|
|
840
|
+
[CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST]: updateNotificationsList,
|
|
841
|
+
};
|
|
842
|
+
const coreNotificationsReducers = (state = initialNotificationsState, action) => {
|
|
843
|
+
if (actionToReducerMap$2[action.type]) {
|
|
844
|
+
return actionToReducerMap$2[action.type](state, action);
|
|
1331
845
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
846
|
+
return state;
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
const updateI18nState = (state, action) => ({
|
|
850
|
+
...state,
|
|
851
|
+
...action.payload,
|
|
852
|
+
});
|
|
853
|
+
const actionToReducerMap$1 = {
|
|
854
|
+
[CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
|
|
855
|
+
};
|
|
856
|
+
const corI18nReducers = (state = initialI18nState, action) => {
|
|
857
|
+
if (actionToReducerMap$1[action.type]) {
|
|
858
|
+
return actionToReducerMap$1[action.type](state, action);
|
|
1343
859
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
860
|
+
return state;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
const updateLocaleState = (state, action) => ({
|
|
864
|
+
...state,
|
|
865
|
+
...action.payload,
|
|
866
|
+
});
|
|
867
|
+
const actionToReducerMap = {
|
|
868
|
+
[CoreLocaleActionTypes.UPDATE_LOCALE_STATE]: updateLocaleState,
|
|
869
|
+
};
|
|
870
|
+
const coreLocaleReducers = (state = initialLocaleState, action) => {
|
|
871
|
+
if (actionToReducerMap[action.type]) {
|
|
872
|
+
return actionToReducerMap[action.type](state, action);
|
|
1354
873
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
874
|
+
return state;
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
const coreReducers = Object.assign({}, {
|
|
878
|
+
app: coreAppReducers,
|
|
879
|
+
user: coreUserReducers,
|
|
880
|
+
notifications: coreNotificationsReducers,
|
|
881
|
+
i18n: corI18nReducers,
|
|
882
|
+
locale: coreLocaleReducers,
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
const extend = extendProxy.default || extendProxy;
|
|
886
|
+
/**
|
|
887
|
+
* Utility meta-reducer to load the state from the local storage
|
|
888
|
+
* @param reducer the action reducer
|
|
889
|
+
*/
|
|
890
|
+
function localStorageSync(reducer) {
|
|
891
|
+
return cb(reducer, localStorage);
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Utility meta-reducer to load the state from the session storage
|
|
895
|
+
* @param reducer the action reducer
|
|
896
|
+
*/
|
|
897
|
+
function sessionStorageSync(reducer) {
|
|
898
|
+
return cb(reducer, sessionStorage);
|
|
899
|
+
}
|
|
900
|
+
// Keys that are allowed to be synced with NgRx state from BrowserStorage
|
|
901
|
+
const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
|
|
902
|
+
/**
|
|
903
|
+
* filters the AppState by removing those keys from the state and return a new state Object
|
|
904
|
+
* @param app the AppState
|
|
905
|
+
*/
|
|
906
|
+
const filterAppState = (app) => {
|
|
907
|
+
// in case app is undefined or null it should return empty object
|
|
908
|
+
if (!app) {
|
|
909
|
+
return {};
|
|
910
|
+
}
|
|
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 storageType
|
|
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;
|
|
1362
930
|
}
|
|
931
|
+
// deserialize state
|
|
932
|
+
let state = JSON.parse(serializedState);
|
|
933
|
+
// filter AppState and replace
|
|
934
|
+
state = { ...state, app: filterAppState(state?.app) };
|
|
935
|
+
return state;
|
|
1363
936
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
937
|
+
catch (err) {
|
|
938
|
+
return undefined;
|
|
1366
939
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
940
|
+
};
|
|
941
|
+
const cb = (reducer, storage) => (state, action) => {
|
|
942
|
+
if (action.type === CoreAppActionTypes.INIT_STORE) {
|
|
943
|
+
// This action must be dispatched from an app initializer
|
|
944
|
+
// We load the state from a storage and compare the version and userId with the provided ones.
|
|
945
|
+
// If they are the same, we merge the local state into the initial state.
|
|
946
|
+
// If there is a mismatch, we don't merge the local state, but update only the initial state.
|
|
947
|
+
// load the state from the localStorage
|
|
948
|
+
const localState = loadState(storage);
|
|
949
|
+
// extract the details about user and app version from the action payload
|
|
950
|
+
const payload = action.payload;
|
|
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
|
+
}
|
|
963
|
+
}
|
|
964
|
+
// update the app version, if defined
|
|
965
|
+
if (payloadVersion) {
|
|
966
|
+
state = { ...state, app: { ...state?.app, version: payloadVersion } };
|
|
967
|
+
}
|
|
1369
968
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
969
|
+
return reducer(state, action);
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
class StoreServiceMock extends StoreService {
|
|
973
|
+
constructor() {
|
|
974
|
+
super(null, null);
|
|
1376
975
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
976
|
+
init() { }
|
|
977
|
+
addAutoSaveHandler() { }
|
|
978
|
+
handleAutoSave() { }
|
|
979
|
+
dispatch() { }
|
|
980
|
+
select() {
|
|
981
|
+
return of({});
|
|
1383
982
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
983
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: StoreServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
984
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: StoreServiceMock }); }
|
|
985
|
+
}
|
|
986
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: StoreServiceMock, decorators: [{
|
|
987
|
+
type: Injectable
|
|
988
|
+
}], ctorParameters: function () { return []; } });
|
|
989
|
+
|
|
990
|
+
const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
|
|
991
|
+
class CoreModule {
|
|
992
|
+
/**
|
|
993
|
+
* No more providing config from forRoot, you have to use EUI_CONFIG_TOKEN to pass config via providers.
|
|
994
|
+
*/
|
|
995
|
+
static forRoot() {
|
|
996
|
+
return {
|
|
997
|
+
ngModule: CoreModule,
|
|
998
|
+
providers: [
|
|
999
|
+
{
|
|
1000
|
+
provide: EuiCoreRootGuardClass,
|
|
1001
|
+
useFactory: euiCoreRootGuardClass,
|
|
1002
|
+
deps: [],
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
provide: CORE_ROOT_GUARD,
|
|
1006
|
+
useFactory: createEuiCoreRootGuard,
|
|
1007
|
+
deps: [[EuiCoreRootGuardClass, new Optional(), new SkipSelf()]],
|
|
1008
|
+
},
|
|
1009
|
+
...getCoreProviders(),
|
|
1010
|
+
],
|
|
1011
|
+
};
|
|
1390
1012
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
}
|
|
1396
|
-
this.activateToolbarCssVars();
|
|
1013
|
+
static forChild(moduleName) {
|
|
1014
|
+
return {
|
|
1015
|
+
ngModule: CoreModule,
|
|
1016
|
+
providers: getCoreChildProviders(moduleName),
|
|
1017
|
+
};
|
|
1397
1018
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1019
|
+
constructor(guard, parentModule, injector) {
|
|
1020
|
+
// if there is a parentModule, a new instance is created in a lazy loaded module
|
|
1021
|
+
if (parentModule) {
|
|
1022
|
+
// extract the i18n service and the i18n loader config
|
|
1023
|
+
// todo, this thing should be achieved by store, and localization service dependency should be removed
|
|
1024
|
+
const storeService = injector.get(StoreService);
|
|
1025
|
+
const moduleName = injector.get(MODULE_NAME_TOKEN);
|
|
1026
|
+
const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
|
|
1027
|
+
storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
|
|
1028
|
+
}
|
|
1403
1029
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1030
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1031
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreModule }); }
|
|
1032
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreModule }); }
|
|
1033
|
+
}
|
|
1034
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CoreModule, decorators: [{
|
|
1035
|
+
type: NgModule,
|
|
1036
|
+
args: [{
|
|
1037
|
+
imports: [
|
|
1038
|
+
// HttpClientModule, no more..
|
|
1039
|
+
],
|
|
1040
|
+
}]
|
|
1041
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1042
|
+
type: Optional
|
|
1043
|
+
}, {
|
|
1044
|
+
type: Inject,
|
|
1045
|
+
args: [CORE_ROOT_GUARD]
|
|
1046
|
+
}] }, { type: CoreModule, decorators: [{
|
|
1047
|
+
type: Optional
|
|
1048
|
+
}, {
|
|
1049
|
+
type: SkipSelf
|
|
1050
|
+
}] }, { type: i0.Injector }]; } });
|
|
1051
|
+
const createEuiCoreRootGuard = (core) => {
|
|
1052
|
+
if (core) {
|
|
1053
|
+
throw new TypeError(`CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.`);
|
|
1426
1054
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1055
|
+
return 'guarded';
|
|
1056
|
+
};
|
|
1057
|
+
class EuiCoreRootGuardClass {
|
|
1058
|
+
constructor() { }
|
|
1059
|
+
}
|
|
1060
|
+
const euiCoreRootGuardClass = () => new EuiCoreRootGuardClass();
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Function to be used before the AppModule is bootstrapped. It is currently used to load dynamic configurations.
|
|
1064
|
+
* It needs to be added in your application main.ts file.
|
|
1065
|
+
* @param envConfig the current environment configuration
|
|
1066
|
+
* @returns the updated environment configuration, as a promise
|
|
1067
|
+
*/
|
|
1068
|
+
async function preInitApp(envConfig) {
|
|
1069
|
+
const envDynamicConfig = envConfig && envConfig.envDynamicConfig;
|
|
1070
|
+
if (envDynamicConfig) {
|
|
1071
|
+
// load the local configuration file, if defined
|
|
1072
|
+
const euiAppJsonConfig = await loadEuiDynamicEnvironmentConfig(envDynamicConfig.uri, envDynamicConfig.configTimeout || 2000);
|
|
1073
|
+
envConfig.loadedEnvDynamicConfig = euiAppJsonConfig;
|
|
1074
|
+
return envConfig;
|
|
1436
1075
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1076
|
+
return envConfig;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Function to load asynchronously a dynamic configuration (from a local path or a web service)
|
|
1080
|
+
*
|
|
1081
|
+
* @param url the path to the configuration
|
|
1082
|
+
* @param timeout possible timeout
|
|
1083
|
+
* @returns EuiAppJsonConfig promise
|
|
1084
|
+
*/
|
|
1085
|
+
async function loadEuiDynamicEnvironmentConfig(url, timeout) {
|
|
1086
|
+
// if the url is specified
|
|
1087
|
+
if (url) {
|
|
1088
|
+
// fetch the config
|
|
1089
|
+
try {
|
|
1090
|
+
return await xhr({
|
|
1091
|
+
url,
|
|
1092
|
+
timeout,
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
catch (error) {
|
|
1096
|
+
// send a warning to the console
|
|
1097
|
+
console.warn('Dynamic configuration cannot be loaded from url', url, error);
|
|
1098
|
+
}
|
|
1439
1099
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1100
|
+
// the dynamic config is not loaded
|
|
1101
|
+
return null;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
const errorCodes = {
|
|
1105
|
+
ERR_GENERIC: 'ERR_GENERIC',
|
|
1106
|
+
};
|
|
1107
|
+
const messages = {
|
|
1108
|
+
ERR_GENERIC: 'An error occured',
|
|
1109
|
+
};
|
|
1110
|
+
// Intermediate "hacky" subclass taken from
|
|
1111
|
+
// https://www.bennadel.com/blog/3226-experimenting-with-error-sub-classing-using-es5-and-typescript-2-1-5.htm
|
|
1112
|
+
class ErrorSubClass {
|
|
1113
|
+
constructor(code, msg, args) {
|
|
1114
|
+
if (!msg && code && code in messages) {
|
|
1115
|
+
if (typeof messages[code] === 'function') {
|
|
1116
|
+
msg = messages[code](...args.messageParams);
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
msg = messages[code];
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
this.name = 'ErrorSubClass';
|
|
1123
|
+
this.message = msg;
|
|
1124
|
+
this.code = code;
|
|
1125
|
+
this.stack = new Error(msg).stack;
|
|
1126
|
+
if (args) {
|
|
1127
|
+
Object.keys(args).forEach((k) => {
|
|
1128
|
+
if (k !== 'messageParams') {
|
|
1129
|
+
this[k] = args[k];
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1442
1133
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1134
|
+
}
|
|
1135
|
+
// This replaces the "extends" on the Class
|
|
1136
|
+
// ErrorSubClass.prototype = <any>Object.create(Error.prototype);
|
|
1137
|
+
class EuiError extends ErrorSubClass {
|
|
1138
|
+
constructor(code = errorCodes.ERR_GENERIC, msg, args) {
|
|
1139
|
+
super(code, msg, args);
|
|
1140
|
+
this.name = 'EuiError';
|
|
1445
1141
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
class GlobalErrorHandler extends ErrorHandler {
|
|
1145
|
+
constructor(logService) {
|
|
1146
|
+
super();
|
|
1147
|
+
this.logService = logService;
|
|
1448
1148
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1149
|
+
handleError(error) {
|
|
1150
|
+
// log error
|
|
1151
|
+
this.logService.error(error.message || error.toString());
|
|
1152
|
+
// throw error;
|
|
1153
|
+
super.handleError(error);
|
|
1451
1154
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1155
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1156
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' }); }
|
|
1157
|
+
}
|
|
1158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: GlobalErrorHandler, decorators: [{
|
|
1159
|
+
type: Injectable,
|
|
1160
|
+
args: [{
|
|
1161
|
+
providedIn: 'root',
|
|
1162
|
+
}]
|
|
1163
|
+
}], ctorParameters: function () { return [{ type: LogService }]; } });
|
|
1164
|
+
|
|
1165
|
+
class HttpErrorHandlerInterceptor {
|
|
1166
|
+
constructor(config = DEFAULT_HTTP_ERROR_HANDLER_CONFIG, injector, router) {
|
|
1167
|
+
this.config = config;
|
|
1168
|
+
this.injector = injector;
|
|
1169
|
+
this.router = router;
|
|
1459
1170
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1171
|
+
intercept(req, next) {
|
|
1172
|
+
return next.handle(req).pipe(tap(() => { }, (error) => {
|
|
1173
|
+
// in case of http error
|
|
1174
|
+
if (error instanceof HttpErrorResponse) {
|
|
1175
|
+
const routeConfig = this.getRouteConfig(error);
|
|
1176
|
+
const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
|
|
1177
|
+
if (typeof rule === 'string') {
|
|
1178
|
+
// perform a redirect
|
|
1179
|
+
this.router.navigate([rule]);
|
|
1180
|
+
}
|
|
1181
|
+
else if (typeof rule === 'function') {
|
|
1182
|
+
// callback function
|
|
1183
|
+
rule.call(null, error, this.injector);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}));
|
|
1463
1187
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1188
|
+
/**
|
|
1189
|
+
* Search in the configuration for the first matching route
|
|
1190
|
+
*
|
|
1191
|
+
* @param error http error response
|
|
1192
|
+
* @returns HttpErrorRouteConfig or null
|
|
1193
|
+
*/
|
|
1194
|
+
getRouteConfig(error) {
|
|
1195
|
+
// filter the routes
|
|
1196
|
+
const routes = this.config.routes.filter((route) => {
|
|
1197
|
+
const regex = new RegExp('^' + route.path.split('*').join('.*') + '$');
|
|
1198
|
+
return regex.test(error.url) && (typeof route[error.status] !== 'undefined' || typeof route.default !== 'undefined');
|
|
1199
|
+
});
|
|
1200
|
+
// return the first matching route, if any
|
|
1201
|
+
return routes.length > 0 ? routes[0] : null;
|
|
1469
1202
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1203
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i1$4.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1204
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: HttpErrorHandlerInterceptor }); }
|
|
1205
|
+
}
|
|
1206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
|
|
1207
|
+
type: Injectable
|
|
1208
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1209
|
+
type: Inject,
|
|
1210
|
+
args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
|
|
1211
|
+
}] }, { type: i0.Injector }, { type: i1$4.Router }]; } });
|
|
1212
|
+
|
|
1213
|
+
function AlertHttpErrorCallbackFn(error) {
|
|
1214
|
+
alert(error.statusText);
|
|
1215
|
+
}
|
|
1216
|
+
function ConsoleHttpErrorCallbackFn(error) {
|
|
1217
|
+
console.error('HttpError', error);
|
|
1218
|
+
}
|
|
1219
|
+
function LogHttpErrorCallbackFn(error, injector) {
|
|
1220
|
+
const logService = injector.get(LogService);
|
|
1221
|
+
logService.error('HttpError', error);
|
|
1222
|
+
}
|
|
1223
|
+
function GrowlHttpErrorCallbackFn(error, injector) {
|
|
1224
|
+
const asService = injector.get(EuiGrowlService);
|
|
1225
|
+
asService.growlError(error.statusText);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
class ApiQueueService {
|
|
1229
|
+
constructor(store, http, logService) {
|
|
1230
|
+
this.store = store;
|
|
1231
|
+
this.http = http;
|
|
1232
|
+
this.logService = logService;
|
|
1472
1233
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1234
|
+
/**
|
|
1235
|
+
* Adds an item in the queue by dispatching an action to the store.
|
|
1236
|
+
* @param id - The id of the item inside the queue.
|
|
1237
|
+
* WARNING if matches any other queue item id will overwrite it.
|
|
1238
|
+
* @param item - an item for Queue
|
|
1239
|
+
*/
|
|
1240
|
+
addQueueItem(id, item) {
|
|
1241
|
+
const allowedMethods = ['post', 'put', 'get'];
|
|
1242
|
+
if (allowedMethods.indexOf(item.method) < 0) {
|
|
1243
|
+
throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
|
|
1244
|
+
}
|
|
1245
|
+
this.store.dispatch(new AddApiQueueItemAction({ id, item }));
|
|
1475
1246
|
}
|
|
1476
1247
|
/**
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
* Sets the value in the --eui-app-vw custom property to the root of the document
|
|
1480
|
-
* Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
|
|
1481
|
-
* Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
|
|
1482
|
-
* Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
|
|
1248
|
+
* Subscribes to the store to retrieve queue and then converts the queue object to an array of items.
|
|
1249
|
+
* @return An Observable of array of all items inside the current queue (ApiQueueItem[])
|
|
1483
1250
|
*/
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1251
|
+
getQueue() {
|
|
1252
|
+
return this.store.select(getApiQueue).pipe(take(1), map((queue) => {
|
|
1253
|
+
const queueArray = queue && Object.values(queue);
|
|
1254
|
+
if (!queueArray || queueArray.length < 1) {
|
|
1255
|
+
this.logService.warn('No items in the queue exist.');
|
|
1256
|
+
}
|
|
1257
|
+
return queueArray;
|
|
1258
|
+
}));
|
|
1489
1259
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1260
|
+
/**
|
|
1261
|
+
* Subscribes to the store to retrieve an item from the queue.
|
|
1262
|
+
* @param id - id of the item inside the queue
|
|
1263
|
+
* @return An Observable of ApiQueueItem type
|
|
1264
|
+
*/
|
|
1265
|
+
getQueueItem(id) {
|
|
1266
|
+
return this.store.select(getApiQueueItem(id)).pipe(take(1), map((queue) => {
|
|
1267
|
+
if (!queue) {
|
|
1268
|
+
this.logService.warn(`Queue item with id "${id}" does not exist`);
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
return queue;
|
|
1272
|
+
}));
|
|
1495
1273
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1274
|
+
/**
|
|
1275
|
+
* Removes a given item from the queue.
|
|
1276
|
+
* @param id - id of the item inside the queue
|
|
1277
|
+
*/
|
|
1278
|
+
removeQueueItem(id) {
|
|
1279
|
+
this.store.dispatch(new RemoveApiQueueItemAction(id));
|
|
1500
1280
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1281
|
+
/**
|
|
1282
|
+
* Removes all items placed in the queue.
|
|
1283
|
+
*/
|
|
1284
|
+
removeAllQueueItem() {
|
|
1285
|
+
this.store.dispatch(new EmptyApiQueueAction(null));
|
|
1503
1286
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
if (!
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
if (state.isSidebarActive) {
|
|
1515
|
-
classes.push('sidebar-active');
|
|
1516
|
-
}
|
|
1517
|
-
if (state.isSidebarInnerActive) {
|
|
1518
|
-
classes.push('sidebar-inner-active');
|
|
1519
|
-
}
|
|
1520
|
-
if (state.isSidebarStateCloseWithIcons) {
|
|
1521
|
-
classes.push('sidebar-state-close-with-icons');
|
|
1522
|
-
}
|
|
1523
|
-
// NEW APP-SHELL props
|
|
1524
|
-
if (state.isSidebarHidden) {
|
|
1525
|
-
classes.push('sidebar--hidden');
|
|
1526
|
-
}
|
|
1527
|
-
if (state.isSidebarOpen) {
|
|
1528
|
-
classes.push('sidebar--open');
|
|
1529
|
-
}
|
|
1530
|
-
else {
|
|
1531
|
-
classes.push('sidebar--close');
|
|
1532
|
-
}
|
|
1533
|
-
if (state.isSidebarHover) {
|
|
1534
|
-
classes.push('sidebar--hover');
|
|
1287
|
+
/**
|
|
1288
|
+
* Process an item from the queue.
|
|
1289
|
+
* @param id - id of the item inside the queue
|
|
1290
|
+
* @return An Observable of type any
|
|
1291
|
+
*/
|
|
1292
|
+
processQueueItem(id) {
|
|
1293
|
+
return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
|
|
1294
|
+
if (!queue) {
|
|
1295
|
+
this.logService.warn(`Queue item with id "${id}" does not exist`);
|
|
1296
|
+
return of(null);
|
|
1535
1297
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
classes.push('ff');
|
|
1539
|
-
}
|
|
1540
|
-
if (state.deviceInfo && state.deviceInfo.isIE) {
|
|
1541
|
-
classes.push('ie');
|
|
1542
|
-
}
|
|
1543
|
-
if (state.deviceInfo && state.deviceInfo.isIE11) {
|
|
1544
|
-
classes.push('ie11');
|
|
1545
|
-
}
|
|
1546
|
-
if (state.deviceInfo && state.deviceInfo.isChrome) {
|
|
1547
|
-
classes.push('chrome');
|
|
1548
|
-
}
|
|
1549
|
-
return classes.join(' ');
|
|
1550
|
-
}
|
|
1551
|
-
getBreakpoint(windowWidth) {
|
|
1552
|
-
let bkp = '';
|
|
1553
|
-
switch (true) {
|
|
1554
|
-
case windowWidth >= 0 && windowWidth < 576:
|
|
1555
|
-
bkp = 'xs';
|
|
1556
|
-
break;
|
|
1557
|
-
case windowWidth >= 576 && windowWidth < 768:
|
|
1558
|
-
bkp = 'sm';
|
|
1559
|
-
break;
|
|
1560
|
-
case windowWidth >= 768 && windowWidth < 992:
|
|
1561
|
-
bkp = 'md';
|
|
1562
|
-
break;
|
|
1563
|
-
case windowWidth >= 992 && windowWidth < 1200:
|
|
1564
|
-
bkp = 'lg';
|
|
1565
|
-
break;
|
|
1566
|
-
case windowWidth >= 1200 && windowWidth < 1400:
|
|
1567
|
-
bkp = 'xl';
|
|
1568
|
-
break;
|
|
1569
|
-
case windowWidth >= 1400 && windowWidth < 1920:
|
|
1570
|
-
bkp = 'xxl';
|
|
1571
|
-
break;
|
|
1572
|
-
case windowWidth >= 1920 && windowWidth < 2560:
|
|
1573
|
-
bkp = 'fhd';
|
|
1574
|
-
break;
|
|
1575
|
-
case windowWidth >= 2560 && windowWidth < 3840:
|
|
1576
|
-
bkp = '2k';
|
|
1577
|
-
break;
|
|
1578
|
-
case windowWidth >= 3840:
|
|
1579
|
-
bkp = '4k';
|
|
1580
|
-
break;
|
|
1581
|
-
}
|
|
1582
|
-
return bkp;
|
|
1583
|
-
}
|
|
1584
|
-
getBreakpoints(bkp) {
|
|
1585
|
-
return {
|
|
1586
|
-
isMobile: bkp === 'xs' || bkp === 'sm',
|
|
1587
|
-
isTablet: bkp === 'md',
|
|
1588
|
-
isLtDesktop: bkp === 'xs' || bkp === 'sm' || bkp === 'md',
|
|
1589
|
-
isDesktop: bkp === 'lg',
|
|
1590
|
-
isXL: bkp === 'xl',
|
|
1591
|
-
isXXL: bkp === 'xxl',
|
|
1592
|
-
isFHD: bkp === 'fhd',
|
|
1593
|
-
is2K: bkp === '2k',
|
|
1594
|
-
is4K: bkp === '4k',
|
|
1595
|
-
};
|
|
1298
|
+
return this.buildHttpRequest(id, queue);
|
|
1299
|
+
}));
|
|
1596
1300
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1301
|
+
/**
|
|
1302
|
+
* Process all the items inside the queue.
|
|
1303
|
+
* @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
|
|
1304
|
+
* @return An Observable with an array which contains all responses from all items in queue.
|
|
1305
|
+
*/
|
|
1306
|
+
processAllQueueItems(continueOnError = true) {
|
|
1307
|
+
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
1308
|
+
this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
1309
|
+
if (!continueOnError) {
|
|
1310
|
+
throw error;
|
|
1311
|
+
}
|
|
1312
|
+
return of(error);
|
|
1313
|
+
})))), switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
|
|
1599
1314
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1315
|
+
/**
|
|
1316
|
+
* Process all items in queue after it order them based on their timestamp. Beware that order
|
|
1317
|
+
* matter in execution of Http Request in queue. When a request completes only then next will begin. Emission
|
|
1318
|
+
* or Http response follows order.
|
|
1319
|
+
* @param [ascending=true] - sets the order of queue items based on timestamp
|
|
1320
|
+
*/
|
|
1321
|
+
processAllQueueItemsSequential(ascending = true) {
|
|
1322
|
+
return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
|
|
1323
|
+
.sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
|
|
1324
|
+
.map(([id, item]) => this.buildHttpRequest(id, item))));
|
|
1603
1325
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* Short dates ascending based on input
|
|
1328
|
+
* @param a - Date one
|
|
1329
|
+
* @param b - Date two
|
|
1330
|
+
*
|
|
1331
|
+
* @beta
|
|
1332
|
+
*/
|
|
1333
|
+
sortOnTimestamp(a, b) {
|
|
1334
|
+
return +new Date(a[1].timestamp) - +new Date(b[1].timestamp);
|
|
1607
1335
|
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1336
|
+
/**
|
|
1337
|
+
* build and HttpRequest Observable based on the given queue.
|
|
1338
|
+
* After successful request completion removes the item from the queue.
|
|
1339
|
+
* @param id - id of the item inside the queue
|
|
1340
|
+
* @param item - the item of the queue that matches the id.
|
|
1341
|
+
* @return An Observable of HttpClient Request
|
|
1342
|
+
*/
|
|
1343
|
+
buildHttpRequest(id, item) {
|
|
1344
|
+
return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
|
|
1617
1345
|
}
|
|
1618
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1619
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1346
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$5.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1347
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
|
|
1620
1348
|
}
|
|
1621
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1349
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: ApiQueueService, decorators: [{
|
|
1622
1350
|
type: Injectable,
|
|
1623
1351
|
args: [{
|
|
1624
1352
|
providedIn: 'root',
|
|
1625
1353
|
}]
|
|
1626
|
-
}], ctorParameters: function () { return [{ type:
|
|
1627
|
-
type: Optional
|
|
1628
|
-
}, {
|
|
1629
|
-
type: Inject,
|
|
1630
|
-
args: [GLOBAL_CONFIG_TOKEN]
|
|
1631
|
-
}] }, { type: i1$2.HttpClient }, { type: undefined, decorators: [{
|
|
1632
|
-
type: Inject,
|
|
1633
|
-
args: [PLATFORM_ID]
|
|
1634
|
-
}] }, { type: i2$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
|
|
1635
|
-
type: Optional
|
|
1636
|
-
}] }]; } });
|
|
1354
|
+
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$5.HttpClient }, { type: LogService }]; } });
|
|
1637
1355
|
|
|
1638
|
-
class
|
|
1639
|
-
constructor(
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1356
|
+
class ApiQueueServiceMock extends ApiQueueService {
|
|
1357
|
+
constructor() {
|
|
1358
|
+
super(null, null, null);
|
|
1359
|
+
}
|
|
1360
|
+
getQueue() {
|
|
1361
|
+
return of([]);
|
|
1362
|
+
}
|
|
1363
|
+
getQueueItem(id) {
|
|
1364
|
+
return of({ uri: id, method: 'GET' });
|
|
1365
|
+
}
|
|
1366
|
+
removeAllQueueItem() { }
|
|
1367
|
+
processAllQueueItems() {
|
|
1368
|
+
return of({});
|
|
1369
|
+
}
|
|
1370
|
+
addQueueItem() { }
|
|
1371
|
+
removeQueueItem() { }
|
|
1372
|
+
processQueueItem() {
|
|
1373
|
+
return of({});
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
class I18nResourceImpl {
|
|
1378
|
+
/**
|
|
1379
|
+
* Resource constructor
|
|
1380
|
+
*
|
|
1381
|
+
* @param prefix the prefix of the resource
|
|
1382
|
+
* @param suffix the suffix of the resource, optional parameter
|
|
1383
|
+
* @param compileTranslations compiler function, optional parameter
|
|
1384
|
+
*/
|
|
1385
|
+
constructor(prefix, suffix = '', compileTranslationsFn = (translations) => translations) {
|
|
1386
|
+
this.prefix = prefix;
|
|
1387
|
+
this.suffix = suffix;
|
|
1388
|
+
this.compileTranslationsFn = compileTranslationsFn;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Translations pre-processor
|
|
1392
|
+
*
|
|
1393
|
+
* @param translations the object to be pre-processed
|
|
1394
|
+
* @param lang the translations language
|
|
1395
|
+
* @returns the pre-processed translations
|
|
1396
|
+
*/
|
|
1397
|
+
compileTranslations(translations, lang) {
|
|
1398
|
+
return this.compileTranslationsFn(translations, lang);
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Indicates whether other object is equal-to this one.
|
|
1402
|
+
*
|
|
1403
|
+
* @param obj the reference object with which to compare
|
|
1404
|
+
* @returns true if this object is the same as obj, false otherwise
|
|
1405
|
+
*/
|
|
1406
|
+
equals(obj) {
|
|
1407
|
+
return this.prefix === obj.prefix && this.suffix === obj.suffix;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* The path to the resource
|
|
1411
|
+
*
|
|
1412
|
+
* @param lang the resource language
|
|
1413
|
+
* @returns the path
|
|
1414
|
+
*/
|
|
1415
|
+
getPath(lang) {
|
|
1416
|
+
return `${this.prefix}${lang}${this.suffix}`;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
class I18nLoader {
|
|
1421
|
+
constructor(http, logService, euiAppConfig) {
|
|
1422
|
+
this.http = http;
|
|
1423
|
+
this.logService = logService;
|
|
1424
|
+
this.euiAppConfig = euiAppConfig;
|
|
1425
|
+
this.resources = [];
|
|
1426
|
+
this.failedResources = [];
|
|
1427
|
+
// create the resources from the config object
|
|
1428
|
+
const i18nConfig = this.euiAppConfig.global && this.euiAppConfig.global.i18n;
|
|
1429
|
+
const i18nLoaderConfig = i18nConfig && i18nConfig.i18nLoader;
|
|
1430
|
+
this.resources.push(...this.createResources(i18nLoaderConfig));
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Gets the translations from the server
|
|
1434
|
+
*
|
|
1435
|
+
* @param lang
|
|
1436
|
+
* @returns Observable<any>
|
|
1437
|
+
*/
|
|
1438
|
+
getTranslation(lang) {
|
|
1439
|
+
return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
|
|
1440
|
+
this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
|
|
1441
|
+
return loadedResources.translations;
|
|
1442
|
+
}));
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Adds resources
|
|
1446
|
+
*
|
|
1447
|
+
* @param config loader configuration
|
|
1448
|
+
* @returns Observable<any> | false
|
|
1449
|
+
*/
|
|
1450
|
+
addResources(config) {
|
|
1451
|
+
// create the resources
|
|
1452
|
+
let resources = this.createResources(config);
|
|
1453
|
+
// filter the resources first, to avoid duplicates
|
|
1454
|
+
resources = resources.filter((resource) => !this.resources.some((res) => res.equals(resource)));
|
|
1455
|
+
// add the new resources to the list of existing resources
|
|
1456
|
+
this.resources.push(...resources);
|
|
1457
|
+
// return the filtered resources
|
|
1458
|
+
return resources;
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Removes resources from the loader instance
|
|
1462
|
+
*/
|
|
1463
|
+
removeResources(removedResources) {
|
|
1464
|
+
this.resources = this.resources.filter((res) => !removedResources.some((removedResource) => removedResource.equals(res)));
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Loads an array of resources, by language
|
|
1468
|
+
*
|
|
1469
|
+
* @param resources the definition of the resources
|
|
1470
|
+
* @param lang the resource language to load
|
|
1471
|
+
* @returns Observable<any>
|
|
1472
|
+
*/
|
|
1473
|
+
loadResources(resources, lang) {
|
|
1474
|
+
// if there are resources to load
|
|
1475
|
+
if (Array.isArray(resources) && resources.length > 0) {
|
|
1476
|
+
// load all the resources in an array of Observable
|
|
1477
|
+
const requests = resources.map((resource) => this.loadResource(resource, lang));
|
|
1478
|
+
// group all the observables with forkJoin and deep merge them
|
|
1479
|
+
return forkJoin(requests).pipe(map((response) => {
|
|
1480
|
+
const successResp = [];
|
|
1481
|
+
const errResp = [];
|
|
1482
|
+
response.forEach((item) => {
|
|
1483
|
+
if (item.isError) {
|
|
1484
|
+
errResp.push({ resource: item.resource, error: item.error });
|
|
1485
|
+
}
|
|
1486
|
+
else {
|
|
1487
|
+
successResp.push(item);
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
if (successResp.length === response.length) {
|
|
1491
|
+
return { hasError: false, translations: mergeAll(successResp) };
|
|
1669
1492
|
}
|
|
1670
1493
|
else {
|
|
1671
|
-
|
|
1672
|
-
// TODO v17 - should be subscribed from the eui-app to display growl
|
|
1673
|
-
// this.asService.growl(
|
|
1674
|
-
// { severity: 'danger', summary: 'ERROR', detail: translation, life: lifespan },
|
|
1675
|
-
// lifespan < 1,
|
|
1676
|
-
// false
|
|
1677
|
-
// );
|
|
1678
|
-
});
|
|
1494
|
+
return { hasError: true, translations: mergeAll(successResp), errors: errResp };
|
|
1679
1495
|
}
|
|
1496
|
+
}));
|
|
1497
|
+
}
|
|
1498
|
+
else {
|
|
1499
|
+
// no resources to load
|
|
1500
|
+
return of({ hasError: false, translations: {} });
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Returns resources that failed
|
|
1505
|
+
*/
|
|
1506
|
+
getFailedResources() {
|
|
1507
|
+
return this.failedResources;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Create resources from a config file
|
|
1511
|
+
*
|
|
1512
|
+
* @param config loader configuration
|
|
1513
|
+
* @returns I18nResourceImpl[] resources
|
|
1514
|
+
*/
|
|
1515
|
+
createResources(config) {
|
|
1516
|
+
// use the default config as a reference base
|
|
1517
|
+
config = getI18nLoaderConfig(config);
|
|
1518
|
+
const resources = [];
|
|
1519
|
+
// extract the i18n folders from config
|
|
1520
|
+
const i18nFolders = Array.isArray(config.i18nFolders)
|
|
1521
|
+
? config.i18nFolders
|
|
1522
|
+
: config.i18nFolders
|
|
1523
|
+
? [config.i18nFolders]
|
|
1524
|
+
: [];
|
|
1525
|
+
if (i18nFolders) {
|
|
1526
|
+
// add the i18n folders to resources
|
|
1527
|
+
resources.push(...i18nFolders.map((folder) => new I18nResourceImpl(`assets/${folder}/`, '.json')));
|
|
1528
|
+
}
|
|
1529
|
+
// extract the i18n services from config
|
|
1530
|
+
const i18nServices = Array.isArray(config.i18nServices)
|
|
1531
|
+
? config.i18nServices
|
|
1532
|
+
: config.i18nServices
|
|
1533
|
+
? [config.i18nServices]
|
|
1534
|
+
: [];
|
|
1535
|
+
if (i18nServices) {
|
|
1536
|
+
// add the i18n services to resources
|
|
1537
|
+
resources.push(...i18nServices.map((service) => new I18nResourceImpl(service)));
|
|
1538
|
+
}
|
|
1539
|
+
// extract the i18n resources from config
|
|
1540
|
+
const i18nResources = Array.isArray(config.i18nResources)
|
|
1541
|
+
? config.i18nResources
|
|
1542
|
+
: config.i18nResources
|
|
1543
|
+
? [config.i18nResources]
|
|
1544
|
+
: [];
|
|
1545
|
+
if (i18nResources) {
|
|
1546
|
+
// add the i18n resources to resources
|
|
1547
|
+
resources.push(...i18nResources.map((resource) => new I18nResourceImpl(resource.prefix, resource.suffix, this.getResourceCompileFunction(resource.compileTranslations))));
|
|
1548
|
+
}
|
|
1549
|
+
return resources;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Loads a resource, by language
|
|
1553
|
+
*
|
|
1554
|
+
* @param resource the definition of the resource
|
|
1555
|
+
* @param lang the resource language to load
|
|
1556
|
+
* @returns Observable<any>
|
|
1557
|
+
*/
|
|
1558
|
+
loadResource(resource, lang) {
|
|
1559
|
+
// the path to the resource
|
|
1560
|
+
const path = resource.getPath(lang);
|
|
1561
|
+
// load the translations from the path
|
|
1562
|
+
return this.http.get(path).pipe(
|
|
1563
|
+
// preprocess the translations using the resource compiler
|
|
1564
|
+
map((translations) => resource.compileTranslations(translations, lang)), map((translations) => {
|
|
1565
|
+
// resource loaded properly, send a info message
|
|
1566
|
+
if (this.logService) {
|
|
1567
|
+
this.logService.info(`I18n resource loaded from path ${path}`);
|
|
1680
1568
|
}
|
|
1681
|
-
|
|
1569
|
+
// return the translations
|
|
1570
|
+
return translations;
|
|
1571
|
+
}), catchError((err) => {
|
|
1572
|
+
// remove failed resource from loaded resource array
|
|
1573
|
+
this.removeResources([resource]);
|
|
1574
|
+
// resource not loaded properly, send a warning message
|
|
1575
|
+
if (this.logService) {
|
|
1576
|
+
this.logService.warn(`I18n resource NOT loaded from path ${path}`, err);
|
|
1577
|
+
}
|
|
1578
|
+
const resourceError = { error: `I18n resource NOT loaded from path ${path}`, resource, isError: true };
|
|
1579
|
+
return of(resourceError);
|
|
1580
|
+
}));
|
|
1581
|
+
}
|
|
1582
|
+
getResourceCompileFunction(id) {
|
|
1583
|
+
const customHandlers = this.euiAppConfig.customHandler;
|
|
1584
|
+
if (customHandlers && typeof customHandlers[id] === 'function') {
|
|
1585
|
+
return customHandlers[id];
|
|
1586
|
+
}
|
|
1587
|
+
return undefined;
|
|
1682
1588
|
}
|
|
1683
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1684
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1589
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nLoader, deps: [{ token: i1$5.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1590
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nLoader }); }
|
|
1685
1591
|
}
|
|
1686
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nLoader, decorators: [{
|
|
1687
1593
|
type: Injectable
|
|
1688
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
1594
|
+
}], ctorParameters: function () { return [{ type: i1$5.HttpClient }, { type: LogService, decorators: [{
|
|
1595
|
+
type: Optional
|
|
1596
|
+
}] }, { type: undefined, decorators: [{
|
|
1689
1597
|
type: Inject,
|
|
1690
|
-
args: [
|
|
1691
|
-
}] }
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
|
|
1697
|
-
const AddAppLoadedConfigModules = (state, action) => ({
|
|
1698
|
-
...state,
|
|
1699
|
-
loadedConfigModules: {
|
|
1700
|
-
lastAddedModule: action.payload.moduleName,
|
|
1701
|
-
modulesConfig: {
|
|
1702
|
-
...state.loadedConfigModules.modulesConfig,
|
|
1703
|
-
[action.payload.moduleName]: {
|
|
1704
|
-
...action.payload.moduleConfig,
|
|
1705
|
-
},
|
|
1706
|
-
},
|
|
1598
|
+
args: [CONFIG_TOKEN]
|
|
1599
|
+
}] }]; } });
|
|
1600
|
+
const translateConfig = {
|
|
1601
|
+
loader: {
|
|
1602
|
+
provide: TranslateLoader,
|
|
1603
|
+
useClass: I18nLoader,
|
|
1707
1604
|
},
|
|
1708
|
-
});
|
|
1709
|
-
const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
|
|
1710
|
-
const updateCurrentModule = (state, action) => Object.assign({}, state, { currentModule: action.payload });
|
|
1711
|
-
const addApiQueueItem = (state, action) => {
|
|
1712
|
-
// apply the timestamp to the queue item
|
|
1713
|
-
const apiQueueItem = Object.assign({}, action.payload.item, { timestamp: new Date().getTime() });
|
|
1714
|
-
// update the queue
|
|
1715
|
-
const apiQueue = Object.assign({}, state.apiQueue, { [action.payload.id]: apiQueueItem });
|
|
1716
|
-
return Object.assign({}, state, { apiQueue });
|
|
1717
|
-
};
|
|
1718
|
-
const removeApiQueueItem = (state, action) => {
|
|
1719
|
-
// remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
|
|
1720
|
-
const apiQueue = Object.keys(state.apiQueue)
|
|
1721
|
-
.filter((id) => id !== action.payload)
|
|
1722
|
-
.reduce((queue, key) => {
|
|
1723
|
-
queue[key] = state.apiQueue[key];
|
|
1724
|
-
return queue;
|
|
1725
|
-
}, {});
|
|
1726
|
-
return Object.assign({}, state, { apiQueue });
|
|
1727
|
-
};
|
|
1728
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1729
|
-
const emptyApiQueue = (state, action) =>
|
|
1730
|
-
// remove all items in the Api Queue
|
|
1731
|
-
Object.assign({}, state, { apiQueue: {} });
|
|
1732
|
-
const actionToReducerMap$4 = {
|
|
1733
|
-
[CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
|
|
1734
|
-
[CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
|
|
1735
|
-
[CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
|
|
1736
|
-
[CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
|
|
1737
|
-
[CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
|
|
1738
|
-
[CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
|
|
1739
|
-
[CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
|
|
1740
|
-
[CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
|
|
1741
|
-
};
|
|
1742
|
-
const coreAppReducers = (state = initialAppState, action) => {
|
|
1743
|
-
if (actionToReducerMap$4[action.type]) {
|
|
1744
|
-
return actionToReducerMap$4[action.type](state, action);
|
|
1745
|
-
}
|
|
1746
|
-
// if the action type is not in the map, call the base reducers method
|
|
1747
|
-
return state;
|
|
1748
1605
|
};
|
|
1749
1606
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
|
|
1761
|
-
}
|
|
1762
|
-
// todo should be checked if state.details is really there
|
|
1763
|
-
const details = Object.assign({}, state.details, action.payload, { fullName });
|
|
1764
|
-
return Object.assign({}, state, details);
|
|
1765
|
-
};
|
|
1766
|
-
const updateUserPreferences = (state, action) => {
|
|
1767
|
-
const preferences = Object.assign({}, state.preferences, action.payload);
|
|
1768
|
-
return Object.assign({}, state, { preferences });
|
|
1769
|
-
};
|
|
1770
|
-
const updateUserRights = (state, action) => Object.assign({}, state, { rights: [...action.payload] });
|
|
1771
|
-
const updateUserDashboard = (state, action) => {
|
|
1772
|
-
// apply the dashboard to preferences
|
|
1773
|
-
const preferences = Object.assign({}, state.preferences, { dashboard: action.payload });
|
|
1774
|
-
// update the state
|
|
1775
|
-
return { ...state, preferences };
|
|
1776
|
-
};
|
|
1777
|
-
const actionToReducerMap$3 = {
|
|
1778
|
-
[CoreUserActionTypes.UPDATE_USER_DETAILS]: updateUserDetails,
|
|
1779
|
-
[CoreUserActionTypes.UPDATE_USER_PREFERENCES]: updateUserPreferences,
|
|
1780
|
-
[CoreUserActionTypes.UPDATE_USER_STATE]: updateUser,
|
|
1781
|
-
[CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
|
|
1782
|
-
[CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
|
|
1783
|
-
};
|
|
1784
|
-
const coreUserReducers = (state = initialUserState, action) => {
|
|
1785
|
-
if (actionToReducerMap$3[action.type]) {
|
|
1786
|
-
return actionToReducerMap$3[action.type](state, action);
|
|
1607
|
+
class I18nService extends EuiLazyService {
|
|
1608
|
+
constructor(baseGlobalConfig, translateService, logService, store, document) {
|
|
1609
|
+
super({ activeLang: 'en' });
|
|
1610
|
+
this.baseGlobalConfig = baseGlobalConfig;
|
|
1611
|
+
this.translateService = translateService;
|
|
1612
|
+
this.logService = logService;
|
|
1613
|
+
this.store = store;
|
|
1614
|
+
this.document = document;
|
|
1615
|
+
this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
|
|
1616
|
+
this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
|
|
1787
1617
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1618
|
+
getState(keyOrMapFn) {
|
|
1619
|
+
let selector = getI18nState;
|
|
1620
|
+
let dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
|
|
1621
|
+
if (keyOrMapFn) {
|
|
1622
|
+
switch (typeof keyOrMapFn) {
|
|
1623
|
+
case 'function':
|
|
1624
|
+
selector = createSelector(getI18nState, keyOrMapFn);
|
|
1625
|
+
break;
|
|
1626
|
+
case 'string':
|
|
1627
|
+
selector = createSelector(getI18nState, (state) => dotNotationToObject(state, keyOrMapFn));
|
|
1628
|
+
break;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
return this.store.select(selector);
|
|
1798
1632
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
const updateI18nState = (state, action) => ({
|
|
1803
|
-
...state,
|
|
1804
|
-
...action.payload,
|
|
1805
|
-
});
|
|
1806
|
-
const actionToReducerMap$1 = {
|
|
1807
|
-
[CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
|
|
1808
|
-
};
|
|
1809
|
-
const corI18nReducers = (state = initialI18nState, action) => {
|
|
1810
|
-
if (actionToReducerMap$1[action.type]) {
|
|
1811
|
-
return actionToReducerMap$1[action.type](state, action);
|
|
1633
|
+
updateState(langState) {
|
|
1634
|
+
this.updateHTMLDOMLang(langState.activeLang);
|
|
1635
|
+
this.store.dispatch(new UpdateI18nStateAction(langState));
|
|
1812
1636
|
}
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
return actionToReducerMap[action.type](state, action);
|
|
1637
|
+
init(langState) {
|
|
1638
|
+
const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
|
|
1639
|
+
const initState = {
|
|
1640
|
+
...langState,
|
|
1641
|
+
activeLang: initLang,
|
|
1642
|
+
};
|
|
1643
|
+
if (typeof initLang === 'string') {
|
|
1644
|
+
super.initEuiService(this.store);
|
|
1645
|
+
this.updateState(initState);
|
|
1646
|
+
return this.setup(initLang);
|
|
1647
|
+
}
|
|
1648
|
+
return of({ success: false, error: 'Initial active lang should be string' });
|
|
1826
1649
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
return cb(reducer, localStorage);
|
|
1845
|
-
}
|
|
1846
|
-
/**
|
|
1847
|
-
* Utility meta-reducer to load the state from the session storage
|
|
1848
|
-
* @param reducer the action reducer
|
|
1849
|
-
*/
|
|
1850
|
-
function sessionStorageSync(reducer) {
|
|
1851
|
-
return cb(reducer, sessionStorage);
|
|
1852
|
-
}
|
|
1853
|
-
// Keys that are allowed to be synced with NgRx state from BrowserStorage
|
|
1854
|
-
const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
|
|
1855
|
-
/**
|
|
1856
|
-
* filters the AppState by removing those keys from the state and return a new state Object
|
|
1857
|
-
* @param app the AppState
|
|
1858
|
-
*/
|
|
1859
|
-
const filterAppState = (app) => {
|
|
1860
|
-
// in case app is undefined or null it should return empty object
|
|
1861
|
-
if (!app) {
|
|
1862
|
-
return {};
|
|
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
|
+
onReady(moduleName) {
|
|
1660
|
+
return this.onModuleLoad.pipe(switchMap((evt) => moduleName
|
|
1661
|
+
? of(evt)
|
|
1662
|
+
: this.store.select(getLastAddedModule).pipe(tap((m) => (moduleName = m)), map(() => evt))),
|
|
1663
|
+
// emit only if event emitted matches the module name and is ready
|
|
1664
|
+
filter((evt) => evt.ready === true && evt.name === moduleName),
|
|
1665
|
+
// make sure that observable completes
|
|
1666
|
+
take(1));
|
|
1863
1667
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
.
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1668
|
+
lazyLoad(config) {
|
|
1669
|
+
const moduleId = Math.floor(Math.random() * 100000 + 1).toLocaleString();
|
|
1670
|
+
return this.addResources(config, moduleId);
|
|
1671
|
+
}
|
|
1672
|
+
lazyLoadInit(moduleConfig, moduleName) {
|
|
1673
|
+
const i18nLoaderConfig = moduleConfig;
|
|
1674
|
+
// add resources
|
|
1675
|
+
return this.addResources(i18nLoaderConfig, moduleName);
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Add resources based of a config loader
|
|
1679
|
+
*
|
|
1680
|
+
* @param config I18nLoaderConfig
|
|
1681
|
+
* @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
|
|
1682
|
+
*/
|
|
1683
|
+
addResources(config, moduleName) {
|
|
1684
|
+
// emit that module is loading
|
|
1685
|
+
this.onModuleLoad.next({ ready: false, name: moduleName });
|
|
1686
|
+
const loader = this.translateService.currentLoader;
|
|
1687
|
+
if (loader instanceof I18nLoader) {
|
|
1688
|
+
const langSubscription = [];
|
|
1689
|
+
const i18nLoader = loader;
|
|
1690
|
+
// add the resources to the loader
|
|
1691
|
+
const resources = i18nLoader.addResources(config);
|
|
1692
|
+
// manually load the resources for the CURRENT language and add them to the translate service
|
|
1693
|
+
langSubscription.push(i18nLoader.loadResources(resources, this.translateService.currentLang).pipe(take(1), tap((loadedResources) => {
|
|
1694
|
+
// add the new set of translations to the current language
|
|
1695
|
+
this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
|
|
1696
|
+
})));
|
|
1697
|
+
// if the current language is different than the DEFAULT language
|
|
1698
|
+
const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
|
|
1699
|
+
if (this.translateService.currentLang !== defaultLang) {
|
|
1700
|
+
// manually load the resources for the default language and add them to the translate service
|
|
1701
|
+
langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
|
|
1702
|
+
this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
|
|
1703
|
+
})));
|
|
1704
|
+
}
|
|
1705
|
+
return forkJoin(langSubscription).pipe(map((loadedResourcesArr) => !loadedResourcesArr[0].hasError ? { success: true } : { success: false, error: loadedResourcesArr[0].errors }), tap(() => {
|
|
1706
|
+
// emit status of module loading progress
|
|
1707
|
+
this.onModuleLoad.next({ ready: true, name: moduleName });
|
|
1708
|
+
}), catchError((error) => {
|
|
1709
|
+
// emit status of module loading progress
|
|
1710
|
+
this.onModuleLoad.next({ ready: true, name: moduleName, error });
|
|
1711
|
+
return of({ success: false, error });
|
|
1712
|
+
}));
|
|
1713
|
+
}
|
|
1714
|
+
else {
|
|
1715
|
+
return of({ success: false, error: 'currentLoader is not an I18nLoader.' });
|
|
1883
1716
|
}
|
|
1884
|
-
// deserialize state
|
|
1885
|
-
let state = JSON.parse(serializedState);
|
|
1886
|
-
// filter AppState and replace
|
|
1887
|
-
state = { ...state, app: filterAppState(state?.app) };
|
|
1888
|
-
return state;
|
|
1889
1717
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1718
|
+
/**
|
|
1719
|
+
* Prepares the default language
|
|
1720
|
+
*/
|
|
1721
|
+
preparedDefaultLanguage() {
|
|
1722
|
+
const browserPref = getBrowserDefaultLanguage();
|
|
1723
|
+
// If user has browser preferred lang, and that language is part of the languages array
|
|
1724
|
+
if (browserPref && this.config.languages && EuiEuLanguages.getLanguageCodes(this.config.languages).includes(browserPref)) {
|
|
1725
|
+
return browserPref;
|
|
1726
|
+
}
|
|
1727
|
+
return this.config.defaultLanguage;
|
|
1892
1728
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
//
|
|
1899
|
-
|
|
1900
|
-
//
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
if (localState) {
|
|
1906
|
-
// TODO: Why all these checks here? What is the purpose of this code?
|
|
1907
|
-
// extract the details about user and app version from the storage state
|
|
1908
|
-
const localVersion = localState?.app?.version;
|
|
1909
|
-
// const localUserId = localState.user && localState.user.userId;
|
|
1910
|
-
const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
|
|
1911
|
-
// const isUserIdOK = (localUserId === payloadUserId);
|
|
1912
|
-
// update the entire state with deep merge of states, if the version and user are the same
|
|
1913
|
-
if (isVersionOK) {
|
|
1914
|
-
state = extend(true, {}, state, localState);
|
|
1729
|
+
/**
|
|
1730
|
+
* @param default_language if given default language to override default language coming from the
|
|
1731
|
+
* configuration token.
|
|
1732
|
+
*/
|
|
1733
|
+
setup(initLanguage) {
|
|
1734
|
+
// use the default config as a reference base
|
|
1735
|
+
this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
|
|
1736
|
+
// configure the translate config service
|
|
1737
|
+
if (this.config.languages) {
|
|
1738
|
+
this.translateService.addLangs(EuiEuLanguages.getLanguageCodes(this.config.languages));
|
|
1739
|
+
if (this.logService) {
|
|
1740
|
+
this.logService.info(`I18n accepted languages set to ${EuiEuLanguages.getLanguageCodes(this.config.languages)}`);
|
|
1915
1741
|
}
|
|
1916
1742
|
}
|
|
1917
|
-
//
|
|
1918
|
-
|
|
1919
|
-
|
|
1743
|
+
// set the current language, causing to load translations
|
|
1744
|
+
return this.translateService.use(initLanguage).pipe(tap(() => {
|
|
1745
|
+
this.bindActiveLangStateToTranslateService();
|
|
1746
|
+
this.bindTranslateServiceLangChangeToState();
|
|
1747
|
+
if (this.config.defaultLanguage) {
|
|
1748
|
+
this.setDefaultLanguage(this.config.defaultLanguage);
|
|
1749
|
+
}
|
|
1750
|
+
}), map(() => {
|
|
1751
|
+
if (this.translateService.currentLoader instanceof I18nLoader) {
|
|
1752
|
+
const failedResources = this.translateService.currentLoader.getFailedResources();
|
|
1753
|
+
if (failedResources.length > 0) {
|
|
1754
|
+
return { success: false, error: failedResources };
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return { success: true };
|
|
1758
|
+
}), catchError((error) => of({ success: false, error })));
|
|
1759
|
+
}
|
|
1760
|
+
bindActiveLangStateToTranslateService() {
|
|
1761
|
+
this.store.select(getActiveLang).subscribe((lang) => {
|
|
1762
|
+
if (lang !== null && this.translateService.currentLang !== lang) {
|
|
1763
|
+
this.use(lang);
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
bindTranslateServiceLangChangeToState() {
|
|
1768
|
+
this.translateService.onLangChange.subscribe((event) => {
|
|
1769
|
+
if (this.stateInstance.activeLang !== event.lang) {
|
|
1770
|
+
this.updateState({ activeLang: event.lang });
|
|
1771
|
+
}
|
|
1772
|
+
if (this.logService) {
|
|
1773
|
+
this.logService.info(`I18n current language set to ${event.lang}`);
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
setDefaultLanguage(defaultLanguage) {
|
|
1778
|
+
// removed, current language is already calculated in init, setup function fill use it directly, not default
|
|
1779
|
+
// this.translateService.currentLang = default_language || this.config.defaultLanguage;
|
|
1780
|
+
this.translateService.setDefaultLang(defaultLanguage);
|
|
1781
|
+
if (this.logService) {
|
|
1782
|
+
this.logService.info(`I18n default language set to ${defaultLanguage}`);
|
|
1920
1783
|
}
|
|
1921
1784
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1785
|
+
/**
|
|
1786
|
+
* change the currently used language
|
|
1787
|
+
*
|
|
1788
|
+
* @param lang is the language code based on the convention you used e.g. (en or en-EN)
|
|
1789
|
+
* @returns Observable that returns an object contain the object translation for given language after language
|
|
1790
|
+
* fully loaded.
|
|
1791
|
+
*/
|
|
1792
|
+
use(lang) {
|
|
1793
|
+
return this.translateService.use(lang);
|
|
1928
1794
|
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1795
|
+
/**
|
|
1796
|
+
* updates the HTML element lang attribute
|
|
1797
|
+
*
|
|
1798
|
+
* @private
|
|
1799
|
+
*/
|
|
1800
|
+
updateHTMLDOMLang(lang) {
|
|
1801
|
+
this.document.documentElement.lang = lang;
|
|
1935
1802
|
}
|
|
1936
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1937
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1803
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$3.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1804
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nService, providedIn: 'root' }); }
|
|
1938
1805
|
}
|
|
1939
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1940
|
-
type: Injectable
|
|
1941
|
-
|
|
1806
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nService, decorators: [{
|
|
1807
|
+
type: Injectable,
|
|
1808
|
+
args: [{
|
|
1809
|
+
providedIn: 'root',
|
|
1810
|
+
}]
|
|
1811
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1812
|
+
type: Inject,
|
|
1813
|
+
args: [GLOBAL_CONFIG_TOKEN]
|
|
1814
|
+
}] }, { type: i1$3.TranslateService }, { type: LogService, decorators: [{
|
|
1815
|
+
type: Optional
|
|
1816
|
+
}] }, { type: StoreService }, { type: Document, decorators: [{
|
|
1817
|
+
type: Inject,
|
|
1818
|
+
args: [DOCUMENT]
|
|
1819
|
+
}] }]; } });
|
|
1942
1820
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
*/
|
|
1948
|
-
static forRoot() {
|
|
1949
|
-
return {
|
|
1950
|
-
ngModule: CoreModule,
|
|
1951
|
-
providers: [
|
|
1952
|
-
{
|
|
1953
|
-
provide: EuiCoreRootGuardClass,
|
|
1954
|
-
useFactory: euiCoreRootGuardClass,
|
|
1955
|
-
deps: [],
|
|
1956
|
-
},
|
|
1957
|
-
{
|
|
1958
|
-
provide: CORE_ROOT_GUARD,
|
|
1959
|
-
useFactory: createEuiCoreRootGuard,
|
|
1960
|
-
deps: [[EuiCoreRootGuardClass, new Optional(), new SkipSelf()]],
|
|
1961
|
-
},
|
|
1962
|
-
...getCoreProviders(),
|
|
1963
|
-
],
|
|
1964
|
-
};
|
|
1821
|
+
class I18nServiceMock extends I18nService {
|
|
1822
|
+
constructor() {
|
|
1823
|
+
super(null, null, null, null, null);
|
|
1824
|
+
this.DEFAULT_LANGUAGE = 'en';
|
|
1965
1825
|
}
|
|
1966
|
-
|
|
1967
|
-
return
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
};
|
|
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 });
|
|
1971
1844
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
if (parentModule) {
|
|
1975
|
-
// extract the i18n service and the i18n loader config
|
|
1976
|
-
// todo, this thing should be achieved by store, and localization service dependency should be removed
|
|
1977
|
-
const storeService = injector.get(StoreService);
|
|
1978
|
-
const moduleName = injector.get(MODULE_NAME_TOKEN);
|
|
1979
|
-
const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
|
|
1980
|
-
storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
|
|
1981
|
-
}
|
|
1845
|
+
lazyLoadInit() {
|
|
1846
|
+
return of({ success: true });
|
|
1982
1847
|
}
|
|
1983
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1984
|
-
/** @nocollapse */ static { this.ɵ
|
|
1985
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: CoreModule }); }
|
|
1848
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1849
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nServiceMock }); }
|
|
1986
1850
|
}
|
|
1987
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
1988
|
-
type:
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
throw new TypeError(`CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.`);
|
|
1851
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: I18nServiceMock, decorators: [{
|
|
1852
|
+
type: Injectable
|
|
1853
|
+
}], ctorParameters: function () { return []; } });
|
|
1854
|
+
|
|
1855
|
+
const diffDays = (dateStart, dateEnd) => Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
|
|
1856
|
+
const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Provides read-only equivalent of jQuery's position function:
|
|
1860
|
+
* http://api.jquery.com/position/
|
|
1861
|
+
*/
|
|
1862
|
+
const position = (nativeEl) => {
|
|
1863
|
+
let elBCR = offset(nativeEl);
|
|
1864
|
+
let offsetParentBCR = { top: 0, left: 0 };
|
|
1865
|
+
let offsetParentEl = parentOffsetEl(nativeEl);
|
|
1866
|
+
if (offsetParentEl !== document) {
|
|
1867
|
+
offsetParentBCR = offset(offsetParentEl);
|
|
1868
|
+
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
|
|
1869
|
+
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
|
|
2007
1870
|
}
|
|
2008
|
-
|
|
1871
|
+
let boundingClientRect = nativeEl.getBoundingClientRect();
|
|
1872
|
+
return {
|
|
1873
|
+
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
1874
|
+
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
1875
|
+
top: elBCR.top - offsetParentBCR.top,
|
|
1876
|
+
left: elBCR.left - offsetParentBCR.left,
|
|
1877
|
+
};
|
|
2009
1878
|
};
|
|
2010
|
-
class EuiCoreRootGuardClass {
|
|
2011
|
-
constructor() { }
|
|
2012
|
-
}
|
|
2013
|
-
const euiCoreRootGuardClass = () => new EuiCoreRootGuardClass();
|
|
2014
|
-
|
|
2015
1879
|
/**
|
|
2016
|
-
*
|
|
2017
|
-
*
|
|
2018
|
-
* @param envConfig the current environment configuration
|
|
2019
|
-
* @returns the updated environment configuration, as a promise
|
|
1880
|
+
* Provides read-only equivalent of jQuery's offset function:
|
|
1881
|
+
* http://api.jquery.com/offset/
|
|
2020
1882
|
*/
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
1883
|
+
const offset = (nativeEl) => {
|
|
1884
|
+
let boundingClientRect = nativeEl.getBoundingClientRect();
|
|
1885
|
+
return {
|
|
1886
|
+
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
1887
|
+
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
1888
|
+
top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
|
|
1889
|
+
left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft),
|
|
1890
|
+
};
|
|
1891
|
+
};
|
|
1892
|
+
// PRIVATE FUNCTIONS
|
|
1893
|
+
const getStyle = (nativeEl, cssProp) => {
|
|
1894
|
+
// IE
|
|
1895
|
+
if (nativeEl.currentStyle) {
|
|
1896
|
+
return nativeEl.currentStyle[cssProp];
|
|
2028
1897
|
}
|
|
2029
|
-
|
|
2030
|
-
|
|
1898
|
+
if (window.getComputedStyle) {
|
|
1899
|
+
return window.getComputedStyle(nativeEl)[cssProp];
|
|
1900
|
+
}
|
|
1901
|
+
// finally try and get inline style
|
|
1902
|
+
return nativeEl.style[cssProp];
|
|
1903
|
+
};
|
|
2031
1904
|
/**
|
|
2032
|
-
*
|
|
2033
|
-
*
|
|
2034
|
-
* @param url the path to the configuration
|
|
2035
|
-
* @param timeout possible timeout
|
|
2036
|
-
* @returns EuiAppJsonConfig promise
|
|
1905
|
+
* Checks if a given element is statically positioned
|
|
2037
1906
|
*/
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
1907
|
+
const isStaticPositioned = (nativeEl) => (getStyle(nativeEl, 'position') || 'static') === 'static';
|
|
1908
|
+
/**
|
|
1909
|
+
* returns the closest, non-statically positioned parentOffset of a given element
|
|
1910
|
+
* @param nativeEl
|
|
1911
|
+
*/
|
|
1912
|
+
const parentOffsetEl = (nativeEl) => {
|
|
1913
|
+
let offsetParent = nativeEl.offsetParent || document;
|
|
1914
|
+
while (offsetParent && offsetParent !== document && isStaticPositioned(offsetParent)) {
|
|
1915
|
+
offsetParent = offsetParent.offsetParent;
|
|
1916
|
+
}
|
|
1917
|
+
return offsetParent || document;
|
|
1918
|
+
};
|
|
1919
|
+
const getViewElement = (fixture, componentClass, klass) => {
|
|
1920
|
+
let de, el, domElement;
|
|
1921
|
+
de = fixture.debugElement.query(By.css(componentClass));
|
|
1922
|
+
if (de) {
|
|
1923
|
+
el = de.nativeElement;
|
|
1924
|
+
if (el && klass) {
|
|
1925
|
+
domElement = el.querySelectorAll(klass);
|
|
1926
|
+
if (domElement.length <= 1) {
|
|
1927
|
+
domElement = el.querySelector(klass);
|
|
1928
|
+
}
|
|
2047
1929
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
1930
|
+
}
|
|
1931
|
+
return { de, el, domElement };
|
|
1932
|
+
};
|
|
1933
|
+
const closestMatchingParent = (target, className) => {
|
|
1934
|
+
let element = target;
|
|
1935
|
+
while (element && element.nodeType === Node.ELEMENT_NODE) {
|
|
1936
|
+
if (element.classList.contains(className)) {
|
|
1937
|
+
return element;
|
|
2051
1938
|
}
|
|
1939
|
+
element = element.parentElement;
|
|
2052
1940
|
}
|
|
2053
|
-
// the dynamic config is not loaded
|
|
2054
1941
|
return null;
|
|
2055
|
-
}
|
|
1942
|
+
};
|
|
2056
1943
|
|
|
2057
|
-
const
|
|
2058
|
-
|
|
1944
|
+
const consumeEvent = (event) => {
|
|
1945
|
+
if (event) {
|
|
1946
|
+
event.preventDefault();
|
|
1947
|
+
event.stopPropagation();
|
|
1948
|
+
event.cancelBubble = true;
|
|
1949
|
+
}
|
|
1950
|
+
return false;
|
|
2059
1951
|
};
|
|
2060
|
-
|
|
2061
|
-
|
|
1952
|
+
|
|
1953
|
+
const forOwn = (object, iteratee) => {
|
|
1954
|
+
object = Object(object);
|
|
1955
|
+
Object.keys(object).forEach((key) => iteratee(object[key], key, object));
|
|
2062
1956
|
};
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
if (
|
|
2067
|
-
|
|
1957
|
+
const markFormGroupTouched = (FormControls) => {
|
|
1958
|
+
const markFormGroupTouchedRecursive = (controls) => {
|
|
1959
|
+
forOwn(controls, (c) => {
|
|
1960
|
+
if (c instanceof FormGroup || c instanceof FormArray) {
|
|
1961
|
+
markFormGroupTouchedRecursive(c.controls);
|
|
2068
1962
|
}
|
|
2069
1963
|
else {
|
|
2070
|
-
|
|
1964
|
+
c.markAsTouched();
|
|
1965
|
+
c.updateValueAndValidity();
|
|
2071
1966
|
}
|
|
1967
|
+
});
|
|
1968
|
+
};
|
|
1969
|
+
markFormGroupTouchedRecursive(FormControls);
|
|
1970
|
+
};
|
|
1971
|
+
const markControlsTouched = (group) => {
|
|
1972
|
+
Object.keys(group.controls).forEach((key) => {
|
|
1973
|
+
const abstractControl = group.controls[key];
|
|
1974
|
+
if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
|
|
1975
|
+
markControlsTouched(abstractControl);
|
|
2072
1976
|
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
1977
|
+
else {
|
|
1978
|
+
abstractControl.markAsTouched();
|
|
1979
|
+
}
|
|
1980
|
+
});
|
|
1981
|
+
};
|
|
1982
|
+
const validateEmail = (c) => {
|
|
1983
|
+
const EMAIL_REGEXP =
|
|
1984
|
+
// eslint-disable-next-line max-len, no-useless-escape
|
|
1985
|
+
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1986
|
+
const error = {
|
|
1987
|
+
validateEmail: {
|
|
1988
|
+
valid: false,
|
|
1989
|
+
},
|
|
1990
|
+
};
|
|
1991
|
+
return EMAIL_REGEXP.test(c.value) ? null : error;
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
/**
|
|
1995
|
+
* returns a random string with radix=36
|
|
1996
|
+
*/
|
|
1997
|
+
const uniqueId = () => Math.random().toString(36).substr(2, 9);
|
|
1998
|
+
/**
|
|
1999
|
+
* Its job is to parse number and format it based on given input.
|
|
2000
|
+
* @param value can be a number or a string number
|
|
2001
|
+
* @param fractionSize size of fraction of a number e.g. 1000.88 fraction is 2 (88) default is 2
|
|
2002
|
+
* @param inDecimalSeparator separator for decimal part of the number default is ','
|
|
2003
|
+
* @param inThousandSeparator separator for the whole part of the number default is ''
|
|
2004
|
+
*/
|
|
2005
|
+
const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThousandSeparator = '') => {
|
|
2006
|
+
if (inDecimalSeparator || inThousandSeparator) {
|
|
2007
|
+
console.warn('The inDecimalSeparator and inThousandSeparator are deprecated. They will be a ' +
|
|
2008
|
+
'BREAKING CHANGE for eUI 9 and be replaced by localization strategy.');
|
|
2009
|
+
}
|
|
2010
|
+
let decimalSeparator = '';
|
|
2011
|
+
let thousandsSeparator = '';
|
|
2012
|
+
if (value === null || value === undefined) {
|
|
2013
|
+
return null;
|
|
2014
|
+
}
|
|
2015
|
+
if (typeof value === 'string') {
|
|
2016
|
+
// get all non characters
|
|
2017
|
+
let nonChars = value.match(/[^0-9]+/g) || [];
|
|
2018
|
+
// get all unique chars
|
|
2019
|
+
let uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
|
|
2020
|
+
// get separators
|
|
2021
|
+
let separators = Array.from(uniqueChars.keys());
|
|
2022
|
+
// sense where decimal separator and where thousand separator is
|
|
2023
|
+
if (separators.length > 1) {
|
|
2024
|
+
// left detected separator will be thousand and second will be decimal
|
|
2025
|
+
thousandsSeparator = separators[0];
|
|
2026
|
+
decimalSeparator = separators[1];
|
|
2027
|
+
}
|
|
2028
|
+
else if (separators.length > 0) {
|
|
2029
|
+
// in case there is only one separator you don't know exactly who this separator is.
|
|
2030
|
+
// in case there are more than two occurrences means we have a thousand otherwise we'll
|
|
2031
|
+
// agree by conventions that is decimal
|
|
2032
|
+
if (nonChars.length > 1) {
|
|
2033
|
+
return value
|
|
2034
|
+
.split(separators[0])
|
|
2035
|
+
.join('')
|
|
2036
|
+
.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2037
|
+
}
|
|
2038
|
+
else {
|
|
2039
|
+
return value.replace(separators[0], inDecimalSeparator).replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2040
|
+
}
|
|
2083
2041
|
}
|
|
2042
|
+
else {
|
|
2043
|
+
// in case there are no separators then only format based on thousand one
|
|
2044
|
+
return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2045
|
+
}
|
|
2046
|
+
// do the replacement of separators and parseInt
|
|
2047
|
+
// Beware! Always replace thousand separator first and then decimal
|
|
2048
|
+
value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
|
|
2084
2049
|
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2050
|
+
decimalSeparator = inDecimalSeparator;
|
|
2051
|
+
thousandsSeparator = inThousandSeparator;
|
|
2052
|
+
const maxFraction = '0'.repeat(fractionSize);
|
|
2053
|
+
let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
|
|
2054
|
+
fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
|
|
2055
|
+
// this rule makes sense only in number in case fraction is all zero
|
|
2056
|
+
fraction = typeof value === 'number' && fraction === maxFraction ? '' : decimalSeparator + fraction;
|
|
2057
|
+
return integer.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator) + fraction;
|
|
2058
|
+
};
|
|
2094
2059
|
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
handleError(error) {
|
|
2101
|
-
// log error
|
|
2102
|
-
this.logService.error(error.message || error.toString());
|
|
2103
|
-
// throw error;
|
|
2104
|
-
super.handleError(error);
|
|
2105
|
-
}
|
|
2106
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2107
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' }); }
|
|
2108
|
-
}
|
|
2109
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: GlobalErrorHandler, decorators: [{
|
|
2110
|
-
type: Injectable,
|
|
2111
|
-
args: [{
|
|
2112
|
-
providedIn: 'root',
|
|
2113
|
-
}]
|
|
2114
|
-
}], ctorParameters: function () { return [{ type: LogService }]; } });
|
|
2060
|
+
const handleError = (error) => {
|
|
2061
|
+
let errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
|
2062
|
+
// console.error(errMsg);
|
|
2063
|
+
return throwError(errMsg);
|
|
2064
|
+
};
|
|
2115
2065
|
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
}
|
|
2132
|
-
else if (typeof rule === 'function') {
|
|
2133
|
-
// callback function
|
|
2134
|
-
rule.call(null, error, this.injector);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
}));
|
|
2066
|
+
/**
|
|
2067
|
+
* check if a value is null or undefined. If it's not both returns true otherwise false
|
|
2068
|
+
*
|
|
2069
|
+
* @param value
|
|
2070
|
+
*/
|
|
2071
|
+
const isDefined = (value) => value !== undefined && value !== null;
|
|
2072
|
+
|
|
2073
|
+
class EuiPermissionService extends EuiService {
|
|
2074
|
+
constructor(log, store) {
|
|
2075
|
+
super([]);
|
|
2076
|
+
this.log = log;
|
|
2077
|
+
this.store = store;
|
|
2078
|
+
if (log) {
|
|
2079
|
+
this.logger = log.getLogger('core.PermissionService');
|
|
2080
|
+
}
|
|
2138
2081
|
}
|
|
2139
2082
|
/**
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
* @param error http error response
|
|
2143
|
-
* @returns HttpErrorRouteConfig or null
|
|
2083
|
+
* initialize the service by providing a state
|
|
2084
|
+
* @param rights
|
|
2144
2085
|
*/
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
return
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2086
|
+
init(rights) {
|
|
2087
|
+
super.initEuiService();
|
|
2088
|
+
if (Array.isArray(rights)) {
|
|
2089
|
+
this.updateState(rights);
|
|
2090
|
+
return of({ success: true });
|
|
2091
|
+
}
|
|
2092
|
+
if (this.logger) {
|
|
2093
|
+
this.logger.error('Init object should be instance of BaseUserState');
|
|
2094
|
+
}
|
|
2095
|
+
return of({ success: false, error: 'Init object should be instance of BaseUserState' });
|
|
2153
2096
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
}
|
|
2157
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
|
|
2158
|
-
type: Injectable
|
|
2159
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2160
|
-
type: Inject,
|
|
2161
|
-
args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
|
|
2162
|
-
}] }, { type: i0.Injector }, { type: i2$1.Router }]; } });
|
|
2163
|
-
|
|
2164
|
-
// import { UxAppShellService } from '../ux-app-shell.service';
|
|
2165
|
-
function AlertHttpErrorCallbackFn(error) {
|
|
2166
|
-
alert(error.statusText);
|
|
2167
|
-
}
|
|
2168
|
-
function ConsoleHttpErrorCallbackFn(error) {
|
|
2169
|
-
console.error('HttpError', error);
|
|
2170
|
-
}
|
|
2171
|
-
function LogHttpErrorCallbackFn(error, injector) {
|
|
2172
|
-
const logService = injector.get(LogService);
|
|
2173
|
-
logService.error('HttpError', error);
|
|
2174
|
-
}
|
|
2175
|
-
function GrowlHttpErrorCallbackFn(error, injector) {
|
|
2176
|
-
// TODO v17 should not display growl from here but from where it's called
|
|
2177
|
-
// const asService = injector.get(UxAppShellService);
|
|
2178
|
-
// asService.growlError(error.statusText);
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
class ApiQueueService {
|
|
2182
|
-
constructor(store, http, logService) {
|
|
2183
|
-
this.store = store;
|
|
2184
|
-
this.http = http;
|
|
2185
|
-
this.logService = logService;
|
|
2097
|
+
get userRights() {
|
|
2098
|
+
return this.stateInstance;
|
|
2186
2099
|
}
|
|
2187
2100
|
/**
|
|
2188
|
-
*
|
|
2189
|
-
* @param id - The id of the item inside the queue.
|
|
2190
|
-
* WARNING if matches any other queue item id will overwrite it.
|
|
2191
|
-
* @param item - an item for Queue
|
|
2101
|
+
* get the user's Rights from the state
|
|
2192
2102
|
*/
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
if (allowedMethods.indexOf(item.method) < 0) {
|
|
2196
|
-
throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
|
|
2197
|
-
}
|
|
2198
|
-
this.store.dispatch(new AddApiQueueItemAction({ id, item }));
|
|
2103
|
+
getState() {
|
|
2104
|
+
return this.store.select(getUserRights);
|
|
2199
2105
|
}
|
|
2200
2106
|
/**
|
|
2201
|
-
*
|
|
2202
|
-
* @
|
|
2107
|
+
* update the state with the given user's rights
|
|
2108
|
+
* @param rights
|
|
2203
2109
|
*/
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
const queueArray = queue && Object.values(queue);
|
|
2207
|
-
if (!queueArray || queueArray.length < 1) {
|
|
2208
|
-
this.logService.warn('No items in the queue exist.');
|
|
2209
|
-
}
|
|
2210
|
-
return queueArray;
|
|
2211
|
-
}));
|
|
2110
|
+
updateState(rights) {
|
|
2111
|
+
this.store.dispatch(new UpdateUserRightsAction(rights || []));
|
|
2212
2112
|
}
|
|
2213
2113
|
/**
|
|
2214
|
-
*
|
|
2215
|
-
*
|
|
2216
|
-
*
|
|
2114
|
+
* accepts a string of right and or a permission. In string first comes the right and or followed by permission in
|
|
2115
|
+
* a dot separated way e.g. 'RIGHT.PERMISSION' or 'RIGHT'. The string can contain more that 2 separated fields.
|
|
2116
|
+
* In that case the last field should be the permission and all the others a Right. e.g. 'RIGHT1.RIGHT2.PERMISSION'
|
|
2117
|
+
* The last part is useful where you want a user to have multiple rights and the permission of the last right.
|
|
2118
|
+
* @param rightsAndPermission
|
|
2217
2119
|
*/
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2120
|
+
checkAttributePermission(rightsAndPermission) {
|
|
2121
|
+
const permProps = rightsAndPermission.split('.');
|
|
2122
|
+
const rightId = permProps[0];
|
|
2123
|
+
const hasRight = this.checkRight(rightId);
|
|
2124
|
+
if (hasRight) {
|
|
2125
|
+
if (permProps.length === 2) {
|
|
2126
|
+
// in case of 'RIGHT.PERMISSION'
|
|
2127
|
+
const permission = permProps[1];
|
|
2128
|
+
return this.checkPermission(rightId, permission);
|
|
2223
2129
|
}
|
|
2224
|
-
|
|
2225
|
-
|
|
2130
|
+
else if (permProps.length > 2) {
|
|
2131
|
+
// in case of 'RIGHT1.RIGHT2.....PERMISSION' string call recursively
|
|
2132
|
+
return this.checkAttributePermission(rightsAndPermission.slice(rightId.length + 1));
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
return hasRight;
|
|
2226
2136
|
}
|
|
2227
2137
|
/**
|
|
2228
|
-
*
|
|
2229
|
-
* @param
|
|
2138
|
+
* check if a user has the right.
|
|
2139
|
+
* @param rightId the id of Right
|
|
2230
2140
|
*/
|
|
2231
|
-
|
|
2232
|
-
this.
|
|
2141
|
+
checkRight(rightId) {
|
|
2142
|
+
return this.userRights.some((right) => right && right.id === rightId);
|
|
2233
2143
|
}
|
|
2234
2144
|
/**
|
|
2235
|
-
*
|
|
2145
|
+
* check if a user has that right and that right has the permission given.
|
|
2146
|
+
* @param rightId the right of the user
|
|
2147
|
+
* @param permission the permission of the right
|
|
2236
2148
|
*/
|
|
2237
|
-
|
|
2238
|
-
|
|
2149
|
+
checkPermission(rightId, permission) {
|
|
2150
|
+
// the user has to have that right and that right has to have the given permission
|
|
2151
|
+
return this.userRights.some((right) => right && right.id === rightId && right.permissions && right.permissions.includes(permission));
|
|
2239
2152
|
}
|
|
2240
2153
|
/**
|
|
2241
|
-
*
|
|
2242
|
-
* @param
|
|
2243
|
-
* @return An Observable of type any
|
|
2154
|
+
* checks whether a user have all rights passed as an argument
|
|
2155
|
+
* @param rights an array of EuiUserRight
|
|
2244
2156
|
*/
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2157
|
+
haveAllRights(rights) {
|
|
2158
|
+
if (!isDefined(rights)) {
|
|
2159
|
+
throw Error(`The rights should be an array but instead it's not defined!`);
|
|
2160
|
+
}
|
|
2161
|
+
return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
|
|
2162
|
+
}
|
|
2163
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiPermissionService, deps: [{ token: LogService, optional: true }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2164
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiPermissionService, providedIn: 'root' }); }
|
|
2165
|
+
}
|
|
2166
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiPermissionService, decorators: [{
|
|
2167
|
+
type: Injectable,
|
|
2168
|
+
args: [{
|
|
2169
|
+
providedIn: 'root',
|
|
2170
|
+
}]
|
|
2171
|
+
}], ctorParameters: function () { return [{ type: LogService, decorators: [{
|
|
2172
|
+
type: Optional
|
|
2173
|
+
}] }, { type: StoreService }]; } });
|
|
2174
|
+
|
|
2175
|
+
class EuiDynamicMenuService {
|
|
2176
|
+
// TODO: it should be moved euiservice, or it should be static
|
|
2177
|
+
// TODO: can we moved that service inside the module of the component that's using it?
|
|
2178
|
+
constructor(euiPermission, store) {
|
|
2179
|
+
this.euiPermission = euiPermission;
|
|
2180
|
+
this.store = store;
|
|
2181
|
+
this.menuLinks = [];
|
|
2182
|
+
this.store.select(getUserState).subscribe((user) => {
|
|
2183
|
+
if (user.menuLinks) {
|
|
2184
|
+
this.menuLinks = user.menuLinks;
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
getMenuLinks() {
|
|
2189
|
+
return this.menuLinks;
|
|
2190
|
+
}
|
|
2191
|
+
filterEuiMenuItemsWithRights(links) {
|
|
2192
|
+
return links.filter((link) => {
|
|
2193
|
+
if (link.hasChildren) {
|
|
2194
|
+
link.children = this.filterEuiMenuItemsWithRights(link.children);
|
|
2250
2195
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
* @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
|
|
2257
|
-
* @return An Observable with an array which contains all responses from all items in queue.
|
|
2258
|
-
*/
|
|
2259
|
-
processAllQueueItems(continueOnError = true) {
|
|
2260
|
-
return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
|
|
2261
|
-
this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
|
|
2262
|
-
if (!continueOnError) {
|
|
2263
|
-
throw error;
|
|
2196
|
+
// First check if the user is denied access:
|
|
2197
|
+
if (link.deniedRightId) {
|
|
2198
|
+
if (this.euiPermission.checkRight(link.deniedRightId)) {
|
|
2199
|
+
return false;
|
|
2200
|
+
}
|
|
2264
2201
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2202
|
+
if (link.deniedRightIds) {
|
|
2203
|
+
for (const deniedRightId of link.deniedRightIds) {
|
|
2204
|
+
if (this.euiPermission.checkRight(deniedRightId)) {
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
// Then check if the user needs to be allowed access explicitly:
|
|
2210
|
+
if (link.allowedRightId) {
|
|
2211
|
+
return this.euiPermission.checkRight(link.allowedRightId);
|
|
2212
|
+
}
|
|
2213
|
+
if (link.allowedRightIds) {
|
|
2214
|
+
for (const allowedRightId of link.allowedRightIds) {
|
|
2215
|
+
if (this.euiPermission.checkRight(allowedRightId)) {
|
|
2216
|
+
return true;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
// User doesn't have one of the allowed rights. Deny access:
|
|
2220
|
+
return false;
|
|
2221
|
+
}
|
|
2222
|
+
// Access to the menu item is not denied, therefore allow it:
|
|
2223
|
+
return true;
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicMenuService, deps: [{ token: EuiPermissionService }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2227
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicMenuService, providedIn: 'root' }); }
|
|
2228
|
+
}
|
|
2229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicMenuService, decorators: [{
|
|
2230
|
+
type: Injectable,
|
|
2231
|
+
args: [{
|
|
2232
|
+
providedIn: 'root',
|
|
2233
|
+
}]
|
|
2234
|
+
}], ctorParameters: function () { return [{ type: EuiPermissionService }, { type: StoreService }]; } });
|
|
2235
|
+
|
|
2236
|
+
const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
|
|
2237
|
+
class EuiDynamicComponentService {
|
|
2238
|
+
constructor(componentFactoryResolver, injector, appRef) {
|
|
2239
|
+
this.componentFactoryResolver = componentFactoryResolver;
|
|
2240
|
+
this.injector = injector;
|
|
2241
|
+
this.appRef = appRef;
|
|
2267
2242
|
}
|
|
2268
2243
|
/**
|
|
2269
|
-
*
|
|
2270
|
-
*
|
|
2271
|
-
*
|
|
2272
|
-
* @param
|
|
2244
|
+
* Adds a component to portal host dynamically
|
|
2245
|
+
* @param component The component to be injected
|
|
2246
|
+
* @param el The element reference for the component to be injected
|
|
2247
|
+
* @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
|
|
2273
2248
|
*/
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2249
|
+
add(component, el, config) {
|
|
2250
|
+
// TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
|
|
2251
|
+
// Create a portalHost from a DOM element
|
|
2252
|
+
this.portalHost = new DomPortalOutlet(el ? el.nativeElement : document.body, this.componentFactoryResolver, this.appRef, this.injector);
|
|
2253
|
+
// Locate the component factory for the ComponentToIncludeDynamicallyComponent
|
|
2254
|
+
this.portal = new ComponentPortal(component, null, config ? this.createInjector(config) : null);
|
|
2255
|
+
// Attach portal to host
|
|
2256
|
+
this.portalComponentInstance = this.portalHost.attach(this.portal);
|
|
2257
|
+
if (config) {
|
|
2258
|
+
Object.assign(config, {
|
|
2259
|
+
portalHostRef: this.portalHost,
|
|
2260
|
+
portalRef: this.portal,
|
|
2261
|
+
portalComponentInstanceRef: this.portalComponentInstance,
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
return {
|
|
2265
|
+
portalHost: this.portalHost,
|
|
2266
|
+
portal: this.portal,
|
|
2267
|
+
portalComponentInstance: this.portalComponentInstance,
|
|
2268
|
+
};
|
|
2278
2269
|
}
|
|
2279
2270
|
/**
|
|
2280
|
-
*
|
|
2281
|
-
* @param
|
|
2282
|
-
* @param b - Date two
|
|
2283
|
-
*
|
|
2284
|
-
* @beta
|
|
2271
|
+
* detaches a portalHost
|
|
2272
|
+
* @param portalHostRef reference of portal host to be detached
|
|
2285
2273
|
*/
|
|
2286
|
-
|
|
2287
|
-
|
|
2274
|
+
remove(portalHostRef) {
|
|
2275
|
+
portalHostRef.detach();
|
|
2276
|
+
this.portalHost = null;
|
|
2277
|
+
this.portal = null;
|
|
2278
|
+
this.portalComponentInstance = null;
|
|
2288
2279
|
}
|
|
2289
2280
|
/**
|
|
2290
|
-
*
|
|
2291
|
-
*
|
|
2292
|
-
* @param id - id of the item inside the queue
|
|
2293
|
-
* @param item - the item of the queue that matches the id.
|
|
2294
|
-
* @return An Observable of HttpClient Request
|
|
2281
|
+
* creates a custom injector to be used when providing custom injection tokens to components inside a portal
|
|
2282
|
+
* @param data to be used by DYNAMIC_COMPONENT_CONFIG token
|
|
2295
2283
|
*/
|
|
2296
|
-
|
|
2297
|
-
|
|
2284
|
+
createInjector(data) {
|
|
2285
|
+
const injectorTokens = new WeakMap();
|
|
2286
|
+
injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
|
|
2287
|
+
return new PortalInjector(this.injector, injectorTokens);
|
|
2298
2288
|
}
|
|
2299
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2300
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2289
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicComponentService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2290
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicComponentService }); }
|
|
2301
2291
|
}
|
|
2302
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2303
|
-
type: Injectable
|
|
2304
|
-
|
|
2305
|
-
providedIn: 'root',
|
|
2306
|
-
}]
|
|
2307
|
-
}], ctorParameters: function () { return [{ type: StoreService }, { type: i1$2.HttpClient }, { type: LogService }]; } });
|
|
2292
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiDynamicComponentService, decorators: [{
|
|
2293
|
+
type: Injectable
|
|
2294
|
+
}], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }]; } });
|
|
2308
2295
|
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2296
|
+
const initialState = {
|
|
2297
|
+
appName: '',
|
|
2298
|
+
appShortName: '',
|
|
2299
|
+
appSubTitle: '',
|
|
2300
|
+
appBaseFontSize: '',
|
|
2301
|
+
userInfos: null,
|
|
2302
|
+
userSubInfos: null,
|
|
2303
|
+
impersonatedUserInfos: null,
|
|
2304
|
+
isSidebarOpen: true,
|
|
2305
|
+
isSidebarHover: false,
|
|
2306
|
+
isSidebarActive: false,
|
|
2307
|
+
isSidebarInnerActive: false,
|
|
2308
|
+
isSidebarStateCloseWithIcons: false,
|
|
2309
|
+
isSidebarExpandOnHover: true,
|
|
2310
|
+
hasSidebar: false,
|
|
2311
|
+
hasHeader: false,
|
|
2312
|
+
hasBreadcrumb: false,
|
|
2313
|
+
hasHeaderLogo: false,
|
|
2314
|
+
hasHeaderEnvironment: false,
|
|
2315
|
+
hasToolbar: false,
|
|
2316
|
+
hasToolbarMenu: false,
|
|
2317
|
+
environmentValue: '',
|
|
2318
|
+
isSidebarHidden: false,
|
|
2319
|
+
hasTopMessage: false,
|
|
2320
|
+
windowWidth: 0,
|
|
2321
|
+
windowHeight: 0,
|
|
2322
|
+
mainContentHeight: 0,
|
|
2323
|
+
pageHeaderHeight: 0,
|
|
2324
|
+
wrapperClasses: '',
|
|
2325
|
+
breakpoint: '',
|
|
2326
|
+
breakpoints: {
|
|
2327
|
+
isMobile: false,
|
|
2328
|
+
isTablet: false,
|
|
2329
|
+
isLtDesktop: false,
|
|
2330
|
+
isDesktop: false,
|
|
2331
|
+
isXL: false,
|
|
2332
|
+
isXXL: false,
|
|
2333
|
+
isFHD: false,
|
|
2334
|
+
is2K: false,
|
|
2335
|
+
is4K: false,
|
|
2336
|
+
},
|
|
2337
|
+
menuLinks: [],
|
|
2338
|
+
sidebarLinks: [],
|
|
2339
|
+
combinedLinks: [],
|
|
2340
|
+
isBlockDocumentActive: false,
|
|
2341
|
+
deviceInfo: null,
|
|
2342
|
+
activeLanguage: 'en',
|
|
2343
|
+
languages: EuiEuLanguages.getLanguages(),
|
|
2344
|
+
appMetadata: null,
|
|
2345
|
+
hasModalActive: false,
|
|
2346
|
+
isDimmerActive: false,
|
|
2347
|
+
};
|
|
2348
|
+
class EuiAppShellService {
|
|
2349
|
+
// -------------------
|
|
2350
|
+
get state$() {
|
|
2351
|
+
return this._state$.asObservable();
|
|
2312
2352
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2353
|
+
// -------------------
|
|
2354
|
+
// exposed observables
|
|
2355
|
+
get breakpoint$() {
|
|
2356
|
+
return this._breakpoint$.asObservable();
|
|
2315
2357
|
}
|
|
2316
|
-
|
|
2317
|
-
return
|
|
2358
|
+
get breakpoints$() {
|
|
2359
|
+
return this._breakpoints$.asObservable();
|
|
2318
2360
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2361
|
+
// ----------------
|
|
2362
|
+
// state operations
|
|
2363
|
+
// ----------------
|
|
2364
|
+
get state() {
|
|
2365
|
+
return this._state$.getValue();
|
|
2322
2366
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2367
|
+
// ----------------------------
|
|
2368
|
+
// public setters and functions
|
|
2369
|
+
// ----------------------------
|
|
2370
|
+
set isSidebarOpen(isOpen) {
|
|
2371
|
+
this.setState({
|
|
2372
|
+
...this.state,
|
|
2373
|
+
isSidebarOpen: isOpen,
|
|
2374
|
+
});
|
|
2327
2375
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
const diffDays = (dateStart, dateEnd) => Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
|
|
2331
|
-
const diffDaysFromToday = (date) => diffDays(new Date(), date);
|
|
2332
|
-
|
|
2333
|
-
/**
|
|
2334
|
-
* Provides read-only equivalent of jQuery's position function:
|
|
2335
|
-
* http://api.jquery.com/position/
|
|
2336
|
-
*/
|
|
2337
|
-
const position = (nativeEl) => {
|
|
2338
|
-
let elBCR = offset(nativeEl);
|
|
2339
|
-
let offsetParentBCR = { top: 0, left: 0 };
|
|
2340
|
-
let offsetParentEl = parentOffsetEl(nativeEl);
|
|
2341
|
-
if (offsetParentEl !== document) {
|
|
2342
|
-
offsetParentBCR = offset(offsetParentEl);
|
|
2343
|
-
offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
|
|
2344
|
-
offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
|
|
2376
|
+
get isSidebarOpen() {
|
|
2377
|
+
return this.state.isSidebarOpen;
|
|
2345
2378
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
* http://api.jquery.com/offset/
|
|
2357
|
-
*/
|
|
2358
|
-
const offset = (nativeEl) => {
|
|
2359
|
-
let boundingClientRect = nativeEl.getBoundingClientRect();
|
|
2360
|
-
return {
|
|
2361
|
-
width: boundingClientRect.width || nativeEl.offsetWidth,
|
|
2362
|
-
height: boundingClientRect.height || nativeEl.offsetHeight,
|
|
2363
|
-
top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
|
|
2364
|
-
left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft),
|
|
2365
|
-
};
|
|
2366
|
-
};
|
|
2367
|
-
// PRIVATE FUNCTIONS
|
|
2368
|
-
const getStyle = (nativeEl, cssProp) => {
|
|
2369
|
-
// IE
|
|
2370
|
-
if (nativeEl.currentStyle) {
|
|
2371
|
-
return nativeEl.currentStyle[cssProp];
|
|
2379
|
+
set isSidebarHover(isHover) {
|
|
2380
|
+
if (this.state.isSidebarExpandOnHover) {
|
|
2381
|
+
this.setState({
|
|
2382
|
+
...this.state,
|
|
2383
|
+
isSidebarHover: isHover,
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
get isSidebarHover() {
|
|
2388
|
+
return this.state.isSidebarHover;
|
|
2372
2389
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2390
|
+
set isSidebarActive(isActive) {
|
|
2391
|
+
this.setState({
|
|
2392
|
+
...this.state,
|
|
2393
|
+
isSidebarActive: isActive,
|
|
2394
|
+
});
|
|
2375
2395
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
*/
|
|
2382
|
-
const isStaticPositioned = (nativeEl) => (getStyle(nativeEl, 'position') || 'static') === 'static';
|
|
2383
|
-
/**
|
|
2384
|
-
* returns the closest, non-statically positioned parentOffset of a given element
|
|
2385
|
-
* @param nativeEl
|
|
2386
|
-
*/
|
|
2387
|
-
const parentOffsetEl = (nativeEl) => {
|
|
2388
|
-
let offsetParent = nativeEl.offsetParent || document;
|
|
2389
|
-
while (offsetParent && offsetParent !== document && isStaticPositioned(offsetParent)) {
|
|
2390
|
-
offsetParent = offsetParent.offsetParent;
|
|
2396
|
+
set isSidebarInnerActive(isOpen) {
|
|
2397
|
+
this.setState({
|
|
2398
|
+
...this.state,
|
|
2399
|
+
isSidebarInnerActive: isOpen,
|
|
2400
|
+
});
|
|
2391
2401
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
if (de) {
|
|
2398
|
-
el = de.nativeElement;
|
|
2399
|
-
if (el && klass) {
|
|
2400
|
-
domElement = el.querySelectorAll(klass);
|
|
2401
|
-
if (domElement.length <= 1) {
|
|
2402
|
-
domElement = el.querySelector(klass);
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2402
|
+
set sidebarLinks(links) {
|
|
2403
|
+
this.setState({
|
|
2404
|
+
...this.state,
|
|
2405
|
+
sidebarLinks: links,
|
|
2406
|
+
});
|
|
2405
2407
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
if (element.classList.contains(className)) {
|
|
2412
|
-
return element;
|
|
2413
|
-
}
|
|
2414
|
-
element = element.parentElement;
|
|
2408
|
+
set menuLinks(links) {
|
|
2409
|
+
this.setState({
|
|
2410
|
+
...this.state,
|
|
2411
|
+
menuLinks: links,
|
|
2412
|
+
});
|
|
2415
2413
|
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
event.preventDefault();
|
|
2422
|
-
event.stopPropagation();
|
|
2423
|
-
event.cancelBubble = true;
|
|
2414
|
+
set isBlockDocumentActive(isActive) {
|
|
2415
|
+
this.setState({
|
|
2416
|
+
...this.state,
|
|
2417
|
+
isBlockDocumentActive: isActive,
|
|
2418
|
+
});
|
|
2424
2419
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
markFormGroupTouchedRecursive(c.controls);
|
|
2437
|
-
}
|
|
2438
|
-
else {
|
|
2439
|
-
c.markAsTouched();
|
|
2440
|
-
c.updateValueAndValidity();
|
|
2441
|
-
}
|
|
2420
|
+
get hasHeader() {
|
|
2421
|
+
return this.state.hasHeader;
|
|
2422
|
+
}
|
|
2423
|
+
// Edit mode
|
|
2424
|
+
get isDimmerActive() {
|
|
2425
|
+
return this.state.isDimmerActive;
|
|
2426
|
+
}
|
|
2427
|
+
set isDimmerActive(isActive) {
|
|
2428
|
+
this.setState({
|
|
2429
|
+
...this.state,
|
|
2430
|
+
isDimmerActive: isActive,
|
|
2442
2431
|
});
|
|
2443
|
-
};
|
|
2444
|
-
markFormGroupTouchedRecursive(FormControls);
|
|
2445
|
-
};
|
|
2446
|
-
const markControlsTouched = (group) => {
|
|
2447
|
-
Object.keys(group.controls).forEach((key) => {
|
|
2448
|
-
const abstractControl = group.controls[key];
|
|
2449
|
-
if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
|
|
2450
|
-
markControlsTouched(abstractControl);
|
|
2451
|
-
}
|
|
2452
|
-
else {
|
|
2453
|
-
abstractControl.markAsTouched();
|
|
2454
|
-
}
|
|
2455
|
-
});
|
|
2456
|
-
};
|
|
2457
|
-
const validateEmail = (c) => {
|
|
2458
|
-
const EMAIL_REGEXP =
|
|
2459
|
-
// eslint-disable-next-line max-len, no-useless-escape
|
|
2460
|
-
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
2461
|
-
const error = {
|
|
2462
|
-
validateEmail: {
|
|
2463
|
-
valid: false,
|
|
2464
|
-
},
|
|
2465
|
-
};
|
|
2466
|
-
return EMAIL_REGEXP.test(c.value) ? null : error;
|
|
2467
|
-
};
|
|
2468
|
-
|
|
2469
|
-
/**
|
|
2470
|
-
* returns a random string with radix=36
|
|
2471
|
-
*/
|
|
2472
|
-
const uniqueId = () => Math.random().toString(36).substr(2, 9);
|
|
2473
|
-
/**
|
|
2474
|
-
* Its job is to parse number and format it based on given input.
|
|
2475
|
-
* @param value can be a number or a string number
|
|
2476
|
-
* @param fractionSize size of fraction of a number e.g. 1000.88 fraction is 2 (88) default is 2
|
|
2477
|
-
* @param inDecimalSeparator separator for decimal part of the number default is ','
|
|
2478
|
-
* @param inThousandSeparator separator for the whole part of the number default is ''
|
|
2479
|
-
*/
|
|
2480
|
-
const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThousandSeparator = '') => {
|
|
2481
|
-
if (inDecimalSeparator || inThousandSeparator) {
|
|
2482
|
-
console.warn('The inDecimalSeparator and inThousandSeparator are deprecated. They will be a ' +
|
|
2483
|
-
'BREAKING CHANGE for eUI 9 and be replaced by localization strategy.');
|
|
2484
2432
|
}
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2433
|
+
constructor(config, http, platformId, router, storeService, i18nService) {
|
|
2434
|
+
this.config = config;
|
|
2435
|
+
this.http = http;
|
|
2436
|
+
this.platformId = platformId;
|
|
2437
|
+
this.router = router;
|
|
2438
|
+
this.storeService = storeService;
|
|
2439
|
+
this.i18nService = i18nService;
|
|
2440
|
+
this.cssVars = [];
|
|
2441
|
+
let stateWithConfig = initialState;
|
|
2442
|
+
const languages = config?.i18n?.i18nService?.languages || initialState.languages;
|
|
2443
|
+
const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
|
|
2444
|
+
stateWithConfig = {
|
|
2445
|
+
...stateWithConfig,
|
|
2446
|
+
...{
|
|
2447
|
+
languages,
|
|
2448
|
+
activeLanguage: defaultLanguage,
|
|
2449
|
+
},
|
|
2450
|
+
};
|
|
2451
|
+
this._state$ = new BehaviorSubject(stateWithConfig);
|
|
2452
|
+
this._breakpoint$ = new BehaviorSubject('');
|
|
2453
|
+
this._breakpoints$ = new BehaviorSubject({});
|
|
2454
|
+
this.bindActiveLanguageToAppShellState();
|
|
2455
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
2456
|
+
router.events.subscribe((event) => {
|
|
2457
|
+
if (event instanceof NavigationEnd) {
|
|
2458
|
+
window.scrollTo(0, 0);
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2489
2462
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
let
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
decimalSeparator = separators[1];
|
|
2463
|
+
setState(nextState, updateI18 = true) {
|
|
2464
|
+
let breakpoint, breakpoints, wrapperClasses;
|
|
2465
|
+
let combinedLinks;
|
|
2466
|
+
const state = this.state;
|
|
2467
|
+
// check if window width has been updated from previous state
|
|
2468
|
+
if (this.state.windowWidth !== nextState.windowWidth) {
|
|
2469
|
+
breakpoint = this.getBreakpoint(nextState.windowWidth);
|
|
2470
|
+
breakpoints = this.getBreakpoints(breakpoint);
|
|
2471
|
+
this._breakpoint$.next(breakpoint);
|
|
2472
|
+
this._breakpoints$.next(breakpoints);
|
|
2473
|
+
// if not propagate the old ones without doing any calculations
|
|
2502
2474
|
}
|
|
2503
|
-
else
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
}
|
|
2513
|
-
else {
|
|
2514
|
-
return value.replace(separators[0], inDecimalSeparator).replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2515
|
-
}
|
|
2475
|
+
else {
|
|
2476
|
+
breakpoint = state.breakpoint;
|
|
2477
|
+
breakpoints = state.breakpoints;
|
|
2478
|
+
}
|
|
2479
|
+
// finally get the wrapper classes when both the state and breakpoint are known
|
|
2480
|
+
wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
|
|
2481
|
+
// check if the menuLinks or sidebarLinks have changed from previous state
|
|
2482
|
+
if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
|
|
2483
|
+
combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
|
|
2516
2484
|
}
|
|
2517
2485
|
else {
|
|
2518
|
-
|
|
2519
|
-
return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
|
|
2486
|
+
combinedLinks = this.state.combinedLinks;
|
|
2520
2487
|
}
|
|
2521
|
-
|
|
2522
|
-
//
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
};
|
|
2534
|
-
|
|
2535
|
-
const handleError = (error) => {
|
|
2536
|
-
let errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
|
2537
|
-
// console.error(errMsg);
|
|
2538
|
-
return throwError(errMsg);
|
|
2539
|
-
};
|
|
2540
|
-
|
|
2541
|
-
/**
|
|
2542
|
-
* check if a value is null or undefined. If it's not both returns true otherwise false
|
|
2543
|
-
*
|
|
2544
|
-
* @param value
|
|
2545
|
-
*/
|
|
2546
|
-
const isDefined = (value) => value !== undefined && value !== null;
|
|
2547
|
-
|
|
2548
|
-
class EuiPermissionService extends EuiService {
|
|
2549
|
-
constructor(log, store) {
|
|
2550
|
-
super([]);
|
|
2551
|
-
this.log = log;
|
|
2552
|
-
this.store = store;
|
|
2553
|
-
if (log) {
|
|
2554
|
-
this.logger = log.getLogger('core.PermissionService');
|
|
2488
|
+
const stateBeforeUpdate = { ...this.state };
|
|
2489
|
+
// we put it all together with the calculated properties
|
|
2490
|
+
this._state$.next({
|
|
2491
|
+
...nextState,
|
|
2492
|
+
wrapperClasses,
|
|
2493
|
+
breakpoint,
|
|
2494
|
+
breakpoints,
|
|
2495
|
+
combinedLinks,
|
|
2496
|
+
appBaseFontSize: this.getBaseFontSize(),
|
|
2497
|
+
});
|
|
2498
|
+
// update the Store Language
|
|
2499
|
+
if (updateI18 && nextState.activeLanguage !== stateBeforeUpdate.activeLanguage) {
|
|
2500
|
+
this.i18nService.updateState({ activeLang: nextState.activeLanguage });
|
|
2555
2501
|
}
|
|
2556
2502
|
}
|
|
2557
2503
|
/**
|
|
2558
|
-
*
|
|
2559
|
-
*
|
|
2504
|
+
* Emits a slice from the state whether that changes
|
|
2505
|
+
*
|
|
2506
|
+
* @param key can be 'key' or 'key.sub.sub'
|
|
2560
2507
|
*/
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
if
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
this.
|
|
2569
|
-
}
|
|
2570
|
-
return of({ success: false, error: 'Init object should be instance of BaseUserState' });
|
|
2508
|
+
getState(key) {
|
|
2509
|
+
return defer(() =>
|
|
2510
|
+
// check if key exists
|
|
2511
|
+
key
|
|
2512
|
+
? this.state$.pipe(map((state) => get(state, key)),
|
|
2513
|
+
// filter((state) => state),
|
|
2514
|
+
distinctUntilChanged((x, y) => isEqual(x, y)))
|
|
2515
|
+
: this.state$);
|
|
2571
2516
|
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2517
|
+
sidebarToggle() {
|
|
2518
|
+
this.isSidebarOpen = !this.state.isSidebarOpen;
|
|
2574
2519
|
}
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2520
|
+
// Edit mode
|
|
2521
|
+
dimmerActiveToggle() {
|
|
2522
|
+
const isActive = this.isDimmerActive;
|
|
2523
|
+
this.setState({
|
|
2524
|
+
...this.state,
|
|
2525
|
+
isDimmerActive: !isActive,
|
|
2526
|
+
});
|
|
2527
|
+
this.activateEditModeCssVars(!isActive);
|
|
2580
2528
|
}
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
this.
|
|
2529
|
+
setDimmerActiveState(activeState) {
|
|
2530
|
+
this.setState({
|
|
2531
|
+
...this.state,
|
|
2532
|
+
isDimmerActive: activeState,
|
|
2533
|
+
});
|
|
2534
|
+
this.activateEditModeCssVars(activeState);
|
|
2587
2535
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
const hasRight = this.checkRight(rightId);
|
|
2599
|
-
if (hasRight) {
|
|
2600
|
-
if (permProps.length === 2) {
|
|
2601
|
-
// in case of 'RIGHT.PERMISSION'
|
|
2602
|
-
const permission = permProps[1];
|
|
2603
|
-
return this.checkPermission(rightId, permission);
|
|
2604
|
-
}
|
|
2605
|
-
else if (permProps.length > 2) {
|
|
2606
|
-
// in case of 'RIGHT1.RIGHT2.....PERMISSION' string call recursively
|
|
2607
|
-
return this.checkAttributePermission(rightsAndPermission.slice(rightId.length + 1));
|
|
2608
|
-
}
|
|
2536
|
+
activateEditModeCssVars(isActive) {
|
|
2537
|
+
if (isActive) {
|
|
2538
|
+
this._setCssVarValue('--eui-docpage-navigation-z-index', 'inherit'); // Reset doc-page-navigation-column z-index
|
|
2539
|
+
this._setCssVarValue('--eui-z-index-sidebar', 'inherit'); // Reset eui-app-sidebar z-index
|
|
2540
|
+
this._setCssVarValue('--eui-z-index-root', 'inherit'); // Reset eui-app-main-content z-index
|
|
2541
|
+
}
|
|
2542
|
+
else {
|
|
2543
|
+
this._setCssVarValue('--eui-docpage-navigation-z-index', '2'); // Restore doc-page-navigation-column z-index
|
|
2544
|
+
this._setCssVarValue('--eui-z-index-sidebar', '1044'); // Restore eui-app-sidebar z-index
|
|
2545
|
+
this._setCssVarValue('--eui-z-index-root', '1'); // Restore eui-app-main-content z-index
|
|
2609
2546
|
}
|
|
2610
|
-
return hasRight;
|
|
2611
|
-
}
|
|
2612
|
-
/**
|
|
2613
|
-
* check if a user has the right.
|
|
2614
|
-
* @param rightId the id of Right
|
|
2615
|
-
*/
|
|
2616
|
-
checkRight(rightId) {
|
|
2617
|
-
return this.userRights.some((right) => right && right.id === rightId);
|
|
2618
2547
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2548
|
+
// --------------
|
|
2549
|
+
// public methods
|
|
2550
|
+
// --------------
|
|
2551
|
+
fetchAppMetadata(metadataFilePath = 'assets/app-metadata.json') {
|
|
2552
|
+
this.getJson(metadataFilePath).then((data) => {
|
|
2553
|
+
this.setState({
|
|
2554
|
+
...this.state,
|
|
2555
|
+
appMetadata: data,
|
|
2556
|
+
});
|
|
2557
|
+
});
|
|
2627
2558
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
if (!
|
|
2634
|
-
|
|
2559
|
+
activateSidebar() {
|
|
2560
|
+
this.setState({
|
|
2561
|
+
...this.state,
|
|
2562
|
+
hasSidebar: true,
|
|
2563
|
+
});
|
|
2564
|
+
if (!this.state.isSidebarHidden) {
|
|
2565
|
+
this.activateSidebarCssVars();
|
|
2635
2566
|
}
|
|
2636
|
-
return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
|
|
2637
2567
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
}] }, { type: StoreService }]; } });
|
|
2649
|
-
|
|
2650
|
-
class EuiDynamicMenuService {
|
|
2651
|
-
// TODO: it should be moved euiservice, or it should be static
|
|
2652
|
-
// TODO: can we moved that service inside the module of the component that's using it?
|
|
2653
|
-
constructor(uxPermission, store) {
|
|
2654
|
-
this.uxPermission = uxPermission;
|
|
2655
|
-
this.store = store;
|
|
2656
|
-
this.menuLinks = [];
|
|
2657
|
-
this.store.select(getUserState).subscribe((user) => {
|
|
2658
|
-
if (user.menuLinks) {
|
|
2659
|
-
this.menuLinks = user.menuLinks;
|
|
2660
|
-
}
|
|
2568
|
+
activateSidebarHeader() {
|
|
2569
|
+
this.activateSidebarHeaderCssVars();
|
|
2570
|
+
}
|
|
2571
|
+
activateSidebarFooter() {
|
|
2572
|
+
this.activateSidebarFooterCssVars();
|
|
2573
|
+
}
|
|
2574
|
+
activateHeader() {
|
|
2575
|
+
this.setState({
|
|
2576
|
+
...this.state,
|
|
2577
|
+
hasHeader: true,
|
|
2661
2578
|
});
|
|
2579
|
+
this.activateHeaderCssVars();
|
|
2662
2580
|
}
|
|
2663
|
-
|
|
2664
|
-
|
|
2581
|
+
activateBreadcrumb() {
|
|
2582
|
+
this.setState({
|
|
2583
|
+
...this.state,
|
|
2584
|
+
hasBreadcrumb: true,
|
|
2585
|
+
});
|
|
2586
|
+
this.activateBreadcrumbCssVars();
|
|
2665
2587
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
// Then check if the user needs to be allowed access explicitly:
|
|
2685
|
-
if (link.allowedRightId) {
|
|
2686
|
-
return this.uxPermission.checkRight(link.allowedRightId);
|
|
2687
|
-
}
|
|
2688
|
-
if (link.allowedRightIds) {
|
|
2689
|
-
for (const allowedRightId of link.allowedRightIds) {
|
|
2690
|
-
if (this.uxPermission.checkRight(allowedRightId)) {
|
|
2691
|
-
return true;
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
// User doesn't have one of the allowed rights. Deny access:
|
|
2695
|
-
return false;
|
|
2696
|
-
}
|
|
2697
|
-
// Access to the menu item is not denied, therefore allow it:
|
|
2698
|
-
return true;
|
|
2588
|
+
activateTopMessage(height) {
|
|
2589
|
+
this.setState({
|
|
2590
|
+
...this.state,
|
|
2591
|
+
hasTopMessage: true,
|
|
2592
|
+
});
|
|
2593
|
+
this.activateTopMessageCssVars(height);
|
|
2594
|
+
}
|
|
2595
|
+
activateToolbar() {
|
|
2596
|
+
this.setState({
|
|
2597
|
+
...this.state,
|
|
2598
|
+
hasToolbar: true,
|
|
2599
|
+
});
|
|
2600
|
+
this.activateToolbarCssVars();
|
|
2601
|
+
}
|
|
2602
|
+
activateToolbarMenu() {
|
|
2603
|
+
this.setState({
|
|
2604
|
+
...this.state,
|
|
2605
|
+
hasToolbarMenu: true,
|
|
2699
2606
|
});
|
|
2700
2607
|
}
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
}
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
this.
|
|
2729
|
-
this.
|
|
2730
|
-
this.
|
|
2608
|
+
fetchCssVars() {
|
|
2609
|
+
const cssVarNames = [
|
|
2610
|
+
'--eui-app-header-height-default',
|
|
2611
|
+
'--eui-app-header-height-active',
|
|
2612
|
+
'--eui-app-header-height-shrink',
|
|
2613
|
+
'--eui-app-breadcrumb-height-default',
|
|
2614
|
+
'--eui-app-breadcrumb-height-active',
|
|
2615
|
+
'--eui-app-top-message-height-default',
|
|
2616
|
+
'--eui-app-top-message-height-active',
|
|
2617
|
+
'--eui-app-top-message-height-shrink',
|
|
2618
|
+
'--eui-app-toolbar-height-default',
|
|
2619
|
+
'--eui-app-toolbar-height-active',
|
|
2620
|
+
'--eui-app-sidebar-width-default',
|
|
2621
|
+
'--eui-app-sidebar-width-active',
|
|
2622
|
+
'--eui-app-sidebar-width-close-default',
|
|
2623
|
+
'--eui-app-sidebar-width-close-active',
|
|
2624
|
+
'--eui-app-sidebar-header-height-default',
|
|
2625
|
+
'--eui-app-sidebar-header-height-active',
|
|
2626
|
+
'--eui-app-sidebar-footer-height-default',
|
|
2627
|
+
'--eui-app-sidebar-footer-height-active',
|
|
2628
|
+
];
|
|
2629
|
+
this.cssVars = cssVarNames.map((v) => ({ key: v, value: this.getCssVarValue(v) }));
|
|
2630
|
+
}
|
|
2631
|
+
initCssVars() {
|
|
2632
|
+
this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height');
|
|
2633
|
+
this.setCssVar('--eui-app-breadcrumb-height-default', '--eui-app-breadcrumb-height');
|
|
2634
|
+
this.setCssVar('--eui-app-top-message-height-default', '--eui-app-top-message-height');
|
|
2635
|
+
this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height');
|
|
2636
|
+
this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width');
|
|
2637
|
+
this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close');
|
|
2638
|
+
this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height');
|
|
2639
|
+
this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height');
|
|
2640
|
+
}
|
|
2641
|
+
activateHeaderCssVars() {
|
|
2642
|
+
this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
|
|
2643
|
+
}
|
|
2644
|
+
activateBreadcrumbCssVars() {
|
|
2645
|
+
this.setCssVar('--eui-app-breadcrumb-height-active', '--eui-app-breadcrumb-height');
|
|
2731
2646
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2647
|
+
activateTopMessageCssVars(height) {
|
|
2648
|
+
this._setCssVarValue('--eui-app-top-message-height', `${height}px`);
|
|
2649
|
+
}
|
|
2650
|
+
activateToolbarCssVars() {
|
|
2651
|
+
this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height');
|
|
2652
|
+
}
|
|
2653
|
+
activateFooterCssVars() {
|
|
2654
|
+
this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height');
|
|
2655
|
+
}
|
|
2656
|
+
setHeaderShrinkCssVar(active) {
|
|
2657
|
+
if (active) {
|
|
2658
|
+
this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height');
|
|
2738
2659
|
}
|
|
2739
2660
|
else {
|
|
2740
|
-
this.
|
|
2661
|
+
this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
|
|
2741
2662
|
}
|
|
2742
2663
|
}
|
|
2664
|
+
activateSidebarCssVars() {
|
|
2665
|
+
this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width');
|
|
2666
|
+
this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close');
|
|
2667
|
+
}
|
|
2668
|
+
removeSidebarCssVars() {
|
|
2669
|
+
document.documentElement.style.removeProperty('--eui-app-sidebar-header-height');
|
|
2670
|
+
document.documentElement.style.removeProperty('--eui-app-sidebar-footer-height');
|
|
2671
|
+
document.documentElement.style.removeProperty('--eui-app-sidebar-width');
|
|
2672
|
+
document.documentElement.style.removeProperty('--eui-app-sidebar-width-close');
|
|
2673
|
+
}
|
|
2674
|
+
activateSidebarHeaderCssVars() {
|
|
2675
|
+
this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height');
|
|
2676
|
+
}
|
|
2677
|
+
activateSidebarFooterCssVars() {
|
|
2678
|
+
this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height');
|
|
2679
|
+
}
|
|
2743
2680
|
/**
|
|
2744
|
-
*
|
|
2681
|
+
* Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
|
|
2682
|
+
* Sets the value in the --eui-app-vh custom property to the root of the document
|
|
2683
|
+
* Sets the value in the --eui-app-vw custom property to the root of the document
|
|
2684
|
+
* Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
|
|
2685
|
+
* Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
|
|
2686
|
+
* Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
|
|
2745
2687
|
*/
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
// const growlLife = 10000;
|
|
2752
|
-
// const position = 'bottom-right';
|
|
2753
|
-
// feedBacks.forEach((feedback: UxErrorFeedback) =>
|
|
2754
|
-
// this.translateService
|
|
2755
|
-
// .get(feedback.msgId)
|
|
2756
|
-
// .pipe(take(1))
|
|
2757
|
-
// .subscribe((translate) => {
|
|
2758
|
-
// this.asService.growl(
|
|
2759
|
-
// {
|
|
2760
|
-
// severity: feedback.severity || 'danger',
|
|
2761
|
-
// summary: 'ERROR',
|
|
2762
|
-
// detail: translate,
|
|
2763
|
-
// },
|
|
2764
|
-
// isGrowlSticky,
|
|
2765
|
-
// isGrowlMultiple,
|
|
2766
|
-
// growlLife,
|
|
2767
|
-
// position
|
|
2768
|
-
// );
|
|
2769
|
-
// })
|
|
2770
|
-
// );
|
|
2688
|
+
setAppViewportCssVars() {
|
|
2689
|
+
let vh = window.innerHeight * 0.01;
|
|
2690
|
+
let vw = window.innerWidth * 0.01;
|
|
2691
|
+
this._setCssVarValue('--eui-app-vh', `${vh}px`);
|
|
2692
|
+
this._setCssVarValue('--eui-app-vw', `${vw}px`);
|
|
2771
2693
|
}
|
|
2772
|
-
|
|
2773
|
-
|
|
2694
|
+
/**
|
|
2695
|
+
* Returns the current value of --eui-base-font-size CSS variable
|
|
2696
|
+
*/
|
|
2697
|
+
getBaseFontSize() {
|
|
2698
|
+
return this.state.appBaseFontSize || this.getCssVarValue('--eui-base-font-size');
|
|
2699
|
+
}
|
|
2700
|
+
/**
|
|
2701
|
+
* Updates the current value of --eui-base-font-size CSS variable and the UIState appBaseFontSize
|
|
2702
|
+
*/
|
|
2703
|
+
setBaseFontSize(newsize) {
|
|
2704
|
+
this.setState({
|
|
2705
|
+
...this.state,
|
|
2706
|
+
appBaseFontSize: newsize,
|
|
2707
|
+
}, false);
|
|
2708
|
+
this._setCssVarValue('--eui-base-font-size', newsize);
|
|
2774
2709
|
}
|
|
2775
|
-
|
|
2776
|
-
|
|
2710
|
+
// ---------------
|
|
2711
|
+
// private getters
|
|
2712
|
+
// ---------------
|
|
2713
|
+
getCssVarValue(inputProperty) {
|
|
2714
|
+
return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
|
|
2777
2715
|
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2716
|
+
setCssVar(inputProperty, outputProperty) {
|
|
2717
|
+
const cssVarValue = this.cssVars.filter((v) => v.key === inputProperty)[0].value;
|
|
2718
|
+
this._setCssVarValue(outputProperty, cssVarValue);
|
|
2719
|
+
// console.log(inputProperty, outputProperty, cssVarValue);
|
|
2780
2720
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.3", ngImport: i0, type: UxErrorFeedbackService, decorators: [{
|
|
2785
|
-
type: Injectable,
|
|
2786
|
-
args: [{
|
|
2787
|
-
providedIn: 'root',
|
|
2788
|
-
}]
|
|
2789
|
-
}], ctorParameters: function () { return [{ type: UxAppShellService }, { type: i2.TranslateService }]; } });
|
|
2790
|
-
class UxErrorManager {
|
|
2791
|
-
constructor(uxErrorFeedbackService, isGlobal) {
|
|
2792
|
-
this.uxErrorFeedbackService = uxErrorFeedbackService;
|
|
2793
|
-
this.isGlobal = isGlobal;
|
|
2794
|
-
this.httpErrorOperator = withUxErrorManager(this);
|
|
2795
|
-
this.id = Math.random().toString();
|
|
2796
|
-
}
|
|
2797
|
-
publishError(err, groupId, accumulate) {
|
|
2798
|
-
if (!this.isGlobal) {
|
|
2799
|
-
this.uxErrorFeedbackService.publishError(err, this.id, groupId, accumulate);
|
|
2800
|
-
}
|
|
2801
|
-
else {
|
|
2802
|
-
this.uxErrorFeedbackService.publishError(err, undefined, groupId, accumulate);
|
|
2803
|
-
}
|
|
2721
|
+
_setCssVarValue(varName, varValue) {
|
|
2722
|
+
document.documentElement.style.setProperty(varName, varValue);
|
|
2804
2723
|
}
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2724
|
+
getWrapperClasses(state, breakpoint) {
|
|
2725
|
+
let classes = [];
|
|
2726
|
+
classes.push(breakpoint);
|
|
2727
|
+
if (state.hasSidebar) {
|
|
2728
|
+
if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
|
|
2729
|
+
classes.push('sidebar-state-open');
|
|
2730
|
+
}
|
|
2731
|
+
if (!state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
|
|
2732
|
+
classes.push('sidebar-state-close');
|
|
2733
|
+
}
|
|
2734
|
+
if (state.isSidebarActive) {
|
|
2735
|
+
classes.push('sidebar-active');
|
|
2736
|
+
}
|
|
2737
|
+
if (state.isSidebarInnerActive) {
|
|
2738
|
+
classes.push('sidebar-inner-active');
|
|
2739
|
+
}
|
|
2740
|
+
if (state.isSidebarStateCloseWithIcons) {
|
|
2741
|
+
classes.push('sidebar-state-close-with-icons');
|
|
2742
|
+
}
|
|
2743
|
+
// NEW APP-SHELL props
|
|
2744
|
+
if (state.isSidebarHidden) {
|
|
2745
|
+
classes.push('sidebar--hidden');
|
|
2746
|
+
}
|
|
2747
|
+
if (state.isSidebarOpen) {
|
|
2748
|
+
classes.push('sidebar--open');
|
|
2749
|
+
}
|
|
2750
|
+
else {
|
|
2751
|
+
classes.push('sidebar--close');
|
|
2752
|
+
}
|
|
2753
|
+
if (state.isSidebarHover) {
|
|
2754
|
+
classes.push('sidebar--hover');
|
|
2755
|
+
}
|
|
2808
2756
|
}
|
|
2809
|
-
|
|
2810
|
-
|
|
2757
|
+
if (state.deviceInfo && state.deviceInfo.isFF) {
|
|
2758
|
+
classes.push('ff');
|
|
2811
2759
|
}
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
this.uxErrorFeedbackService.growlError(err);
|
|
2815
|
-
}
|
|
2816
|
-
errors() {
|
|
2817
|
-
if (!this.isGlobal) {
|
|
2818
|
-
return this.uxErrorFeedbackService.errors.pipe(filter((evt) => evt.id === this.id));
|
|
2760
|
+
if (state.deviceInfo && state.deviceInfo.isIE) {
|
|
2761
|
+
classes.push('ie');
|
|
2819
2762
|
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2763
|
+
if (state.deviceInfo && state.deviceInfo.isIE11) {
|
|
2764
|
+
classes.push('ie11');
|
|
2822
2765
|
}
|
|
2766
|
+
if (state.deviceInfo && state.deviceInfo.isChrome) {
|
|
2767
|
+
classes.push('chrome');
|
|
2768
|
+
}
|
|
2769
|
+
return classes.join(' ');
|
|
2823
2770
|
}
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2771
|
+
getBreakpoint(windowWidth) {
|
|
2772
|
+
let bkp = '';
|
|
2773
|
+
switch (true) {
|
|
2774
|
+
case windowWidth >= 0 && windowWidth < 576:
|
|
2775
|
+
bkp = 'xs';
|
|
2776
|
+
break;
|
|
2777
|
+
case windowWidth >= 576 && windowWidth < 768:
|
|
2778
|
+
bkp = 'sm';
|
|
2779
|
+
break;
|
|
2780
|
+
case windowWidth >= 768 && windowWidth < 992:
|
|
2781
|
+
bkp = 'md';
|
|
2782
|
+
break;
|
|
2783
|
+
case windowWidth >= 992 && windowWidth < 1200:
|
|
2784
|
+
bkp = 'lg';
|
|
2785
|
+
break;
|
|
2786
|
+
case windowWidth >= 1200 && windowWidth < 1400:
|
|
2787
|
+
bkp = 'xl';
|
|
2788
|
+
break;
|
|
2789
|
+
case windowWidth >= 1400 && windowWidth < 1920:
|
|
2790
|
+
bkp = 'xxl';
|
|
2791
|
+
break;
|
|
2792
|
+
case windowWidth >= 1920 && windowWidth < 2560:
|
|
2793
|
+
bkp = 'fhd';
|
|
2794
|
+
break;
|
|
2795
|
+
case windowWidth >= 2560 && windowWidth < 3840:
|
|
2796
|
+
bkp = '2k';
|
|
2797
|
+
break;
|
|
2798
|
+
case windowWidth >= 3840:
|
|
2799
|
+
bkp = '4k';
|
|
2800
|
+
break;
|
|
2853
2801
|
}
|
|
2802
|
+
return bkp;
|
|
2803
|
+
}
|
|
2804
|
+
getBreakpoints(bkp) {
|
|
2854
2805
|
return {
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2806
|
+
isMobile: bkp === 'xs' || bkp === 'sm',
|
|
2807
|
+
isTablet: bkp === 'md',
|
|
2808
|
+
isLtDesktop: bkp === 'xs' || bkp === 'sm' || bkp === 'md',
|
|
2809
|
+
isDesktop: bkp === 'lg',
|
|
2810
|
+
isXL: bkp === 'xl',
|
|
2811
|
+
isXXL: bkp === 'xxl',
|
|
2812
|
+
isFHD: bkp === 'fhd',
|
|
2813
|
+
is2K: bkp === '2k',
|
|
2814
|
+
is4K: bkp === '4k',
|
|
2858
2815
|
};
|
|
2859
2816
|
}
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
* @param portalHostRef reference of portal host to be detached
|
|
2863
|
-
*/
|
|
2864
|
-
remove(portalHostRef) {
|
|
2865
|
-
portalHostRef.detach();
|
|
2866
|
-
this.portalHost = null;
|
|
2867
|
-
this.portal = null;
|
|
2868
|
-
this.portalComponentInstance = null;
|
|
2817
|
+
getJson(url) {
|
|
2818
|
+
return this.http.get(url).toPromise().then(this.extractData).catch(this.handleError);
|
|
2869
2819
|
}
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2820
|
+
extractData(res) {
|
|
2821
|
+
const body = res;
|
|
2822
|
+
return body || {};
|
|
2823
|
+
}
|
|
2824
|
+
handleError(error) {
|
|
2825
|
+
console.error('An error occurred', error);
|
|
2826
|
+
return Promise.reject(error.message || error);
|
|
2827
|
+
}
|
|
2828
|
+
bindActiveLanguageToAppShellState() {
|
|
2829
|
+
this.storeService.select(getActiveLang).subscribe((activeLang) => {
|
|
2830
|
+
if (activeLang !== this.state.activeLanguage) {
|
|
2831
|
+
this.setState({
|
|
2832
|
+
...this.state,
|
|
2833
|
+
activeLanguage: activeLang,
|
|
2834
|
+
}, false);
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2878
2837
|
}
|
|
2879
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2880
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2838
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", 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 }); }
|
|
2839
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiAppShellService, providedIn: 'root' }); }
|
|
2881
2840
|
}
|
|
2882
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
2883
|
-
type: Injectable
|
|
2884
|
-
|
|
2841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiAppShellService, decorators: [{
|
|
2842
|
+
type: Injectable,
|
|
2843
|
+
args: [{
|
|
2844
|
+
providedIn: 'root',
|
|
2845
|
+
}]
|
|
2846
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2847
|
+
type: Optional
|
|
2848
|
+
}, {
|
|
2849
|
+
type: Inject,
|
|
2850
|
+
args: [GLOBAL_CONFIG_TOKEN]
|
|
2851
|
+
}] }, { type: i1$5.HttpClient }, { type: undefined, decorators: [{
|
|
2852
|
+
type: Inject,
|
|
2853
|
+
args: [PLATFORM_ID]
|
|
2854
|
+
}] }, { type: i1$4.Router }, { type: StoreService }, { type: I18nService, decorators: [{
|
|
2855
|
+
type: Optional
|
|
2856
|
+
}] }]; } });
|
|
2885
2857
|
|
|
2886
2858
|
/* eslint-disable */
|
|
2887
2859
|
const EUI_COUNTRIES = {
|
|
@@ -3590,10 +3562,10 @@ class EuiTimezoneService {
|
|
|
3590
3562
|
getTimezone(tz) {
|
|
3591
3563
|
return EUI_TIMEZONES.find((item) => item.name === tz);
|
|
3592
3564
|
}
|
|
3593
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3594
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3565
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiTimezoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3566
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiTimezoneService }); }
|
|
3595
3567
|
}
|
|
3596
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3568
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuiTimezoneService, decorators: [{
|
|
3597
3569
|
type: Injectable
|
|
3598
3570
|
}] });
|
|
3599
3571
|
|
|
@@ -3712,10 +3684,10 @@ class LocalStorageService extends StorageService {
|
|
|
3712
3684
|
}
|
|
3713
3685
|
}
|
|
3714
3686
|
}
|
|
3715
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3716
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3687
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3688
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalStorageService }); }
|
|
3717
3689
|
}
|
|
3718
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalStorageService, decorators: [{
|
|
3719
3691
|
type: Injectable
|
|
3720
3692
|
}], ctorParameters: function () { return [{ type: LogService, decorators: [{
|
|
3721
3693
|
type: Optional
|
|
@@ -3783,10 +3755,10 @@ class SessionStorageService extends StorageService {
|
|
|
3783
3755
|
}
|
|
3784
3756
|
}
|
|
3785
3757
|
}
|
|
3786
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3787
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3758
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: SessionStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3759
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: SessionStorageService }); }
|
|
3788
3760
|
}
|
|
3789
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3761
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: SessionStorageService, decorators: [{
|
|
3790
3762
|
type: Injectable
|
|
3791
3763
|
}], ctorParameters: function () { return [{ type: LogService, decorators: [{
|
|
3792
3764
|
type: Optional
|
|
@@ -3864,10 +3836,10 @@ class LocalForageService extends AsyncStorageService {
|
|
|
3864
3836
|
}
|
|
3865
3837
|
}));
|
|
3866
3838
|
}
|
|
3867
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3868
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3839
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3840
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalForageService }); }
|
|
3869
3841
|
}
|
|
3870
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
3842
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocalForageService, decorators: [{
|
|
3871
3843
|
type: Injectable
|
|
3872
3844
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
3873
3845
|
type: Inject,
|
|
@@ -4074,10 +4046,10 @@ class LocaleService extends EuiService {
|
|
|
4074
4046
|
}
|
|
4075
4047
|
});
|
|
4076
4048
|
}
|
|
4077
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4078
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4049
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", 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 }); }
|
|
4050
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
|
|
4079
4051
|
}
|
|
4080
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4052
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocaleService, decorators: [{
|
|
4081
4053
|
type: Injectable,
|
|
4082
4054
|
args: [{
|
|
4083
4055
|
providedIn: 'root',
|
|
@@ -4123,10 +4095,10 @@ class LocaleServiceMock extends LocaleService {
|
|
|
4123
4095
|
this.DEFAULT_LOCALE = state.id || 'en';
|
|
4124
4096
|
return of({ success: true });
|
|
4125
4097
|
}
|
|
4126
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4127
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4098
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocaleServiceMock, deps: [{ token: LOCALE_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4099
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocaleServiceMock }); }
|
|
4128
4100
|
}
|
|
4129
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4101
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: LocaleServiceMock, decorators: [{
|
|
4130
4102
|
type: Injectable
|
|
4131
4103
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
4132
4104
|
type: Optional
|
|
@@ -4182,10 +4154,10 @@ class UserService extends EuiService {
|
|
|
4182
4154
|
this.store.dispatch(new UpdateUserStateAction(userState));
|
|
4183
4155
|
}
|
|
4184
4156
|
}
|
|
4185
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4186
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4157
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4158
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserService, providedIn: 'root' }); }
|
|
4187
4159
|
}
|
|
4188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserService, decorators: [{
|
|
4189
4161
|
type: Injectable,
|
|
4190
4162
|
args: [{
|
|
4191
4163
|
providedIn: 'root',
|
|
@@ -4213,10 +4185,10 @@ class UserServiceMock extends UserService {
|
|
|
4213
4185
|
getUserId() {
|
|
4214
4186
|
return of('anonymous');
|
|
4215
4187
|
}
|
|
4216
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4217
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4188
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4189
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserServiceMock }); }
|
|
4218
4190
|
}
|
|
4219
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4191
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UserServiceMock, decorators: [{
|
|
4220
4192
|
type: Injectable
|
|
4221
4193
|
}], ctorParameters: function () { return []; } });
|
|
4222
4194
|
|
|
@@ -4245,12 +4217,12 @@ class AddLangParamInterceptor {
|
|
|
4245
4217
|
params: req.params.set(langParam, langValue),
|
|
4246
4218
|
}));
|
|
4247
4219
|
}
|
|
4248
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4249
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4220
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$3.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4221
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: AddLangParamInterceptor }); }
|
|
4250
4222
|
}
|
|
4251
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4223
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
|
|
4252
4224
|
type: Injectable
|
|
4253
|
-
}], ctorParameters: function () { return [{ type:
|
|
4225
|
+
}], ctorParameters: function () { return [{ type: i1$3.TranslateService }]; } });
|
|
4254
4226
|
|
|
4255
4227
|
class CachePreventionInterceptor {
|
|
4256
4228
|
intercept(req, next) {
|
|
@@ -4264,10 +4236,10 @@ class CachePreventionInterceptor {
|
|
|
4264
4236
|
headers: req.headers.set('Cache-Control', 'No-Cache'),
|
|
4265
4237
|
}));
|
|
4266
4238
|
}
|
|
4267
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4268
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4239
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CachePreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4240
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CachePreventionInterceptor }); }
|
|
4269
4241
|
}
|
|
4270
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4242
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CachePreventionInterceptor, decorators: [{
|
|
4271
4243
|
type: Injectable
|
|
4272
4244
|
}] });
|
|
4273
4245
|
|
|
@@ -4277,10 +4249,10 @@ class CorsSecurityInterceptor {
|
|
|
4277
4249
|
withCredentials: true,
|
|
4278
4250
|
}));
|
|
4279
4251
|
}
|
|
4280
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4281
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4252
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CorsSecurityInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4253
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CorsSecurityInterceptor }); }
|
|
4282
4254
|
}
|
|
4283
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CorsSecurityInterceptor, decorators: [{
|
|
4284
4256
|
type: Injectable
|
|
4285
4257
|
}] });
|
|
4286
4258
|
|
|
@@ -4290,10 +4262,10 @@ class CsrfPreventionInterceptor {
|
|
|
4290
4262
|
headers: request.headers.set('X-Requested-With', 'XMLHttpRequest'),
|
|
4291
4263
|
}));
|
|
4292
4264
|
}
|
|
4293
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4294
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4265
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CsrfPreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4266
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CsrfPreventionInterceptor }); }
|
|
4295
4267
|
}
|
|
4296
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4268
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: CsrfPreventionInterceptor, decorators: [{
|
|
4297
4269
|
type: Injectable
|
|
4298
4270
|
}] });
|
|
4299
4271
|
|
|
@@ -4358,10 +4330,10 @@ class EuLoginSessionTimeoutHandlingInterceptor {
|
|
|
4358
4330
|
reauthenticate() {
|
|
4359
4331
|
document.location.reload();
|
|
4360
4332
|
}
|
|
4361
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4362
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4333
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4334
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor }); }
|
|
4363
4335
|
}
|
|
4364
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4336
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, decorators: [{
|
|
4365
4337
|
type: Injectable
|
|
4366
4338
|
}] });
|
|
4367
4339
|
|
|
@@ -4380,10 +4352,10 @@ class UxRequestErrorModelInterceptor {
|
|
|
4380
4352
|
return of(err);
|
|
4381
4353
|
}));
|
|
4382
4354
|
}
|
|
4383
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4384
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4355
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UxRequestErrorModelInterceptor, deps: [{ token: UX_ERROR_MAPPING_HANDLER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4356
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UxRequestErrorModelInterceptor }); }
|
|
4385
4357
|
}
|
|
4386
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: UxRequestErrorModelInterceptor, decorators: [{
|
|
4387
4359
|
type: Injectable
|
|
4388
4360
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
4389
4361
|
type: Inject,
|
|
@@ -4532,10 +4504,10 @@ class OpenIdConnectInterceptor {
|
|
|
4532
4504
|
return this.defaultMaximumRequestRetries;
|
|
4533
4505
|
}
|
|
4534
4506
|
}
|
|
4535
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4536
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4507
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4508
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectInterceptor }); }
|
|
4537
4509
|
}
|
|
4538
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4510
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectInterceptor, decorators: [{
|
|
4539
4511
|
type: Injectable
|
|
4540
4512
|
}], ctorParameters: function () { return []; } });
|
|
4541
4513
|
|
|
@@ -4582,10 +4554,10 @@ class OpenIdConnectService {
|
|
|
4582
4554
|
getUserDetails() {
|
|
4583
4555
|
return this.userDetails;
|
|
4584
4556
|
}
|
|
4585
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4586
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4557
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4558
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectService, providedIn: 'root' }); }
|
|
4587
4559
|
}
|
|
4588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
|
4560
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.4", ngImport: i0, type: OpenIdConnectService, decorators: [{
|
|
4589
4561
|
type: Injectable,
|
|
4590
4562
|
args: [{
|
|
4591
4563
|
providedIn: 'root',
|
|
@@ -4604,5 +4576,5 @@ class OpenIdConnectServiceMock extends OpenIdConnectService {
|
|
|
4604
4576
|
* Generated bundle index. Do not edit.
|
|
4605
4577
|
*/
|
|
4606
4578
|
|
|
4607
|
-
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, EuiCoreRootGuardClass, EuiDynamicMenuService, EuiError, EuiPermissionService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, I18nServiceMock, 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,
|
|
4579
|
+
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, I18nServiceMock, 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 };
|
|
4608
4580
|
//# sourceMappingURL=eui-core.mjs.map
|