Browse Source

fix(iot-hub): alarm rule prompt + open-detail route on install success

* `selectEntityConfig` did not have an `ALARM_RULE` entry. The install
  dialog routes both `CALCULATED_FIELD` and `ALARM_RULE` to the
  `select-entity` step, but the per-`ItemType` config map (introduced
  by the CE 4.2 rule chain work) only had `CALCULATED_FIELD` and
  `RULE_CHAIN` entries. The alarm rule prompt paragraph silently
  dropped and the picker bindings had no config to read from. Add an
  `ALARM_RULE` entry with the same allow-list as CF and the new i18n
  key `iot-hub.select-entity-for-alarm-rule`.

* `resolveEntityDetailsUrl` returned `/calculatedFields/{id}` for
  ALARM_RULE installs because the `ITEM_TYPE_TO_ENTITY_TYPE` map sent
  `ALARM_RULE` through `EntityType.CALCULATED_FIELD`. Alarm rules
  share the CalculatedField data structure on the backend but live at
  `/alarms/alarm-rules/{id}` in the UI. Resolve the URL directly for
  ALARM_RULE before falling through to the entity-type map, and drop
  the misleading `'ALARM_RULE' → CALCULATED_FIELD` entry / switch case.
pull/15646/head
dshvaika 5 months ago
parent
commit
f9ba9098fd
  1. 8
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts
  2. 6
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts
  3. 1
      ui-ngx/src/assets/locale/locale.constant-en_US.json

8
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts

@ -22,7 +22,6 @@ 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
};
@ -31,6 +30,12 @@ export function resolveEntityDetailsUrl(descriptor: IotHubInstalledItemDescripto
if (!descriptor) {
return null;
}
// Alarm rules share the CalculatedField data structure but live at a different
// route, so resolve their URL directly instead of going through the entity-type map.
if (itemType === 'ALARM_RULE' && descriptor.type === 'ALARM_RULE') {
const id = descriptor.calculatedFieldId?.id;
return id ? `/alarms/alarm-rules/${id}` : null;
}
const entityType = ITEM_TYPE_TO_ENTITY_TYPE[itemType];
if (!entityType) {
return null;
@ -40,7 +45,6 @@ export function resolveEntityDetailsUrl(descriptor: IotHubInstalledItemDescripto
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) {

6
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts

@ -87,6 +87,12 @@ export class TbIotHubInstallDialogComponent extends DialogComponent<TbIotHubInst
required: true,
promptKey: 'iot-hub.select-entity-for-cf',
},
[ItemType.ALARM_RULE]: {
allowed: [EntityType.DEVICE, EntityType.ASSET, EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE],
defaultType: EntityType.DEVICE_PROFILE,
required: true,
promptKey: 'iot-hub.select-entity-for-alarm-rule',
},
[ItemType.RULE_CHAIN]: {
allowed: [EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE],
defaultType: EntityType.DEVICE_PROFILE,

1
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -4301,6 +4301,7 @@
"remove-desc-solution-template": "Removing this solution template will also remove all created entities including dashboards, rule chains, devices, and other associated resources within your tenant",
"remove-anyway": "Remove anyway",
"select-entity-for-cf": "Select entity for calculated field '{{name}}'",
"select-entity-for-alarm-rule": "Select entity for alarm rule '{{name}}'",
"rule-chain-install-desc": "Installing this will automatically create the rule chain within your tenant. Use 'Set for profile' to also set it as default for Device or Asset profile.",
"rule-chain-install-as-default": "Set for profile",
"select-profile-for-rule-chain": "Select profile for rule chain '{{name}}'",

Loading…
Cancel
Save