@c8y/ngx-components 1023.80.2 → 1023.81.2

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.
@@ -11339,22 +11339,96 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
11339
11339
  args: [{ providedIn: 'root' }]
11340
11340
  }], ctorParameters: () => [{ type: i1.InventoryService }] });
11341
11341
 
11342
+ class FeatureCacheService {
11343
+ constructor(featureService, appState) {
11344
+ this.featureService = featureService;
11345
+ this.appState = appState;
11346
+ this.refreshTrigger = new BehaviorSubject(undefined);
11347
+ this.features$ = this.appState.currentUser.pipe(switchMap(user => {
11348
+ if (!user) {
11349
+ return NEVER;
11350
+ }
11351
+ return this.refreshTrigger.pipe(switchMap(() => this.loadFeatures()));
11352
+ }), shareReplay(1));
11353
+ }
11354
+ /**
11355
+ * Needed for the angularJS implmentation to show/hide some old features.
11356
+ * Returns a promise
11357
+ */
11358
+ getFeatureStatePromise(key) {
11359
+ return firstValueFrom(this.getFeatureState(key));
11360
+ }
11361
+ /**
11362
+ *
11363
+ * @param key - The feature key to check
11364
+ * @returns true if the feature key exists in the list of features and it is no GA
11365
+ */
11366
+ featureExists(key) {
11367
+ return this.features$.pipe(map(features => features.some(feature => feature.key === key && feature.phase !== 'GENERALLY_AVAILABLE')));
11368
+ }
11369
+ getFeatureState(key) {
11370
+ return this.features$.pipe(map(features => {
11371
+ const feature = features.find(f => f.key === key);
11372
+ return feature?.active || false;
11373
+ }));
11374
+ }
11375
+ resetFeatureState() {
11376
+ this.refreshTrigger.next();
11377
+ }
11378
+ async loadFeatures() {
11379
+ try {
11380
+ const response = await this.featureService.list({ pageSize: 1000 });
11381
+ return response.data || [];
11382
+ }
11383
+ catch (e) {
11384
+ console.error('Error loading features:', e);
11385
+ return [];
11386
+ }
11387
+ }
11388
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, deps: [{ token: i1.FeatureService }, { token: AppStateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11389
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, providedIn: 'root' }); }
11390
+ }
11391
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, decorators: [{
11392
+ type: Injectable,
11393
+ args: [{ providedIn: 'root' }]
11394
+ }], ctorParameters: () => [{ type: i1.FeatureService }, { type: AppStateService }] });
11395
+
11342
11396
  class AppSwitcherService {
11343
- constructor(ui) {
11397
+ constructor(ui, featureToggles) {
11344
11398
  this.ui = ui;
11399
+ this.featureToggles = featureToggles;
11345
11400
  this.visibleApplicationTypes = ['HOSTED', 'EXTERNAL'];
11346
11401
  const { currentTenant } = this.ui;
11347
- this.appsOfCurrentUser$ = this.ui.currentAppsOfUser.pipe(map(apps => this.filterVisible(apps)), shareReplay(1));
11402
+ this.appsOfCurrentUser$ = this.ui.currentAppsOfUser.pipe(switchMap(apps => this.filterVisible(apps)), shareReplay(1));
11348
11403
  this.oneCloudApps$ = this.appsOfCurrentUser$.pipe(map(apps => apps.filter(app => this.isCloudApp(app))), map(cloudApps => this.orderApps(cloudApps)), shareReplay(1));
11349
11404
  const nonCloudApps$ = this.appsOfCurrentUser$.pipe(map(apps => apps.filter(app => !this.isCloudApp(app))));
11350
11405
  this.apps$ = combineLatest([nonCloudApps$, currentTenant]).pipe(map(([apps, tenant]) => this.filterDuplicates(apps, tenant)), map(apps => this.orderApps(apps)), shareReplay(1));
11351
11406
  this.finishedLoading$ = combineLatest([this.apps$, this.oneCloudApps$]).pipe(map(() => true), take(1), shareReplay(1));
11352
11407
  }
11353
- filterVisible(apps) {
11354
- return apps.filter(app => this.visibleApplicationTypes.includes(app.type) &&
11355
- !app.noAppSwitcher &&
11356
- !this.isPackage(app) &&
11357
- !get(app, 'manifest.noAppSwitcher'));
11408
+ async filterVisible(apps) {
11409
+ const filteredApps = new Array();
11410
+ for (const app of apps) {
11411
+ if (!this.visibleApplicationTypes.includes(app.type)) {
11412
+ continue;
11413
+ }
11414
+ if (this.isPackage(app)) {
11415
+ continue;
11416
+ }
11417
+ if (!app.noAppSwitcher && !get(app, 'manifest.noAppSwitcher')) {
11418
+ filteredApps.push(app);
11419
+ continue;
11420
+ }
11421
+ const dependsOnFeatureToggle = get(app, 'manifest.noAppSwitcher');
11422
+ if (dependsOnFeatureToggle && typeof dependsOnFeatureToggle === 'string') {
11423
+ const stateOfFeatureToggle = await this.featureToggles.getFeatureStatePromise(dependsOnFeatureToggle);
11424
+ if (stateOfFeatureToggle) {
11425
+ filteredApps.push(app);
11426
+ continue;
11427
+ }
11428
+ }
11429
+ continue;
11430
+ }
11431
+ return filteredApps;
11358
11432
  }
11359
11433
  isPackage(app) {
11360
11434
  return !!app.manifest?.isPackage;
@@ -11373,13 +11447,13 @@ class AppSwitcherService {
11373
11447
  orderApps(apps) {
11374
11448
  return orderBy(apps, ({ name }) => name.toLowerCase());
11375
11449
  }
11376
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AppSwitcherService, deps: [{ token: AppStateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11450
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AppSwitcherService, deps: [{ token: AppStateService }, { token: FeatureCacheService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11377
11451
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AppSwitcherService, providedIn: 'root' }); }
11378
11452
  }
11379
11453
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AppSwitcherService, decorators: [{
11380
11454
  type: Injectable,
11381
11455
  args: [{ providedIn: 'root' }]
11382
- }], ctorParameters: () => [{ type: AppStateService }] });
11456
+ }], ctorParameters: () => [{ type: AppStateService }, { type: FeatureCacheService }] });
11383
11457
 
