@open-rlb/ng-app 3.0.21 → 3.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.
|
@@ -502,8 +502,19 @@ class AppsService {
|
|
|
502
502
|
appRoutesMatched = appRoutes?.filter(app => app.routes?.some(r => r.includes(fullPath))) ?? [];
|
|
503
503
|
}
|
|
504
504
|
this.logger.info('Route fullPath:', fullPath, 'Matched appRoute:', appRoutesMatched);
|
|
505
|
-
return this.store.select(state => state[appContextFeatureKey].apps).pipe(
|
|
506
|
-
|
|
505
|
+
return this.store.select(state => state[appContextFeatureKey].apps).pipe(
|
|
506
|
+
// waiting for all "finalizeApp" dispatches
|
|
507
|
+
filter(apps => {
|
|
508
|
+
if (!apps || apps.length === 0)
|
|
509
|
+
return true;
|
|
510
|
+
const allFinalized = !apps.some(app => !app.id);
|
|
511
|
+
if (!allFinalized) {
|
|
512
|
+
this.logger.info('Waiting for apps initialization (finalizeApp)...');
|
|
513
|
+
}
|
|
514
|
+
return allFinalized;
|
|
515
|
+
}),
|
|
516
|
+
// Return config in there are matched apps, or it's root route case
|
|
517
|
+
map(apps => {
|
|
507
518
|
if (appRoutesMatched.length > 0 || fullPath === '') {
|
|
508
519
|
return { route, appsConfig: appRoutesMatched, apps };
|
|
509
520
|
}
|
|
@@ -513,27 +524,28 @@ class AppsService {
|
|
|
513
524
|
handleResolvedApps(data) {
|
|
514
525
|
const route = this.findDeepestChild(this.activatedRoute);
|
|
515
526
|
const storedId = this.getStoredAppId();
|
|
516
|
-
// Check if
|
|
527
|
+
// Check if route is root
|
|
517
528
|
const currentPath = route.snapshot.url.map(s => s.path).join('/');
|
|
518
529
|
const isRoot = currentPath === '';
|
|
530
|
+
// Basic check
|
|
519
531
|
if (data?.apps?.some(app => !app.id)) {
|
|
520
532
|
this.logger.error('Some apps are not finalized...');
|
|
521
533
|
return;
|
|
522
534
|
}
|
|
523
535
|
if (!data || !data.apps || data.apps.length === 0) {
|
|
524
|
-
this.logger.warn(`No apps found
|
|
536
|
+
this.logger.warn(`No apps found. Path: '${currentPath}'`);
|
|
525
537
|
this.selectApp(undefined);
|
|
526
538
|
return;
|
|
527
539
|
}
|
|
528
|
-
// domain
|
|
540
|
+
// Filter by domain
|
|
529
541
|
const domainApps = data.apps.filter(app => !app.domains || app.domains?.some((domain) => domain.includes(this.currentDomain)));
|
|
530
542
|
if (domainApps.length === 0) {
|
|
531
543
|
this.logger.warn(`No apps allowed for domain: ${this.currentDomain}`);
|
|
532
544
|
this.selectApp(undefined);
|
|
533
545
|
return;
|
|
534
546
|
}
|
|
535
|
-
//
|
|
536
|
-
//
|
|
547
|
+
// CASE 1: SINGLE APP REDIRECT (Partners)
|
|
548
|
+
// We are in root route and there is only one app available
|
|
537
549
|
if (isRoot && domainApps.length === 1) {
|
|
538
550
|
const singleApp = domainApps[0];
|
|
539
551
|
const targetUrl = singleApp.core?.url;
|
|
@@ -543,26 +555,35 @@ class AppsService {
|
|
|
543
555
|
queryParams: route.snapshot.queryParams,
|
|
544
556
|
replaceUrl: true
|
|
545
557
|
});
|
|
546
|
-
// break flow, to prevent selectApp
|
|
547
558
|
return;
|
|
548
559
|
}
|
|
549
560
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
561
|
+
// CASE 2: MULTI APP HUB / CORE HOME PAGE
|
|
562
|
+
// We are in root route, and there are more than one app available
|
|
563
|
+
// ====================================================================
|
|
564
|
+
if (isRoot && domainApps.length > 1) {
|
|
565
|
+
this.logger.info(`Root detected with multiple apps (${domainApps.length}). Showing App Hub / Core home page.`);
|
|
566
|
+
this.selectApp(undefined); // Explicit reset chosen app
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
// CASE 3: Standard logic to get app (Deep linking) ---
|
|
570
|
+
// Here we go only if route not empty !="" and not root !="/"
|
|
571
|
+
const matchedApps = domainApps.filter(app => app.routes?.some(r => r.includes(route.routeConfig?.path)) ||
|
|
572
|
+
app.core?.url === '/' + route.routeConfig?.path);
|
|
554
573
|
let appToSelect;
|
|
555
574
|
if (matchedApps.length === 1) {
|
|
556
575
|
appToSelect = matchedApps[0];
|
|
557
576
|
this.logger.info('Single app matched route:', appToSelect);
|
|
558
577
|
}
|
|
559
578
|
else if (matchedApps.length > 1) {
|
|
579
|
+
// Fallback in case of conflict routes
|
|
560
580
|
appToSelect = matchedApps.find(a => a.id === storedId) || matchedApps[0];
|
|
561
581
|
this.logger.info('Multiple apps matched route, selected:', appToSelect);
|
|
562
582
|
}
|
|
563
583
|
else {
|
|
564
|
-
|
|
565
|
-
|
|
584
|
+
// Fallback: Route path doesn't exist
|
|
585
|
+
appToSelect = undefined;
|
|
586
|
+
this.logger.warn('No app matched this specific route:', currentPath);
|
|
566
587
|
}
|
|
567
588
|
const qp = new URLSearchParams(route.snapshot.queryParams).toString();
|
|
568
589
|
const url = currentPath + (qp ? `?${qp}` : '');
|
|
@@ -1367,23 +1388,11 @@ class AuthenticationService {
|
|
|
1367
1388
|
}
|
|
1368
1389
|
else {
|
|
1369
1390
|
this.logger.info(`User authenticated, no redirectUrl found. Staying on current route.`);
|
|
1370
|
-
// this.router.navigate([], {
|
|
1371
|
-
// queryParams: {},
|
|
1372
|
-
// replaceUrl: true,
|
|
1373
|
-
// relativeTo: this.router.routerState.root
|
|
1374
|
-
// });
|
|
1375
1391
|
}
|
|
1376
1392
|
}
|
|
1377
1393
|
else {
|
|
1378
1394
|
this.logger.warn(`No authenticatedConfig found for ${url}`);
|
|
1379
1395
|
}
|
|
1380
|
-
// if (data.some(o => o.isAuthenticated)) {
|
|
1381
|
-
// const redirect = this.cookiesService.getCookie('loginRedirectUrl');
|
|
1382
|
-
// if (redirect) {
|
|
1383
|
-
// this.cookiesService.deleteCookie('loginRedirectUrl');
|
|
1384
|
-
// this.router.navigate([redirect]);
|
|
1385
|
-
// }
|
|
1386
|
-
// }
|
|
1387
1396
|
}));
|
|
1388
1397
|
//}
|
|
1389
1398
|
}
|