@acorex-platform/module-settings-management-client 1.0.1 → 2.0.0-beta.0
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/fesm2022/{acorex-platform-module-settings-management-client-setting-page.component-Ck_FPVsq.mjs → acorex-platform-module-settings-management-client-setting-page.component-Bl-QvxlQ.mjs} +39 -6
- package/fesm2022/acorex-platform-module-settings-management-client-setting-page.component-Bl-QvxlQ.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-settings-management-client-setting-view.component-BrUkHvXK.mjs → acorex-platform-module-settings-management-client-setting-view.component-xXzZppqE.mjs} +14 -4
- package/fesm2022/acorex-platform-module-settings-management-client-setting-view.component-xXzZppqE.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-settings-management-client.mjs +115 -58
- package/fesm2022/acorex-platform-module-settings-management-client.mjs.map +1 -1
- package/i18n/en-AU/settings-management.json +3 -0
- package/i18n/en-US/settings-management.json +3 -0
- package/i18n/fa-IR/settings-management.json +3 -0
- package/package.json +2 -2
- package/types/acorex-platform-module-settings-management-client.d.ts +4 -0
- package/fesm2022/acorex-platform-module-settings-management-client-setting-page.component-Ck_FPVsq.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-settings-management-client-setting-view.component-BrUkHvXK.mjs.map +0 -1
|
@@ -2,8 +2,9 @@ import { AXPPageStatus } from '@acorex-platform/framework-shared/widget-core';
|
|
|
2
2
|
import { AXToastService } from '@acorex/components/toast';
|
|
3
3
|
import { AXLocaleService } from '@acorex/core/locale';
|
|
4
4
|
import { AXTranslationService } from '@acorex/core/translation';
|
|
5
|
+
import { AXPSessionService, AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex-platform/framework-client/auth';
|
|
5
6
|
import * as i2 from '@acorex-platform/framework-client/common';
|
|
6
|
-
import { traceSettingsPageLoadStarted, traceSettingsPageLoadComplete, AXPSettingDefinitionProviderService, AXPSettingsService, createUnsavedChangesCanDeactivateGuard,
|
|
7
|
+
import { traceSettingsPageLoadStarted, traceSettingsPageLoadComplete, AXPSettingDefinitionProviderService, AXPSettingsService, createUnsavedChangesCanDeactivateGuard, axpInTabErrorUrlTree, axpIsLikelyNetworkFailure, AXP_PROTECTED_ROUTE_GUARDS, traceSettingsAppStartupLoadStarted, traceSettingsAppStartupLoadComplete, AXP_SETTINGS_SYNC_KEYS, AXP_SEARCH_PROVIDER, AXP_SEARCH_DEFINITION_PROVIDER, AXP_MENU_PROVIDER } from '@acorex-platform/framework-client/common';
|
|
7
8
|
import { getSmart, resolvePlatformScopeName, AXPPlatformScope, resolvePlatformScopeKey } from '@acorex-platform/framework-shared/core';
|
|
8
9
|
import * as i1 from '@acorex-platform/framework-client/core';
|
|
9
10
|
import { AXPDeviceService, AXP_APP_STARTUP_PRIORITY, AXP_HOOK_PROVIDER } from '@acorex-platform/framework-client/core';
|
|
@@ -11,8 +12,7 @@ import * as i0 from '@angular/core';
|
|
|
11
12
|
import { computed, inject, Injectable, NgModule } from '@angular/core';
|
|
12
13
|
import { signalStore, withState, withComputed, withMethods, patchState, withHooks } from '@ngrx/signals';
|
|
13
14
|
import { cloneDeep, isEqual, isNil, isEmpty, get, sortBy } from 'lodash';
|
|
14
|
-
import { filter, merge,
|
|
15
|
-
import { AXPSessionService, AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex-platform/framework-client/auth';
|
|
15
|
+
import { filter, merge, combineLatest, map, distinctUntilChanged, first, firstValueFrom } from 'rxjs';
|
|
16
16
|
import { AXPRootLayoutComponent } from '@acorex-platform/framework-client/themes/default';
|
|
17
17
|
import { Router, ROUTES } from '@angular/router';
|
|
18
18
|
import { AXPApplicationsPlatformPermissionKeys, RootConfig, AXPSettingsManagementMenuKeys, AXMSettingsManagementCommandKeys, axmSettingsSyncKeys } from '@acorex-platform/module-settings-management-client/contracts';
|
|
@@ -162,6 +162,8 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
162
162
|
//
|
|
163
163
|
status: AXPPageStatus.Processing,
|
|
164
164
|
form: null,
|
|
165
|
+
/** Edition catalog identity last applied to `groups`. Empty until the first successful load. */
|
|
166
|
+
editionAvailabilityKey: '',
|
|
165
167
|
})), withComputed((store, deviceService = inject(AXPDeviceService)) => ({
|
|
166
168
|
searchResults: computed(() => {
|
|
167
169
|
const q = store.searchExpression();
|
|
@@ -189,6 +191,13 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
189
191
|
form: form,
|
|
190
192
|
});
|
|
191
193
|
},
|
|
194
|
+
/** Aligns the heading scope with the route before the first title read. Ignored once groups are loaded. */
|
|
195
|
+
adoptRouteScope(scope) {
|
|
196
|
+
if (store.groups().length > 0 || store.scope() === scope) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
patchState(store, { scope });
|
|
200
|
+
},
|
|
192
201
|
async load(scope) {
|
|
193
202
|
traceSettingsPageLoadStarted(scope, 'settings-page-vm-load');
|
|
194
203
|
const startedAt = Date.now();
|
|
@@ -196,8 +205,10 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
196
205
|
scope: scope,
|
|
197
206
|
status: AXPPageStatus.Processing,
|
|
198
207
|
});
|
|
208
|
+
let fetchedAvailabilityKey = '';
|
|
199
209
|
try {
|
|
200
210
|
const groups = filterSettingsPageVisibleGroups(await settingDefinitionService.getListAsync(scope));
|
|
211
|
+
fetchedAvailabilityKey = settingDefinitionService.getAvailabilityKey();
|
|
201
212
|
patchState(store, {
|
|
202
213
|
groups: groups,
|
|
203
214
|
});
|
|
@@ -224,12 +235,43 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
224
235
|
console.error('Settings page load failed', error);
|
|
225
236
|
}
|
|
226
237
|
finally {
|
|
238
|
+
const latestAvailabilityKey = settingDefinitionService.getAvailabilityKey();
|
|
239
|
+
if (fetchedAvailabilityKey && latestAvailabilityKey !== fetchedAvailabilityKey) {
|
|
240
|
+
const groups = filterSettingsPageVisibleGroups(await settingDefinitionService.getListAsync(store.scope()));
|
|
241
|
+
patchState(store, { groups });
|
|
242
|
+
}
|
|
227
243
|
// Always leave Processing so Apply/Discard are not stuck disabled after a partial load.
|
|
228
244
|
patchState(store, {
|
|
229
245
|
status: AXPPageStatus.Rendered,
|
|
246
|
+
editionAvailabilityKey: settingDefinitionService.getAvailabilityKey(),
|
|
230
247
|
});
|
|
231
248
|
}
|
|
232
249
|
},
|
|
250
|
+
/**
|
|
251
|
+
* Edition features arrived after the page was already open.
|
|
252
|
+
* Refreshes the in-memory catalog only — setting values stay on their existing load.
|
|
253
|
+
*/
|
|
254
|
+
async syncGroupsForEdition() {
|
|
255
|
+
if (store.status() !== AXPPageStatus.Rendered) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const availabilityKey = settingDefinitionService.getAvailabilityKey();
|
|
259
|
+
if (!availabilityKey || availabilityKey === store.editionAvailabilityKey()) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const groups = filterSettingsPageVisibleGroups(await settingDefinitionService.getListAsync(store.scope()));
|
|
263
|
+
const previousName = store.activateGroup()?.name;
|
|
264
|
+
const defaults = await settingValueService.scope(store.scope()).defaultValues();
|
|
265
|
+
const nextGroup = previousName ? groups.find((group) => group.name === previousName) : undefined;
|
|
266
|
+
patchState(store, {
|
|
267
|
+
groups,
|
|
268
|
+
activateGroup: nextGroup,
|
|
269
|
+
context: { ...defaults, ...store.context() },
|
|
270
|
+
previousContext: { ...defaults, ...store.previousContext() },
|
|
271
|
+
editionAvailabilityKey: settingDefinitionService.getAvailabilityKey(),
|
|
272
|
+
});
|
|
273
|
+
await this.rebuildSettingSearchIndex();
|
|
274
|
+
},
|
|
233
275
|
async reload() {
|
|
234
276
|
await settingDefinitionService.reload();
|
|
235
277
|
const groups = filterSettingsPageVisibleGroups(await settingDefinitionService.getListAsync(store.scope()));
|
|
@@ -241,6 +283,9 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
241
283
|
if (oldActivateGroupName) {
|
|
242
284
|
this.setActivateGroupByName(oldActivateGroupName);
|
|
243
285
|
}
|
|
286
|
+
patchState(store, {
|
|
287
|
+
editionAvailabilityKey: settingDefinitionService.getAvailabilityKey(),
|
|
288
|
+
});
|
|
244
289
|
await this.rebuildSettingSearchIndex();
|
|
245
290
|
},
|
|
246
291
|
async rebuildSettingSearchIndex() {
|
|
@@ -464,38 +509,52 @@ const AXPSettingsViewModel = signalStore(withState(() => ({
|
|
|
464
509
|
this.discard();
|
|
465
510
|
}
|
|
466
511
|
},
|
|
467
|
-
})), withHooks((store, settingValueService = inject(AXPSettingsService), translationService = inject(AXTranslationService), localeService = inject(AXLocaleService)) =>
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
512
|
+
})), withHooks((store, settingValueService = inject(AXPSettingsService), translationService = inject(AXTranslationService), localeService = inject(AXLocaleService), settingDefinitionService = inject(AXPSettingDefinitionProviderService), sessionService = inject(AXPSessionService)) => {
|
|
513
|
+
let editionSync;
|
|
514
|
+
return {
|
|
515
|
+
async onInit() {
|
|
516
|
+
//
|
|
517
|
+
settingValueService.onChanged.pipe(filter((c) => c.scope == store.scope())).subscribe((e) => {
|
|
518
|
+
e.keys.forEach((k) => {
|
|
519
|
+
const currentValue = e.values[k];
|
|
520
|
+
const contextValue = get(store.context(), k);
|
|
521
|
+
const previousValue = get(store.previousContext(), k);
|
|
522
|
+
if (!isEqual(previousValue, currentValue) || !isEqual(currentValue, contextValue)) {
|
|
523
|
+
patchState(store, {
|
|
524
|
+
previousContext: {
|
|
525
|
+
...store.previousContext(),
|
|
526
|
+
[k]: currentValue,
|
|
527
|
+
},
|
|
528
|
+
context: {
|
|
529
|
+
...store.context(),
|
|
530
|
+
[k]: currentValue,
|
|
531
|
+
},
|
|
532
|
+
formDirty: false,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
//
|
|
538
|
+
merge(translationService.langChanges$, localeService.profileChanged$).subscribe(async () => {
|
|
539
|
+
if (store.isLoaded()) {
|
|
540
|
+
await store.reload();
|
|
487
541
|
}
|
|
488
542
|
});
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
543
|
+
editionSync = combineLatest([
|
|
544
|
+
sessionService.tenant$,
|
|
545
|
+
sessionService.application$,
|
|
546
|
+
sessionService.features$,
|
|
547
|
+
])
|
|
548
|
+
.pipe(map(() => settingDefinitionService.getAvailabilityKey()), distinctUntilChanged())
|
|
549
|
+
.subscribe(() => {
|
|
550
|
+
void store.syncGroupsForEdition();
|
|
551
|
+
});
|
|
552
|
+
},
|
|
553
|
+
onDestroy() {
|
|
554
|
+
editionSync?.unsubscribe();
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
}));
|
|
499
558
|
|
|
500
559
|
class AXPSettingSearchDefinitionProvider {
|
|
501
560
|
async provide(context) {
|
|
@@ -521,10 +580,7 @@ class AXPSettingSearchProvider {
|
|
|
521
580
|
this.translateService = inject(AXTranslationService);
|
|
522
581
|
}
|
|
523
582
|
async search(text) {
|
|
524
|
-
const groupsSetting = this.settingsService.
|
|
525
|
-
if (groupsSetting.length == 0) {
|
|
526
|
-
groupsSetting.push(...(await this.settingsService.getListAsync(AXPPlatformScope.User)));
|
|
527
|
-
}
|
|
583
|
+
const groupsSetting = await this.settingsService.getListAsync(AXPPlatformScope.User);
|
|
528
584
|
// Step 2: Flatten settings from groups
|
|
529
585
|
const allSettings = [];
|
|
530
586
|
const extractSettings = (group) => {
|
|
@@ -600,7 +656,7 @@ const SCOPE_PERMISSIONS = {
|
|
|
600
656
|
* Menu visibility alone is not enough — hidden Platform Settings items are not
|
|
601
657
|
* menu-matched, so {@link AXPMenuRouteGuard} would otherwise allow the route.
|
|
602
658
|
*/
|
|
603
|
-
const axpSettingsScopeCanActivateGuard = (route) => {
|
|
659
|
+
const axpSettingsScopeCanActivateGuard = (route, state) => {
|
|
604
660
|
const sessionService = inject(AXPSessionService);
|
|
605
661
|
const router = inject(Router);
|
|
606
662
|
return sessionService.isAuthorizedWithLoading$.pipe(first(), map(() => {
|
|
@@ -613,7 +669,7 @@ const axpSettingsScopeCanActivateGuard = (route) => {
|
|
|
613
669
|
if (sessionService.authorize(requiredPermission)) {
|
|
614
670
|
return true;
|
|
615
671
|
}
|
|
616
|
-
return router.
|
|
672
|
+
return axpInTabErrorUrlTree(router, '401', state.url);
|
|
617
673
|
}));
|
|
618
674
|
};
|
|
619
675
|
function resolveScopeParam(route) {
|
|
@@ -822,9 +878,11 @@ function sleep(ms) {
|
|
|
822
878
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
823
879
|
}
|
|
824
880
|
async function loadPlatformSettingsWithRetry(settingsService, offlineBootstrap) {
|
|
825
|
-
//
|
|
881
|
+
// A prepared device adopts its public settings snapshot before the remaining
|
|
882
|
+
// startup tasks restore the leased session and module catalog.
|
|
826
883
|
if (offlineBootstrap.isDeviceOffline()) {
|
|
827
|
-
|
|
884
|
+
await settingsService.ensurePlatformSettingsLoaded();
|
|
885
|
+
return;
|
|
828
886
|
}
|
|
829
887
|
let lastError;
|
|
830
888
|
for (let attempt = 1; attempt <= PLATFORM_SETTINGS_STARTUP_MAX_ATTEMPTS; attempt++) {
|
|
@@ -838,6 +896,15 @@ async function loadPlatformSettingsWithRetry(settingsService, offlineBootstrap)
|
|
|
838
896
|
if (offlineBootstrap.isDeviceOffline()) {
|
|
839
897
|
throw error;
|
|
840
898
|
}
|
|
899
|
+
// A prepared device already has a bounded fallback. Do not multiply the
|
|
900
|
+
// transport deadline by five startup attempts before offering it.
|
|
901
|
+
if (axpIsLikelyNetworkFailure(error) && await offlineBootstrap.canOfferOfflineContinue()) {
|
|
902
|
+
// Adopt before advancing startup: aborting here skips remaining modules.
|
|
903
|
+
// A later confirmation dialog cannot resume the aborted startup tasks.
|
|
904
|
+
if (await offlineBootstrap.confirmAndContinueOffline())
|
|
905
|
+
return;
|
|
906
|
+
throw error;
|
|
907
|
+
}
|
|
841
908
|
if (attempt < PLATFORM_SETTINGS_STARTUP_MAX_ATTEMPTS) {
|
|
842
909
|
await sleep(PLATFORM_SETTINGS_STARTUP_RETRY_DELAY_MS);
|
|
843
910
|
}
|
|
@@ -857,13 +924,13 @@ function routesFacory() {
|
|
|
857
924
|
children: [
|
|
858
925
|
{
|
|
859
926
|
path: '',
|
|
860
|
-
loadComponent: () => import('./acorex-platform-module-settings-management-client-setting-page.component-
|
|
927
|
+
loadComponent: () => import('./acorex-platform-module-settings-management-client-setting-page.component-Bl-QvxlQ.mjs').then((c) => c.AXPSettingPageComponent),
|
|
861
928
|
canDeactivate: [axpSettingsPageCanDeactivateGuard],
|
|
862
929
|
data: { reuse: true },
|
|
863
930
|
children: [
|
|
864
931
|
{
|
|
865
932
|
path: ':group',
|
|
866
|
-
loadComponent: () => import('./acorex-platform-module-settings-management-client-setting-view.component-
|
|
933
|
+
loadComponent: () => import('./acorex-platform-module-settings-management-client-setting-view.component-xXzZppqE.mjs').then((c) => c.AXPSettingsViewComponent),
|
|
867
934
|
data: { reuse: false },
|
|
868
935
|
},
|
|
869
936
|
],
|
|
@@ -882,24 +949,14 @@ class AXMSettingsManagementModule {
|
|
|
882
949
|
try {
|
|
883
950
|
await loadPlatformSettingsWithRetry(settingsService, offlineBootstrap);
|
|
884
951
|
platformSettingsLoadState.clear();
|
|
952
|
+
if (offlineBootstrap.isDeviceOffline())
|
|
953
|
+
platformSettingsLoadState.setOfflineMode(true);
|
|
885
954
|
}
|
|
886
955
|
catch (error) {
|
|
887
956
|
console.error('Platform settings bootstrap failed after retries', error);
|
|
888
|
-
//
|
|
889
|
-
//
|
|
890
|
-
|
|
891
|
-
try {
|
|
892
|
-
canOfferOffline = await offlineBootstrap.canOfferOfflineContinue();
|
|
893
|
-
}
|
|
894
|
-
catch (offlineError) {
|
|
895
|
-
console.error('Offline continue cache check failed', offlineError);
|
|
896
|
-
}
|
|
897
|
-
if (canOfferOffline) {
|
|
898
|
-
platformSettingsLoadState.setPendingOfflineContinue(error);
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
platformSettingsLoadState.setFailure(error);
|
|
902
|
-
}
|
|
957
|
+
// A permitted network fallback was already adopted before reaching
|
|
958
|
+
// this branch. Denials and missing snapshots must remain visible.
|
|
959
|
+
platformSettingsLoadState.setFailure(error);
|
|
903
960
|
// Keep only platform-settings-failure-redirect; skip Settings/regional/theme (they hang on API).
|
|
904
961
|
appInitService.abortRemainingStartupTasks();
|
|
905
962
|
}
|