11384
11458
  class AppIconComponent {
11385
11459
  constructor(options) {
@@ -17431,60 +17505,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
17431
17505
  type: Output
17432
17506
  }] } });
17433
17507
 
17434
- class FeatureCacheService {
17435
- constructor(featureService, appState) {
17436
- this.featureService = featureService;
17437
- this.appState = appState;
17438
- this.refreshTrigger = new BehaviorSubject(undefined);
17439
- this.features$ = this.appState.currentUser.pipe(switchMap(user => {
17440
- if (!user) {
17441
- return NEVER;
17442
- }
17443
- return this.refreshTrigger.pipe(switchMap(() => this.loadFeatures()));
17444
- }), shareReplay(1));
17445
- }
17446
- /**
17447
- * Needed for the angularJS implmentation to show/hide some old features.
17448
- * Returns a promise
17449
- */
17450
- getFeatureStatePromise(key) {
17451
- return firstValueFrom(this.getFeatureState(key));
17452
- }
17453
- /**
17454
- *
17455
- * @param key - The feature key to check
17456
- * @returns true if the feature key exists in the list of features and it is no GA
17457
- */
17458
- featureExists(key) {
17459
- return this.features$.pipe(map(features => features.some(feature => feature.key === key && feature.phase !== 'GENERALLY_AVAILABLE')));
17460
- }
17461
- getFeatureState(key) {
17462
- return this.features$.pipe(map(features => {
17463
- const feature = features.find(f => f.key === key);
17464
- return feature?.active || false;
17465
- }));
17466
- }
17467
- resetFeatureState() {
17468
- this.refreshTrigger.next();
17469
- }
17470
- async loadFeatures() {
17471
- try {
17472
- const response = await this.featureService.list({ pageSize: 1000 });
17473
- return response.data || [];
17474
- }
17475
- catch (e) {
17476
- console.error('Error loading features:', e);
17477
- return [];
17478
- }
17479
- }
17480
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, deps: [{ token: i1.FeatureService }, { token: AppStateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
17481
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, providedIn: 'root' }); }
17482
- }
17483
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: FeatureCacheService, decorators: [{
17484
- type: Injectable,
17485
- args: [{ providedIn: 'root' }]
17486
- }], ctorParameters: () => [{ type: i1.FeatureService }, { type: AppStateService }] });
17487
-
17488
17508
  /**
17489
17509
  * Feature key for wildcard search.
17490
17510
  */