@c8y/ngx-components 1018.0.112 → 1018.0.115

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.
@@ -7,8 +7,8 @@ import { gettext, PackageType, Status, DropAreaComponent, C8yStepper, CoreModule
7
7
  import * as i2$1 from '@ngx-translate/core';
8
8
  import { saveAs } from 'file-saver';
9
9
  import { groupBy, uniqBy, get, pick, kebabCase, cloneDeep } from 'lodash-es';
10
- import { BehaviorSubject, merge, combineLatest } from 'rxjs';
11
- import { debounceTime, take, distinctUntilKeyChanged, map, tap, filter, switchMap, shareReplay } from 'rxjs/operators';
10
+ import { BehaviorSubject, defer, merge, combineLatest } from 'rxjs';
11
+ import { map, shareReplay, debounceTime, take, distinctUntilKeyChanged, tap, filter, switchMap } from 'rxjs/operators';
12
12
  import { gt, coerce } from 'semver';
13
13
  import * as i3$1 from '@angular/common';
14
14
  import * as i4 from '@angular/router';
@@ -215,6 +215,7 @@ class EcosystemService {
215
215
  this.wizardModalService = wizardModalService;
216
216
  this.appDeleted = new EventEmitter();
217
217
  this.progress = new BehaviorSubject(null);
218
+ this.appsGroupedByContextPath$ = defer(() => this.getWebApplications()).pipe(map(webApps => groupBy(webApps, 'contextPath')), shareReplay({ bufferSize: 1, refCount: true }));
218
219
  }
219
220
  getUniqueAppConfig(srcApp, existingApps) {
220
221
  let app = {
@@ -314,7 +315,6 @@ class EcosystemService {
314
315
  async getWebApplications(customFilter = {}) {
315
316
  const apps = (await this.getApplications(customFilter)).data;
316
317
  const webApps = apps.filter(app => this.isApplication(app));
317
- this.appsGroupedByContextPath = groupBy(webApps, 'contextPath');
318
318
  return webApps.sort((a, b) => a.name.localeCompare(b.name));
319
319
  }
320
320
  async getFeatureApplications(customFilter = {}) {
@@ -356,7 +356,7 @@ class EcosystemService {
356
356
  window.open(this.applicationService.getHref(app), '_blank', 'noopener,noreferrer');
357
357
  }
358
358
  async canDeleteApp(app) {
359
- return (this.isOwner(app) && ((await this.hasSubscribedAppParent(app)) || !this.isCurrentApp(app)));
359
+ return (this.isOwner(app) && (!this.isCurrentApp(app) || (await this.hasSubscribedAppParent(app))));
360
360
  }
361
361
  isOwner(app) {
362
362
  const currentTenant = this.appStateService.currentTenant.value;
@@ -693,10 +693,8 @@ class EcosystemService {
693
693
  return !this.isOwner(app) && (await this.hasSubscribedAppParent(app));
694
694
  }
695
695
  async hasSubscribedAppParent(app) {
696
- if (!this.appsGroupedByContextPath) {
697
- await this.getWebApplications();
698
- }
699
- return app.contextPath && this.appsGroupedByContextPath[app.contextPath]?.length === 2;
696
+ const appsGroupedByContextPath = await this.appsGroupedByContextPath$.pipe(take(1)).toPromise();
697
+ return app.contextPath && appsGroupedByContextPath[app.contextPath]?.length === 2;
700
698
  }
701
699
  /**
702
700
  * @deprecated