diff --git a/ui-ngx/src/app/core/http/iot-hub-api.service.ts b/ui-ngx/src/app/core/http/iot-hub-api.service.ts index 33f19d285f..2074976126 100644 --- a/ui-ngx/src/app/core/http/iot-hub-api.service.ts +++ b/ui-ngx/src/app/core/http/iot-hub-api.service.ts @@ -87,7 +87,7 @@ export class IotHubApiService { return this.http.get(url, { params: this.buildParams(config) }); } - public getWidgetCategories(textSearch?: string, scadaFirst?: boolean, + public getWidgetCategories(textSearch?: string, scadaFirst?: boolean, creatorVerified?: boolean, config?: IotHubRequestConfig): Observable { const queryParams: string[] = [ `peOnly=false`, @@ -99,6 +99,9 @@ export class IotHubApiService { if (scadaFirst != null) { queryParams.push(`scadaFirst=${scadaFirst}`); } + if (creatorVerified) { + queryParams.push(`creatorVerified=true`); + } const url = `${this.baseUrl}/api/item-listing/widgetCategories?${queryParams.join('&')}`; return this.http.get(url, { params: this.buildParams(config) }); } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html index aa5c1deb90..2dccec902f 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html @@ -457,120 +457,129 @@ } } @else { - - - - {{ 'iot-hub.type' | translate }} - @if (iotHubAppliedWidgetTypes.size) { - {{ iotHubAppliedWidgetTypes.size }} - } - - - @if (iotHubWidgetTypeOptions.length >= 10) { - - } -
- @for (opt of getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType'); track opt.key) { -
- - {{ getIotHubWidgetTypeLabel(opt.key) }} - -
- } -
-
- @if (!hideCategoriesFilterSection) { +
+ + {{ 'iot-hub.verified-creators-only' | translate }} + +
+ @if (iotHubSubMode !== 'default') { - + - {{ 'iot-hub.category' | translate }} - @if (iotHubAppliedCategories.size) { - {{ iotHubAppliedCategories.size }} + {{ 'iot-hub.type' | translate }} + @if (iotHubAppliedWidgetTypes.size) { + {{ iotHubAppliedWidgetTypes.size }} } - @if (iotHubCategoryOptions.length >= 10) { + @if (iotHubWidgetTypeOptions.length >= 10) { } -
- @for (opt of getFilteredIotHubItems(iotHubCategoryOptions, 'category'); track opt.key) { + @for (opt of getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType'); track opt.key) {
- - {{ opt.key }} + + {{ getIotHubWidgetTypeLabel(opt.key) }}
}
- } - - - - - {{ 'iot-hub.use-case' | translate }} - @if (iotHubAppliedUseCases.size) { - {{ iotHubAppliedUseCases.size }} - } - - - @if (iotHubUseCaseOptions.length >= 10) { - - } -
- @for (group of getGroupedIotHubFilterItems(iotHubUseCaseOptions, 'useCase'); track group.label) { - @if (group.label) { -
{{ group.label | translate }}
- } - @for (opt of group.items; track opt.key) { -
- - {{ opt.key }} - + @if (!hideCategoriesFilterSection) { + + + + + {{ 'iot-hub.category' | translate }} + @if (iotHubAppliedCategories.size) { + {{ iotHubAppliedCategories.size }} + } + + + @if (iotHubCategoryOptions.length >= 10) { + } +
+ @for (opt of getFilteredIotHubItems(iotHubCategoryOptions, 'category'); track opt.key) { +
+ + {{ opt.key }} + +
+ } +
+
+ } + + + + + {{ 'iot-hub.use-case' | translate }} + @if (iotHubAppliedUseCases.size) { + {{ iotHubAppliedUseCases.size }} + } + + + @if (iotHubUseCaseOptions.length >= 10) { + } -
- +
+ @for (group of getGroupedIotHubFilterItems(iotHubUseCaseOptions, 'useCase'); track group.label) { + @if (group.label) { +
{{ group.label | translate }}
+ } + @for (opt of group.items; track opt.key) { +
+ + {{ opt.key }} + +
+ } + } +
+ + } }
diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts index d93a1e504e..e6331f9a66 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts @@ -137,6 +137,7 @@ export class DashboardWidgetSelectComponent { this.iotHubAppliedWidgetTypes.clear(); this.iotHubAppliedCategories.clear(); this.iotHubAppliedUseCases.clear(); + this.iotHubVerifiedCreatorsOnly = false; this.iotHubFilterCount = 0; } } @@ -260,6 +261,7 @@ export class DashboardWidgetSelectComponent { iotHubAppliedWidgetTypes = new Set(); iotHubAppliedCategories = new Set(); iotHubAppliedUseCases = new Set(); + iotHubVerifiedCreatorsOnly = false; iotHubWidgetTypeOptions: FilterParamInfo[] = []; iotHubCategoryOptions: FilterParamInfo[] = []; @@ -314,7 +316,8 @@ export class DashboardWidgetSelectComponent { categories: effectiveCategories, useCases: this.iotHubAppliedUseCases.size > 0 ? Array.from(this.iotHubAppliedUseCases) : undefined, widgetTypes: this.iotHubAppliedWidgetTypes.size > 0 ? Array.from(this.iotHubAppliedWidgetTypes) : undefined, - scadaFirst: this.scadaFirst ? true : undefined + scadaFirst: this.scadaFirst ? true : undefined, + creatorVerified: this.iotHubVerifiedCreatorsOnly }); return this.iotHubApiService.getPublishedVersions(query, { ignoreLoading: true }); }; @@ -337,7 +340,8 @@ export class DashboardWidgetSelectComponent { this.iotHubDefaultFetchFunction = (pageSize, page, filter) => { const search = typeof filter === 'string' ? filter.split('|')[0] : filter; return this.iotHubApiService.getWidgetCategories(search || undefined, - this.scadaFirst ? true : undefined, { ignoreLoading: true }).pipe( + this.scadaFirst ? true : undefined, + this.iotHubVerifiedCreatorsOnly, { ignoreLoading: true }).pipe( map(categories => ({ data: categories.slice(page * pageSize, page * pageSize + pageSize), totalPages: Math.ceil(categories.length / pageSize), @@ -554,11 +558,19 @@ export class DashboardWidgetSelectComponent { this.onIotHubFiltersChanged(); } + toggleIotHubVerifiedCreators(): void { + this.iotHubVerifiedCreatorsOnly = !this.iotHubVerifiedCreatorsOnly; + this.loadWidgetCategories(); + this.onIotHubFiltersChanged(); + } + clearIotHubFilters(): void { this.iotHubAppliedWidgetTypes.clear(); this.iotHubAppliedCategories.clear(); this.iotHubAppliedUseCases.clear(); + this.iotHubVerifiedCreatorsOnly = false; this.iotHubFilterSearch = {}; + this.loadWidgetCategories(); this.onIotHubFiltersChanged(); } @@ -566,7 +578,8 @@ export class DashboardWidgetSelectComponent { this.iotHubFilterCount = this.iotHubAppliedWidgetTypes.size + (this.iotHubSelectedCategory ? 0 : this.iotHubAppliedCategories.size) + - this.iotHubAppliedUseCases.size; + this.iotHubAppliedUseCases.size + + (this.iotHubVerifiedCreatorsOnly ? 1 : 0); this.reloadIotHubWidgets(); } @@ -582,6 +595,9 @@ export class DashboardWidgetSelectComponent { if (this.selectWidgetMode === 'installed') { return (this.filterWidgetTypes?.length ?? 0) + (this.includeDeprecated ? 1 : 0); } + if (this.iotHubSubMode === 'default') { + return this.iotHubVerifiedCreatorsOnly ? 1 : 0; + } return this.iotHubFilterCount; } @@ -591,7 +607,8 @@ export class DashboardWidgetSelectComponent { } return this.iotHubAppliedWidgetTypes.size > 0 || this.iotHubAppliedCategories.size > 0 - || this.iotHubAppliedUseCases.size > 0; + || this.iotHubAppliedUseCases.size > 0 + || this.iotHubVerifiedCreatorsOnly; } clearAllFilters(): void { @@ -630,7 +647,8 @@ export class DashboardWidgetSelectComponent { isFilterVisible(): boolean { if (this.selectWidgetMode === 'iotHub') { - return this.iotHubSubMode !== 'default'; + // The category landing honours only the verified filter, so the button stays while it is on + return this.iotHubSubMode !== 'default' || this.iotHubVerifiedCreatorsOnly; } return this.installedSubMode === 'allWidgets' || this.widgetsBundle !== null; } @@ -838,6 +856,9 @@ export class DashboardWidgetSelectComponent { if (this.iotHubAppliedUseCases.size > 0) { filtered = filtered.filter(v => v.useCases?.some(u => this.iotHubAppliedUseCases.has(u))); } + if (this.iotHubVerifiedCreatorsOnly) { + filtered = filtered.filter(v => v.creatorVerified); + } filtered = this.sortInstalledVersions(filtered); const start = page * pageSize; const data = filtered.slice(start, start + pageSize); diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.html index 40ffca34c8..740be1f42d 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.html @@ -25,6 +25,13 @@
+ + {{ 'iot-hub.verified-creators-only' | translate }} + +
+ @if (!fixedSubType && subtypeOptions.length > 0 && activeType !== ItemType.ALARM_RULE) { @@ -253,6 +260,12 @@
+ @if (verifiedCreatorsOnly) { + + {{ 'iot-hub.verified-creators-only' | translate }} + close + + } @for (key of getActiveSubtypesArray(); track key) { {{ getSubtypeLabel(key) }} @@ -305,6 +318,8 @@
+
{{ 'iot-hub.filter' | translate }}
+
@@ -347,6 +362,12 @@ @if (hasActiveDropdownFilters()) { + @if (verifiedCreatorsOnly) { + + {{ 'iot-hub.verified-creators-only' | translate }} + close + + } @for (key of getActiveSubtypesArray(); track key) { {{ getSubtypeLabel(key) }} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss index d16491e4a3..2808db8ae4 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss @@ -97,6 +97,17 @@ } } +.tb-iot-hub-filters-header { + padding: 16px 16px 12px 56px; + font-size: 18px; + font-weight: 500; + color: rgba(0, 0, 0, 0.87); +} + +.tb-iot-hub-filters-desktop .tb-iot-hub-filters-inner { + padding-top: 8px; +} + .tb-iot-hub-filters-wrapper { position: sticky; max-height: calc(100vh - var(--mat-toolbar-standard-height, 64px)); @@ -167,6 +178,10 @@ padding: 0; } + .tb-iot-hub-filter-standalone { + margin-left: 13px; + } + .tb-iot-hub-filter-panel.mat-expansion-panel { .mat-expansion-panel-header { padding-left: 24px; @@ -199,6 +214,21 @@ background: rgba(0, 0, 0, 0.12); } +// 56px section-title inset minus the checkbox's own 11px +.tb-iot-hub-filter-standalone { + margin-left: 45px; +} + +.tb-iot-hub-filter-panel.mat-expansion-panel mat-checkbox, +.tb-iot-hub-filter-standalone { + display: block; + overflow: hidden; + + &:hover { + background: rgba(0, 0, 0, 0.04); + } +} + // Filter expansion panels — Design: no shadow, pl-40 for content .tb-iot-hub-filter-panel.mat-expansion-panel { box-shadow: none; @@ -221,15 +251,6 @@ padding: 0 8px 0 0; } - mat-checkbox { - display: block; - overflow: hidden; - - &:hover { - background: rgba(0, 0, 0, 0.04); - } - } - .tb-iot-hub-filter-items { padding-left: 44px; max-height: 340px; diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts index 1568146cfc..caa4920eff 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts @@ -128,6 +128,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy activeConnectivity = new Set(); activeHardwareTypes = new Set(); activeVendors = new Set(); + verifiedCreatorsOnly = false; sortOptions: SortOption[] = [ { value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC }, @@ -396,6 +397,12 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy this.loadItems(); } + onVerifiedCreatorsToggle(): void { + this.verifiedCreatorsOnly = !this.verifiedCreatorsOnly; + this.pageIndex = 0; + this.loadItems(); + } + isVendorActive(vendor: string): boolean { return this.activeVendors.has(vendor); } @@ -499,12 +506,14 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy this.activeConnectivity.clear(); this.activeHardwareTypes.clear(); this.activeVendors.clear(); + this.verifiedCreatorsOnly = false; } get activeFilterCount(): number { const subtypeCount = this.fixedSubType ? this.getActiveSubtypesArray().length : (this.getActiveSubtypes()?.size || 0); return subtypeCount + this.activeCategories.size + this.activeUseCases.size + - this.activeConnectivity.size + this.activeHardwareTypes.size + this.activeVendors.size; + this.activeConnectivity.size + this.activeHardwareTypes.size + this.activeVendors.size + + (this.verifiedCreatorsOnly ? 1 : 0); } hasActiveDropdownFilters(): boolean { @@ -512,7 +521,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy return this.activeCategories.size > 0 || this.activeUseCases.size > 0 || subtypeCount > 0 || this.activeConnectivity.size > 0 || this.activeHardwareTypes.size > 0 || - this.activeVendors.size > 0; + this.activeVendors.size > 0 || this.verifiedCreatorsOnly; } hasActiveFilters(): boolean { @@ -700,7 +709,8 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy ruleChainTypes: this.activeRuleChainTypes.size > 0 ? Array.from(this.activeRuleChainTypes) : undefined, hardwareTypes: this.activeHardwareTypes.size > 0 ? Array.from(this.activeHardwareTypes) : undefined, connectivity: this.activeConnectivity.size > 0 ? Array.from(this.activeConnectivity) : undefined, - vendors: this.activeVendors.size > 0 ? Array.from(this.activeVendors) : undefined + vendors: this.activeVendors.size > 0 ? Array.from(this.activeVendors) : undefined, + creatorVerified: this.verifiedCreatorsOnly }); this.iotHubApiService.getPublishedVersions( query, diff --git a/ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts b/ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts index 349a4f62e8..e726fe4b39 100644 --- a/ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts +++ b/ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts @@ -131,6 +131,8 @@ export interface MpItemVersionQueryOptions { connectivity?: string[]; vendors?: string[]; scadaFirst?: boolean; + // Serialized only when true: the API matches the value, so `false` would mean "unverified only" + creatorVerified?: boolean; } export class MpItemVersionQuery { @@ -178,6 +180,9 @@ export class MpItemVersionQuery { if (o.scadaFirst != null) { query += `&scadaFirst=${o.scadaFirst}`; } + if (o.creatorVerified) { + query += `&creatorVerified=true`; + } return query; } } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 8abf9917d2..5e71c56e0c 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3772,6 +3772,7 @@ "sort-newest": "Newest", "sort-name": "Name (A-Z)", "type-filter-label": "Type", + "verified-creators-only": "Verified creators only", "category": "Category", "use-case": "Use case", "vendor": "Vendor",