monkey-front-core 0.0.303 → 0.0.305
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/directives/monkeyecx-security-directive.mjs +9 -7
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +11 -8
- package/esm2020/lib/core/services/error/monkeyecx-http-error-handling.service.mjs +4 -4
- package/esm2020/lib/core/services/storage/monkeyecx-token-storage.service.mjs +88 -25
- package/esm2020/lib/store/actions/monkeyecx-storage.actions.mjs +3 -3
- package/esm2020/lib/store/reducers/monkeyecx-seeder.reducer.mjs +5 -5
- package/esm2020/lib/store/selectors/monkeyecx-storage.selector.mjs +2 -2
- package/fesm2015/monkey-front-core.mjs +366 -296
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +282 -217
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/directives/monkeyecx-security-directive.d.ts +1 -0
- package/lib/core/services/commons/monkeyecx-commons.service.d.ts +6 -6
- package/lib/core/services/error/monkeyecx-http-error-handling.service.d.ts +4 -4
- package/lib/core/services/storage/monkeyecx-token-storage.service.d.ts +26 -4
- package/lib/store/actions/monkeyecx-storage.actions.d.ts +6 -6
- package/lib/store/selectors/monkeyecx-storage.selector.d.ts +1 -1
- package/monkey-front-core-0.0.305.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.303.tgz +0 -0
|
@@ -19,14 +19,14 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
19
19
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
20
20
|
import * as i1$4 from '@angular/cdk/overlay';
|
|
21
21
|
import { OverlayModule } from '@angular/cdk/overlay';
|
|
22
|
+
import * as i2$3 from '@ngrx/store';
|
|
23
|
+
import { createAction, props, INIT, UPDATE, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
|
|
24
|
+
import { createEntityAdapter } from '@ngrx/entity';
|
|
22
25
|
import { __decorate } from 'tslib';
|
|
23
26
|
import { datadogRum } from '@datadog/browser-rum';
|
|
24
27
|
import * as i1$5 from '@angular/service-worker';
|
|
25
28
|
import { ServiceWorkerModule } from '@angular/service-worker';
|
|
26
29
|
import { initialize } from 'launchdarkly-js-client-sdk';
|
|
27
|
-
import * as i6 from '@ngrx/store';
|
|
28
|
-
import { createAction, props, INIT, UPDATE, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
|
|
29
|
-
import { createEntityAdapter } from '@ngrx/entity';
|
|
30
30
|
|
|
31
31
|
class AlertsComponent {
|
|
32
32
|
constructor(modalService) {
|
|
@@ -2431,6 +2431,183 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2431
2431
|
args: ['monkeyecxPopoverHeight']
|
|
2432
2432
|
}] } });
|
|
2433
2433
|
|
|
2434
|
+
const clear = createAction('[MECX Core Storage] Clear All');
|
|
2435
|
+
const create = createAction('[MECX Core Storage] Create', props());
|
|
2436
|
+
const deleteOne = createAction('[MECX Core Storage] Delete One', props());
|
|
2437
|
+
const updateControl = createAction('[MECX Core Storage] Update Control', props());
|
|
2438
|
+
const updateOne = createAction('[MECX Core Storage] Update One', props());
|
|
2439
|
+
|
|
2440
|
+
var monkeyecxStorage_actions = /*#__PURE__*/Object.freeze({
|
|
2441
|
+
__proto__: null,
|
|
2442
|
+
clear: clear,
|
|
2443
|
+
create: create,
|
|
2444
|
+
deleteOne: deleteOne,
|
|
2445
|
+
updateControl: updateControl,
|
|
2446
|
+
updateOne: updateOne
|
|
2447
|
+
});
|
|
2448
|
+
|
|
2449
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
2450
|
+
__proto__: null,
|
|
2451
|
+
monkeyecxStorage: monkeyecxStorage_actions
|
|
2452
|
+
});
|
|
2453
|
+
|
|
2454
|
+
const seederReducer = (keys) => {
|
|
2455
|
+
return (reducer) => {
|
|
2456
|
+
return (state, action) => {
|
|
2457
|
+
const handledState = reducer(state, action);
|
|
2458
|
+
if (action.type === INIT || action.type === UPDATE) {
|
|
2459
|
+
const storageValue = localStorage.getItem('mecx-store');
|
|
2460
|
+
if (storageValue) {
|
|
2461
|
+
try {
|
|
2462
|
+
const handled = {
|
|
2463
|
+
...handledState,
|
|
2464
|
+
...JSON.parse(atob(storageValue))
|
|
2465
|
+
};
|
|
2466
|
+
return handled;
|
|
2467
|
+
}
|
|
2468
|
+
catch {
|
|
2469
|
+
localStorage.removeItem('mecx-store');
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
let data = handledState;
|
|
2474
|
+
try {
|
|
2475
|
+
keys.forEach((key) => {
|
|
2476
|
+
data = {
|
|
2477
|
+
...data,
|
|
2478
|
+
[key]: handledState[key]
|
|
2479
|
+
};
|
|
2480
|
+
});
|
|
2481
|
+
localStorage.setItem('mecx-store', btoa(JSON.stringify(data)));
|
|
2482
|
+
}
|
|
2483
|
+
catch (e) {
|
|
2484
|
+
localStorage.removeItem('mecx-store');
|
|
2485
|
+
}
|
|
2486
|
+
return data || handledState;
|
|
2487
|
+
};
|
|
2488
|
+
};
|
|
2489
|
+
};
|
|
2490
|
+
|
|
2491
|
+
var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
|
|
2492
|
+
__proto__: null,
|
|
2493
|
+
seederReducer: seederReducer
|
|
2494
|
+
});
|
|
2495
|
+
|
|
2496
|
+
const featureKey = 'mecx-core-storage';
|
|
2497
|
+
const adapter = createEntityAdapter({
|
|
2498
|
+
selectId: (item) => {
|
|
2499
|
+
return item.username;
|
|
2500
|
+
}
|
|
2501
|
+
});
|
|
2502
|
+
const initialState = adapter.getInitialState({
|
|
2503
|
+
control: {
|
|
2504
|
+
isLoading: false
|
|
2505
|
+
},
|
|
2506
|
+
error: null
|
|
2507
|
+
});
|
|
2508
|
+
const reducer = createReducer(initialState, on(clear, (state) => {
|
|
2509
|
+
return adapter.removeAll(state);
|
|
2510
|
+
}), on(create, (state, action) => {
|
|
2511
|
+
return adapter.upsertMany(action.data, {
|
|
2512
|
+
...state
|
|
2513
|
+
});
|
|
2514
|
+
}), on(updateControl, (state, action) => {
|
|
2515
|
+
return {
|
|
2516
|
+
...state,
|
|
2517
|
+
control: {
|
|
2518
|
+
...state.control,
|
|
2519
|
+
...action.data
|
|
2520
|
+
}
|
|
2521
|
+
};
|
|
2522
|
+
}), on(updateOne, (state, action) => {
|
|
2523
|
+
const { username } = action.data;
|
|
2524
|
+
return adapter.upsertOne({ ...action.data, username }, {
|
|
2525
|
+
...state
|
|
2526
|
+
});
|
|
2527
|
+
}), on(deleteOne, (state, action) => {
|
|
2528
|
+
const { username } = action.data;
|
|
2529
|
+
return adapter.removeOne(username, state);
|
|
2530
|
+
}));
|
|
2531
|
+
const { selectAll: selectAll$1, selectEntities, selectIds, selectTotal } = adapter.getSelectors();
|
|
2532
|
+
|
|
2533
|
+
var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
|
|
2534
|
+
__proto__: null,
|
|
2535
|
+
featureKey: featureKey,
|
|
2536
|
+
adapter: adapter,
|
|
2537
|
+
initialState: initialState,
|
|
2538
|
+
reducer: reducer,
|
|
2539
|
+
selectAll: selectAll$1,
|
|
2540
|
+
selectEntities: selectEntities,
|
|
2541
|
+
selectIds: selectIds,
|
|
2542
|
+
selectTotal: selectTotal
|
|
2543
|
+
});
|
|
2544
|
+
|
|
2545
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
2546
|
+
__proto__: null,
|
|
2547
|
+
fromMonkeyecxSeeder: monkeyecxSeeder_reducer,
|
|
2548
|
+
fromMonkeyecxStorage: monkeyecxStorage_reducer
|
|
2549
|
+
});
|
|
2550
|
+
|
|
2551
|
+
const selectState = createFeatureSelector(featureKey);
|
|
2552
|
+
const selectAll = createSelector(selectState, selectAll$1);
|
|
2553
|
+
const select = (props) => {
|
|
2554
|
+
return createSelector(selectAll, (entities) => {
|
|
2555
|
+
return entities.find((_) => {
|
|
2556
|
+
return _.username === props.username;
|
|
2557
|
+
});
|
|
2558
|
+
});
|
|
2559
|
+
};
|
|
2560
|
+
const selectControl = () => {
|
|
2561
|
+
return createSelector(selectState, (state) => {
|
|
2562
|
+
return state.control;
|
|
2563
|
+
});
|
|
2564
|
+
};
|
|
2565
|
+
|
|
2566
|
+
var monkeyecxStorage_selector = /*#__PURE__*/Object.freeze({
|
|
2567
|
+
__proto__: null,
|
|
2568
|
+
selectState: selectState,
|
|
2569
|
+
selectAll: selectAll,
|
|
2570
|
+
select: select,
|
|
2571
|
+
selectControl: selectControl
|
|
2572
|
+
});
|
|
2573
|
+
|
|
2574
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
2575
|
+
__proto__: null,
|
|
2576
|
+
monkeyecxStorage: monkeyecxStorage_selector
|
|
2577
|
+
});
|
|
2578
|
+
|
|
2579
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
2580
|
+
__proto__: null,
|
|
2581
|
+
actions: index$3,
|
|
2582
|
+
reducers: index$2,
|
|
2583
|
+
selectors: index$1
|
|
2584
|
+
});
|
|
2585
|
+
|
|
2586
|
+
class Link {
|
|
2587
|
+
constructor(data) {
|
|
2588
|
+
this.href = data?.href;
|
|
2589
|
+
this.type = data?.type;
|
|
2590
|
+
this.templated = data?.templated;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
class MonkeyEcxModel {
|
|
2594
|
+
getAction(type, replaceOptions) {
|
|
2595
|
+
const { _links } = this;
|
|
2596
|
+
if (!_links)
|
|
2597
|
+
return null;
|
|
2598
|
+
let link = _links[type.toLowerCase()];
|
|
2599
|
+
link = new Link(link);
|
|
2600
|
+
if (link && replaceOptions && link?.templated) {
|
|
2601
|
+
const { from, to } = replaceOptions;
|
|
2602
|
+
link = new Link({
|
|
2603
|
+
...link,
|
|
2604
|
+
href: `${link.href}`.replace(from, to),
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
return link;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2434
2611
|
class MonkeyEcxRequestPagedHandling {
|
|
2435
2612
|
constructor(url, pagedParams, links, samePage = false) {
|
|
2436
2613
|
this.samePage = false;
|
|
@@ -2472,31 +2649,6 @@ class MonkeyEcxRequestPagedHandling {
|
|
|
2472
2649
|
}
|
|
2473
2650
|
}
|
|
2474
2651
|
|
|
2475
|
-
class Link {
|
|
2476
|
-
constructor(data) {
|
|
2477
|
-
this.href = data?.href;
|
|
2478
|
-
this.type = data?.type;
|
|
2479
|
-
this.templated = data?.templated;
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
class MonkeyEcxModel {
|
|
2483
|
-
getAction(type, replaceOptions) {
|
|
2484
|
-
const { _links } = this;
|
|
2485
|
-
if (!_links)
|
|
2486
|
-
return null;
|
|
2487
|
-
let link = _links[type.toLowerCase()];
|
|
2488
|
-
link = new Link(link);
|
|
2489
|
-
if (link && replaceOptions && link?.templated) {
|
|
2490
|
-
const { from, to } = replaceOptions;
|
|
2491
|
-
link = new Link({
|
|
2492
|
-
...link,
|
|
2493
|
-
href: `${link.href}`.replace(from, to),
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
return link;
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
2652
|
class LinksModel extends MonkeyEcxModel {
|
|
2501
2653
|
constructor(data) {
|
|
2502
2654
|
super();
|
|
@@ -2528,7 +2680,7 @@ class MonkeyEcxCommonsService {
|
|
|
2528
2680
|
this.__onZipCodeDataChanged$ = new BehaviorSubject(null);
|
|
2529
2681
|
this.__oni18nDataChanged$ = new BehaviorSubject(null);
|
|
2530
2682
|
this.__onDoSearch$ = new BehaviorSubject({});
|
|
2531
|
-
this.__tokenCredentials =
|
|
2683
|
+
this.__tokenCredentials = undefined;
|
|
2532
2684
|
this.__schedule = null;
|
|
2533
2685
|
this.__callbackPagination = () => {
|
|
2534
2686
|
// eslint-disable-next-line no-console
|
|
@@ -2537,9 +2689,9 @@ class MonkeyEcxCommonsService {
|
|
|
2537
2689
|
this.__isAbleToDoPagination = {};
|
|
2538
2690
|
this.handleInit();
|
|
2539
2691
|
}
|
|
2540
|
-
handleInit() {
|
|
2692
|
+
async handleInit() {
|
|
2541
2693
|
if (this.tokenStorage) {
|
|
2542
|
-
this.__tokenCredentials = this.tokenStorage.getToken();
|
|
2694
|
+
this.__tokenCredentials = await this.tokenStorage.getToken();
|
|
2543
2695
|
}
|
|
2544
2696
|
if (this.otherArgs?.router) {
|
|
2545
2697
|
const { clearOnChangeRoute } = this.otherArgs?.schedule?.options || {
|
|
@@ -2722,7 +2874,7 @@ class MonkeyEcxCommonsService {
|
|
|
2722
2874
|
this.__handledError = null;
|
|
2723
2875
|
this.flagValidator = false;
|
|
2724
2876
|
}
|
|
2725
|
-
resolve(route, state, otherArgs) {
|
|
2877
|
+
async resolve(route, state, otherArgs) {
|
|
2726
2878
|
if (JSON.stringify(route?.queryParams) === '{}') {
|
|
2727
2879
|
this.__data = null;
|
|
2728
2880
|
this.__page = null;
|
|
@@ -2730,7 +2882,10 @@ class MonkeyEcxCommonsService {
|
|
|
2730
2882
|
this.__requestPaged = null;
|
|
2731
2883
|
this.flagValidator = true;
|
|
2732
2884
|
if (this.tokenStorage) {
|
|
2733
|
-
|
|
2885
|
+
console.log('resolve commmons');
|
|
2886
|
+
this.__tokenCredentials = await this.tokenStorage.getToken();
|
|
2887
|
+
console.log('this.__tokenCredentials');
|
|
2888
|
+
console.log(this.__tokenCredentials);
|
|
2734
2889
|
}
|
|
2735
2890
|
const pend = this.allowedSecurityAccessByPendency(otherArgs?.pendency);
|
|
2736
2891
|
const allowedByProgram = this.allowedSecurityAccessByFeature(otherArgs?.featureByProgram);
|
|
@@ -3452,8 +3607,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
3452
3607
|
}], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxi18nConfigService }, { type: MonkeyEcxLogsConfigService }, { type: i1.MonkeyStyleGuideSettingsService }, { type: MonkeyEcxServiceWorkerConfigService }, { type: MonkeyEcxSecurityConsoleConfigService }, { type: MonkeyEcxMaintenanceConfigService }, { type: MonkeyEcxErrorConfigService }, { type: MonkeyEcxFeatureToggleService }, { type: MonkeyEcxGTMConfigService }, { type: MonkeyEcxAlertsConfigService }]; }, propDecorators: { init: [] } });
|
|
3453
3608
|
|
|
3454
3609
|
class MonkeyEcxTokenStorageService {
|
|
3455
|
-
constructor(monkeyecxConfigService) {
|
|
3610
|
+
constructor(monkeyecxConfigService, store) {
|
|
3456
3611
|
this.monkeyecxConfigService = monkeyecxConfigService;
|
|
3612
|
+
this.store = store;
|
|
3457
3613
|
this.config = null;
|
|
3458
3614
|
this.token = {
|
|
3459
3615
|
username: '',
|
|
@@ -3470,8 +3626,8 @@ class MonkeyEcxTokenStorageService {
|
|
|
3470
3626
|
role: '',
|
|
3471
3627
|
ownerGovernmentId: '',
|
|
3472
3628
|
_clearIgnore: {
|
|
3473
|
-
ignore: ['username', 'program', 'accessType']
|
|
3474
|
-
}
|
|
3629
|
+
ignore: ['username', 'program', 'accessType']
|
|
3630
|
+
}
|
|
3475
3631
|
};
|
|
3476
3632
|
this.token$ = new BehaviorSubject(null);
|
|
3477
3633
|
this.me$ = new BehaviorSubject(null);
|
|
@@ -3480,44 +3636,82 @@ class MonkeyEcxTokenStorageService {
|
|
|
3480
3636
|
});
|
|
3481
3637
|
}
|
|
3482
3638
|
setAllTokens(token) {
|
|
3483
|
-
const { token
|
|
3639
|
+
const { token$, store } = this;
|
|
3484
3640
|
Object.entries(token).forEach(([key, value]) => {
|
|
3485
3641
|
if (MonkeyEcxUtils.persistNullEmptyUndefined(value)) {
|
|
3486
3642
|
localStorage.setItem(key, value);
|
|
3487
3643
|
}
|
|
3488
3644
|
});
|
|
3645
|
+
const username = token.username || localStorage.getItem('username');
|
|
3646
|
+
if (username) {
|
|
3647
|
+
store.dispatch(create({
|
|
3648
|
+
data: [
|
|
3649
|
+
{
|
|
3650
|
+
username,
|
|
3651
|
+
...token
|
|
3652
|
+
}
|
|
3653
|
+
]
|
|
3654
|
+
}));
|
|
3655
|
+
}
|
|
3489
3656
|
token$.next(token);
|
|
3490
3657
|
}
|
|
3491
|
-
getAllTokens() {
|
|
3492
|
-
const {
|
|
3493
|
-
const
|
|
3494
|
-
|
|
3658
|
+
async getAllTokens() {
|
|
3659
|
+
const { store, monkeyecxConfigService } = this;
|
|
3660
|
+
const username = localStorage.getItem('username');
|
|
3661
|
+
let data = {
|
|
3662
|
+
username: username || '',
|
|
3663
|
+
program: ''
|
|
3495
3664
|
};
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3665
|
+
if (username) {
|
|
3666
|
+
data = await store.select(select({ username })).pipe(take(1)).toPromise();
|
|
3667
|
+
delete data?.me;
|
|
3668
|
+
}
|
|
3669
|
+
const config = await monkeyecxConfigService.config()
|
|
3670
|
+
.pipe(first((val) => {
|
|
3671
|
+
return !!val && JSON.stringify(val) !== '{}';
|
|
3672
|
+
}))
|
|
3673
|
+
.toPromise();
|
|
3674
|
+
if (data && !data?.program && config?.program) {
|
|
3675
|
+
data.program = config?.program?.token;
|
|
3501
3676
|
}
|
|
3502
|
-
return
|
|
3677
|
+
return data;
|
|
3503
3678
|
}
|
|
3504
3679
|
setAllMe(me) {
|
|
3505
|
-
const { me
|
|
3680
|
+
const { me$, store } = this;
|
|
3506
3681
|
let previousMe = JSON.parse(localStorage?.getItem('me') || '{}');
|
|
3507
3682
|
Object.entries(me).forEach(([key, value]) => {
|
|
3508
3683
|
if (MonkeyEcxUtils.persistNullEmptyUndefined(value)) {
|
|
3509
3684
|
previousMe = {
|
|
3510
3685
|
...previousMe,
|
|
3511
|
-
[key]: value
|
|
3686
|
+
[key]: value
|
|
3512
3687
|
};
|
|
3513
3688
|
}
|
|
3514
3689
|
});
|
|
3690
|
+
const username = me.username || localStorage.getItem('username');
|
|
3691
|
+
if (username) {
|
|
3692
|
+
store.dispatch(create({
|
|
3693
|
+
data: [
|
|
3694
|
+
{
|
|
3695
|
+
username,
|
|
3696
|
+
me
|
|
3697
|
+
}
|
|
3698
|
+
]
|
|
3699
|
+
}));
|
|
3700
|
+
}
|
|
3515
3701
|
localStorage.setItem('me', JSON.stringify(previousMe));
|
|
3516
3702
|
me$.next(previousMe);
|
|
3517
3703
|
}
|
|
3518
|
-
getAllMe() {
|
|
3519
|
-
const
|
|
3520
|
-
|
|
3704
|
+
async getAllMe() {
|
|
3705
|
+
const { store } = this;
|
|
3706
|
+
const username = localStorage.getItem('username');
|
|
3707
|
+
let data = {
|
|
3708
|
+
username: username || '',
|
|
3709
|
+
program: ''
|
|
3710
|
+
};
|
|
3711
|
+
if (username) {
|
|
3712
|
+
data = await store.select(select({ username })).pipe(take(1)).toPromise();
|
|
3713
|
+
}
|
|
3714
|
+
return data?.me;
|
|
3521
3715
|
}
|
|
3522
3716
|
tokenHasChanged() {
|
|
3523
3717
|
return this.token$.asObservable();
|
|
@@ -3538,7 +3732,7 @@ class MonkeyEcxTokenStorageService {
|
|
|
3538
3732
|
this.setAllMe(me);
|
|
3539
3733
|
}
|
|
3540
3734
|
clear(force) {
|
|
3541
|
-
const { token } = this;
|
|
3735
|
+
const { token, store } = this;
|
|
3542
3736
|
try {
|
|
3543
3737
|
Object.entries(token || {}).forEach(([key, value]) => {
|
|
3544
3738
|
if ((token?._clearIgnore?.ignore || []).filter((val) => {
|
|
@@ -3549,6 +3743,10 @@ class MonkeyEcxTokenStorageService {
|
|
|
3549
3743
|
}
|
|
3550
3744
|
});
|
|
3551
3745
|
localStorage.removeItem('me');
|
|
3746
|
+
const username = localStorage.getItem('username');
|
|
3747
|
+
if (username) {
|
|
3748
|
+
store.dispatch(deleteOne({ data: { username } }));
|
|
3749
|
+
}
|
|
3552
3750
|
}
|
|
3553
3751
|
catch (error) {
|
|
3554
3752
|
return of(false);
|
|
@@ -3559,19 +3757,36 @@ class MonkeyEcxTokenStorageService {
|
|
|
3559
3757
|
* @param fields (the name of fields you want to clear. ie: ['companyId', 'role', ...])
|
|
3560
3758
|
*/
|
|
3561
3759
|
clearCredentials(fields = ['companyId', 'governmentId', 'companyType', 'programAdmin', 'role']) {
|
|
3760
|
+
const { store } = this;
|
|
3761
|
+
let obj = null;
|
|
3562
3762
|
fields?.forEach((key) => {
|
|
3763
|
+
obj = {
|
|
3764
|
+
...obj,
|
|
3765
|
+
[key]: null
|
|
3766
|
+
};
|
|
3563
3767
|
localStorage.removeItem(key);
|
|
3564
3768
|
});
|
|
3769
|
+
const username = localStorage.getItem('username');
|
|
3770
|
+
if (username) {
|
|
3771
|
+
store.dispatch(create({
|
|
3772
|
+
data: [
|
|
3773
|
+
{
|
|
3774
|
+
username,
|
|
3775
|
+
...obj
|
|
3776
|
+
}
|
|
3777
|
+
]
|
|
3778
|
+
}));
|
|
3779
|
+
}
|
|
3565
3780
|
}
|
|
3566
3781
|
}
|
|
3567
|
-
MonkeyEcxTokenStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, deps: [{ token: MonkeyEcxConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3782
|
+
MonkeyEcxTokenStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, deps: [{ token: MonkeyEcxConfigService }, { token: i2$3.Store }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3568
3783
|
MonkeyEcxTokenStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, providedIn: 'root' });
|
|
3569
3784
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, decorators: [{
|
|
3570
3785
|
type: Injectable,
|
|
3571
3786
|
args: [{
|
|
3572
|
-
providedIn: 'root'
|
|
3787
|
+
providedIn: 'root'
|
|
3573
3788
|
}]
|
|
3574
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxConfigService }]; } });
|
|
3789
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxConfigService }, { type: i2$3.Store }]; } });
|
|
3575
3790
|
|
|
3576
3791
|
class MonkeyEcxSecurityDirective {
|
|
3577
3792
|
constructor(elementRef, tokenStorageService, cdr) {
|
|
@@ -3580,7 +3795,7 @@ class MonkeyEcxSecurityDirective {
|
|
|
3580
3795
|
this.cdr = cdr;
|
|
3581
3796
|
this.roles = [];
|
|
3582
3797
|
this.byExclusion = false;
|
|
3583
|
-
this.tokenCredentials =
|
|
3798
|
+
this.tokenCredentials = undefined;
|
|
3584
3799
|
// not to do
|
|
3585
3800
|
}
|
|
3586
3801
|
getRole() {
|
|
@@ -3613,15 +3828,17 @@ class MonkeyEcxSecurityDirective {
|
|
|
3613
3828
|
this.elementRef.nativeElement.style.display = display;
|
|
3614
3829
|
this.cdr.detectChanges();
|
|
3615
3830
|
}
|
|
3831
|
+
async handleData() {
|
|
3832
|
+
this.tokenCredentials = await this.tokenStorageService.getToken();
|
|
3833
|
+
this.handleAccess();
|
|
3834
|
+
}
|
|
3616
3835
|
ngOnInit() {
|
|
3617
3836
|
this.elementRef.nativeElement.style.display = 'none';
|
|
3618
3837
|
this.cdr.detectChanges();
|
|
3619
3838
|
this.tokenStorageService.tokenHasChanged().subscribe(() => {
|
|
3620
|
-
this.
|
|
3621
|
-
this.handleAccess();
|
|
3839
|
+
this.handleData();
|
|
3622
3840
|
});
|
|
3623
|
-
this.
|
|
3624
|
-
this.handleAccess();
|
|
3841
|
+
this.handleData();
|
|
3625
3842
|
}
|
|
3626
3843
|
}
|
|
3627
3844
|
MonkeyEcxSecurityDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxSecurityDirective, deps: [{ token: i0.ElementRef }, { token: MonkeyEcxTokenStorageService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -3629,7 +3846,7 @@ MonkeyEcxSecurityDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0
|
|
|
3629
3846
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxSecurityDirective, decorators: [{
|
|
3630
3847
|
type: Directive,
|
|
3631
3848
|
args: [{
|
|
3632
|
-
selector: '[monkeyecxSecurity]'
|
|
3849
|
+
selector: '[monkeyecxSecurity]'
|
|
3633
3850
|
}]
|
|
3634
3851
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MonkeyEcxTokenStorageService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { roles: [{
|
|
3635
3852
|
type: Input,
|
|
@@ -4119,10 +4336,10 @@ class MonkeyEcxHttpErrorHandlingService extends MonkeyEcxCommonsService {
|
|
|
4119
4336
|
this.showMessage(customMessage, error, mkc);
|
|
4120
4337
|
}
|
|
4121
4338
|
}
|
|
4122
|
-
handleError(error, mkc) {
|
|
4339
|
+
async handleError(error, mkc) {
|
|
4123
4340
|
const { router, tokenStorage } = this;
|
|
4124
4341
|
const { status } = error;
|
|
4125
|
-
const { companyType } = tokenStorage?.getToken() || { companyType: '' };
|
|
4342
|
+
const { companyType } = await tokenStorage?.getToken() || { companyType: '' };
|
|
4126
4343
|
const routes = {
|
|
4127
4344
|
403: 'forbidden',
|
|
4128
4345
|
500: 'service-problems',
|
|
@@ -5375,163 +5592,11 @@ class MonkeyEcxSpecificationSearch {
|
|
|
5375
5592
|
}
|
|
5376
5593
|
}
|
|
5377
5594
|
|
|
5378
|
-
const clear = createAction('[MECX Core Storage] Clear All');
|
|
5379
|
-
const create = createAction('[MECX Core Storage] Create', props());
|
|
5380
|
-
const updateControl = createAction('[MECX Core Storage] Update Control', props());
|
|
5381
|
-
const updateOne = createAction('[MECX Core Storage] Update One', props());
|
|
5382
|
-
const deleteOne = createAction('[MECX Core Storage] Delete One', props());
|
|
5383
|
-
|
|
5384
|
-
var monkeyecxStorage_actions = /*#__PURE__*/Object.freeze({
|
|
5385
|
-
__proto__: null,
|
|
5386
|
-
clear: clear,
|
|
5387
|
-
create: create,
|
|
5388
|
-
updateControl: updateControl,
|
|
5389
|
-
updateOne: updateOne,
|
|
5390
|
-
deleteOne: deleteOne
|
|
5391
|
-
});
|
|
5392
|
-
|
|
5393
|
-
var index$3 = /*#__PURE__*/Object.freeze({
|
|
5394
|
-
__proto__: null,
|
|
5395
|
-
monkeyecxStorage: monkeyecxStorage_actions
|
|
5396
|
-
});
|
|
5397
|
-
|
|
5398
|
-
const seederReducer = (keys) => {
|
|
5399
|
-
return (reducer) => {
|
|
5400
|
-
return (state, action) => {
|
|
5401
|
-
const handledState = reducer(state, action);
|
|
5402
|
-
if (action.type === INIT || action.type === UPDATE) {
|
|
5403
|
-
const storageValue = localStorage.getItem('state');
|
|
5404
|
-
if (storageValue) {
|
|
5405
|
-
try {
|
|
5406
|
-
const handled = {
|
|
5407
|
-
...handledState,
|
|
5408
|
-
...JSON.parse(atob(storageValue))
|
|
5409
|
-
};
|
|
5410
|
-
return handled;
|
|
5411
|
-
}
|
|
5412
|
-
catch {
|
|
5413
|
-
localStorage.removeItem('state');
|
|
5414
|
-
}
|
|
5415
|
-
}
|
|
5416
|
-
}
|
|
5417
|
-
let data = handledState;
|
|
5418
|
-
try {
|
|
5419
|
-
keys.forEach((key) => {
|
|
5420
|
-
data = {
|
|
5421
|
-
...data,
|
|
5422
|
-
[key]: handledState[key]
|
|
5423
|
-
};
|
|
5424
|
-
});
|
|
5425
|
-
localStorage.setItem('state', btoa(JSON.stringify(data)));
|
|
5426
|
-
}
|
|
5427
|
-
catch (e) {
|
|
5428
|
-
localStorage.removeItem('state');
|
|
5429
|
-
}
|
|
5430
|
-
return data || handledState;
|
|
5431
|
-
};
|
|
5432
|
-
};
|
|
5433
|
-
};
|
|
5434
|
-
|
|
5435
|
-
var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
|
|
5436
|
-
__proto__: null,
|
|
5437
|
-
seederReducer: seederReducer
|
|
5438
|
-
});
|
|
5439
|
-
|
|
5440
|
-
const featureKey = 'mecx-core-storage';
|
|
5441
|
-
const adapter = createEntityAdapter({
|
|
5442
|
-
selectId: (item) => {
|
|
5443
|
-
return item.username;
|
|
5444
|
-
}
|
|
5445
|
-
});
|
|
5446
|
-
const initialState = adapter.getInitialState({
|
|
5447
|
-
control: {
|
|
5448
|
-
isLoading: false
|
|
5449
|
-
},
|
|
5450
|
-
error: null
|
|
5451
|
-
});
|
|
5452
|
-
const reducer = createReducer(initialState, on(clear, (state) => {
|
|
5453
|
-
return adapter.removeAll(state);
|
|
5454
|
-
}), on(create, (state, action) => {
|
|
5455
|
-
return adapter.upsertMany(action.data, {
|
|
5456
|
-
...state
|
|
5457
|
-
});
|
|
5458
|
-
}), on(updateControl, (state, action) => {
|
|
5459
|
-
return {
|
|
5460
|
-
...state,
|
|
5461
|
-
control: {
|
|
5462
|
-
...state.control,
|
|
5463
|
-
...action.data
|
|
5464
|
-
}
|
|
5465
|
-
};
|
|
5466
|
-
}), on(updateOne, (state, action) => {
|
|
5467
|
-
const { username } = action.data;
|
|
5468
|
-
return adapter.upsertOne({ ...action.data, username }, {
|
|
5469
|
-
...state
|
|
5470
|
-
});
|
|
5471
|
-
}), on(deleteOne, (state, action) => {
|
|
5472
|
-
const { username } = action.data;
|
|
5473
|
-
return adapter.removeOne(username, state);
|
|
5474
|
-
}));
|
|
5475
|
-
const { selectAll: selectAll$1, selectEntities, selectIds, selectTotal } = adapter.getSelectors();
|
|
5476
|
-
|
|
5477
|
-
var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
|
|
5478
|
-
__proto__: null,
|
|
5479
|
-
featureKey: featureKey,
|
|
5480
|
-
adapter: adapter,
|
|
5481
|
-
initialState: initialState,
|
|
5482
|
-
reducer: reducer,
|
|
5483
|
-
selectAll: selectAll$1,
|
|
5484
|
-
selectEntities: selectEntities,
|
|
5485
|
-
selectIds: selectIds,
|
|
5486
|
-
selectTotal: selectTotal
|
|
5487
|
-
});
|
|
5488
|
-
|
|
5489
|
-
var index$2 = /*#__PURE__*/Object.freeze({
|
|
5490
|
-
__proto__: null,
|
|
5491
|
-
fromMonkeyecxSeeder: monkeyecxSeeder_reducer,
|
|
5492
|
-
fromMonkeyecxStorage: monkeyecxStorage_reducer
|
|
5493
|
-
});
|
|
5494
|
-
|
|
5495
|
-
const selectState = createFeatureSelector(featureKey);
|
|
5496
|
-
const selectAll = createSelector(selectState, selectAll$1);
|
|
5497
|
-
const select = (props) => {
|
|
5498
|
-
return createSelector(selectAll, (entities) => {
|
|
5499
|
-
return entities.filter((_) => {
|
|
5500
|
-
return _.username === props.username;
|
|
5501
|
-
});
|
|
5502
|
-
});
|
|
5503
|
-
};
|
|
5504
|
-
const selectControl = () => {
|
|
5505
|
-
return createSelector(selectState, (state) => {
|
|
5506
|
-
return state.control;
|
|
5507
|
-
});
|
|
5508
|
-
};
|
|
5509
|
-
|
|
5510
|
-
var monkeyecxStorage_selector = /*#__PURE__*/Object.freeze({
|
|
5511
|
-
__proto__: null,
|
|
5512
|
-
selectState: selectState,
|
|
5513
|
-
selectAll: selectAll,
|
|
5514
|
-
select: select,
|
|
5515
|
-
selectControl: selectControl
|
|
5516
|
-
});
|
|
5517
|
-
|
|
5518
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
5519
|
-
__proto__: null,
|
|
5520
|
-
monkeyecxStorage: monkeyecxStorage_selector
|
|
5521
|
-
});
|
|
5522
|
-
|
|
5523
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
5524
|
-
__proto__: null,
|
|
5525
|
-
actions: index$3,
|
|
5526
|
-
reducers: index$2,
|
|
5527
|
-
selectors: index$1
|
|
5528
|
-
});
|
|
5529
|
-
|
|
5530
5595
|
class MonkeyFrontCoreModule {
|
|
5531
5596
|
}
|
|
5532
5597
|
MonkeyFrontCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
5533
5598
|
MonkeyFrontCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, imports: [CommonModule,
|
|
5534
|
-
HttpClientModule, i1$1.TranslateModule, MonkeyEcxConfigModule, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxErrorHandlingModule, MonkeyStyleGuideModule, i1$5.ServiceWorkerModule, ClosedToMaintenanceModule,
|
|
5599
|
+
HttpClientModule, i1$1.TranslateModule, MonkeyEcxConfigModule, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxErrorHandlingModule, MonkeyStyleGuideModule, i1$5.ServiceWorkerModule, ClosedToMaintenanceModule, i2$3.StoreFeatureModule, VersionChangedModule,
|
|
5535
5600
|
AlertsModule,
|
|
5536
5601
|
CurrencyConfigModule] });
|
|
5537
5602
|
MonkeyFrontCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, providers: [
|