@c8y/ngx-components 1017.0.262 → 1017.0.263

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.
@@ -11,8 +11,8 @@ import { ApplicationAvailability, ApplicationType } from '@c8y/client';
11
11
  import * as i2$1 from '@ngx-translate/core';
12
12
  import { saveAs } from 'file-saver';
13
13
  import { groupBy, uniqBy, get, pick, kebabCase, cloneDeep } from 'lodash-es';
14
- import { BehaviorSubject, merge, combineLatest } from 'rxjs';
15
- import { debounceTime, take, distinctUntilKeyChanged, map, tap, filter, switchMap, shareReplay } from 'rxjs/operators';
14
+ import { BehaviorSubject, defer, merge, combineLatest } from 'rxjs';
15
+ import { map, shareReplay, debounceTime, take, distinctUntilKeyChanged, tap, filter, switchMap } from 'rxjs/operators';
16
16
  import { gt, coerce } from 'semver';
17
17
  import * as i3$1 from '@angular/common';
18
18
  import * as i4 from '@angular/router';
@@ -185,6 +185,7 @@ class EcosystemService {
185
185
  this.inventoryService = inventoryService;
186
186
  this.appDeleted = new EventEmitter();
187
187
  this.progress = new BehaviorSubject(null);
188
+ this.appsGroupedByContextPath$ = defer(() => this.getWebApplications()).pipe(map(webApps => groupBy(webApps, 'contextPath')), shareReplay({ bufferSize: 1, refCount: true }));
188
189
  }
189
190
  getUniqueAppConfig(srcApp, existingApps) {
190
191
  let app = {
@@ -255,7 +256,6 @@ class EcosystemService {
255
256
  async getWebApplications(customFilter = {}) {
256
257
  const apps = (await this.getApplications(customFilter)).data;
257
258
  const webApps = apps.filter(app => this.isApplication(app));
258
- this.appsGroupedByContextPath = groupBy(webApps, 'contextPath');
259
259
  return webApps.sort((a, b) => a.name.localeCompare(b.name));
260
260
  }
261
261
  async getFeatureApplications(customFilter = {}) {
@@ -297,7 +297,7 @@ class EcosystemService {
297
297
  window.open(this.applicationService.getHref(app), '_blank', 'noopener,noreferrer');
298
298
  }
299
299
  async canDeleteApp(app) {
300
- return (this.isOwner(app) && ((await this.hasSubscribedAppParent(app)) || !this.isCurrentApp(app)));
300
+ return (this.isOwner(app) && (!this.isCurrentApp(app) || (await this.hasSubscribedAppParent(app))));
301
301
  }
302
302
  isOwner(app) {
303
303
  const currentTenant = this.appStateService.currentTenant.value;
@@ -628,10 +628,8 @@ class EcosystemService {
628
628
  return !this.isOwner(app) && (await this.hasSubscribedAppParent(app));
629
629
  }
630
630
  async hasSubscribedAppParent(app) {
631
- if (!this.appsGroupedByContextPath) {
632
- await this.getWebApplications();
633
- }
634
- return app.contextPath && this.appsGroupedByContextPath[app.contextPath]?.length === 2;
631
+ const appsGroupedByContextPath = await this.appsGroupedByContextPath$.pipe(take(1)).toPromise();
632
+ return app.contextPath && appsGroupedByContextPath[app.contextPath]?.length === 2;
635
633
  }
636
634
  /**
637
635
  * @deprecated