Browse Source

refactor(iot-hub): broaden count-based deep-link resolution

Treat DEVICE, CALCULATED_FIELD, ALARM_RULE, and RULE_CHAIN as
count-based item types in maybeOpenDeepLinkedItem: all four resolve
via getInstalledItemCounts(this.config.type) and pass only { count }
to openItemDetail. Singular-entity types (widgets, dashboards,
solution templates) still go through resolveInstalledItem and pass
{ installed }.
pull/15772/head
Igor Kulikov 4 months ago
parent
commit
5194067c6b
  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