@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 * as i3 from '@c8y/client';
11
11
  import { ApplicationAvailability, ApplicationType } from '@c8y/client';
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 i2$1 from '@ngx-translate/core';
18
18
  import * as i3$1 from '@angular/common';
@@ -186,6 +186,7 @@ class EcosystemService {
186
186
  this.inventoryService = inventoryService;
187
187
  this.appDeleted = new EventEmitter();
188
188
  this.progress = new BehaviorSubject(null);
189
+ this.appsGroupedByContextPath$ = defer(() => this.getWebApplications()).pipe(map(webApps => groupBy(webApps, 'contextPath')), shareReplay({ bufferSize: 1, refCount: true }));
189
190
  }
190
191
  getUniqueAppConfig(srcApp, existingApps) {
191
192
  let app = {
@@ -261,7 +262,6 @@ class EcosystemService {
261
262
  return __awaiter(this, void 0, void 0, function* () {
262
263
  const apps = (yield this.getApplications(customFilter)).data;
263
264
  const webApps = apps.filter(app => this.isApplication(app));
264
- this.appsGroupedByContextPath = groupBy(webApps, 'contextPath');
265
265
  return webApps.sort((a, b) => a.name.localeCompare(b.name));
266
266
  });
267
267
  }
@@ -311,7 +311,7 @@ class EcosystemService {
311
311
  }
312
312
  canDeleteApp(app) {
313
313
  return __awaiter(this, void 0, void 0, function* () {
314
- return (this.isOwner(app) && ((yield this.hasSubscribedAppParent(app)) || !this.isCurrentApp(app)));
314
+ return (this.isOwner(app) && (!this.isCurrentApp(app) || (yield this.hasSubscribedAppParent(app))));
315
315
  });
316
316
  }
317
317
  isOwner(app) {
@@ -677,10 +677,8 @@ class EcosystemService {
677
677
  hasSubscribedAppParent(app) {
678
678
  var _a;
679
679
  return __awaiter(this, void 0, void 0, function* () {
680
- if (!this.appsGroupedByContextPath) {
681
- yield this.getWebApplications();
682
- }
683
- return app.contextPath && ((_a = this.appsGroupedByContextPath[app.contextPath]) === null || _a === void 0 ? void 0 : _a.length) === 2;
680
+ const appsGroupedByContextPath = yield this.appsGroupedByContextPath$.pipe(take(1)).toPromise();
681
+ return app.contextPath && ((_a = appsGroupedByContextPath[app.contextPath]) === null || _a === void 0 ? void 0 : _a.length) === 2;
684
682
  });
685
683
  }
686
684
  /**