diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 09de886036..78a7dc76df 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -43,7 +43,13 @@ import { RuleChainService } from '@core/http/rule-chain.service'; import { AliasInfo, StateParams, SubscriptionInfo } from '@core/api/widget-api.models'; import { DataKey, Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models'; import { UtilsService } from '@core/services/utils.service'; -import { AliasFilterType, EntityAlias, EntityAliasFilter, EntityAliasFilterResult } from '@shared/models/alias.models'; +import { + AliasFilterType, + edgeAliasFilterTypes, + EntityAlias, + EntityAliasFilter, + EntityAliasFilterResult +} from '@shared/models/alias.models'; import { EdgeImportEntityData, EntitiesKeysByQuery, @@ -495,7 +501,11 @@ export class EntityService { } public getAliasFilterTypesByEntityTypes(entityTypes: Array): Array { - const allAliasFilterTypes: Array = Object.keys(AliasFilterType).map((key) => AliasFilterType[key]); + const authState = getCurrentAuthState(this.store); + let allAliasFilterTypes: Array = Object.values(AliasFilterType); + if (!authState.edgesSupportEnabled) { + allAliasFilterTypes = allAliasFilterTypes.filter(aliasFilterType => !edgeAliasFilterTypes.includes(aliasFilterType)); + } if (!entityTypes || !entityTypes.length) { return allAliasFilterTypes; } @@ -622,14 +632,14 @@ export class EntityService { case Authority.TENANT_ADMIN: entityTypes.push(EntityType.DEVICE); entityTypes.push(EntityType.ASSET); - if (authState.edgesSupportEnabled) { - entityTypes.push(EntityType.EDGE); - } entityTypes.push(EntityType.ENTITY_VIEW); entityTypes.push(EntityType.TENANT); entityTypes.push(EntityType.CUSTOMER); entityTypes.push(EntityType.USER); entityTypes.push(EntityType.DASHBOARD); + if (authState.edgesSupportEnabled) { + entityTypes.push(EntityType.EDGE); + } if (useAliasEntityTypes) { entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); entityTypes.push(AliasEntityType.CURRENT_TENANT); @@ -638,13 +648,13 @@ export class EntityService { case Authority.CUSTOMER_USER: entityTypes.push(EntityType.DEVICE); entityTypes.push(EntityType.ASSET); - if (authState.edgesSupportEnabled) { - entityTypes.push(EntityType.EDGE); - } entityTypes.push(EntityType.ENTITY_VIEW); entityTypes.push(EntityType.CUSTOMER); entityTypes.push(EntityType.USER); entityTypes.push(EntityType.DASHBOARD); + if (authState.edgesSupportEnabled) { + entityTypes.push(EntityType.EDGE); + } if (useAliasEntityTypes) { entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index e77b6a461e..a704c44dc0 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -121,7 +121,6 @@ import { DisplayWidgetTypesPanelData } from '@home/components/dashboard-page/widget-types-panel.component'; import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component'; -import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; import { MobileService } from '@core/services/mobile.service'; import { @@ -193,8 +192,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC isToolbarOpenedAnimate = false; isRightLayoutOpened = false; - allowedEntityTypes: Array = null; - editingWidget: Widget = null; editingWidgetLayout: WidgetLayout = null; editingWidgetOriginal: Widget = null; @@ -409,8 +406,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC }; this.window.parent.postMessage(JSON.stringify(message), '*'); } - - this.allowedEntityTypes = this.entityService.prepareAllowedEntityTypesList(null, true); } private reset() { @@ -658,8 +653,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC data: { entityAliases: deepClone(this.dashboard.configuration.entityAliases), widgets: this.dashboardUtils.getWidgetsArray(this.dashboard), - isSingleEntityAlias: false, - allowedEntityTypes: this.allowedEntityTypes + isSingleEntityAlias: false } }).afterClosed().subscribe((entityAliases) => { if (entityAliases) { diff --git a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts index 3bd63b046b..1327f23054 100644 --- a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts +++ b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts @@ -45,7 +45,7 @@ import { } from '@home/components/alias/entity-aliases-dialog.component'; import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service'; import { FileType, ImportWidgetResult, JSON_TYPE, WidgetsBundleItem, ZIP_TYPE } from './import-export.models'; -import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; +import { EntityType } from '@shared/models/entity-type.models'; import { UtilsService } from '@core/services/utils.service'; import { WidgetService } from '@core/http/widget.service'; import { NULL_UUID } from '@shared/models/id/has-uuid'; @@ -686,9 +686,6 @@ export class ImportExportService { private editMissingAliases(widgets: Array, isSingleWidget: boolean, customTitle: string, missingEntityAliases: EntityAliases): Observable { - const allowedEntityTypes: Array = - this.entityService.prepareAllowedEntityTypesList(null, true); - return this.dialog.open(EntityAliasesDialogComponent, { disableClose: true, @@ -698,8 +695,7 @@ export class ImportExportService { widgets, customTitle, isSingleWidget, - disableAdd: true, - allowedEntityTypes + disableAdd: true } }).afterClosed().pipe( map((updatedEntityAliases) => { diff --git a/ui-ngx/src/app/shared/models/alias.models.ts b/ui-ngx/src/app/shared/models/alias.models.ts index 1f900d29a1..5df31c2a3c 100644 --- a/ui-ngx/src/app/shared/models/alias.models.ts +++ b/ui-ngx/src/app/shared/models/alias.models.ts @@ -37,6 +37,11 @@ export enum AliasFilterType { entityViewSearchQuery = 'entityViewSearchQuery' } +export const edgeAliasFilterTypes = new Array( + AliasFilterType.edgeType, + AliasFilterType.edgeSearchQuery +); + export const aliasFilterTypeTranslationMap = new Map( [ [ AliasFilterType.singleEntity, 'alias.filter-type-single-entity' ],