Browse Source

Merge lts-4.2 IoT Hub search work into lts-4.3

Forward-port of thingsboard/thingsboard#16148: the hero search popup asks the Hub for
sectioned results and renders them, the search page gains a filter panel and a
column-driven page size, and relevance becomes the sort default on every surface that
carries a search field.

Merged with no conflicts. Two files auto-merged - iot-hub-components.module.ts, where
lts-4.3 and this branch each added a declaration, and the en_US locale, where lts-4.3
added 708 lines and this branch four keys.
pull/16161/head
dshvaika 2 months ago
parent
commit
67ecf4a9df
  1. 42
      ui-ngx/src/app/core/http/iot-hub-api.service.ts
  2. 23
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts
  3. 36
      ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss
  4. 21
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
  5. 3
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts
  6. 31
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.html
  7. 67
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss
  8. 80
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.ts
  9. 4
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html
  10. 13
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts
  11. 164
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.html
  12. 171
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss
  13. 294
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts
  14. 5
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-creator-profile.component.html
  15. 73
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html
  16. 101
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss
  17. 130
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts
  18. 101
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search-page.component.scss
  19. 45
      ui-ngx/src/app/shared/models/iot-hub/iot-hub-item.models.ts
  20. 134
      ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts
  21. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json

42
ui-ngx/src/app/core/http/iot-hub-api.service.ts

@ -6,7 +6,13 @@ import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { PageData } from '@shared/models/page/page-data';
import { PageLink } from '@shared/models/page/page-link';
import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import {
MpItemVersionGroupedQuery,
MpItemVersionQuery,
MpItemVersionQueryOptions,
MpItemVersionSection,
MpItemVersionView
} from '@shared/models/iot-hub/iot-hub-version.models';
import { CreatorView } from '@shared/models/iot-hub/iot-hub-creator.models';
import { IotHubInstalledItem, InstallItemVersionResult, InstallPlan, InstallPlanResult, UpdateItemVersionResult, ItemPublishedVersionInfo } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { ItemType, ItemTypeFilterInfo, WidgetCategory } from '@shared/models/iot-hub/iot-hub-item.models';
@ -69,18 +75,40 @@ export class IotHubApiService {
}
public getPublishedVersions(query: MpItemVersionQuery, config?: IotHubRequestConfig): Observable<PageData<MpItemVersionView>> {
if (query.options.tbVersion == null) {
query.options.tbVersion = tbVersionToInt(env.tbVersion);
}
if (query.options.peOnly == null) {
query.options.peOnly = false;
}
this.applyPlatformFilters(query.options);
return this.http.get<PageData<MpItemVersionView>>(
`${this.baseUrl}/api/versions/published${query.toQuery()}`,
{ params: this.buildParams(config) }
);
}
/**
* The sectioned answer: one section per item type, in the server's order, each capped by the
* server and carrying the total behind that cap. Its own endpoint, which takes no page, page
* size or sort direction.
*/
public getPublishedVersionsGrouped(query: MpItemVersionGroupedQuery,
config?: IotHubRequestConfig): Observable<MpItemVersionSection[]> {
this.applyPlatformFilters(query.options);
return this.http.get<MpItemVersionSection[]>(
`${this.baseUrl}/api/versions/published/grouped${query.toQuery()}`,
{ params: this.buildParams(config) }
);
}
/**
* What this platform can install, filled in for a caller that did not say: items built for a
* newer ThingsBoard, and PE-only items on a CE instance, cannot be installed from here.
*/
private applyPlatformFilters(options: MpItemVersionQueryOptions): void {
if (options.tbVersion == null) {
options.tbVersion = tbVersionToInt(env.tbVersion);
}
if (options.peOnly == null) {
options.peOnly = false;
}
}
public getFilterInfo(itemType: ItemType, config?: IotHubRequestConfig): Observable<ItemTypeFilterInfo> {
const url = `${this.baseUrl}/api/item-listing/filterInfo/${itemType}`
+ `?peOnly=false&tbVersion=${tbVersionToInt(env.tbVersion)}`;

23
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts

@ -21,7 +21,12 @@ import { ItemSizeStrategy } from '@shared/components/grid/scroll-grid.component'
import { coerceBoolean } from '@shared/decorators/coercion';
import { TranslateService } from '@ngx-translate/core';
import { MpItemVersionQuery, MpItemVersionView, widgetTypeTranslations } from '@shared/models/iot-hub/iot-hub-version.models';
import { ItemType, FilterParamInfo, WidgetCategory } from '@shared/models/iot-hub/iot-hub-item.models';
import {
FilterParamInfo,
IOT_HUB_SORT_OPTIONS,
ItemType,
WidgetCategory
} from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service';
@ -38,12 +43,6 @@ type selectWidgetMode = 'installed' | 'iotHub';
type installedSubMode = 'default' | 'allWidgets';
type iotHubSubMode = 'default' | 'allWidgets' | 'installed' | 'category';
interface WidgetSelectSortOption {
value: string;
label: string;
direction: Direction;
}
const LOGICAL_ALL_WIDGETS = '__logical_all_widgets__';
const LOGICAL_INSTALLED_FROM_IOT_HUB = '__logical_installed_from_iot_hub__';
@ -88,11 +87,11 @@ export class DashboardWidgetSelectComponent {
includeDeprecated = false;
searchFocused = false;
iotHubSortOptions: WidgetSelectSortOption[] = [
{ value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
{ value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
{ value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
];
/**
* scadaFirst is unaffected by the sort: the backend prepends it ahead of the caller's key AND
* ahead of relevance, so a SCADA context still lists SCADA widgets first.
*/
readonly iotHubSortOptions = IOT_HUB_SORT_OPTIONS;
iotHubSelectedSortIndex = 0;
@Input()

36
ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss

@ -119,3 +119,39 @@
pointer-events: none;
}
}
// Scroll area that shows its thumb only while the container is hovered — the filter panels'
// own treatment, kept here so the two that use it cannot drift apart.
//
// Not the app-wide one: theme.scss keeps its thumb permanently visible. Whether these panels
// should do the same, and whether to add the standardised scrollbar-width / scrollbar-color
// that Firefox reads, is a question for the IoT Hub filter UI as a whole rather than for one
// panel; iot-hub-browse and dashboard-widget-select carry copies of this same treatment.
@mixin tb-iot-hub-hover-scrollbar {
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background-color: transparent;
}
&::-webkit-scrollbar-thumb {
background-color: transparent;
border-radius: 3px;
}
&:hover {
&::-webkit-scrollbar-track {
background-color: rgba(0, 0, 0, 0.04);
}
&::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.2);
&:hover {
background-color: rgba(0, 0, 0, 0.35);
}
}
}
}

21
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts

