monkey-front-core 0.0.441 → 0.0.443
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/esm2020/lib/core/services/config/monkeyecx-config.service.mjs +16 -19
- package/esm2020/lib/core/services/config/monkeyecx-i18n-config.service.mjs +63 -24
- package/fesm2015/monkey-front-core.mjs +72 -35
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +77 -41
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/services/config/monkeyecx-config.service.d.ts +2 -2
- package/lib/core/services/config/monkeyecx-i18n-config.service.d.ts +3 -1
- package/monkey-front-core-0.0.443.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.441.tgz +0 -0
|
@@ -3307,27 +3307,38 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
|
|
|
3307
3307
|
this.translateService.setDefaultLang('pt-BR');
|
|
3308
3308
|
this.translateService.use('pt-BR');
|
|
3309
3309
|
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3310
|
+
apply(params, environment, change = false) {
|
|
3311
|
+
this.applyInternal(environment);
|
|
3312
|
+
this.applyExternal(params, environment, change);
|
|
3313
|
+
}
|
|
3314
|
+
async applyInternal(environment) {
|
|
3315
|
+
const { monkeyecxService, monkeyecxErrorConfigService } = this;
|
|
3316
|
+
const lang = `${environment?.lang || 'pt-BR'}`;
|
|
3317
|
+
try {
|
|
3318
|
+
const currenti18n = await monkeyecxService
|
|
3319
|
+
?.get(`${environment.localAssets}/i18n/${lang}.json`)
|
|
3320
|
+
.pipe(take(1))
|
|
3321
|
+
.toPromise();
|
|
3322
|
+
const { data } = currenti18n;
|
|
3323
|
+
this.translateService.setTranslation('pt-BR', data, true);
|
|
3324
|
+
this.translateService.setTranslation(lang, data, true);
|
|
3325
|
+
this.translateService.use(lang);
|
|
3317
3326
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3327
|
+
catch (err) {
|
|
3328
|
+
console.error(`i18n ${lang} not found!`);
|
|
3329
|
+
monkeyecxErrorConfigService.apply('i18n');
|
|
3330
|
+
throwError(err);
|
|
3320
3331
|
}
|
|
3321
3332
|
try {
|
|
3322
|
-
const
|
|
3323
|
-
const services =
|
|
3324
|
-
return monkeyecxService
|
|
3333
|
+
const pathName = ['alerts', 'auth', 'register', 'shared'];
|
|
3334
|
+
const services = pathName?.map((name) => {
|
|
3335
|
+
return monkeyecxService
|
|
3336
|
+
?.get(`${environment.urlAssets}/data/i18n/${name}/${lang}.json`)
|
|
3337
|
+
.pipe(take(1))
|
|
3338
|
+
.toPromise();
|
|
3325
3339
|
});
|
|
3326
|
-
if (!services?.length)
|
|
3327
|
-
return;
|
|
3328
3340
|
const externali18nData = await Promise.all(services);
|
|
3329
3341
|
externali18nData?.forEach((config) => {
|
|
3330
|
-
const { lang } = config;
|
|
3331
3342
|
const { data } = config;
|
|
3332
3343
|
this.translateService.setTranslation('pt-BR', data, true);
|
|
3333
3344
|
this.translateService.setTranslation(lang, data, true);
|
|
@@ -3336,25 +3347,53 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
|
|
|
3336
3347
|
catch (err) {
|
|
3337
3348
|
// not to do
|
|
3338
3349
|
}
|
|
3350
|
+
}
|
|
3351
|
+
async applyExternal(params, environment, change = false) {
|
|
3352
|
+
const { monkeyecxCookieStorageService, monkeyecxErrorConfigService, monkeyecxService } = this;
|
|
3353
|
+
let { i18n } = params;
|
|
3354
|
+
const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
|
|
3355
|
+
if (cookie && !change) {
|
|
3356
|
+
i18n = JSON.parse(atob(cookie));
|
|
3357
|
+
}
|
|
3358
|
+
else {
|
|
3359
|
+
monkeyecxCookieStorageService.setCookie('monkey-app-locale', btoa(JSON.stringify(i18n)), environment);
|
|
3360
|
+
}
|
|
3339
3361
|
try {
|
|
3340
|
-
const
|
|
3341
|
-
const {
|
|
3342
|
-
let
|
|
3362
|
+
const lang = `${i18n?.lang || 'pt-BR'}`;
|
|
3363
|
+
const currentExternali18n = params?.externali18n?.[`${lang}`];
|
|
3364
|
+
let data = {};
|
|
3343
3365
|
if (currentExternali18n) {
|
|
3344
3366
|
data = {
|
|
3345
|
-
...data,
|
|
3346
3367
|
EXTERNAL: currentExternali18n
|
|
3347
3368
|
};
|
|
3348
3369
|
}
|
|
3349
3370
|
this.translateService.setTranslation('pt-BR', data, true);
|
|
3350
|
-
this.translateService.setTranslation(lang
|
|
3351
|
-
this.translateService.use(lang);
|
|
3371
|
+
this.translateService.setTranslation(`${lang}`, data, true);
|
|
3372
|
+
this.translateService.use(`${lang}`);
|
|
3352
3373
|
}
|
|
3353
3374
|
catch (err) {
|
|
3354
3375
|
console.error(`i18n ${i18n?.lang} not found!`);
|
|
3355
3376
|
monkeyecxErrorConfigService.apply('i18n');
|
|
3356
3377
|
throwError(err);
|
|
3357
3378
|
}
|
|
3379
|
+
try {
|
|
3380
|
+
const externali18nPaths = params?.i18n?.paths || [];
|
|
3381
|
+
const services = externali18nPaths?.map((url) => {
|
|
3382
|
+
return monkeyecxService?.get(`${url}/${i18n?.lang}.json`).pipe(take(1)).toPromise();
|
|
3383
|
+
});
|
|
3384
|
+
if (!services?.length)
|
|
3385
|
+
return;
|
|
3386
|
+
const externali18nData = await Promise.all(services);
|
|
3387
|
+
externali18nData?.forEach((config) => {
|
|
3388
|
+
const { lang } = config;
|
|
3389
|
+
const { data } = config;
|
|
3390
|
+
this.translateService.setTranslation('pt-BR', data, true);
|
|
3391
|
+
this.translateService.setTranslation(lang, data, true);
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3394
|
+
catch (err) {
|
|
3395
|
+
// not to do
|
|
3396
|
+
}
|
|
3358
3397
|
}
|
|
3359
3398
|
}
|
|
3360
3399
|
MonkeyEcxi18nConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, deps: [{ token: MonkeyEcxService }, { token: i1$1.TranslateService }, { token: MonkeyEcxCookieStorageService }, { token: MonkeyEcxErrorConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -3368,13 +3407,13 @@ __decorate([
|
|
|
3368
3407
|
showProgress: false
|
|
3369
3408
|
}
|
|
3370
3409
|
})
|
|
3371
|
-
], MonkeyEcxi18nConfigService.prototype, "
|
|
3410
|
+
], MonkeyEcxi18nConfigService.prototype, "applyInternal", null);
|
|
3372
3411
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, decorators: [{
|
|
3373
3412
|
type: Injectable,
|
|
3374
3413
|
args: [{
|
|
3375
3414
|
providedIn: 'root'
|
|
3376
3415
|
}]
|
|
3377
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: {
|
|
3416
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { applyInternal: [] } });
|
|
3378
3417
|
|
|
3379
3418
|
class MonkeyEcxLogsConfigService {
|
|
3380
3419
|
apply(params, configBootstrap, environment, identifyCode) {
|
|
@@ -3696,28 +3735,26 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
|
|
|
3696
3735
|
this.configSubject$ = new BehaviorSubject({});
|
|
3697
3736
|
this.configBootstrapSubject$ = new BehaviorSubject({});
|
|
3698
3737
|
}
|
|
3699
|
-
async
|
|
3700
|
-
const {
|
|
3701
|
-
const configBootstrap = args[0];
|
|
3702
|
-
const callback = args[1];
|
|
3703
|
-
monkeyecxSecurityConsoleConfigService.apply();
|
|
3738
|
+
async getSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
|
|
3739
|
+
const { monkeyecxSecurityConsoleConfigService, monkeyecxServiceWorkerConfigService, monkeyecxMaintenanceConfigService, monkeyStyleGuideSettingsService, monkeyecxi18nConfigService, monkeyGTMConfigService, getWhiteLabel } = this;
|
|
3704
3740
|
monkeyecxServiceWorkerConfigService.apply(configBootstrap);
|
|
3705
3741
|
monkeyecxMaintenanceConfigService.apply(configBootstrap);
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
const { monkeyecxService, configSubject$, monkeyStyleGuideSettingsService, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyGTMConfigService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService, internalValidations } = this;
|
|
3742
|
+
monkeyecxSecurityConsoleConfigService.apply();
|
|
3743
|
+
monkeyGTMConfigService.apply(environment);
|
|
3744
|
+
await monkeyecxi18nConfigService.applyInternal(environment);
|
|
3710
3745
|
const url = `${environment.urlAssets}/${monkeyecxCode.toLowerCase()}`;
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3746
|
+
monkeyStyleGuideSettingsService.bootstrap(`${url}/monkey-style-guide-settings.json`, getWhiteLabel.bind(this, configBootstrap, callback, environment, identifyCode, url));
|
|
3747
|
+
}
|
|
3748
|
+
getWhiteLabel(configBootstrap, callback, environment, identifyCode, url) {
|
|
3749
|
+
const { monkeyecxService, configSubject$, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService } = this;
|
|
3750
|
+
monkeyecxService?.get(`${url}/white-label.json`)?.subscribe(async (config) => {
|
|
3751
|
+
await monkeyecxi18nConfigService.applyExternal(config, environment);
|
|
3715
3752
|
monkeyecxLogsConfigService.apply(config, configBootstrap, environment, identifyCode);
|
|
3716
3753
|
monkeyEcxFeatureToggleService.apply(configSubject$, environment);
|
|
3717
|
-
monkeyGTMConfigService.apply(environment);
|
|
3718
3754
|
monkeyEcxAlertsConfigService.apply(config);
|
|
3719
|
-
monkeyStyleGuideSettingsService.bootstrap(`${url}/monkey-style-guide-settings.json`, internalValidations.bind(this, configBootstrap, callback));
|
|
3720
3755
|
configSubject$.next(config);
|
|
3756
|
+
if (callback)
|
|
3757
|
+
callback();
|
|
3721
3758
|
}, (err) => {
|
|
3722
3759
|
monkeyecxErrorConfigService.apply('theme');
|
|
3723
3760
|
console.error('Program Configuration not found!');
|
|
@@ -3730,11 +3767,10 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
|
|
|
3730
3767
|
?.get(`${environment.bootstrapAssets}`, {
|
|
3731
3768
|
observe: 'response'
|
|
3732
3769
|
})
|
|
3733
|
-
?.subscribe((
|
|
3734
|
-
const { headers, body } = resp;
|
|
3770
|
+
?.subscribe(({ headers, body }) => {
|
|
3735
3771
|
const monkeyCode = headers.get('monkey-code') || monkeyecxCode;
|
|
3736
3772
|
if (monkeyCode) {
|
|
3737
|
-
this.
|
|
3773
|
+
this.getSettings(monkeyCode, body, callback, environment, identifyCode);
|
|
3738
3774
|
configBootstrapSubject$.next(body);
|
|
3739
3775
|
}
|
|
3740
3776
|
else {
|