@elite.framework/ng.core 2.0.22 → 2.0.23
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/directives/index.d.ts +44 -3
- package/fesm2022/elite.framework-ng.core-directives.mjs +203 -2
- package/fesm2022/elite.framework-ng.core-directives.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-models.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-pipes.mjs +60 -2
- package/fesm2022/elite.framework-ng.core-pipes.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-providers.mjs +7 -6
- package/fesm2022/elite.framework-ng.core-providers.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-services.mjs +179 -5
- package/fesm2022/elite.framework-ng.core-services.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-tokens.mjs +6 -1
- package/fesm2022/elite.framework-ng.core-tokens.mjs.map +1 -1
- package/fesm2022/elite.framework-ng.core-utils.mjs +20 -1
- package/fesm2022/elite.framework-ng.core-utils.mjs.map +1 -1
- package/models/index.d.ts +57 -4
- package/package.json +1 -1
- package/pipes/index.d.ts +21 -3
- package/providers/index.d.ts +2 -2
- package/services/index.d.ts +63 -5
- package/tokens/index.d.ts +6 -2
- package/utils/index.d.ts +10 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, inject, Inject, InjectionToken, PLATFORM_ID, Optional, isDevMode, SkipSelf, effect, signal, Injector } from '@angular/core';
|
|
3
|
-
import { throwError, catchError, map as map$1, Subject, BehaviorSubject, combineLatest, from, switchMap as switchMap$1, Subscription, of, timer, firstValueFrom, noop, lastValueFrom } from 'rxjs';
|
|
3
|
+
import { throwError, catchError, map as map$1, Subject, BehaviorSubject, combineLatest, from, switchMap as switchMap$1, Subscription, of, timer, firstValueFrom, noop as noop$1, lastValueFrom } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpParams, HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
6
6
|
import { CORE_OPTIONS, INCUDE_LOCALIZATION_RESOURCES_TOKEN, localizations$, DISABLE_PROJECT_NAME, OTHERS_GROUP, TENANT_KEY, TENANT_NOT_FOUND_BY_NAME, CHECK_AUTHENTICATION_STATE_FN_KEY, APP_INIT_ERROR_HANDLERS } from '@elite.framework/ng.core/tokens';
|
|
7
|
-
import { InternalStore, isFunction, transformStringToArray, isPlainObject, createLocalizer, createLocalizerWithFallback, interpolate, createTreeFromList, BaseTreeNode, createGroupMap, pushValueTo, deepMerge, createTokenParser } from '@elite.framework/ng.core/utils';
|
|
7
|
+
import { InternalStore, isFunction, transformStringToArray, isPlainObject, createLocalizer, createLocalizerWithFallback, interpolate, createTreeFromList, BaseTreeNode, createGroupMap, pushValueTo, noop, getPathName, deepMerge, createTokenParser } from '@elite.framework/ng.core/utils';
|
|
8
8
|
import { map, switchMap, tap, take, filter, mapTo, takeUntil, catchError as catchError$1 } from 'rxjs/operators';
|
|
9
9
|
import { isPlatformBrowser, DOCUMENT, registerLocaleData } from '@angular/common';
|
|
10
10
|
import * as i1$1 from '@ngx-translate/core';
|
|
11
11
|
import Swal from 'sweetalert2';
|
|
12
12
|
import * as i2 from '@angular/router';
|
|
13
|
-
import { RouterStateSnapshot, TitleStrategy, NavigationStart, NavigationError, NavigationEnd, NavigationCancel, Router } from '@angular/router';
|
|
13
|
+
import { RouterStateSnapshot, TitleStrategy, NavigationStart, NavigationError, NavigationEnd, NavigationCancel, Router, PRIMARY_OUTLET } from '@angular/router';
|
|
14
14
|
import { DEFAULT_REDIRECT_KEY, NavItem, UserMenu } from '@elite.framework/ng.core/models';
|
|
15
15
|
import compare from 'just-compare';
|
|
16
16
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -2603,6 +2603,180 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
|
|
|
2603
2603
|
args: [{ providedIn: 'root' }]
|
|
2604
2604
|
}] });
|
|
2605
2605
|
|
|
2606
|
+
function findRoute(routesService, path) {
|
|
2607
|
+
const node = routesService.find(route => route.path === path);
|
|
2608
|
+
return node || path === '/'
|
|
2609
|
+
? node
|
|
2610
|
+
: findRoute(routesService, path.split('/').slice(0, -1).join('/') || '/');
|
|
2611
|
+
}
|
|
2612
|
+
function getRoutePath(router, url = router.url) {
|
|
2613
|
+
const emptyGroup = { segments: [] };
|
|
2614
|
+
const primaryGroup = router.parseUrl(url).root.children[PRIMARY_OUTLET];
|
|
2615
|
+
return '/' + (primaryGroup || emptyGroup).segments.map(({ path }) => path).join('/');
|
|
2616
|
+
}
|
|
2617
|
+
function reloadRoute(router, ngZone) {
|
|
2618
|
+
const { shouldReuseRoute } = router.routeReuseStrategy;
|
|
2619
|
+
const setRouteReuse = (reuse) => {
|
|
2620
|
+
router.routeReuseStrategy.shouldReuseRoute = reuse;
|
|
2621
|
+
};
|
|
2622
|
+
setRouteReuse(() => false);
|
|
2623
|
+
router.navigated = false;
|
|
2624
|
+
ngZone.run(async () => {
|
|
2625
|
+
await router.navigateByUrl(router.url).catch(noop);
|
|
2626
|
+
setRouteReuse(shouldReuseRoute);
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
class ReplaceableComponentsService {
|
|
2631
|
+
ngZone;
|
|
2632
|
+
router;
|
|
2633
|
+
store;
|
|
2634
|
+
get replaceableComponents$() {
|
|
2635
|
+
return this.store.sliceState(state => state);
|
|
2636
|
+
}
|
|
2637
|
+
get replaceableComponents() {
|
|
2638
|
+
return this.store.state;
|
|
2639
|
+
}
|
|
2640
|
+
get onUpdate$() {
|
|
2641
|
+
return this.store.sliceUpdate(state => state);
|
|
2642
|
+
}
|
|
2643
|
+
constructor(ngZone, router) {
|
|
2644
|
+
this.ngZone = ngZone;
|
|
2645
|
+
this.router = router;
|
|
2646
|
+
this.store = new InternalStore([]);
|
|
2647
|
+
}
|
|
2648
|
+
add(replaceableComponent, reload) {
|
|
2649
|
+
const replaceableComponents = [...this.store.state];
|
|
2650
|
+
const index = replaceableComponents.findIndex(component => component.key === replaceableComponent.key);
|
|
2651
|
+
if (index > -1) {
|
|
2652
|
+
replaceableComponents[index] = replaceableComponent;
|
|
2653
|
+
}
|
|
2654
|
+
else {
|
|
2655
|
+
replaceableComponents.push(replaceableComponent);
|
|
2656
|
+
}
|
|
2657
|
+
this.store.set(replaceableComponents);
|
|
2658
|
+
if (reload)
|
|
2659
|
+
reloadRoute(this.router, this.ngZone);
|
|
2660
|
+
}
|
|
2661
|
+
get(replaceableComponentKey) {
|
|
2662
|
+
return this.replaceableComponents.find(component => component.key === replaceableComponentKey);
|
|
2663
|
+
}
|
|
2664
|
+
get$(replaceableComponentKey) {
|
|
2665
|
+
return this.replaceableComponents$.pipe(map(components => components.find(component => component.key === replaceableComponentKey)));
|
|
2666
|
+
}
|
|
2667
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: ReplaceableComponentsService, deps: [{ token: i0.NgZone }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2668
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: ReplaceableComponentsService, providedIn: 'root' });
|
|
2669
|
+
}
|
|
2670
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: ReplaceableComponentsService, decorators: [{
|
|
2671
|
+
type: Injectable,
|
|
2672
|
+
args: [{ providedIn: 'root' }]
|
|
2673
|
+
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i2.Router }] });
|
|
2674
|
+
|
|
2675
|
+
class HttpWaitService {
|
|
2676
|
+
store = new InternalStore({
|
|
2677
|
+
requests: [],
|
|
2678
|
+
filteredRequests: [],
|
|
2679
|
+
});
|
|
2680
|
+
delay;
|
|
2681
|
+
destroy$ = new Subject();
|
|
2682
|
+
constructor(injector) {
|
|
2683
|
+
this.delay = 500;
|
|
2684
|
+
}
|
|
2685
|
+
getLoading() {
|
|
2686
|
+
return !!this.applyFilter(this.store.state.requests).length;
|
|
2687
|
+
}
|
|
2688
|
+
getLoading$() {
|
|
2689
|
+
return this.store
|
|
2690
|
+
.sliceState(({ requests }) => requests)
|
|
2691
|
+
.pipe(map(requests => !!this.applyFilter(requests).length), switchMap(condition => condition
|
|
2692
|
+
? this.delay === 0
|
|
2693
|
+
? of(true)
|
|
2694
|
+
: timer(this.delay).pipe(mapTo(true), takeUntil(this.destroy$))
|
|
2695
|
+
: of(false)), tap(() => this.destroy$.next()));
|
|
2696
|
+
}
|
|
2697
|
+
updateLoading$() {
|
|
2698
|
+
return this.store.sliceUpdate(({ requests }) => !!this.applyFilter(requests).length);
|
|
2699
|
+
}
|
|
2700
|
+
clearLoading() {
|
|
2701
|
+
this.store.patch({ requests: [] });
|
|
2702
|
+
}
|
|
2703
|
+
addRequest(request) {
|
|
2704
|
+
this.store.patch({ requests: [...this.store.state.requests, request] });
|
|
2705
|
+
}
|
|
2706
|
+
deleteRequest(request) {
|
|
2707
|
+
const requests = this.store.state.requests.filter(r => r !== request);
|
|
2708
|
+
this.store.patch({ requests });
|
|
2709
|
+
}
|
|
2710
|
+
addFilter(request) {
|
|
2711
|
+
const requests = Array.isArray(request) ? request : [request];
|
|
2712
|
+
const filteredRequests = [
|
|
2713
|
+
...this.store.state.filteredRequests.filter(f => !requests.some(r => this.isSameRequest(f, r))),
|
|
2714
|
+
...requests,
|
|
2715
|
+
];
|
|
2716
|
+
this.store.patch({ filteredRequests });
|
|
2717
|
+
}
|
|
2718
|
+
removeFilter(request) {
|
|
2719
|
+
const requests = Array.isArray(request) ? request : [request];
|
|
2720
|
+
const filteredRequests = this.store.state.filteredRequests.filter(f => !requests.some(r => this.isSameRequest(f, r)));
|
|
2721
|
+
this.store.patch({ filteredRequests });
|
|
2722
|
+
}
|
|
2723
|
+
applyFilter(requests) {
|
|
2724
|
+
if (!requests) {
|
|
2725
|
+
return [];
|
|
2726
|
+
}
|
|
2727
|
+
const { filteredRequests } = this.store.state;
|
|
2728
|
+
return requests.filter(({ method, url }) => !filteredRequests.find(filteredRequest => this.isSameRequest(filteredRequest, { method, endpoint: getPathName(url) })));
|
|
2729
|
+
}
|
|
2730
|
+
isSameRequest(filteredRequest, request) {
|
|
2731
|
+
const { method, endpoint } = filteredRequest;
|
|
2732
|
+
return endpoint === request.endpoint && method === request.method;
|
|
2733
|
+
}
|
|
2734
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: HttpWaitService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2735
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: HttpWaitService, providedIn: 'root' });
|
|
2736
|
+
}
|
|
2737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: HttpWaitService, decorators: [{
|
|
2738
|
+
type: Injectable,
|
|
2739
|
+
args: [{
|
|
2740
|
+
providedIn: 'root',
|
|
2741
|
+
}]
|
|
2742
|
+
}], ctorParameters: () => [{ type: i0.Injector }] });
|
|
2743
|
+
|
|
2744
|
+
class WindowService {
|
|
2745
|
+
document = inject(DOCUMENT);
|
|
2746
|
+
window = this.document.defaultView;
|
|
2747
|
+
navigator = this.window?.navigator;
|
|
2748
|
+
copyToClipboard(text) {
|
|
2749
|
+
return this.navigator?.clipboard.writeText(text);
|
|
2750
|
+
}
|
|
2751
|
+
open(url, target, features) {
|
|
2752
|
+
return this.window?.open(url, target, features);
|
|
2753
|
+
}
|
|
2754
|
+
reloadPage() {
|
|
2755
|
+
this.window?.location.reload();
|
|
2756
|
+
}
|
|
2757
|
+
downloadBlob(blob, fileName) {
|
|
2758
|
+
const blobUrl = this.window?.URL.createObjectURL(blob);
|
|
2759
|
+
const a = this.document.createElement('a');
|
|
2760
|
+
a.style.display = 'none';
|
|
2761
|
+
a.href = blobUrl ?? '';
|
|
2762
|
+
a.download = fileName;
|
|
2763
|
+
this.document.body.appendChild(a);
|
|
2764
|
+
a.dispatchEvent(new MouseEvent('click', {
|
|
2765
|
+
bubbles: true,
|
|
2766
|
+
cancelable: true,
|
|
2767
|
+
view: this.window,
|
|
2768
|
+
}));
|
|
2769
|
+
this.window?.URL.revokeObjectURL(blobUrl ?? '');
|
|
2770
|
+
this.document.body.removeChild(a);
|
|
2771
|
+
}
|
|
2772
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: WindowService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2773
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: WindowService, providedIn: 'root' });
|
|
2774
|
+
}
|
|
2775
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: WindowService, decorators: [{
|
|
2776
|
+
type: Injectable,
|
|
2777
|
+
args: [{ providedIn: 'root' }]
|
|
2778
|
+
}] });
|
|
2779
|
+
|
|
2606
2780
|
function getRemoteEnv(injector, environment) {
|
|
2607
2781
|
const environmentService = injector.get(EnvironmentService);
|
|
2608
2782
|
const { remoteEnv } = environment;
|
|
@@ -2745,7 +2919,7 @@ async function getInitialData() {
|
|
|
2745
2919
|
await getRemoteEnv(injector, options.environment);
|
|
2746
2920
|
await parseTenantFromUrl(injector);
|
|
2747
2921
|
const authService = injector.get(AuthService, undefined, { optional: true });
|
|
2748
|
-
const checkAuthenticationState = injector.get(CHECK_AUTHENTICATION_STATE_FN_KEY, noop, {
|
|
2922
|
+
const checkAuthenticationState = injector.get(CHECK_AUTHENTICATION_STATE_FN_KEY, noop$1, {
|
|
2749
2923
|
optional: true,
|
|
2750
2924
|
});
|
|
2751
2925
|
if (!options.skipInitAuthService && authService) {
|
|
@@ -2787,5 +2961,5 @@ function localeInitializer() {
|
|
|
2787
2961
|
* Generated bundle index. Do not edit.
|
|
2788
2962
|
*/
|
|
2789
2963
|
|
|
2790
|
-
export { AbstractMenuService, AbstractNavTreeService, AbstractTreeService, ApplicationConfigurationService, ApplicationLocalizationService, BaseService, ConfigStateService, EnvironmentService, FrameworkTitleStrategy, GenericService, HttpErrorReporterService, IdParserService, LocalStorageListenerService, LocalStorageService, LocalizationService, LogLevel, LoggerService, MultiTenancyService, NavItemsService, NavigationEvent, NgxPermissionsGuard, PermissionCheckerService, QueryParser, REQUEST, RestService, RouterEvents, RouterWaitService, RoutesHandler, RoutesService, SORT_COMPARE_FUNC, SessionStateService, SsrCookieService, SubscriptionService, SwalService, UserMenuService, compareFuncFactory, getCurrentTenancyNameFromUrl, getInitialData, getRemoteEnv, isUndefinedOrEmptyString, localeInitializer, ngxPermissionsGuard, parseTenantFromUrl };
|
|
2964
|
+
export { AbstractMenuService, AbstractNavTreeService, AbstractTreeService, ApplicationConfigurationService, ApplicationLocalizationService, BaseService, ConfigStateService, EnvironmentService, FrameworkTitleStrategy, GenericService, HttpErrorReporterService, HttpWaitService, IdParserService, LocalStorageListenerService, LocalStorageService, LocalizationService, LogLevel, LoggerService, MultiTenancyService, NavItemsService, NavigationEvent, NgxPermissionsGuard, PermissionCheckerService, QueryParser, REQUEST, ReplaceableComponentsService, RestService, RouterEvents, RouterWaitService, RoutesHandler, RoutesService, SORT_COMPARE_FUNC, SessionStateService, SsrCookieService, SubscriptionService, SwalService, UserMenuService, WindowService, compareFuncFactory, findRoute, getCurrentTenancyNameFromUrl, getInitialData, getRemoteEnv, getRoutePath, isUndefinedOrEmptyString, localeInitializer, ngxPermissionsGuard, parseTenantFromUrl, reloadRoute };
|
|
2791
2965
|
//# sourceMappingURL=elite.framework-ng.core-services.mjs.map
|