Commit cd78514bc08f3ef2b5411d4fd5db8518734808ae
1 parent
595fb99c
Added correct alias filtering for edge disabled/enabled events
Showing
3 changed files
with
30 additions
and
14 deletions
@@ -43,7 +43,13 @@ import { RuleChainService } from '@core/http/rule-chain.service'; | @@ -43,7 +43,13 @@ import { RuleChainService } from '@core/http/rule-chain.service'; | ||
43 | import { AliasInfo, StateParams, SubscriptionInfo } from '@core/api/widget-api.models'; | 43 | import { AliasInfo, StateParams, SubscriptionInfo } from '@core/api/widget-api.models'; |
44 | import { DataKey, Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models'; | 44 | import { DataKey, Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models'; |
45 | import { UtilsService } from '@core/services/utils.service'; | 45 | import { UtilsService } from '@core/services/utils.service'; |
46 | -import { AliasFilterType, EntityAlias, EntityAliasFilter, EntityAliasFilterResult } from '@shared/models/alias.models'; | 46 | +import { |
47 | + AliasFilterType, | ||
48 | + edgeAliasFilterTypes, | ||
49 | + EntityAlias, | ||
50 | + EntityAliasFilter, | ||
51 | + EntityAliasFilterResult | ||
52 | +} from '@shared/models/alias.models'; | ||
47 | import { | 53 | import { |
48 | EdgeImportEntityData, | 54 | EdgeImportEntityData, |
49 | EntitiesKeysByQuery, | 55 | EntitiesKeysByQuery, |
@@ -495,7 +501,16 @@ export class EntityService { | @@ -495,7 +501,16 @@ export class EntityService { | ||
495 | } | 501 | } |
496 | 502 | ||
497 | public getAliasFilterTypesByEntityTypes(entityTypes: Array<EntityType | AliasEntityType>): Array<AliasFilterType> { | 503 | public getAliasFilterTypesByEntityTypes(entityTypes: Array<EntityType | AliasEntityType>): Array<AliasFilterType> { |
498 | - const allAliasFilterTypes: Array<AliasFilterType> = Object.keys(AliasFilterType).map((key) => AliasFilterType[key]); | 504 | + const authState = getCurrentAuthState(this.store); |
505 | + const allAliasFilterTypes: Array<AliasFilterType> = Object.keys(AliasFilterType) | ||
506 | + .map((key) => AliasFilterType[key]) | ||
507 | + .filter(aft => { | ||
508 | + if (authState.edgesSupportEnabled) { | ||
509 | + return true; | ||
510 | + } else { | ||
511 | + return edgeAliasFilterTypes.indexOf(aft) === -1; | ||
512 | + } | ||
513 | + }); | ||
499 | if (!entityTypes || !entityTypes.length) { | 514 | if (!entityTypes || !entityTypes.length) { |
500 | return allAliasFilterTypes; | 515 | return allAliasFilterTypes; |
501 | } | 516 | } |
@@ -622,14 +637,14 @@ export class EntityService { | @@ -622,14 +637,14 @@ export class EntityService { | ||
622 | case Authority.TENANT_ADMIN: | 637 | case Authority.TENANT_ADMIN: |
623 | entityTypes.push(EntityType.DEVICE); | 638 | entityTypes.push(EntityType.DEVICE); |
624 | entityTypes.push(EntityType.ASSET); | 639 | entityTypes.push(EntityType.ASSET); |
625 | - if (authState.edgesSupportEnabled) { | ||
626 | - entityTypes.push(EntityType.EDGE); | ||
627 | - } | ||
628 | entityTypes.push(EntityType.ENTITY_VIEW); | 640 | entityTypes.push(EntityType.ENTITY_VIEW); |
629 | entityTypes.push(EntityType.TENANT); | 641 | entityTypes.push(EntityType.TENANT); |
630 | entityTypes.push(EntityType.CUSTOMER); | 642 | entityTypes.push(EntityType.CUSTOMER); |
631 | entityTypes.push(EntityType.USER); | 643 | entityTypes.push(EntityType.USER); |
632 | entityTypes.push(EntityType.DASHBOARD); | 644 | entityTypes.push(EntityType.DASHBOARD); |
645 | + if (authState.edgesSupportEnabled) { | ||
646 | + entityTypes.push(EntityType.EDGE); | ||
647 | + } | ||
633 | if (useAliasEntityTypes) { | 648 | if (useAliasEntityTypes) { |
634 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); | 649 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
635 | entityTypes.push(AliasEntityType.CURRENT_TENANT); | 650 | entityTypes.push(AliasEntityType.CURRENT_TENANT); |
@@ -638,13 +653,13 @@ export class EntityService { | @@ -638,13 +653,13 @@ export class EntityService { | ||
638 | case Authority.CUSTOMER_USER: | 653 | case Authority.CUSTOMER_USER: |
639 | entityTypes.push(EntityType.DEVICE); | 654 | entityTypes.push(EntityType.DEVICE); |
640 | entityTypes.push(EntityType.ASSET); | 655 | entityTypes.push(EntityType.ASSET); |
641 | - if (authState.edgesSupportEnabled) { | ||
642 | - entityTypes.push(EntityType.EDGE); | ||
643 | - } | ||
644 | entityTypes.push(EntityType.ENTITY_VIEW); | 656 | entityTypes.push(EntityType.ENTITY_VIEW); |
645 | entityTypes.push(EntityType.CUSTOMER); | 657 | entityTypes.push(EntityType.CUSTOMER); |
646 | entityTypes.push(EntityType.USER); | 658 | entityTypes.push(EntityType.USER); |
647 | entityTypes.push(EntityType.DASHBOARD); | 659 | entityTypes.push(EntityType.DASHBOARD); |
660 | + if (authState.edgesSupportEnabled) { | ||
661 | + entityTypes.push(EntityType.EDGE); | ||
662 | + } | ||
648 | if (useAliasEntityTypes) { | 663 | if (useAliasEntityTypes) { |
649 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); | 664 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
650 | } | 665 | } |
@@ -45,7 +45,7 @@ import { | @@ -45,7 +45,7 @@ import { | ||
45 | } from '@home/components/alias/entity-aliases-dialog.component'; | 45 | } from '@home/components/alias/entity-aliases-dialog.component'; |
46 | import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service'; | 46 | import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service'; |
47 | import { FileType, ImportWidgetResult, JSON_TYPE, WidgetsBundleItem, ZIP_TYPE } from './import-export.models'; | 47 | import { FileType, ImportWidgetResult, JSON_TYPE, WidgetsBundleItem, ZIP_TYPE } from './import-export.models'; |
48 | -import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; | 48 | +import { EntityType } from '@shared/models/entity-type.models'; |
49 | import { UtilsService } from '@core/services/utils.service'; | 49 | import { UtilsService } from '@core/services/utils.service'; |
50 | import { WidgetService } from '@core/http/widget.service'; | 50 | import { WidgetService } from '@core/http/widget.service'; |
51 | import { NULL_UUID } from '@shared/models/id/has-uuid'; | 51 | import { NULL_UUID } from '@shared/models/id/has-uuid'; |
@@ -686,9 +686,6 @@ export class ImportExportService { | @@ -686,9 +686,6 @@ export class ImportExportService { | ||
686 | 686 | ||
687 | private editMissingAliases(widgets: Array<Widget>, isSingleWidget: boolean, | 687 | private editMissingAliases(widgets: Array<Widget>, isSingleWidget: boolean, |
688 | customTitle: string, missingEntityAliases: EntityAliases): Observable<EntityAliases> { | 688 | customTitle: string, missingEntityAliases: EntityAliases): Observable<EntityAliases> { |
689 | - const allowedEntityTypes: Array<EntityType | AliasEntityType> = | ||
690 | - this.entityService.prepareAllowedEntityTypesList(null, true); | ||
691 | - | ||
692 | return this.dialog.open<EntityAliasesDialogComponent, EntityAliasesDialogData, | 689 | return this.dialog.open<EntityAliasesDialogComponent, EntityAliasesDialogData, |
693 | EntityAliases>(EntityAliasesDialogComponent, { | 690 | EntityAliases>(EntityAliasesDialogComponent, { |
694 | disableClose: true, | 691 | disableClose: true, |
@@ -698,8 +695,7 @@ export class ImportExportService { | @@ -698,8 +695,7 @@ export class ImportExportService { | ||
698 | widgets, | 695 | widgets, |
699 | customTitle, | 696 | customTitle, |
700 | isSingleWidget, | 697 | isSingleWidget, |
701 | - disableAdd: true, | ||
702 | - allowedEntityTypes | 698 | + disableAdd: true |
703 | } | 699 | } |
704 | }).afterClosed().pipe( | 700 | }).afterClosed().pipe( |
705 | map((updatedEntityAliases) => { | 701 | map((updatedEntityAliases) => { |
@@ -37,6 +37,11 @@ export enum AliasFilterType { | @@ -37,6 +37,11 @@ export enum AliasFilterType { | ||
37 | entityViewSearchQuery = 'entityViewSearchQuery' | 37 | entityViewSearchQuery = 'entityViewSearchQuery' |
38 | } | 38 | } |
39 | 39 | ||
40 | +export const edgeAliasFilterTypes = new Array<string>( | ||
41 | + AliasFilterType.edgeType, | ||
42 | + AliasFilterType.edgeSearchQuery | ||
43 | +); | ||
44 | + | ||
40 | export const aliasFilterTypeTranslationMap = new Map<AliasFilterType, string>( | 45 | export const aliasFilterTypeTranslationMap = new Map<AliasFilterType, string>( |
41 | [ | 46 | [ |
42 | [ AliasFilterType.singleEntity, 'alias.filter-type-single-entity' ], | 47 | [ AliasFilterType.singleEntity, 'alias.filter-type-single-entity' ], |