Browse Source
- Add a single getInstalledItemUrl(descriptor) helper to iot-hub-installed-item.models that maps every descriptor type (WIDGET / DASHBOARD / CALCULATED_FIELD / ALARM_RULE / RULE_CHAIN / SOLUTION_TEMPLATE) to its entity-details URL via the shared getEntityDetailsPageURL utility, appending `?selectedTab=cf` for calculated-field installs so the entity tabs page lands on the CF tab on first paint. - Drop the parallel resolveEntityDetailsUrl helper + iot-hub-components.models.ts file and rewire every installed-item open path (install dialog, update dialog, installed-items table, item detail dialog) to call getInstalledItemUrl. Installed-items table openEntity collapses to parseUrl + serializeUrl on the helper's output now that any selectedTab is part of the URL. - Teach EntityDetailsPageComponent to honour a `selectedTab=…` query param: read it from the current route on entityId change, strip it (replaceUrl) so refresh doesn't keep jumping the tab, then resolve a tab index via the new EntityTabsComponent.resolveTabIndex(tab) hook. Asset, device, asset-profile, and device-profile tabs override the hook to map the `cf` shortcut to their respective Calculated Fields tab position; other entities fall back to index 0. - EntityDetailsPanelComponent now applies this.selectedTab to the underlying MatTabGroup both when the entity-tabs query list refreshes and after view init, so the initial tab matches the resolved index instead of staying on 0.pull/15772/head
13 changed files with 110 additions and 120 deletions
@ -1,50 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2026 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { EntityType } from '@shared/models/entity-type.models'; |
|||
import { IotHubInstalledItemDescriptor } from '@shared/models/iot-hub/iot-hub-installed-item.models'; |
|||
import { getEntityDetailsPageURL } from '@core/utils'; |
|||
|
|||
export const ITEM_TYPE_TO_ENTITY_TYPE: Record<string, EntityType> = { |
|||
'WIDGET': EntityType.WIDGET_TYPE, |
|||
'DASHBOARD': EntityType.DASHBOARD, |
|||
'CALCULATED_FIELD': EntityType.CALCULATED_FIELD, |
|||
'ALARM_RULE': EntityType.CALCULATED_FIELD, |
|||
'RULE_CHAIN': EntityType.RULE_CHAIN, |
|||
'DEVICE': EntityType.DEVICE_PROFILE |
|||
}; |
|||
|
|||
export function resolveEntityDetailsUrl(descriptor: IotHubInstalledItemDescriptor, itemType: string): string | null { |
|||
if (!descriptor) { |
|||
return null; |
|||
} |
|||
const entityType = ITEM_TYPE_TO_ENTITY_TYPE[itemType]; |
|||
if (!entityType) { |
|||
return null; |
|||
} |
|||
let entityId: string | null = null; |
|||
switch (descriptor.type) { |
|||
case 'WIDGET': entityId = descriptor.widgetTypeId?.id; break; |
|||
case 'DASHBOARD': entityId = descriptor.dashboardId?.id; break; |
|||
case 'CALCULATED_FIELD': entityId = descriptor.calculatedFieldId?.id; break; |
|||
case 'ALARM_RULE': entityId = descriptor.calculatedFieldId?.id; break; |
|||
case 'RULE_CHAIN': entityId = descriptor.ruleChainId?.id; break; |
|||
} |
|||
if (!entityId) { |
|||
return null; |
|||
} |
|||
return getEntityDetailsPageURL(entityId, entityType) || null; |
|||
} |
|||
Loading…
Reference in new issue