@open-rlb/ng-app 3.0.20 → 3.0.21
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.
|
@@ -15,7 +15,7 @@ import { RLB_TRANSLATION_SERVICE, RlbBootstrapModule, ModalDirective, ToastDirec
|
|
|
15
15
|
import * as i1$5 from 'angular-auth-oidc-client';
|
|
16
16
|
import { AbstractLoggerService, AuthModule, provideAuth, AuthInterceptor, AbstractSecurityStorage } from 'angular-auth-oidc-client';
|
|
17
17
|
import * as i1 from 'ngx-cookie-service-ssr';
|
|
18
|
-
import { filter, switchMap,
|
|
18
|
+
import { filter, switchMap, map, BehaviorSubject, of, share, lastValueFrom, from, zip, EMPTY, catchError, Observable, tap, shareReplay, distinctUntilChanged, take } from 'rxjs';
|
|
19
19
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
20
20
|
import * as i1$2 from '@ngx-translate/core';
|
|
21
21
|
import { TranslateModule } from '@ngx-translate/core';
|
|
@@ -485,44 +485,72 @@ class AppsService {
|
|
|
485
485
|
resolveRouteAndApps() {
|
|
486
486
|
const route = this.findDeepestChild(this.activatedRoute);
|
|
487
487
|
const fullPath = this.getFullPath(route);
|
|
488
|
-
this.logger.info(
|
|
489
|
-
if (!fullPath) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
488
|
+
this.logger.info(`Full path for route resolution: '${fullPath}'`);
|
|
489
|
+
// if (!fullPath) {
|
|
490
|
+
// this.logger.warn('No valid path found, treating as default route:', route);
|
|
491
|
+
// return of(null);
|
|
492
|
+
// }
|
|
493
493
|
const appRoutes = this.apps?.map(app => ({
|
|
494
494
|
type: app.type,
|
|
495
495
|
routes: app.routes || [],
|
|
496
496
|
viewMode: app.viewMode,
|
|
497
497
|
enabled: app.enabled,
|
|
498
|
+
core: app.core
|
|
498
499
|
}));
|
|
499
500
|
let appRoutesMatched = [];
|
|
500
|
-
if (!this.isDefaultRoute(fullPath)) {
|
|
501
|
+
if (fullPath && !this.isDefaultRoute(fullPath)) {
|
|
501
502
|
appRoutesMatched = appRoutes?.filter(app => app.routes?.some(r => r.includes(fullPath))) ?? [];
|
|
502
503
|
}
|
|
503
504
|
this.logger.info('Route fullPath:', fullPath, 'Matched appRoute:', appRoutesMatched);
|
|
504
|
-
return this.store.select(state => state[appContextFeatureKey].apps).pipe(map(apps =>
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
return this.store.select(state => state[appContextFeatureKey].apps).pipe(map(apps => {
|
|
506
|
+
// handle root route case
|
|
507
|
+
if (appRoutesMatched.length > 0 || fullPath === '') {
|
|
508
|
+
return { route, appsConfig: appRoutesMatched, apps };
|
|
509
|
+
}
|
|
510
|
+
return null;
|
|
511
|
+
}));
|
|
507
512
|
}
|
|
508
513
|
handleResolvedApps(data) {
|
|
509
514
|
const route = this.findDeepestChild(this.activatedRoute);
|
|
510
515
|
const storedId = this.getStoredAppId();
|
|
516
|
+
// Check if it is a root route
|
|
517
|
+
const currentPath = route.snapshot.url.map(s => s.path).join('/');
|
|
518
|
+
const isRoot = currentPath === '';
|
|
511
519
|
if (data?.apps?.some(app => !app.id)) {
|
|
512
|
-
this.logger.error('Some apps are not finalized
|
|
520
|
+
this.logger.error('Some apps are not finalized...');
|
|
513
521
|
return;
|
|
514
522
|
}
|
|
515
523
|
if (!data || !data.apps || data.apps.length === 0) {
|
|
516
|
-
this.logger.warn(`No
|
|
517
|
-
// const globalDefaultApp = this.apps[0];
|
|
524
|
+
this.logger.warn(`No apps found (or data is null). Path: '${currentPath}'`);
|
|
518
525
|
this.selectApp(undefined);
|
|
519
526
|
return;
|
|
520
527
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
528
|
+
// domain filter
|
|
529
|
+
const domainApps = data.apps.filter(app => !app.domains || app.domains?.some((domain) => domain.includes(this.currentDomain)));
|
|
530
|
+
if (domainApps.length === 0) {
|
|
531
|
+
this.logger.warn(`No apps allowed for domain: ${this.currentDomain}`);
|
|
532
|
+
this.selectApp(undefined);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
// Auto-redirect logic
|
|
536
|
+
// if there is a root route and only 1 app matched -> auto redirect on app home page
|
|
537
|
+
if (isRoot && domainApps.length === 1) {
|
|
538
|
+
const singleApp = domainApps[0];
|
|
539
|
+
const targetUrl = singleApp.core?.url;
|
|
540
|
+
if (targetUrl && targetUrl !== '/' && targetUrl !== '') {
|
|
541
|
+
this.logger.info(`[AutoRedirect] Single app detected at root. Redirecting to: ${targetUrl}`);
|
|
542
|
+
this.router.navigate([targetUrl], {
|
|
543
|
+
queryParams: route.snapshot.queryParams,
|
|
544
|
+
replaceUrl: true
|
|
545
|
+
});
|
|
546
|
+
// break flow, to prevent selectApp
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const matchedApps = domainApps
|
|
524
551
|
.filter(app => app.routes?.some(r => r.includes(route.routeConfig?.path)) ||
|
|
525
|
-
app.core?.url === '/' + route.routeConfig?.path
|
|
552
|
+
app.core?.url === '/' + route.routeConfig?.path ||
|
|
553
|
+
(isRoot && app.core?.url));
|
|
526
554
|
let appToSelect;
|
|
527
555
|
if (matchedApps.length === 1) {
|
|
528
556
|
appToSelect = matchedApps[0];
|
|
@@ -533,11 +561,11 @@ class AppsService {
|
|
|
533
561
|
this.logger.info('Multiple apps matched route, selected:', appToSelect);
|
|
534
562
|
}
|
|
535
563
|
else {
|
|
536
|
-
appToSelect =
|
|
537
|
-
this.logger.info('No
|
|
564
|
+
appToSelect = domainApps[0];
|
|
565
|
+
this.logger.info('No specific route match. Falling back to domain default:', appToSelect);
|
|
538
566
|
}
|
|
539
567
|
const qp = new URLSearchParams(route.snapshot.queryParams).toString();
|
|
540
|
-
const url =
|
|
568
|
+
const url = currentPath + (qp ? `?${qp}` : '');
|
|
541
569
|
const viewMode = this.isSettingsRoute(route) ? 'settings' : 'app';
|
|
542
570
|
this.selectApp(appToSelect, viewMode, url);
|
|
543
571
|
}
|
|
@@ -2890,10 +2918,7 @@ class AuthEffects {
|
|
|
2890
2918
|
return this.actions$.pipe(ofType(AuthActions.setCurrentProvider), map$1(({ currentProvider }) => AuthActionsInternal.setCurrentProvider({ currentProvider })));
|
|
2891
2919
|
});
|
|
2892
2920
|
this.logger = this.loggerService.for(this.constructor.name);
|
|
2893
|
-
this.logger.log(`Initialized AuthEffects
|
|
2894
|
-
// if (authConfig) {
|
|
2895
|
-
// auth.checkAuthMultiple().subscribe();
|
|
2896
|
-
// }
|
|
2921
|
+
this.logger.log(`Initialized AuthEffects}`);
|
|
2897
2922
|
}
|
|
2898
2923
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects, deps: [{ token: i1$8.Actions }, { token: AuthenticationService }, { token: AppLoggerService }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2899
2924
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects }); }
|
|
@@ -3056,18 +3081,6 @@ function provideRlbConfig(env) {
|
|
|
3056
3081
|
},
|
|
3057
3082
|
multi: true,
|
|
3058
3083
|
},
|
|
3059
|
-
// {
|
|
3060
|
-
// provide: APP_INITIALIZER,
|
|
3061
|
-
// useFactory: authInitializer,
|
|
3062
|
-
// deps: [AuthenticationService],
|
|
3063
|
-
// multi: true
|
|
3064
|
-
// },
|
|
3065
|
-
// {
|
|
3066
|
-
// provide: APP_INITIALIZER,
|
|
3067
|
-
// useFactory: appsServiceInitializer,
|
|
3068
|
-
// deps: [AppsService],
|
|
3069
|
-
// multi: true
|
|
3070
|
-
// },
|
|
3071
3084
|
];
|
|
3072
3085
|
}
|
|
3073
3086
|
function provideApp(app) {
|