@ -4,10 +4,15 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, OnDe
import { Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { PageLink } from '@shared/models/page/page-link';
import { Direction, SortOrder } from '@shared/models/page/sort-order';
import { SortOrder } from '@shared/models/page/sort-order';
import { PageData } from '@shared/models/page/page-data';
import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import { ItemType, FilterParamInfo, CREATOR_VISIBLE_ITEM_TYPES } from '@shared/models/iot-hub/iot-hub-item.models';
import {
CREATOR_VISIBLE_ITEM_TYPES,
FilterParamInfo,
IOT_HUB_SORT_OPTIONS,
ItemType
} from '@shared/models/iot-hub/iot-hub-item.models';
import { widgetTypeTranslations, cfTypeTranslations, ruleChainTypeTranslations } from '@shared/models/iot-hub/iot-hub-version.models';
import { IotHubInstalledItem, DeviceInstalledItemDescriptor } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
@ -16,12 +21,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service';
import { filterIotHubItemsBySearch, groupIotHubFilterItems, IotHubFilterGroup } from '@home/components/iot-hub/iot-hub-utils';
interface SortOption {
value: string;
label: string;
direction: Direction;
}
@Component({
selector: 'tb-iot-hub-browse',
standalone: false,
@ -126,11 +125,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
activeHardwareTypes = new Set<string>();
activeVendors = new Set<string>();
sortOptions: SortOption[] = [
{ value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
{ value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
{ value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
];
readonly sortOptions = IOT_HUB_SORT_OPTIONS;
typeTabs: { type: ItemType; label: string }[] = CREATOR_VISIBLE_ITEM_TYPES.map(t => ({
type: t,

3
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts

@ -14,6 +14,7 @@ import { TbIotHubUnpublishedWarningDialogComponent } from './iot-hub-unpublished
import { TbDeviceInstallDialogComponent } from './device-install-dialog/device-install-dialog.component';
import { InstallFormRendererComponent } from './device-install-dialog/install-form-renderer/install-form-renderer.component';
import { TbIotHubSearchComponent } from './iot-hub-search.component';
import { TbIotHubFacetListComponent } from './iot-hub-facet-list.component';
import { TbIotHubInstalledItemsTableComponent } from './iot-hub-installed-items-table.component';
import { TbIotHubInstalledItemsDialogComponent } from './iot-hub-installed-items-dialog.component';
import { TbIotHubSelectCfEntityDialogComponent } from './iot-hub-select-cf-entity-dialog.component';
@ -37,6 +38,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link
TbIotHubUnpublishedWarningDialogComponent,
TbDeviceInstallDialogComponent,
TbIotHubSearchComponent,
TbIotHubFacetListComponent,
TbIotHubInstalledItemsTableComponent,
TbIotHubInstalledItemsDialogComponent,
TbIotHubSelectCfEntityDialogComponent,
@ -66,6 +68,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link
TbIotHubUnpublishedWarningDialogComponent,
TbDeviceInstallDialogComponent,
TbIotHubSearchComponent,
TbIotHubFacetListComponent,
TbIotHubInstalledItemsTableComponent,
TbIotHubInstalledItemsDialogComponent,
TbIotHubSelectCfEntityDialogComponent,

31
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.html

@ -0,0 +1,31 @@
<!--
SPDX-FileCopyrightText: Copyright The Thingsboard Authors
SPDX-License-Identifier: Apache-2.0
-->
<mat-expansion-panel [expanded]="expanded" class="tb-iot-hub-facet-panel">
<mat-expansion-panel-header>
<mat-panel-title>{{ label | translate }}</mat-panel-title>
</mat-expansion-panel-header>
@if (searchable) {
<div class="tb-iot-hub-facet-search">
<mat-icon>search</mat-icon>
<input [placeholder]="'iot-hub.search' | translate" [(ngModel)]="search">
@if (search) {
<button mat-icon-button class="tb-iot-hub-facet-search-clear" (click)="search = ''">
<mat-icon>close</mat-icon>
</button>
}
</div>
}
<div class="tb-iot-hub-facet-items" [class.scrollable]="scrollable">
@for (option of visibleOptions; track option.key) {
<mat-checkbox [checked]="isSelected(option.key)" (change)="onToggle(option.key)">
{{ labelFor(option.key) }}
</mat-checkbox>
}
</div>
</mat-expansion-panel>

67
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss

@ -0,0 +1,67 @@
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0
@import "./iot-hub-common";
// Values follow the type pages' filter panel so the two read as one control, minus its deep
// left indent: that indent exists because the panel there sits in a wider rail.
.tb-iot-hub-facet-panel.mat-expansion-panel {
box-shadow: none;
border-radius: 0;
background: transparent;
// Indented from the column's edges, because the rules between facets are not: they span the
// whole column, as they do on the type pages. The host sets --tb-facet-indent to whatever
// puts this text on the page's own left margin.
.mat-expansion-panel-header {
padding: 8px 16px 8px var(--tb-facet-indent, 16px);
height: 48px;
min-height: 48px;
}
::ng-deep .mat-expansion-panel-header-title {
font-size: 14px;
font-weight: 500;
color: rgba(0, 0, 0, 0.87);
}
::ng-deep .mat-expansion-panel-body {
padding: 0 8px 8px var(--tb-facet-indent, 16px);
}
mat-checkbox {
display: block;
overflow: hidden;
&:hover {
background: rgba(0, 0, 0, 0.04);
}
}
.tb-iot-hub-facet-items {
// Uncapped until the list is long enough to need it, so a three-option facet does not
// reserve a scroll area it never uses.
&.scrollable {
max-height: 280px;
overflow-y: auto;
}
@include tb-iot-hub-hover-scrollbar;
}
.tb-iot-hub-facet-search {
@include tb-iot-hub-search-container;
margin: 4px 8px 8px 0;
mat-icon {
@include tb-iot-hub-search-icon(rgba(0, 0, 0, 0.54));
}
input {
@include tb-iot-hub-search-input-text(0.2px);
}
.tb-iot-hub-facet-search-clear.mat-mdc-icon-button {
@include tb-iot-hub-search-clear;
}
}
}

80
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.ts

@ -0,0 +1,80 @@
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FilterParamInfo } from '@shared/models/iot-hub/iot-hub-item.models';
/**
* One checkbox facet of a filter panel: a title, the options with their item counts, and the
* set of keys currently selected. Presentational only - it owns no filter state and issues no
* request; the host decides what a toggle means.
*
* Written for the cross-type search page, which needs three plain facets (item type, category,
* use case). The type pages keep their own panel in TbIotHubBrowseComponent: theirs carries
* facets this one has no notion of - grouped connectivity, vendor lists, per-type subtypes -
* so folding the two together would mean parameterising that panel for a shape it never uses.
*/
@Component({
selector: 'tb-iot-hub-facet-list',
standalone: false,
templateUrl: './iot-hub-facet-list.component.html',
styleUrls: ['./iot-hub-facet-list.component.scss']
})
export class TbIotHubFacetListComponent {
/** Translation key for the facet's heading. */
@Input() label: string;
@Input() options: FilterParamInfo[] = [];
/** Keys the host currently has selected. Read, never written - the host hands over a new Set
* on every toggle rather than mutating this one. */
@Input() selected = new Set<string>();
/**
* Turns an option key into what the user reads. Defaults to the key, which is already the
* display value for categories and use cases; item types come through as enum names and need
* their translated plural.
*/
@Input() labelFor: (key: string) => string = (key) => key;
/**
* Open on first render. The host decides: a short, always-relevant facet earns the space it
* takes, a long one costs the reader the facets below it — on the search page all three
* headings fit above the fold only because two of them start closed.
*/
@Input() expanded = true;
@Output() toggled = new EventEmitter<string>();
/**
* Above this many options the facet gets its own search box and a scroll cap. Matches the
* threshold the type pages' panel uses, so the two feel the same at the same list lengths.
*/
private static readonly SEARCH_THRESHOLD = 8;
search = '';
get searchable(): boolean {
return this.options.length > TbIotHubFacetListComponent.SEARCH_THRESHOLD;
}
get visibleOptions(): FilterParamInfo[] {
const needle = this.search.trim().toLowerCase();
if (!needle) {
return this.options;
}
return this.options.filter(o => this.labelFor(o.key).toLowerCase().includes(needle));
}
get scrollable(): boolean {
return this.visibleOptions.length > TbIotHubFacetListComponent.SEARCH_THRESHOLD;
}
isSelected(key: string): boolean {
return this.selected.has(key);
}
onToggle(key: string): void {
this.toggled.emit(key);
}
}

4
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html

@ -78,7 +78,9 @@
<img [src]="previewUrl" alt="" class="tb-iot-hub-preview-image">
} @else {
<div class="tb-iot-hub-preview-placeholder">
<tb-icon>{{ getPlaceholderIcon() }}</tb-icon>
<!-- The item's own colour, where it has one: it is what makes a calculated field read
as a calculated field once the compact card's coloured square is not there. -->
<tb-icon [style.color]="item.color || null">{{ getPlaceholderIcon() }}</tb-icon>
</div>
}
</div>

13
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts

@ -23,6 +23,16 @@ export class TbIotHubItemCardComponent {
@Input() showTypeChip = true;
@Input() showSubtype = false;
@Input() mode: 'default' | 'add' = 'default';
/**
* `auto` lets the item's type choose, which is what a single-type grid wants: calculated
* fields, alarm rules and rule chains have nothing to preview, so they get a compact row and
* the grid gives them wider cells.
*
* `preview` forces the tall card on every type. A grid that mixes types cannot widen its
* cells for some rows only, and a horizontal row squeezed into a cell sized for a preview
* truncates its own title and leaves the rest of the cell empty.
*/
@Input() layout: 'auto' | 'preview' = 'auto';
@Output() cardClick = new EventEmitter<MpItemVersionView>();
@Output() creatorClick = new EventEmitter<string>();
@Output() installClick = new EventEmitter<MpItemVersionView>();
@ -47,6 +57,9 @@ export class TbIotHubItemCardComponent {
}
isCompactLayout(): boolean {
if (this.layout === 'preview') {
return false;
}
return this.item.type === ItemType.CALCULATED_FIELD
|| this.item.type === ItemType.ALARM_RULE
|| this.item.type === ItemType.RULE_CHAIN;

164
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.html

@ -4,14 +4,26 @@
SPDX-License-Identifier: Apache-2.0
-->
<div class="mb-10 flex items-baseline gap-4 lt-md:mb-4">
<div class="tb-search-pad mb-10 flex items-baseline gap-4 lt-md:mb-4">
<ng-content></ng-content>
<span class="tb-search-results-count tb-search-results-count-mobile">
{{ 'iot-hub.results-count' | translate:{ count: totalElements } }}
</span>
</div>
<!-- Search + Sort row -->
<div class="flex items-center gap-4">
<!-- Hidden probe — we read its computed grid-template-columns to detect the current column count. -->
<div #cardGridProbe class="tb-search-card-grid tb-search-card-grid-probe" aria-hidden="true"></div>
<!-- Filter + Search + Sort row -->
<div class="tb-search-pad flex items-center gap-4">
@if (showFilters) {
<button mat-stroked-button class="tb-search-filter-btn" (click)="filtersOpen = !filtersOpen">
<mat-icon>filter_alt</mat-icon>
{{ 'iot-hub.filter' | translate }}
@if (activeFilterCount > 0) {
<span class="tb-search-filter-count">{{ activeFilterCount }}</span>
}
</button>
}
<div class="tb-search-input-field flex flex-1 items-center">
<input class="tb-search-input"
[placeholder]="searchPlaceholderKey | translate"
@ -43,7 +55,7 @@
</div>
<!-- Results count + Pagination (shown when results exist) -->
<div class="tb-search-pagination-row" [class.lt-md:!hidden]="totalElements === 0">
<div class="tb-search-pagination-row tb-search-pad" [class.lt-md:!hidden]="totalElements === 0">
<span class="tb-search-results-count">
{{ 'iot-hub.results-count' | translate:{ count: totalElements } }}
</span>
@ -76,62 +88,102 @@
<div class="tb-search-divider"></div>
<div class="relative min-h-0">
<div class="tb-results-container">
<!-- Error -->
@if (hasError) {
<div class="tb-search-empty flex flex-col items-center py-10">
<div class="tb-no-service-bg"></div>
<h3>{{ 'iot-hub.network-server-unavailable' | translate }}</h3>
<p>{{ 'iot-hub.network-server-unavailable-text' | translate }}</p>
<button mat-flat-button color="primary" (click)="retryLoadResults()">
{{ 'iot-hub.try-again' | translate }}
</button>
</div>
<!-- Facets, rendered once and projected into the sidebar or the drawer -->
<ng-template #facetPanel>
<div class="tb-search-facets">
@if (activeFilterCount > 0) {
<button mat-button color="primary" class="tb-search-facets-clear" (click)="clearFilters()">
{{ 'iot-hub.clear-filters' | translate }}
</button>
}
<!-- No results -->
@if (!hasError && totalElements === 0 && searchText?.trim()) {
<div class="tb-search-empty flex flex-col items-center py-10">
<div class="tb-no-data-bg"></div>
<h3>{{ 'iot-hub.no-items-found' | translate }}</h3>
<p>{{ 'iot-hub.try-adjusting-search' | translate }}</p>
</div>
<tb-iot-hub-facet-list label="iot-hub.item-type"
[options]="typeOptions"
[selected]="activeTypes"
[labelFor]="getTypeLabel"
(toggled)="onTypeToggle($event)">
</tb-iot-hub-facet-list>
@if (categoryOptions.length > 0) {
<!-- Closed by default: six item types are a short, fixed list worth showing outright,
while categories and use cases run to dozens and would push each other off screen. -->
<tb-iot-hub-facet-list label="iot-hub.category"
[expanded]="false"
[options]="categoryOptions"
[selected]="activeCategories"
(toggled)="onCategoryToggle($event)">
</tb-iot-hub-facet-list>
}
@if (useCaseOptions.length > 0) {
<tb-iot-hub-facet-list label="iot-hub.use-case"
[expanded]="false"
[options]="useCaseOptions"
[selected]="activeUseCases"
(toggled)="onUseCaseToggle($event)">
</tb-iot-hub-facet-list>
}
</div>
</ng-template>
<!-- Results grouped by type -->
@if (resultGroups.length > 0) {
<div class="tb-search-categories">
@for (group of resultGroups; track group.type) {
<div class="tb-search-section">
<!-- Section header -->
<button mat-button class="tb-search-section-header" (click)="navigateToType(group.type)">
{{ getTypeLabel(group.type) }}
<mat-icon>chevron_right</mat-icon>
</button>
<!-- Card grid -->
<div class="tb-search-card-grid" [class.tb-search-card-grid-compact]="isCompactType(group.type)">
@for (item of group.items; track item.id) {
<tb-iot-hub-item-card
[item]="item"
[installedItem]="getInstalledItem(item)"
[installedItemsCount]="getInstalledItemsCount(item)"
[showTypeChip]="false"
[showSubtype]="false"
[showCreator]="showCreator"
(cardClick)="openItemDetail($event)"
(creatorClick)="navigateToCreator($event)"
(installClick)="installItem($event)"
(updateClick)="updateItem($event)"
(deleteClick)="deleteInstalledItem($event)">
</tb-iot-hub-item-card>
}
</div>
</div>
}
</div>
<div class="relative min-h-0 flex-1">
<!-- Plain flex row, deliberately not a mat-drawer-container: that component owns its own
height and overflow, and a facet list taller than the card grid escaped its box and
painted over the page behind it. Below lt-lg the same panel becomes a block above the
results, opened by the Filter button. -->
<div class="tb-search-layout">
@if (showFilters) {
<aside class="tb-search-facets-desktop" [class.opened]="filtersOpen">
<div class="tb-search-facets-header flex items-center justify-between">
<span>{{ 'iot-hub.filter' | translate }}</span>
<button mat-icon-button (click)="filtersOpen = false">
<mat-icon>close</mat-icon>
</button>
</div>
<ng-container *ngTemplateOutlet="facetPanel"></ng-container>
</aside>
}
<div class="tb-results-container">
<!-- Error -->
@if (hasError) {
<div class="tb-search-empty flex flex-col items-center py-10">
<div class="tb-no-service-bg"></div>
<h3>{{ 'iot-hub.network-server-unavailable' | translate }}</h3>
<p>{{ 'iot-hub.network-server-unavailable-text' | translate }}</p>
<button mat-flat-button color="primary" (click)="retryLoadResults()">
{{ 'iot-hub.try-again' | translate }}
</button>
</div>
}
<!-- No results -->
@if (!hasError && totalElements === 0 && searchText?.trim()) {
<div class="tb-search-empty flex flex-col items-center py-10">
<div class="tb-no-data-bg"></div>
<h3>{{ 'iot-hub.no-items-found' | translate }}</h3>
<p>{{ 'iot-hub.try-adjusting-search' | translate }}</p>
</div>
}
<!-- Results -->
@if (results.length > 0) {
<div class="tb-search-card-grid">
@for (item of results; track item.id) {
<tb-iot-hub-item-card
layout="preview"
[item]="item"
[installedItem]="getInstalledItem(item)"
[installedItemsCount]="getInstalledItemsCount(item)"
[showCreator]="showCreator"
(cardClick)="openItemDetail($event)"
(creatorClick)="navigateToCreator($event)"
(installClick)="installItem($event)"
(updateClick)="updateItem($event)"
(deleteClick)="deleteInstalledItem($event)">
</tb-iot-hub-item-card>
}
</div>
}
</div>
</div>
<!-- Loading -->

171
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.scss

@ -8,6 +8,14 @@
flex-direction: column;
}
// The page hands this component the card's full width and its own side padding as a variable.
// Rows that are ordinary content pad themselves back in; the divider and the filter rail are
// the two things that are supposed to reach the edge, so they do not.
.tb-search-pad {
padding-left: var(--tb-search-side-pad, 0px);
padding-right: var(--tb-search-side-pad, 0px);
}
.tb-search-results-count-mobile {
display: none;
margin-left: auto;
@ -143,69 +151,121 @@
overflow: auto;
}
// Categories / sections
.tb-search-categories {
display: flex;
flex-direction: column;
gap: 48px;
// Card grid
.tb-search-card-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 20px;
// Probe: zero-height element used only to read the computed column count.
// Keeps display: grid and non-zero width so grid-template-columns resolves.
&.tb-search-card-grid-probe {
width: 100%;
height: 0;
gap: 0;
overflow: hidden;
visibility: hidden;
pointer-events: none;
}
}
// Section header
.tb-search-section-header {
font-size: 18px;
font-weight: 500;
line-height: 24px;
color: rgba(0, 0, 0, 0.87);
padding: 0;
margin-bottom: 12px;
// Filter button — the drawer's trigger, and where the active count is shown
.tb-search-filter-btn {
flex-shrink: 0;
}
.tb-search-filter-count {
margin-left: 6px;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 9px;
background: rgba(0, 0, 0, 0.08);
font-size: 12px;
line-height: 18px;
font-variant-numeric: tabular-nums;
}
mat-icon {
font-size: 24px;
width: 24px;
height: 24px;
// Content: facet sidebar beside the grid
// The page gives this component the viewport's remaining height and expects its body to scroll
// inside, not to grow past the white card. So the row takes that height and BOTH columns scroll
// themselves — the grid as it always did, the facets likewise. A facet list can then be any
// length at all without reaching the page behind it.
.tb-search-layout {
display: flex;
gap: 24px;
height: 100%;
min-height: 0;
.tb-results-container {
flex: 1;
min-width: 0;
// Only on the right: the gap to the rail already separates it on the left.
padding-right: var(--tb-search-side-pad, 0px);
}
}
// Card grid
.tb-search-card-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 20px;
.tb-search-facets-desktop {
width: 232px;
flex-shrink: 0;
border-right: 1px solid rgba(0, 0, 0, 0.12);
&.tb-search-card-grid-compact {
grid-template-columns: repeat(3, 1fr);
// The component is already full-bleed, so this column starts at the card's edge with no
// margin of its own and every rule drawn across it reaches that edge. The indent goes INSIDE
// each facet — padding here would inset the rules too — and matches the page's own margin, so
// the words line up with the heading above them.
--tb-facet-indent: var(--tb-search-side-pad, 16px);
align-self: stretch;
height: 100%;
overflow-y: auto;
padding-top: 20px;
@include tb-iot-hub-hover-scrollbar;
}
// The close button and heading belong to the narrow layout only.
.tb-search-facets-header {
display: none;
height: 48px;
font-size: 16px;
font-weight: 500;
}
.tb-search-facets {
display: flex;
flex-direction: column;
padding-bottom: 24px;
// The type pages put a rule between filter sections. No gap and no padding around it: the
// rule sits flush between two sections, edge to edge, rather than floating inside a gap.
tb-iot-hub-facet-list + tb-iot-hub-facet-list {
border-top: 1px solid rgba(0, 0, 0, 0.12);
}
}
.tb-search-facets-clear {
align-self: flex-start;
margin-left: calc(var(--tb-facet-indent, 16px) - 16px);
}
// Responsive
@media #{$mat-gt-xxl} {
.tb-search-card-grid {
grid-template-columns: repeat(6, 1fr);
&.tb-search-card-grid-compact {
grid-template-columns: repeat(4, 1fr);
}
}
}
@media #{$mat-lt-xl} {
.tb-search-card-grid {
grid-template-columns: repeat(4, 1fr);
&.tb-search-card-grid-compact {
grid-template-columns: repeat(3, 1fr);
}
}
}
@media #{$mat-lt-xmd} {
.tb-search-card-grid {
grid-template-columns: repeat(3, 1fr);
&.tb-search-card-grid-compact {
grid-template-columns: repeat(2, 1fr);
}
}
}
@ -228,10 +288,6 @@
.tb-search-card-grid {
grid-template-columns: repeat(2, 1fr);
&.tb-search-card-grid-compact {
grid-template-columns: repeat(1, 1fr);
}
}
}
@ -268,3 +324,38 @@
margin-left: 0;
}
}
// The sidebar costs a whole card column, so below this width it stops being a column: the
// panel collapses, and the Filter button opens it as a block above the results.
@media #{$mat-lt-lg} {
.tb-search-layout {
flex-direction: column;
}
.tb-search-facets-desktop {
display: none;
// As a block above the results it is ordinary content, not a rail, so it lines up with
// the rows above it rather than with the card's edge.
width: 100%;
height: auto;
max-height: 60vh;
border-right: none;
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
padding-right: 0;
&.opened {
display: block;
}
}
.tb-search-facets-header {
display: flex;
}
}
// Wide enough for the sidebar, so the button that opens the block has nothing to open.
@media #{$mat-gt-md} {
.tb-search-filter-btn {
display: none;
}
}

294
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-search.component.ts

@ -1,33 +1,30 @@
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter, ViewChild, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { forkJoin, Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { forkJoin, of, Subject, Subscription } from 'rxjs';
import { catchError, debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { PageLink } from '@shared/models/page/page-link';
import { Direction, SortOrder } from '@shared/models/page/sort-order';
import { SortOrder } from '@shared/models/page/sort-order';
import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import { ItemType, itemTypeTranslations } from '@shared/models/iot-hub/iot-hub-item.models';
import {
CROSS_TYPE_ITEM_TYPES,
FilterParamInfo,
IOT_HUB_SORT_OPTIONS,
ItemType,
itemTypeTranslations
} from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { IotHubActionsService } from './iot-hub-actions.service';
interface SearchResultGroup {
type: ItemType;
items: MpItemVersionView[];
}
interface SortOption {
value: string;
label: string;
direction: Direction;
}
const TYPE_ORDER: ItemType[] = [
ItemType.DEVICE, ItemType.SOLUTION_TEMPLATE, ItemType.WIDGET,
ItemType.CALCULATED_FIELD, ItemType.ALARM_RULE, ItemType.RULE_CHAIN
];
/**
* Rows a page holds, as a multiple of the column count, so a page always ends on a complete row.
* The floor keeps a one- or two-column phone layout from falling to three cards a page.
*/
const ROWS_PER_PAGE = 3;
const MIN_PAGE_SIZE = 12;
@Component({
selector: 'tb-iot-hub-search',
@ -37,32 +34,54 @@ const TYPE_ORDER: ItemType[] = [
})
export class TbIotHubSearchComponent implements OnInit, OnDestroy {
readonly ItemType = ItemType;
@Input() searchText = '';
@Input() creatorId: string;
@Input() showCreator = true;
/**
* Render the filter panel. The search page does; the creator profile does not - it is already
* scoped to one creator, and the site's profile has no panel either.
*/
@Input() showFilters = true;
@Output() searchTextChange = new EventEmitter<string>();
get searchPlaceholderKey(): string {
return this.creatorId ? 'iot-hub.search-published-items' : 'iot-hub.search';
}
resultGroups: SearchResultGroup[] = [];
results: MpItemVersionView[] = [];
totalElements = 0;
isLoading = false;
hasError = false;
private retryTimer: any = null;
pageSize = 15;
pageIndex = 0;
pageSizeOptions = [15, 30, 60];
sortOptions: SortOption[] = [
{ value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
{ value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
{ value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
];
/**
* Read from a hidden probe that carries the real grid's classes, not guessed from breakpoints:
* the grid's column count is a CSS fact, and duplicating its media queries in TypeScript is a
* second source of truth that drifts the first time someone edits the stylesheet.
*/
@ViewChild('cardGridProbe', { static: true }) cardGridProbe!: ElementRef<HTMLElement>;
cols = 5;
pageSize = MIN_PAGE_SIZE;
get pageSizeOptions(): number[] {
const base = Math.max(MIN_PAGE_SIZE, this.cols * ROWS_PER_PAGE);
return [base, base * 2, base * 4];
}
// Filter panel state. Empty sets mean "no filter", which is what the query object expects.
/** Narrow widths only: the facet panel is a block above the results, not a sidebar. */
filtersOpen = false;
typeOptions: FilterParamInfo[] = [];
categoryOptions: FilterParamInfo[] = [];
useCaseOptions: FilterParamInfo[] = [];
activeTypes = new Set<string>();
activeCategories = new Set<string>();
activeUseCases = new Set<string>();
readonly sortOptions = IOT_HUB_SORT_OPTIONS;
selectedSortIndex = 0;
installedWidgets: IotHubInstalledItem[] = [];
@ -83,6 +102,11 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
) {}
ngOnInit(): void {
this.measureCols();
this.observeGridWidth();
if (this.showFilters) {
this.loadFilterInfo();
}
this.loadInstalledItems();
this.searchSubscription = this.searchSubject.pipe(
debounceTime(300),
@ -96,6 +120,161 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
this.searchSubscription?.unsubscribe();
this.resizeSubscription?.unsubscribe();
this.resizeObserver?.disconnect();
}
// Filters
getTypeLabel = (key: string): string => {
const translationKey = itemTypeTranslations.get(key as ItemType);
return translationKey ? this.translate.instant(translationKey + '-plural') : key;
};
onTypeToggle(key: string): void {
this.activeTypes = this.toggled(this.activeTypes, key);
this.reloadFromFirstPage();
}
onCategoryToggle(key: string): void {
this.activeCategories = this.toggled(this.activeCategories, key);
this.reloadFromFirstPage();
}
onUseCaseToggle(key: string): void {
this.activeUseCases = this.toggled(this.activeUseCases, key);
this.reloadFromFirstPage();
}
get activeFilterCount(): number {
return this.activeTypes.size + this.activeCategories.size + this.activeUseCases.size;
}
clearFilters(): void {
if (this.activeFilterCount === 0) {
return;
}
this.activeTypes = new Set<string>();
this.activeCategories = new Set<string>();
this.activeUseCases = new Set<string>();
this.reloadFromFirstPage();
}
/**
* Returns a new Set rather than mutating the one passed in: TbIotHubFacetListComponent holds
* this very instance as an @Input, and a mutation it cannot see is a trap for the first person
* to put that component on OnPush.
*/
private toggled(set: Set<string>, key: string): Set<string> {
const next = new Set(set);
if (!next.delete(key)) {
next.add(key);
}
return next;
}
private reloadFromFirstPage(): void {
this.pageIndex = 0;
this.loadResults();
}
/**
* There is no catalogue-wide filterInfo endpoint - it answers per item type - so the six
* answers are merged here, the way the site merges the same six at build time. Counts are
* deliberately not rendered: filterInfo takes no text query, so beside a searched result they
* would be the whole catalogue's numbers pretending to describe this answer.
*
* Each request carries its own catchError so one type's failure costs that type's categories
* and use cases, not the panel: a bare forkJoin is all-or-nothing, and the Type facet needs no
* server data at all.
*/
private loadFilterInfo(): void {
const config = { ignoreLoading: true, ignoreErrors: true };
forkJoin(
CROSS_TYPE_ITEM_TYPES.map(type =>
this.iotHubApiService.getFilterInfo(type, config).pipe(catchError(() => of(null)))
)
).subscribe({
next: infos => {
// Every item type is offered, not only the ones filterInfo reports facets for: the
// endpoint describes a type's categories and vendors, never how many items it has, and
// a type whose items carry no categories would vanish from its own facet.
this.typeOptions = CROSS_TYPE_ITEM_TYPES.map(type => ({
key: type as string,
totalItems: 0,
totalInstallCount: 0
}));
this.categoryOptions = this.mergeFacet(infos.map(i => i?.categories));
this.useCaseOptions = this.mergeFacet(infos.map(i => i?.useCases));
}
});
}
private mergeFacet(lists: (FilterParamInfo[] | undefined)[]): FilterParamInfo[] {
const byKey = new Map<string, FilterParamInfo>();
for (const list of lists) {
for (const option of list || []) {
const seen = byKey.get(option.key);
if (seen) {
seen.totalItems += option.totalItems;
seen.totalInstallCount += option.totalInstallCount;
} else {
byKey.set(option.key, { ...option });
}
}
}
return [...byKey.values()]
.filter(o => o.totalItems > 0)
.sort((a, b) => a.key.localeCompare(b.key));
}
// Column count -> page size
private resizeObserver?: ResizeObserver;
private resizeSubject = new Subject<void>();
private resizeSubscription?: Subscription;
private observeGridWidth(): void {
const el = this.cardGridProbe?.nativeElement;
if (!el || typeof ResizeObserver === 'undefined') {
return;
}
this.resizeSubscription = this.resizeSubject.pipe(debounceTime(150)).subscribe(() => {
const before = this.pageSizeOptions[0];
this.measureCols();
if (this.pageSizeOptions[0] === before) {
return;
}
// Keep the user roughly where they were in the list rather than on the same page number:
// page 4 of 12-card pages is a different place from page 4 of 18-card pages.
const firstItem = this.pageIndex * this.pageSize;
this.pageSize = this.pageSizeOptions[0];
this.pageIndex = Math.floor(firstItem / this.pageSize);
this.loadResults();
});
this.resizeObserver = new ResizeObserver(() => this.resizeSubject.next());
this.resizeObserver.observe(el);
}
private measureCols(): void {
const el = this.cardGridProbe?.nativeElement;
if (!el) {
return;
}
// Force layout so grid-template-columns resolves to pixel tracks rather than `repeat(...)`.
void el.offsetWidth;
const tracks = getComputedStyle(el).gridTemplateColumns;
if (!tracks || tracks === 'none') {
this.cols = 1;
} else if (tracks.startsWith('repeat(')) {
const match = tracks.match(/^repeat\(\s*(\d+)\s*,/);
this.cols = match ? parseInt(match[1], 10) : 1;
} else {
this.cols = Math.max(1, tracks.trim().split(/\s+/).filter(t => t.length > 0).length);
}
if (!this.pageSizeOptions.includes(this.pageSize)) {
this.pageSize = this.pageSizeOptions[0];
}
}
onSearchInput(): void {
@ -158,35 +337,6 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
this.loadResults();
}
// Type helpers
isCompactType(type: ItemType): boolean {
return type === ItemType.CALCULATED_FIELD
|| type === ItemType.ALARM_RULE
|| type === ItemType.RULE_CHAIN;
}
getTypeLabel(type: ItemType): string {
const key = itemTypeTranslations.get(type);
return key ? this.translate.instant(key + '-plural') : type;
}
getTypeRoute(type: ItemType): string {
switch (type) {
case ItemType.WIDGET: return 'widgets';
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';
}
}
navigateToType(type: ItemType): void {
const search = this.searchText?.trim() || undefined;
void this.router.navigate(['/iot-hub', this.getTypeRoute(type)], { queryParams: { search } });
}
// Installed items
getInstalledItem(item: MpItemVersionView): IotHubInstalledItem | undefined {
switch (item.type) {
@ -281,7 +431,7 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
error: () => {
this.isLoading = false;
this.hasError = true;
this.resultGroups = [];
this.results = [];
this.totalElements = 0;
}
});
@ -291,30 +441,22 @@ export class TbIotHubSearchComponent implements OnInit, OnDestroy {
const sort = this.sortOptions[this.selectedSortIndex];
const sortOrder: SortOrder = { property: sort.value, direction: sort.direction };
const pageLink = new PageLink(this.pageSize, this.pageIndex, text.trim() || null, sortOrder);
const query = new MpItemVersionQuery(pageLink, { creatorId: this.creatorId || undefined });
const query = new MpItemVersionQuery(pageLink, {
creatorId: this.creatorId || undefined,
// Empty sets are left off the query entirely - an empty array would narrow to nothing.
types: this.activeTypes.size ? [...this.activeTypes] : undefined,
categories: this.activeCategories.size ? [...this.activeCategories] : undefined,
useCases: this.activeUseCases.size ? [...this.activeUseCases] : undefined
});
return this.iotHubApiService.getPublishedVersions(query, { ignoreLoading: true, ignoreErrors: true });
}
private applyResults(data: MpItemVersionView[], totalElements: number): void {
this.totalElements = totalElements;
this.resultGroups = this.groupResults(data);
this.results = data;
this.isLoading = false;
}
private groupResults(items: MpItemVersionView[]): SearchResultGroup[] {
const groupMap = new Map<ItemType, MpItemVersionView[]>();
for (const item of items) {
let list = groupMap.get(item.type);
if (!list) {
list = [];
groupMap.set(item.type, list);
}
list.push(item);
}
return TYPE_ORDER
.filter(type => groupMap.has(type))
.map(type => ({ type, items: groupMap.get(type) }));
}
private loadInstalledItems(): void {
const config = { ignoreLoading: true };

5
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-creator-profile.component.html

@ -96,7 +96,10 @@
<div class="tb-creator-divider"></div>
<!-- Right: published items -->
<tb-iot-hub-search class="tb-creator-items" [creatorId]="creatorId" [showCreator]="false">
<!-- No filter panel here: the list is already scoped to one creator, and the site's
profile has none either. -->
<tb-iot-hub-search class="tb-creator-items" [creatorId]="creatorId" [showCreator]="false"
[showFilters]="false">
<h3 class="tb-creator-items-heading">
{{ 'iot-hub.published-items' | translate }} ({{ creator.publishedCount }})
</h3>

73
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html

@ -72,7 +72,7 @@
<mat-option [disabled]="true" class="tb-search-popup-loading">
<mat-spinner diameter="24"></mat-spinner>
</mat-option>
} @else if (searchResults.length === 0 && searchLoaded) {
} @else if (searchResultGroups.length === 0 && searchLoaded) {
<mat-option [disabled]="true" class="tb-search-popup-no-results">
<div class="tb-search-popup-no-results-content">
<mat-icon>search_off</mat-icon>
@ -85,38 +85,51 @@
</mat-option>
} @else {
@for (group of searchResultGroups; track group.type) {
<mat-optgroup [label]="getSearchGroupLabel(group.type)">
@for (item of group.items; track item.id) {
<mat-option [value]="searchText" (click)="openItemDetail(item)">
@if (isCompactType(item.type)) {
<div class="tb-search-popup-icon-square" [style.background]="item.color || '#048ad3'">
<tb-icon class="tb-search-popup-icon-inner">{{ getCompactIcon(item) }}</tb-icon>
</div>
} @else {
<div class="tb-search-popup-thumbnail">
@if (getItemImage(item); as imgUrl) {
<img [src]="imgUrl" alt="">
} @else {
<tb-icon class="tb-search-popup-thumb-placeholder">{{ getItemTypeIcon(item.type) }}</tb-icon>
}
</div>
}
<div class="tb-search-popup-text">
<span class="tb-search-popup-name">{{ item.name }}</span>
<span class="tb-search-popup-author">
<mat-icon>person</mat-icon>
{{ item.creatorDisplayName }}
</span>
</div>
</mat-option>
<mat-option class="tb-search-popup-group-header" [value]="searchText"
(onSelectionChange)="rowSelectedByUser($event) && navigateToSection(group.type)">
<span class="tb-search-popup-group-label">{{ getSearchGroupLabel(group.type) }}</span>
@if (group.remaining > 0) {
<span class="tb-search-popup-group-more">
{{ 'iot-hub.section-more' | translate:{ count: group.remaining } }}
<mat-icon>chevron_right</mat-icon>
</span>
}
</mat-optgroup>
</mat-option>
@for (item of group.items; track item.id) {
<mat-option class="tb-search-popup-item" [value]="searchText"
(onSelectionChange)="rowSelectedByUser($event) && openItemDetail(item)">
@if (isCompactType(item.type)) {
<div class="tb-search-popup-icon-square" [style.background]="item.color || '#048ad3'">
<tb-icon class="tb-search-popup-icon-inner">{{ getCompactIcon(item) }}</tb-icon>
</div>
} @else {
<div class="tb-search-popup-thumbnail">
@if (getItemImage(item); as imgUrl) {
<img [src]="imgUrl" alt="">
} @else {
<tb-icon class="tb-search-popup-thumb-placeholder">{{ getItemTypeIcon(item.type) }}</tb-icon>
}
</div>
}
<div class="tb-search-popup-text">
<span class="tb-search-popup-name">{{ item.name }}</span>
<span class="tb-search-popup-author">
<mat-icon>person</mat-icon>
{{ item.creatorDisplayName }}
</span>
</div>
</mat-option>
}
}
}
<div class="tb-search-popup-footer" role="button" tabindex="0"
(click)="seeAllResults()" (keyup.enter)="seeAllResults()">
{{ 'iot-hub.see-all-results' | translate }}
</div>
<mat-option class="tb-search-popup-footer" [value]="searchText"
(onSelectionChange)="rowSelectedByUser($event) && seeAllResults()">
@if (searchText?.trim(); as query) {
{{ 'iot-hub.see-results-for' | translate:{ search: query } }}
} @else {
{{ 'iot-hub.see-all-results' | translate }}
}
</mat-option>
</mat-autocomplete>
</div>
</div>

101
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.scss

@ -220,52 +220,79 @@
0 114px 46px 0 rgba(0, 0, 0, 0.01),
0 178px 50px 0 rgba(0, 0, 0, 0);
// Section group — 12px gap between groups
.mat-mdc-optgroup + .mat-mdc-optgroup .mat-mdc-optgroup-label {
margin-top: 12px;
// Every row of the panel shares the flex line and the highlight; the boxes differ per kind
// below. Each kind is selected by its own class rather than by leaning on source order, since
// .mat-mdc-option.<kind> and .mat-mdc-option:not(...) tie on specificity.
.mat-mdc-option {
.mdc-list-item__primary-text {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
}
&:hover:not(.mdc-list-item--disabled),
&.mat-mdc-option-active:not(.mdc-list-item--disabled) {
background: rgba(0, 0, 0, 0.04);
}
.mat-icon, tb-icon {
margin-right: 0;
}
}
// Section title — Design: 14px Medium, 0.25 tracking, black-tertiary, 4px V / 16px H
.mat-mdc-optgroup .mat-mdc-optgroup-label {
// Section header — an option like every other row, not a button beside them, so the arrow keys
// reach it and a screen reader reads it in the list. It IS the way into the type page: title
// left, how much is not shown plus a chevron right. There is deliberately no per-section
// "see all" row under the items; six of those on one panel is what this variant avoids.
// Design: 14px Medium, 0.25 tracking, black-tertiary, 4px V / 16px H, 12px above each section.
.mat-mdc-option.tb-search-popup-group-header {
padding: 4px 16px;
min-height: 28px;
margin-top: 12px;
&:first-child {
margin-top: 0;
}
.mdc-list-item__primary-text {
justify-content: space-between;
}
}
.tb-search-popup-group-label {
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: 0.25px;
color: rgba(0, 0, 0, 0.54);
white-space: nowrap;
}
.mdc-list-item__primary-text {
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: 0.25px;
color: rgba(0, 0, 0, 0.54);
.tb-search-popup-group-more {
display: flex;
align-items: center;
gap: 2px;
flex-shrink: 0;
font-size: 12px;
font-weight: 500;
line-height: 16px;
letter-spacing: 0.25px;
color: $tb-primary-color;
.mat-icon {
width: 18px;
height: 18px;
font-size: 18px;
line-height: 18px;
}
}
// Item row — Design: 8px V / 16px H, 16px gap, centered
.mat-mdc-optgroup .mat-mdc-option:not(.mat-mdc-option-multiple) {
.mat-mdc-option.tb-search-popup-item {
padding: 8px 16px;
min-height: auto;
height: auto;
&:hover:not(.mdc-list-item--disabled),
&.mat-mdc-option-active:not(.mdc-list-item--disabled) {
background: rgba(0, 0, 0, 0.04);
}
.mat-icon, tb-icon {
margin-right: 0;
}
.mdc-list-item__primary-text {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
}
}
// Thumbnail — Design: 99px x 56px, 4px radius, 1px border, 4% bg
@ -370,6 +397,7 @@
.tb-search-popup-no-results {
pointer-events: none;
opacity: 1 !important;
padding: 8px 16px;
}
.tb-search-popup-no-results-content {
@ -391,26 +419,31 @@
}
// Footer — Design: 40px h, 8px V / 16px H, 1px top border, tb-primary text
.tb-search-popup-footer {
.mat-mdc-option.tb-search-popup-footer {
position: sticky;
bottom: 0;
z-index: 1;
border-top: 1px solid rgba(0, 0, 0, 0.12);
height: 40px;
min-height: 40px;
padding: 8px 16px;
display: flex;
align-items: center;
justify-content: flex-start;
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: 0.25px;
color: $tb-primary-color;
cursor: pointer;
background: white;
white-space: nowrap;
&:hover {
.mdc-list-item__primary-text {
justify-content: flex-start;
font: inherit;
letter-spacing: inherit;
color: inherit;
}
&:hover:not(.mdc-list-item--disabled),
&.mat-mdc-option-active:not(.mdc-list-item--disabled) {
background: #f5f5f5;
}
}

130
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts

@ -3,14 +3,26 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
import { Router } from '@angular/router';
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
import { MatOptionSelectionChange } from '@angular/material/core';
import { BreakpointObserver } from '@angular/cdk/layout';
import { forkJoin, Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
import { forkJoin, of, Subject, Subscription } from 'rxjs';
import { catchError, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
import { MediaBreakpoints } from '@shared/models/constants';
import { PageLink } from '@shared/models/page/page-link';
import { Direction, SortOrder } from '@shared/models/page/sort-order';
import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import { getItemTypeIcon, ItemType, itemTypeTranslations } from '@shared/models/iot-hub/iot-hub-item.models';
import {
MpItemVersionGroupedQuery,
MpItemVersionQuery,
MpItemVersionSection,
MpItemVersionView
} from '@shared/models/iot-hub/iot-hub-version.models';
import {
CROSS_TYPE_ITEM_TYPES,
getItemTypeIcon,
ItemType,
itemTypeTranslations,
RELEVANCE_SORT_PROPERTY
} from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { TranslateService } from '@ngx-translate/core';
@ -35,13 +47,10 @@ interface HeroTypeConfig {
interface SearchResultGroup {
type: ItemType;
items: MpItemVersionView[];
/** How many rows of this type the header offers beyond the ones shown. Zero renders no "+N more". */
remaining: number;
}
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,
@ -53,12 +62,12 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
readonly ItemType = ItemType;
searchText = '';
searchResults: MpItemVersionView[] = [];
searchResultGroups: SearchResultGroup[] = [];
searchLoaded = false;
searchLoading = false;
@ViewChild(MatAutocompleteTrigger) searchAutoTrigger: MatAutocompleteTrigger;
@ViewChild('searchInput', {read: ElementRef}) searchInputRef: ElementRef;
private enterHandledByRow = false;
private searchSubject = new Subject<string>();
private searchSubscription: Subscription;
@ -156,14 +165,19 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
distinctUntilChanged(),
switchMap(text => {
this.searchLoading = true;
const sortOrder: SortOrder = { property: 'totalInstallCount', direction: Direction.DESC };
const pageLink = new PageLink(10, 0, text.trim() || null, sortOrder);
const query = new MpItemVersionQuery(pageLink);
return this.iotHubApiService.getPublishedVersions(query, { ignoreLoading: true });
const trimmed = text.trim();
// Relevance in both states, the same value every other IoT Hub surface sends: with an
// empty field the backend serves the install count under this key, so the panel opens on
// popularity without this component having to know it.
const query = new MpItemVersionGroupedQuery({}, trimmed, RELEVANCE_SORT_PROPERTY);
// A failed request must not end the subscription: the interceptor reports it, and the
// panel goes back to an empty answer the next keystroke can replace.
return this.iotHubApiService.getPublishedVersionsGrouped(query, { ignoreLoading: true }).pipe(
catchError(() => of([] as MpItemVersionSection[]))
);
})
).subscribe(result => {
this.searchResults = result.data;
this.searchResultGroups = this.groupSearchResults(result.data);
).subscribe(sections => {
this.searchResultGroups = this.toResultGroups(sections);
this.searchLoaded = true;
this.searchLoading = false;
});
@ -205,11 +219,13 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
}
onSearchInput(): void {
this.enterHandledByRow = false;
this.searchLoading = true;
this.searchSubject.next(this.searchText || '');
}
onSearchFocus(): void {
this.enterHandledByRow = false;
if (!this.searchLoaded) {
this.searchLoading = true;
this.searchSubject.next(this.searchText || '');
@ -221,13 +237,45 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
};
clearSearch(): void {
this.enterHandledByRow = false;
this.searchText = '';
this.searchSubject.next('');
this.searchInputRef?.nativeElement?.focus();
setTimeout(() => this.searchAutoTrigger?.openPanel());
}
/**
* Gate on every row's selection: false for the panel's own bookkeeping, true when the user
* picked the row - and then it records whether a keyup is still coming for it.
*
* One Enter reaches two handlers. The autocomplete trigger acts on keydown, the field's own
* handler on keyup, and preventDefault on the first does not stop the second. Only the
* keyboard leaves that second half to deal with, so only the keyboard arms the flag: a pointer
* selection is finished when it returns, and a flag left standing there would swallow the next
* onSearch - which the magnifier button can raise with no keystroke at all.
*
* activeOption is what tells the two apart, and it is readable only here: the trigger holds it
* while it calls _selectViaInteraction and clears it on the next line of its own handler, so by
* keyup it reads empty either way. A pointer never sets it.
*/
rowSelectedByUser(event: MatOptionSelectionChange): boolean {
if (!event.isUserInput) {
return false;
}
this.enterHandledByRow = !!this.searchAutoTrigger?.activeOption;
return true;
}
/**
* Enter in the field opens the search page, unless a row has just acted on this same press.
* Every path that re-enters the field clears the flag too, so nothing survives the keystroke
* it belongs to - including an arrow-then-click, the one selection that arms it by pointer.
*/
onSearch(): void {
if (this.enterHandledByRow) {
this.enterHandledByRow = false;
return;
}
this.seeAllResults();
}
@ -237,6 +285,17 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
void this.router.navigate(['/iot-hub/search'], { queryParams: { search } });
}
/**
* The section header is the way into the rest of a type - the panel carries no per-section
* "see all" row, which would put six identical calls to action on one panel. The query goes
* with it, so the type page opens on the same search rather than on the whole type.
*/
navigateToSection(type: ItemType): void {
this.searchAutoTrigger?.closePanel();
const search = this.searchText?.trim() || undefined;
void this.router.navigate(['/iot-hub', this.getTypeRoute(type)], { queryParams: { search } });
}
isCompactType(type: ItemType): boolean {
return type === ItemType.CALCULATED_FIELD
|| type === ItemType.ALARM_RULE
@ -523,21 +582,26 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy {
});
}
private groupSearchResults(items: MpItemVersionView[]): SearchResultGroup[] {
const groupMap = new Map<ItemType, MpItemVersionView[]>();
for (const item of items) {
if (!SEARCH_GROUP_ORDER.includes(item.type)) {
continue;
}
let list = groupMap.get(item.type);
if (!list) {
list = [];
groupMap.set(item.type, list);
}
list.push(item);
}
return SEARCH_GROUP_ORDER
.filter(type => groupMap.has(type))
.map(type => ({ type, items: groupMap.get(type) }));
/**
* Reads the sections the server built: they arrive capped and in the order to render them, so
* this only drops the types this panel has no layout for - the platform publishes no dashboards
* - and works out each header's "+N more".
*
* `items` is defaulted because the response is an unvalidated cast of a new endpoint, and a
* throw here lands in a subscribe callback, where it would leave the panel on its spinner
* rather than reaching the catchError upstream.
*/
private toResultGroups(sections: MpItemVersionSection[]): SearchResultGroup[] {
return sections
.filter(section => CROSS_TYPE_ITEM_TYPES.includes(section.itemType))
.map(section => {
const items = section.items ?? [];
return {
type: section.itemType,
items,
remaining: Math.max(0, section.total - items.length)
};
});
}
}

101
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-search-page.component.scss

@ -8,12 +8,18 @@
height: 100%;
}
// Same frame as the type pages (iot-hub-items-page): one even padding on the card, the hero
// inside it, and the component below pulled out to the card's edges. It replaces four
// breakpoints' worth of hand-written negative margins — one per element that needed to reach
// an edge — and is why the filter rail, the heading and the grid now line up by construction.
.tb-search-page {
padding: 40px 40px 48px;
}
// Back button
.tb-search-back-btn {
align-self: flex-start;
margin-top: 40px;
margin-left: 123px;
margin-left: -8px;
}
// Title
@ -30,100 +36,37 @@
color: rgba(0, 0, 0, 0.54);
}
// Full bleed, and it pads its own rows back in through --tb-search-side-pad. The rail and the
// dividers are the parts that must reach the edge; everything else lines up with the hero.
tb-iot-hub-search {
flex: 1;
min-height: 0;
padding-left: 123px;
padding-right: 123px;
::ng-deep {
.tb-search-divider {
margin-left: -123px;
margin-right: -123px;
}
.tb-results-container {
padding-right: 123px;
padding-bottom: 40px;
margin-right: -123px;
}
}
}
// Responsive
@media #{$mat-lt-xxl} {
.tb-search-back-btn {
margin-left: 40px;
}
tb-iot-hub-search {
padding-left: 40px;
padding-right: 40px;
::ng-deep {
.tb-search-divider {
margin-left: -40px;
margin-right: -40px;
}
.tb-results-container {
padding-right: 40px;
margin-right: -40px;
}
}
}
--tb-search-side-pad: 40px;
margin-left: -40px;
margin-right: -40px;
}
@media #{$mat-lt-lg} {
.tb-search-back-btn {
margin-top: 24px;
margin-left: 24px;
.tb-search-page {
padding: 24px 24px 32px;
}
tb-iot-hub-search {
padding-left: 24px;
padding-right: 24px;
::ng-deep {
.tb-search-divider {
margin-left: -24px;
margin-right: -24px;
}
.tb-results-container {
padding-right: 24px;
padding-bottom: 24px;
margin-right: -24px;
}
}
--tb-search-side-pad: 24px;
margin-left: -24px;
margin-right: -24px;
}
}
@media #{$mat-lt-sm} {
.tb-search-page {
padding: 16px 16px 24px;
gap: 16px;
}
.tb-search-back-btn {
margin-top: 16px;
margin-left: 16px;
}
tb-iot-hub-search {
padding-left: 16px;
padding-right: 16px;
::ng-deep {
.tb-search-divider {
margin-left: -16px;
margin-right: -16px;
}
.tb-results-container {
padding-right: 16px;
padding-bottom: 16px;
margin-right: -16px;
}
}
--tb-search-side-pad: 16px;
margin-left: -16px;
margin-right: -16px;
}
}

45
ui-ngx/src/app/shared/models/iot-hub/iot-hub-item.models.ts

@ -1,5 +1,7 @@
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0
import { Direction } from '@shared/models/page/sort-order';
export enum ItemType {
WIDGET = 'WIDGET',
DASHBOARD = 'DASHBOARD',
@ -54,6 +56,49 @@ export const CREATOR_VISIBLE_ITEM_TYPES: ItemType[] = [
ItemType.RULE_CHAIN,
];
/**
* Item types a surface that mixes them lays out, in the order they are shown. Distinct from
* CREATOR_VISIBLE_ITEM_TYPES, which is the same six as a membership test and carries the type
* tabs' own order: here DEVICE leads, matching the hero popup's sections and the website.
*/
export const CROSS_TYPE_ITEM_TYPES: ItemType[] = [
ItemType.DEVICE,
ItemType.SOLUTION_TEMPLATE,
ItemType.WIDGET,
ItemType.CALCULATED_FIELD,
ItemType.ALARM_RULE,
ItemType.RULE_CHAIN,
];
/** Sort property served by relevance ranking. */
export const RELEVANCE_SORT_PROPERTY = 'relevance';
export interface SortOption {
value: string;
label: string;
direction: Direction;
}
/**
* The sort menu every IoT Hub surface carrying a search field offers, and the order it offers
* them in: the first entry is the default each surface opens on.
*
* Relevance is that default with or without text. With text it ranks the answer; with none the
* backend serves the install count under the same key, so a surface opens on the order it opened
* on before and nothing here switches on the field state. The cost is a menu reading "Most
* relevant" over an install-ordered list until the user types; the alternative - flipping the
* selector once text appears - moves a control the user did not touch and reorders nothing.
*
* One list rather than one per surface: a new key must reach all of them, and the surface that
* missed it would keep a different default without failing.
*/
export const IOT_HUB_SORT_OPTIONS: SortOption[] = [
{ value: RELEVANCE_SORT_PROPERTY, label: 'iot-hub.sort-most-relevant', direction: Direction.DESC },
{ value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
{ value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
{ value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
];
export interface FilterParamInfo {
key: string;
totalItems: number;

134
ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts

@ -108,6 +108,17 @@ export interface MpItemVersionView {
checksum?: string;
}
/**
* One item type's share of a grouped search: the rows to show and how many exist behind them.
* A grouped answer is a list of these, in the server's section order, and a type nothing matched
* has no section — so a "+N more" header is `total - items.length`.
*/
export interface MpItemVersionSection {
itemType: ItemType;
total: number;
items: MpItemVersionView[];
}
// 404 body shapes returned by the public listing item-version endpoint
// (GET /api/listings/public/by-slug/{slug}/item-version) when no
// version matches the caller's edition / platform combination.
@ -118,7 +129,15 @@ export interface ListingItemVersionNotFound {
}
export interface MpItemVersionQueryOptions {
/** Single item type, for a surface pinned to one (the type pages, the add-item dialog). */
type?: string;
/**
* Several item types at once, for a cross-type surface whose Type facet is multi-select.
* Emitted as a repeated `type` parameter, which is the shape the backend reads
* (`@RequestParam List<ItemType> type`). Kept separate from `type` rather than widening it,
* so a caller that means "exactly this type" cannot be handed an array by accident.
*/
types?: string[];
peOnly?: boolean;
creatorId?: string;
categories?: string[];
@ -133,51 +152,86 @@ export interface MpItemVersionQueryOptions {
scadaFirst?: boolean;
}
/** Every filter, as `&name=value` pairs - shared by both query shapes below. */
function filtersToQuery(o: MpItemVersionQueryOptions): string {
let query = '';
if (o.type) {
query += `&type=${encodeURIComponent(o.type)}`;
}
if (o.types?.length) {
query += o.types.map(t => `&type=${encodeURIComponent(t)}`).join('');
}
if (o.peOnly != null) {
query += `&peOnly=${o.peOnly}`;
}
if (o.creatorId) {
query += `&creatorId=${encodeURIComponent(o.creatorId)}`;
}
if (o.categories?.length) {
query += o.categories.map(c => `&categories=${encodeURIComponent(c)}`).join('');
}
if (o.useCases?.length) {
query += o.useCases.map(u => `&useCases=${encodeURIComponent(u)}`).join('');
}
if (o.cfTypes?.length) {
query += o.cfTypes.map(t => `&cfTypes=${encodeURIComponent(t)}`).join('');
}
if (o.widgetTypes?.length) {
query += o.widgetTypes.map(t => `&widgetTypes=${encodeURIComponent(t)}`).join('');
}
if (o.ruleChainTypes?.length) {
query += o.ruleChainTypes.map(t => `&ruleChainTypes=${encodeURIComponent(t)}`).join('');
}
if (o.tbVersion != null) {
query += `&tbVersion=${o.tbVersion}`;
}
if (o.hardwareTypes?.length) {
query += o.hardwareTypes.map(ht => `&hardwareTypes=${encodeURIComponent(ht)}`).join('');
}
if (o.connectivity?.length) {
query += o.connectivity.map(c => `&connectivity=${encodeURIComponent(c)}`).join('');
}
if (o.vendors?.length) {
query += o.vendors.map(v => `&vendors=${encodeURIComponent(v)}`).join('');
}
if (o.scadaFirst != null) {
query += `&scadaFirst=${o.scadaFirst}`;
}
return query;
}
/** A paged read: the filters, and the page to cut out of them. */
export class MpItemVersionQuery {
constructor(public pageLink: PageLink, public options: MpItemVersionQueryOptions = {}) {}
public toQuery(): string {
let query = this.pageLink.toQuery();
const o = this.options;
if (o.type) {
query += `&type=${o.type}`;
}
if (o.peOnly != null) {
query += `&peOnly=${o.peOnly}`;
}
if (o.creatorId) {
query += `&creatorId=${o.creatorId}`;
}
if (o.categories?.length) {
query += o.categories.map(c => `&categories=${encodeURIComponent(c)}`).join('');
}
if (o.useCases?.length) {
query += o.useCases.map(u => `&useCases=${encodeURIComponent(u)}`).join('');
}
if (o.cfTypes?.length) {
query += o.cfTypes.map(t => `&cfTypes=${encodeURIComponent(t)}`).join('');
}
if (o.widgetTypes?.length) {
query += o.widgetTypes.map(t => `&widgetTypes=${encodeURIComponent(t)}`).join('');
}
if (o.ruleChainTypes?.length) {
query += o.ruleChainTypes.map(t => `&ruleChainTypes=${encodeURIComponent(t)}`).join('');
}
if (o.tbVersion != null) {
query += `&tbVersion=${o.tbVersion}`;
}
if (o.hardwareTypes?.length) {
query += o.hardwareTypes.map(ht => `&hardwareTypes=${encodeURIComponent(ht)}`).join('');
}
if (o.connectivity?.length) {
query += o.connectivity.map(c => `&connectivity=${encodeURIComponent(c)}`).join('');
}
if (o.vendors?.length) {
query += o.vendors.map(v => `&vendors=${encodeURIComponent(v)}`).join('');
return this.pageLink.toQuery() + filtersToQuery(this.options);
}
}
/**
* A sectioned read: the filters, what to search for, and which key orders a section.
*
* No `PageLink`, because the grouped endpoint takes no page and no page size - it sizes its own
* answer from the section limit - and no sort direction either, each key's direction being fixed
* by the chain the server switches on. A page link here could only carry values nobody sends.
*/
export class MpItemVersionGroupedQuery {
constructor(public options: MpItemVersionQueryOptions = {},
public textSearch?: string,
public sortProperty?: string) {}
public toQuery(): string {
const parts: string[] = [];
const text = this.textSearch?.trim();
if (text?.length) {
parts.push(`textSearch=${encodeURIComponent(text)}`);
}
if (o.scadaFirst != null) {
query += `&scadaFirst=${o.scadaFirst}`;
if (this.sortProperty) {
parts.push(`sortProperty=${this.sortProperty}`);
}
return query;
// filtersToQuery() emits leading ampersands, which is what a page link needs in front of it;
// here they may be the whole query string, so the first one is dropped.
return `?${`${parts.join('&')}${filtersToQuery(this.options)}`.replace(/^&/, '')}`;
}
}

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

@ -4200,6 +4200,7 @@
"search": "Search...",
"search-published-items": "Search published items...",
"see-all-results": "See all results",
"see-results-for": "See results for \"{{ search }}\"",
"no-search-results": "No results found for '{{ search }}'",
"no-items-available": "No items available",
"search-results": "Search results",
@ -4222,6 +4223,7 @@
"type": "Type",
"items-per-page": "Items per page",
"filter": "Filter",
"clear-filters": "Clear filters",
"available": "Available",
"items-page-desc-widgets": "Jumpstart your IoT journey with pre-configured widgets designed for your industry. Deploy proven architectures instantly and focus your energy on what matters: your unique business logic.",
"items-page-desc-dashboards": "Explore dashboards to find pre-built visualization templates and interactive UI layouts you can deploy in minutes to bring your IoT data to life.",
@ -4260,9 +4262,11 @@
"search-alarm-rules": "Search alarm rules...",
"search-rule-chains": "Search rule chains...",
"search-devices": "Search devices...",
"sort-most-relevant": "Most relevant",
"sort-most-installed": "Most installed",
"sort-newest": "Newest",
"sort-name": "Name (A-Z)",
"section-more": "{ count, plural, =1 {+1 more} other {+# more} }",
"type-filter-label": "Type",
"category": "Category",
"use-case": "Use case",

Loading…
Cancel
Save