@onecx/angular-integration-interface 6.0.0-rc.2 → 6.0.0-rc.20
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/onecx-angular-integration-interface-mocks.mjs +198 -41
- package/fesm2022/onecx-angular-integration-interface-mocks.mjs.map +1 -1
- package/fesm2022/onecx-angular-integration-interface.mjs +101 -203
- package/fesm2022/onecx-angular-integration-interface.mjs.map +1 -1
- package/index.d.ts +1 -3
- package/lib/api/injection-tokens.d.ts +0 -7
- package/lib/model/config-key.model.d.ts +6 -1
- package/lib/services/app-config-service.d.ts +0 -2
- package/lib/services/app-state.service.d.ts +2 -6
- package/lib/services/configuration.service.d.ts +7 -10
- package/lib/services/portal-message.service.d.ts +0 -2
- package/lib/services/shell-capability.service.d.ts +16 -0
- package/lib/services/theme.service.d.ts +1 -10
- package/lib/services/user.service.d.ts +3 -5
- package/lib/services/workspace.service.d.ts +1 -2
- package/migrations.json +52 -0
- package/mocks/app-config-service-mock.d.ts +20 -0
- package/mocks/app-state-service-mock.d.ts +4 -15
- package/mocks/configuration-service-mock.d.ts +22 -0
- package/mocks/index.d.ts +7 -2
- package/mocks/portal-message-service-mock.d.ts +18 -0
- package/mocks/remote-components-service-mock.d.ts +13 -0
- package/mocks/shell-capability-service-mock.d.ts +13 -0
- package/mocks/user-service-mock.d.ts +21 -0
- package/package.json +15 -8
- package/esm2022/index.mjs +0 -18
- package/esm2022/lib/api/constants.mjs +0 -3
- package/esm2022/lib/api/iauth.service.mjs +0 -2
- package/esm2022/lib/api/injection-tokens.mjs +0 -11
- package/esm2022/lib/model/config-key.model.mjs +0 -31
- package/esm2022/lib/services/app-config-service.mjs +0 -43
- package/esm2022/lib/services/app-state.service.mjs +0 -45
- package/esm2022/lib/services/configuration.service.mjs +0 -79
- package/esm2022/lib/services/initialize-module-guard.service.mjs +0 -60
- package/esm2022/lib/services/portal-message.service.mjs +0 -49
- package/esm2022/lib/services/remote-components.service.mjs +0 -18
- package/esm2022/lib/services/theme.service.mjs +0 -48
- package/esm2022/lib/services/user.service.mjs +0 -89
- package/esm2022/lib/services/workspace.service.mjs +0 -146
- package/esm2022/lib/utils/add-initialize-module-guard.utils.mjs +0 -17
- package/esm2022/mocks/app-state-service-mock.mjs +0 -31
- package/esm2022/mocks/fake-topic.mjs +0 -25
- package/esm2022/mocks/index.mjs +0 -4
- package/esm2022/mocks/mock-user-service.mjs +0 -11
- package/esm2022/mocks/onecx-angular-integration-interface-mocks.mjs +0 -5
- package/esm2022/onecx-angular-integration-interface.mjs +0 -5
- package/lib/api/iauth.service.d.ts +0 -17
- package/lib/services/initialize-module-guard.service.d.ts +0 -22
- package/lib/utils/add-initialize-module-guard.utils.d.ts +0 -3
- package/mocks/fake-topic.d.ts +0 -9
- package/mocks/mock-user-service.d.ts +0 -5
@@ -1,14 +1,15 @@
|
|
1
1
|
import { Location } from '@angular/common';
|
2
|
-
import
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
3
3
|
import * as i0 from '@angular/core';
|
4
|
-
import { Injectable, InjectionToken
|
5
|
-
import { BehaviorSubject, firstValueFrom, map,
|
6
|
-
import { GlobalErrorTopic, GlobalLoadingTopic, CurrentMfeTopic, CurrentPageTopic, CurrentWorkspaceTopic, IsAuthenticatedTopic, ConfigurationTopic, UserProfileTopic, PermissionsTopic, MessageTopic, CurrentThemeTopic, RemoteComponentsTopic } from '@onecx/integration-interface';
|
7
|
-
import
|
4
|
+
import { inject, Injectable, InjectionToken } from '@angular/core';
|
5
|
+
import { BehaviorSubject, firstValueFrom, map, combineLatest, of, first } from 'rxjs';
|
6
|
+
import { GlobalErrorTopic, GlobalLoadingTopic, CurrentMfeTopic, CurrentLocationTopic, CurrentPageTopic, CurrentWorkspaceTopic, IsAuthenticatedTopic, ConfigurationTopic, UserProfileTopic, PermissionsTopic, MessageTopic, CurrentThemeTopic, RemoteComponentsTopic } from '@onecx/integration-interface';
|
7
|
+
import Semaphore from 'ts-semaphore';
|
8
|
+
import { TranslateService } from '@ngx-translate/core';
|
8
9
|
|
9
10
|
class AppConfigService {
|
10
|
-
constructor(
|
11
|
-
this.http =
|
11
|
+
constructor() {
|
12
|
+
this.http = inject(HttpClient);
|
12
13
|
this.config$ = new BehaviorSubject({});
|
13
14
|
}
|
14
15
|
init(baseUrl) {
|
@@ -36,18 +37,19 @@ class AppConfigService {
|
|
36
37
|
getConfig() {
|
37
38
|
return this.config$.getValue();
|
38
39
|
}
|
39
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
40
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
40
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
41
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppConfigService }); }
|
41
42
|
}
|
42
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppConfigService, decorators: [{
|
43
44
|
type: Injectable
|
44
|
-
}]
|
45
|
+
}] });
|
45
46
|
|
46
47
|
class AppStateService {
|
47
48
|
constructor() {
|
48
49
|
this.globalError$ = new GlobalErrorTopic();
|
49
50
|
this.globalLoading$ = new GlobalLoadingTopic();
|
50
51
|
this.currentMfe$ = new CurrentMfeTopic();
|
52
|
+
this.currentLocation$ = new CurrentLocationTopic();
|
51
53
|
/**
|
52
54
|
* This topic will only fire when pageInfo.path matches document.location.pathname,
|
53
55
|
* if not it will fire undefined.
|
@@ -59,39 +61,24 @@ class AppStateService {
|
|
59
61
|
*/
|
60
62
|
this.isAuthenticated$ = new IsAuthenticatedTopic();
|
61
63
|
}
|
62
|
-
/**
|
63
|
-
* @deprecated Will be replaced by currentWorkspace$
|
64
|
-
*/
|
65
|
-
get currentPortal$() {
|
66
|
-
return this.currentWorkspace$;
|
67
|
-
}
|
68
|
-
set currentPortal$(value) {
|
69
|
-
this.currentWorkspace$ = value;
|
70
|
-
}
|
71
64
|
ngOnDestroy() {
|
72
65
|
this.globalError$.destroy();
|
73
66
|
this.globalLoading$.destroy();
|
74
67
|
this.currentMfe$.destroy();
|
75
68
|
this.currentPage$.destroy();
|
76
|
-
this.
|
69
|
+
this.currentLocation$.destroy();
|
77
70
|
this.currentWorkspace$.destroy();
|
78
71
|
this.isAuthenticated$.destroy();
|
79
72
|
}
|
80
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
81
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
73
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
74
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppStateService, providedIn: 'root' }); }
|
82
75
|
}
|
83
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
76
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: AppStateService, decorators: [{
|
84
77
|
type: Injectable,
|
85
78
|
args: [{ providedIn: 'root' }]
|
86
79
|
}] });
|
87
80
|
|
88
81
|
const APP_CONFIG = new InjectionToken('APP_CONFIG');
|
89
|
-
/**
|
90
|
-
* @deprecated
|
91
|
-
* Please do not inject the auth service at all.
|
92
|
-
* There are better ways to achieve what you want. Please use permission service or user service.
|
93
|
-
*/
|
94
|
-
const AUTH_SERVICE = new InjectionToken('AUTH_SERVICE');
|
95
82
|
const SANITY_CHECK = new InjectionToken('OCXSANITY_CHECK');
|
96
83
|
const APPLICATION_NAME = new InjectionToken('APPLICATION_NAME');
|
97
84
|
|
@@ -124,13 +111,20 @@ var CONFIG_KEY;
|
|
124
111
|
CONFIG_KEY["AUTH_SERVICE"] = "AUTH_SERVICE";
|
125
112
|
CONFIG_KEY["AUTH_SERVICE_CUSTOM_URL"] = "AUTH_SERVICE_CUSTOM_URL";
|
126
113
|
CONFIG_KEY["AUTH_SERVICE_CUSTOM_MODULE_NAME"] = "AUTH_SERVICE_CUSTOM_MODULE_NAME";
|
114
|
+
CONFIG_KEY["POLYFILL_SCOPE_MODE"] = "POLYFILL_SCOPE_MODE";
|
127
115
|
})(CONFIG_KEY || (CONFIG_KEY = {}));
|
116
|
+
var POLYFILL_SCOPE_MODE;
|
117
|
+
(function (POLYFILL_SCOPE_MODE) {
|
118
|
+
POLYFILL_SCOPE_MODE["PERFORMANCE"] = "PERFORMANCE";
|
119
|
+
POLYFILL_SCOPE_MODE["PRECISION"] = "PRECISION";
|
120
|
+
})(POLYFILL_SCOPE_MODE || (POLYFILL_SCOPE_MODE = {}));
|
128
121
|
|
129
122
|
class ConfigurationService {
|
130
|
-
constructor(
|
131
|
-
this.http =
|
132
|
-
this.defaultConfig =
|
123
|
+
constructor() {
|
124
|
+
this.http = inject(HttpClient);
|
125
|
+
this.defaultConfig = inject(APP_CONFIG, { optional: true });
|
133
126
|
this.config$ = new ConfigurationTopic();
|
127
|
+
this.semaphore = new Semaphore(1);
|
134
128
|
}
|
135
129
|
ngOnDestroy() {
|
136
130
|
this.config$.destroy();
|
@@ -155,11 +149,9 @@ class ConfigurationService {
|
|
155
149
|
}
|
156
150
|
loadConfigPromise
|
157
151
|
.then(async (config) => {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
});
|
162
|
-
}
|
152
|
+
await this.config$.publish({ ...this.defaultConfig, ...(config ?? {}) }).then(() => {
|
153
|
+
resolve(true);
|
154
|
+
});
|
163
155
|
})
|
164
156
|
.catch((e) => {
|
165
157
|
console.log(`Failed to load env configuration`);
|
@@ -170,32 +162,29 @@ class ConfigurationService {
|
|
170
162
|
get isInitialized() {
|
171
163
|
return this.config$.isInitialized;
|
172
164
|
}
|
173
|
-
getProperty(key) {
|
165
|
+
async getProperty(key) {
|
174
166
|
if (!Object.values(CONFIG_KEY).includes(key)) {
|
175
167
|
console.error('Invalid config key ', key);
|
176
168
|
}
|
177
|
-
return this.config$.
|
169
|
+
return firstValueFrom(this.config$.pipe(map((config) => config[key])));
|
178
170
|
}
|
179
171
|
async setProperty(key, val) {
|
180
|
-
|
181
|
-
|
182
|
-
|
172
|
+
return this.semaphore.use(async () => {
|
173
|
+
const currentValues = await firstValueFrom(this.config$.asObservable());
|
174
|
+
currentValues[key] = val;
|
175
|
+
await this.config$.publish(currentValues);
|
176
|
+
});
|
183
177
|
}
|
184
|
-
getConfig() {
|
185
|
-
return this.config$.
|
178
|
+
async getConfig() {
|
179
|
+
return firstValueFrom(this.config$.asObservable());
|
186
180
|
}
|
187
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
188
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
181
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ConfigurationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
182
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ConfigurationService, providedIn: 'root' }); }
|
189
183
|
}
|
190
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ConfigurationService, decorators: [{
|
191
185
|
type: Injectable,
|
192
186
|
args: [{ providedIn: 'root' }]
|
193
|
-
}]
|
194
|
-
type: Optional
|
195
|
-
}, {
|
196
|
-
type: Inject,
|
197
|
-
args: [APP_CONFIG]
|
198
|
-
}] }] });
|
187
|
+
}] });
|
199
188
|
|
200
189
|
const API_PREFIX = 'portal-api';
|
201
190
|
const DEFAULT_LANG = 'en';
|
@@ -203,34 +192,32 @@ const DEFAULT_LANG = 'en';
|
|
203
192
|
class UserService {
|
204
193
|
constructor() {
|
205
194
|
this.profile$ = new UserProfileTopic();
|
206
|
-
this.permissions$ = new BehaviorSubject([]);
|
207
195
|
this.lang$ = new BehaviorSubject(this.determineLanguage() ?? DEFAULT_LANG);
|
208
196
|
this.permissionsTopic$ = new PermissionsTopic();
|
209
197
|
this.profile$
|
210
198
|
.pipe(map((profile) => profile.accountSettings?.localeAndTimeSettings?.locale ?? this.determineLanguage() ?? DEFAULT_LANG))
|
211
199
|
.subscribe(this.lang$);
|
212
|
-
this.oldStylePermissionsInitialized = firstValueFrom(this.permissions$.pipe(skip(1)));
|
213
|
-
this.profile$
|
214
|
-
.pipe(map((profile) => this.extractPermissions(profile)), filter((permissions) => !!permissions))
|
215
|
-
.subscribe(this.permissions$);
|
216
200
|
}
|
217
201
|
ngOnDestroy() {
|
218
202
|
this.profile$.destroy();
|
219
203
|
}
|
220
|
-
|
204
|
+
getPermissions() {
|
205
|
+
return this.permissionsTopic$.asObservable();
|
206
|
+
}
|
207
|
+
async hasPermission(permissionKey) {
|
208
|
+
if (!permissionKey)
|
209
|
+
return true;
|
221
210
|
if (Array.isArray(permissionKey)) {
|
222
|
-
|
211
|
+
const permissions = await Promise.all(permissionKey.map((key) => this.hasPermission(key)));
|
212
|
+
return permissions.every((hasPermission) => hasPermission);
|
223
213
|
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
console.log(`👮♀️ No permission for: ${permissionKey}`);
|
232
|
-
}
|
233
|
-
return !!result;
|
214
|
+
return firstValueFrom(this.permissionsTopic$.pipe(map((permissions) => {
|
215
|
+
const result = permissions.includes(permissionKey);
|
216
|
+
if (!result) {
|
217
|
+
console.log(`👮♀️ No permission for: ${permissionKey}`);
|
218
|
+
}
|
219
|
+
return !!result;
|
220
|
+
})));
|
234
221
|
}
|
235
222
|
determineLanguage() {
|
236
223
|
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
|
@@ -249,44 +236,24 @@ class UserService {
|
|
249
236
|
}
|
250
237
|
return browserLang;
|
251
238
|
}
|
252
|
-
extractPermissions(userProfile) {
|
253
|
-
if (userProfile) {
|
254
|
-
if (userProfile.memberships) {
|
255
|
-
const permissions = [];
|
256
|
-
userProfile.memberships.forEach((m) => {
|
257
|
-
m.roleMemberships?.forEach((r) => {
|
258
|
-
r.permissions?.forEach((p) => {
|
259
|
-
if (p) {
|
260
|
-
if (p.key !== undefined) {
|
261
|
-
permissions.push(p.key);
|
262
|
-
}
|
263
|
-
}
|
264
|
-
});
|
265
|
-
});
|
266
|
-
});
|
267
|
-
return permissions;
|
268
|
-
}
|
269
|
-
}
|
270
|
-
return null;
|
271
|
-
}
|
272
239
|
get isInitialized() {
|
273
240
|
return Promise.all([
|
274
|
-
|
241
|
+
this.permissionsTopic$.isInitialized,
|
275
242
|
this.profile$.isInitialized,
|
276
243
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
277
244
|
]).then(() => { });
|
278
245
|
}
|
279
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
280
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
246
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: UserService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
247
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: UserService, providedIn: 'root' }); }
|
281
248
|
}
|
282
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: UserService, decorators: [{
|
283
250
|
type: Injectable,
|
284
251
|
args: [{ providedIn: 'root' }]
|
285
252
|
}], ctorParameters: () => [] });
|
286
253
|
|
287
254
|
class PortalMessageService {
|
288
|
-
constructor(
|
289
|
-
this.translateService =
|
255
|
+
constructor() {
|
256
|
+
this.translateService = inject(TranslateService);
|
290
257
|
this.message$ = new MessageTopic();
|
291
258
|
}
|
292
259
|
success(msg) {
|
@@ -319,52 +286,28 @@ class PortalMessageService {
|
|
319
286
|
ngOnDestroy() {
|
320
287
|
this.message$.destroy();
|
321
288
|
}
|
322
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
323
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
289
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: PortalMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
290
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: PortalMessageService, providedIn: 'any' }); }
|
324
291
|
}
|
325
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
292
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: PortalMessageService, decorators: [{
|
326
293
|
type: Injectable,
|
327
294
|
args: [{ providedIn: 'any' }]
|
328
|
-
}]
|
295
|
+
}] });
|
329
296
|
|
330
|
-
const defaultThemeServerUrl = 'http://portal-theme-management:8080';
|
331
297
|
class ThemeService {
|
332
|
-
constructor(
|
333
|
-
this.configService = configService;
|
334
|
-
this.http = http;
|
335
|
-
this.baseUrlV1 = './portal-api';
|
298
|
+
constructor() {
|
336
299
|
this.currentTheme$ = new CurrentThemeTopic();
|
337
300
|
}
|
338
|
-
getThemeHref(themeId) {
|
339
|
-
const themeServerUrl = this.configService.getProperty(CONFIG_KEY.TKIT_PORTAL_THEME_SERVER_URL) || defaultThemeServerUrl;
|
340
|
-
return `${themeServerUrl}/themes/${themeId}/${themeId}.min.css`;
|
341
|
-
}
|
342
|
-
loadAndApplyTheme(themeName) {
|
343
|
-
return this.http.get(`${this.baseUrlV1}/internal/themes/${encodeURI(themeName)}`).pipe(mergeMap((theme) => {
|
344
|
-
return from(this.apply(theme)).pipe(map(() => theme));
|
345
|
-
}));
|
346
|
-
}
|
347
|
-
async apply(theme) {
|
348
|
-
console.log(`🎨 Applying theme: ${theme.name}`);
|
349
|
-
await this.currentTheme$.publish(theme);
|
350
|
-
if (theme.properties) {
|
351
|
-
Object.values(theme.properties).forEach((group) => {
|
352
|
-
for (const [key, value] of Object.entries(group)) {
|
353
|
-
document.documentElement.style.setProperty(`--${key}`, value);
|
354
|
-
}
|
355
|
-
});
|
356
|
-
}
|
357
|
-
}
|
358
301
|
ngOnDestroy() {
|
359
302
|
this.currentTheme$.destroy();
|
360
303
|
}
|
361
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
362
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
304
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
305
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ThemeService, providedIn: 'root' }); }
|
363
306
|
}
|
364
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
307
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ThemeService, decorators: [{
|
365
308
|
type: Injectable,
|
366
309
|
args: [{ providedIn: 'root' }]
|
367
|
-
}]
|
310
|
+
}] });
|
368
311
|
|
369
312
|
class RemoteComponentsService {
|
370
313
|
constructor() {
|
@@ -373,66 +316,17 @@ class RemoteComponentsService {
|
|
373
316
|
ngOnDestroy() {
|
374
317
|
this.remoteComponents$.destroy();
|
375
318
|
}
|
376
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
377
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
319
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: RemoteComponentsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
320
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: RemoteComponentsService, providedIn: 'root' }); }
|
378
321
|
}
|
379
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: RemoteComponentsService, decorators: [{
|
380
323
|
type: Injectable,
|
381
324
|
args: [{ providedIn: 'root' }]
|
382
325
|
}] });
|
383
326
|
|
384
|
-
class InitializeModuleGuard {
|
385
|
-
constructor(translateService, configService, appStateService, userService) {
|
386
|
-
this.translateService = translateService;
|
387
|
-
this.configService = configService;
|
388
|
-
this.appStateService = appStateService;
|
389
|
-
this.userService = userService;
|
390
|
-
this.SUPPORTED_LANGS = ['en', 'de'];
|
391
|
-
this.DEFAULT_LANG = 'en';
|
392
|
-
}
|
393
|
-
canActivate(_route, _state) {
|
394
|
-
console.time('InitializeModuleGuard');
|
395
|
-
return zip([
|
396
|
-
this.loadTranslations(),
|
397
|
-
from(this.configService.isInitialized),
|
398
|
-
from(this.userService.isInitialized),
|
399
|
-
from(this.appStateService.currentWorkspace$.isInitialized),
|
400
|
-
]).pipe(tap(() => {
|
401
|
-
console.timeEnd('InitializeModuleGuard');
|
402
|
-
}), map(() => true));
|
403
|
-
}
|
404
|
-
getBestMatchLanguage(lang) {
|
405
|
-
if (this.SUPPORTED_LANGS.includes(lang)) {
|
406
|
-
return lang;
|
407
|
-
}
|
408
|
-
else {
|
409
|
-
console.log(`${lang} is not supported. Using ${this.DEFAULT_LANG} as a fallback.`);
|
410
|
-
}
|
411
|
-
return this.DEFAULT_LANG;
|
412
|
-
}
|
413
|
-
loadTranslations() {
|
414
|
-
return this.userService.lang$.pipe(filter((v) => v !== undefined), mergeMap((lang) => {
|
415
|
-
const bestMatchLang = this.getBestMatchLanguage(lang);
|
416
|
-
return this.translateService.use(bestMatchLang);
|
417
|
-
}), mergeMap(() => of(true)));
|
418
|
-
}
|
419
|
-
toObservable(canActivateResult) {
|
420
|
-
if (isObservable(canActivateResult)) {
|
421
|
-
return canActivateResult;
|
422
|
-
}
|
423
|
-
return from(Promise.resolve(canActivateResult));
|
424
|
-
}
|
425
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: InitializeModuleGuard, deps: [{ token: i1$1.TranslateService }, { token: ConfigurationService }, { token: AppStateService }, { token: UserService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
426
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: InitializeModuleGuard, providedIn: 'any' }); }
|
427
|
-
}
|
428
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: InitializeModuleGuard, decorators: [{
|
429
|
-
type: Injectable,
|
430
|
-
args: [{ providedIn: 'any' }]
|
431
|
-
}], ctorParameters: () => [{ type: i1$1.TranslateService }, { type: ConfigurationService }, { type: AppStateService }, { type: UserService }] });
|
432
|
-
|
433
327
|
class WorkspaceService {
|
434
|
-
constructor(
|
435
|
-
this.appStateService =
|
328
|
+
constructor() {
|
329
|
+
this.appStateService = inject(AppStateService);
|
436
330
|
this.aliasStart = '[[';
|
437
331
|
this.aliasEnd = ']]';
|
438
332
|
this.paramStart = '{';
|
@@ -560,31 +454,35 @@ class WorkspaceService {
|
|
560
454
|
return String(value);
|
561
455
|
}
|
562
456
|
}
|
563
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
564
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
457
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: WorkspaceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
458
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: WorkspaceService, providedIn: 'root' }); }
|
565
459
|
}
|
566
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
460
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: WorkspaceService, decorators: [{
|
567
461
|
type: Injectable,
|
568
462
|
args: [{
|
569
463
|
providedIn: 'root',
|
570
464
|
}]
|
571
|
-
}]
|
465
|
+
}] });
|
572
466
|
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
});
|
467
|
+
var Capability;
|
468
|
+
(function (Capability) {
|
469
|
+
Capability["CURRENT_LOCATION_TOPIC"] = "currentLocationTopic";
|
470
|
+
Capability["PARAMETERS_TOPIC"] = "parametersTopic";
|
471
|
+
})(Capability || (Capability = {}));
|
472
|
+
class ShellCapabilityService {
|
473
|
+
static setCapabilities(capabilities) {
|
474
|
+
window['onecx-shell-capabilities'] = capabilities;
|
475
|
+
}
|
476
|
+
hasCapability(capability) {
|
477
|
+
return window['onecx-shell-capabilities']?.includes(capability) ?? false;
|
478
|
+
}
|
479
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ShellCapabilityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
480
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ShellCapabilityService, providedIn: 'root' }); }
|
587
481
|
}
|
482
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: ShellCapabilityService, decorators: [{
|
483
|
+
type: Injectable,
|
484
|
+
args: [{ providedIn: 'root' }]
|
485
|
+
}] });
|
588
486
|
|
589
487
|
// services
|
590
488
|
|
@@ -592,5 +490,5 @@ function addInitializeModuleGuard(routes, initializeModuleGuard = InitializeModu
|
|
592
490
|
* Generated bundle index. Do not edit.
|
593
491
|
*/
|
594
492
|
|
595
|
-
export { APPLICATION_NAME, APP_CONFIG,
|
493
|
+
export { APPLICATION_NAME, APP_CONFIG, AppConfigService, AppStateService, CONFIG_KEY, Capability, ConfigurationService, POLYFILL_SCOPE_MODE, PortalMessageService, RemoteComponentsService, SANITY_CHECK, ShellCapabilityService, ThemeService, UserService, WorkspaceService };
|
596
494
|
//# sourceMappingURL=onecx-angular-integration-interface.mjs.map
|