Browse Source

Merge branch 'feature/iot-hub' into feature/lts-4.3-iot-hub

pull/15540/head
Igor Kulikov 4 months ago
parent
commit
2f72b08d0e
  1. 19
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts

19
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts

@ -136,13 +136,22 @@ export class TbIotHubItemsPageComponent implements OnInit {
} }
history.replaceState({ ...history.state, openItem: undefined }, ''); history.replaceState({ ...history.state, openItem: undefined }, '');
const isDevice = this.config.type === ItemType.DEVICE; // Types where multiple entities can be installed from the same
const resolution$: Observable<{ installed?: IotHubInstalledItem; count?: number }> = isDevice // IoT Hub item — we only care about the count per itemId
// (no singular installed entity to surface in the detail dialog).
const countBasedTypes: ReadonlySet<ItemType> = new Set([
ItemType.DEVICE,
ItemType.CALCULATED_FIELD,
ItemType.ALARM_RULE,
ItemType.RULE_CHAIN
]);
const isCountBased = countBasedTypes.has(this.config.type);
const resolution$: Observable<{ installed?: IotHubInstalledItem; count?: number }> = isCountBased
? this.iotHubApiService ? this.iotHubApiService
.getInstalledItemCounts(ItemType.DEVICE, { ignoreLoading: true }) .getInstalledItemCounts(this.config.type, { ignoreLoading: true })
.pipe(map(counts => ({ count: counts[openItem.version.itemId] || 0 }))) .pipe(map(counts => ({ count: counts[openItem.version.itemId] || 0 })))
: this.resolveInstalledItem(openItem.version) : this.resolveInstalledItem(openItem.version)
.pipe(map(installed => ({ installed: installed ?? undefined }))); .pipe(map(installed => ({ installed: installed ?? undefined })));
resolution$.subscribe(({ installed, count }) => { resolution$.subscribe(({ installed, count }) => {
this.iotHubActions.openItemDetail( this.iotHubActions.openItemDetail(

Loading…
Cancel
Save