diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts index 58596a4a15..529d372082 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts @@ -39,8 +39,8 @@ interface SortOption { } const TYPE_ORDER: ItemType[] = [ - ItemType.WIDGET, ItemType.DASHBOARD, ItemType.SOLUTION_TEMPLATE, ItemType.DEVICE, - ItemType.CALCULATED_FIELD, ItemType.RULE_CHAIN + ItemType.DEVICE, ItemType.SOLUTION_TEMPLATE, ItemType.WIDGET, + ItemType.CALCULATED_FIELD, ItemType.ALARM_RULE, ItemType.RULE_CHAIN ]; @Component({ @@ -80,8 +80,8 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { installedWidgets: IotHubInstalledItem[] = []; installedSolutionTemplates: IotHubInstalledItem[] = []; installedDeviceCounts: Record = {}; - installedDashboardCounts: Record = {}; installedCalcFieldCounts: Record = {}; + installedAlarmRuleCounts: Record = {}; installedRuleChainCounts: Record = {}; private searchSubject = new Subject(); @@ -176,7 +176,9 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { // Type helpers isCompactType(type: ItemType): boolean { - return type === ItemType.CALCULATED_FIELD || type === ItemType.RULE_CHAIN; + return type === ItemType.CALCULATED_FIELD + || type === ItemType.ALARM_RULE + || type === ItemType.RULE_CHAIN; } getTypeLabel(type: ItemType): string { @@ -187,9 +189,9 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { getTypeRoute(type: ItemType): string { switch (type) { case ItemType.WIDGET: return 'widgets'; - case ItemType.DASHBOARD: return 'dashboards'; case ItemType.SOLUTION_TEMPLATE: return 'solution-templates'; case ItemType.CALCULATED_FIELD: return 'calculated-fields'; + case ItemType.ALARM_RULE: return 'alarm-rules'; case ItemType.RULE_CHAIN: return 'rule-chains'; case ItemType.DEVICE: return 'devices'; default: return 'widgets'; @@ -217,10 +219,10 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { switch (item.type) { case ItemType.DEVICE: return this.installedDeviceCounts[item.itemId] || 0; - case ItemType.DASHBOARD: - return this.installedDashboardCounts[item.itemId] || 0; case ItemType.CALCULATED_FIELD: return this.installedCalcFieldCounts[item.itemId] || 0; + case ItemType.ALARM_RULE: + return this.installedAlarmRuleCounts[item.itemId] || 0; case ItemType.RULE_CHAIN: return this.installedRuleChainCounts[item.itemId] || 0; default: @@ -311,15 +313,15 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy { widgets: this.iotHubApiService.getInstalledItems(pageLink, ItemType.WIDGET, undefined, config), solutionTemplates: this.iotHubApiService.getInstalledItems(pageLink, ItemType.SOLUTION_TEMPLATE, undefined, config), deviceCounts: this.iotHubApiService.getInstalledItemCounts(ItemType.DEVICE, config), - dashboardCounts: this.iotHubApiService.getInstalledItemCounts(ItemType.DASHBOARD, config), calcFieldCounts: this.iotHubApiService.getInstalledItemCounts(ItemType.CALCULATED_FIELD, config), + alarmRuleCounts: this.iotHubApiService.getInstalledItemCounts(ItemType.ALARM_RULE, config), ruleChainCounts: this.iotHubApiService.getInstalledItemCounts(ItemType.RULE_CHAIN, config) }).subscribe(results => { this.installedWidgets = results.widgets.data; this.installedSolutionTemplates = results.solutionTemplates.data; this.installedDeviceCounts = results.deviceCounts; - this.installedDashboardCounts = results.dashboardCounts; this.installedCalcFieldCounts = results.calcFieldCounts; + this.installedAlarmRuleCounts = results.alarmRuleCounts; this.installedRuleChainCounts = results.ruleChainCounts; }); } diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts index e62ea12143..e83f1dd16a 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts @@ -77,9 +77,6 @@ import { EntityAliasesDialogComponent, EntityAliasesDialogData } from '@home/components/alias/entity-aliases-dialog.component'; -import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; -import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service'; - @Injectable() export class DashboardsTableConfigResolver { @@ -92,7 +89,6 @@ export class DashboardsTableConfigResolver { private dialogService: DialogService, private homeDialogs: HomeDialogsService, private importExport: ImportExportService, - private iotHubActions: IotHubActionsService, private translate: TranslateService, private datePipe: DatePipe, private router: Router, @@ -352,12 +348,6 @@ export class DashboardsTableConfigResolver { icon: 'file_upload', isEnabled: () => true, onAction: ($event) => this.importDashboard($event) - }, - { - name: this.translate.instant('iot-hub.add-from-iot-hub'), - icon: 'store', - isEnabled: () => true, - onAction: ($event) => this.addDashboardFromIotHub($event) } ); } @@ -397,14 +387,6 @@ export class DashboardsTableConfigResolver { } } - addDashboardFromIotHub(_$event: Event) { - this.iotHubActions.addItem(ItemType.DASHBOARD).subscribe(result => { - if (result?.descriptor?.type === 'DASHBOARD' && result.descriptor.dashboardId?.id) { - this.router.navigateByUrl(`dashboards/${result.descriptor.dashboardId.id}`); - } - }); - } - importDashboard(_$event: Event) { this.importExport.importDashboard(this.editMissingAliases.bind(this)).subscribe( (dashboard) => { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts index 76552716ba..e095ef3cc8 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts @@ -52,6 +52,11 @@ interface SearchResultGroup { items: MpItemVersionView[]; } +const SEARCH_GROUP_ORDER: ItemType[] = [ + ItemType.DEVICE, ItemType.SOLUTION_TEMPLATE, ItemType.WIDGET, + ItemType.CALCULATED_FIELD, ItemType.ALARM_RULE, ItemType.RULE_CHAIN +]; + @Component({ selector: 'tb-iot-hub-home', standalone: false, @@ -524,6 +529,9 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { private groupSearchResults(items: MpItemVersionView[]): SearchResultGroup[] { const groupMap = new Map(); for (const item of items) { + if (!SEARCH_GROUP_ORDER.includes(item.type)) { + continue; + } let list = groupMap.get(item.type); if (!list) { list = []; @@ -531,6 +539,8 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { } list.push(item); } - return Array.from(groupMap.entries()).map(([type, groupItems]) => ({ type, items: groupItems })); + return SEARCH_GROUP_ORDER + .filter(type => groupMap.has(type)) + .map(type => ({ type, items: groupMap.get(type) })); } }