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 | 43 | import { AliasInfo, StateParams, SubscriptionInfo } from '@core/api/widget-api.models'; |
44 | 44 | import { DataKey, Datasource, DatasourceType, KeyInfo } from '@app/shared/models/widget.models'; |
45 | 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 | 53 | import { |
48 | 54 | EdgeImportEntityData, |
49 | 55 | EntitiesKeysByQuery, |
... | ... | @@ -495,7 +501,16 @@ export class EntityService { |
495 | 501 | } |
496 | 502 | |
497 | 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 | 514 | if (!entityTypes || !entityTypes.length) { |
500 | 515 | return allAliasFilterTypes; |
501 | 516 | } |
... | ... | @@ -622,14 +637,14 @@ export class EntityService { |
622 | 637 | case Authority.TENANT_ADMIN: |
623 | 638 | entityTypes.push(EntityType.DEVICE); |
624 | 639 | entityTypes.push(EntityType.ASSET); |
625 | - if (authState.edgesSupportEnabled) { | |
626 | - entityTypes.push(EntityType.EDGE); | |
627 | - } | |
628 | 640 | entityTypes.push(EntityType.ENTITY_VIEW); |
629 | 641 | entityTypes.push(EntityType.TENANT); |
630 | 642 | entityTypes.push(EntityType.CUSTOMER); |
631 | 643 | entityTypes.push(EntityType.USER); |
632 | 644 | entityTypes.push(EntityType.DASHBOARD); |
645 | + if (authState.edgesSupportEnabled) { | |
646 | + entityTypes.push(EntityType.EDGE); | |
647 | + } | |
633 | 648 | if (useAliasEntityTypes) { |
634 | 649 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
635 | 650 | entityTypes.push(AliasEntityType.CURRENT_TENANT); |
... | ... | @@ -638,13 +653,13 @@ export class EntityService { |
638 | 653 | case Authority.CUSTOMER_USER: |
639 | 654 | entityTypes.push(EntityType.DEVICE); |
640 | 655 | entityTypes.push(EntityType.ASSET); |
641 | - if (authState.edgesSupportEnabled) { | |
642 | - entityTypes.push(EntityType.EDGE); | |
643 | - } | |
644 | 656 | entityTypes.push(EntityType.ENTITY_VIEW); |
645 | 657 | entityTypes.push(EntityType.CUSTOMER); |
646 | 658 | entityTypes.push(EntityType.USER); |
647 | 659 | entityTypes.push(EntityType.DASHBOARD); |
660 | + if (authState.edgesSupportEnabled) { | |
661 | + entityTypes.push(EntityType.EDGE); | |
662 | + } | |
648 | 663 | if (useAliasEntityTypes) { |
649 | 664 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
650 | 665 | } | ... | ... |
... | ... | @@ -45,7 +45,7 @@ import { |
45 | 45 | } from '@home/components/alias/entity-aliases-dialog.component'; |
46 | 46 | import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service'; |
47 | 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 | 49 | import { UtilsService } from '@core/services/utils.service'; |
50 | 50 | import { WidgetService } from '@core/http/widget.service'; |
51 | 51 | import { NULL_UUID } from '@shared/models/id/has-uuid'; |
... | ... | @@ -686,9 +686,6 @@ export class ImportExportService { |
686 | 686 | |
687 | 687 | private editMissingAliases(widgets: Array<Widget>, isSingleWidget: boolean, |
688 | 688 | customTitle: string, missingEntityAliases: EntityAliases): Observable<EntityAliases> { |
689 | - const allowedEntityTypes: Array<EntityType | AliasEntityType> = | |
690 | - this.entityService.prepareAllowedEntityTypesList(null, true); | |
691 | - | |
692 | 689 | return this.dialog.open<EntityAliasesDialogComponent, EntityAliasesDialogData, |
693 | 690 | EntityAliases>(EntityAliasesDialogComponent, { |
694 | 691 | disableClose: true, |
... | ... | @@ -698,8 +695,7 @@ export class ImportExportService { |
698 | 695 | widgets, |
699 | 696 | customTitle, |
700 | 697 | isSingleWidget, |
701 | - disableAdd: true, | |
702 | - allowedEntityTypes | |
698 | + disableAdd: true | |
703 | 699 | } |
704 | 700 | }).afterClosed().pipe( |
705 | 701 | map((updatedEntityAliases) => { | ... | ... |
... | ... | @@ -37,6 +37,11 @@ export enum AliasFilterType { |
37 | 37 | entityViewSearchQuery = 'entityViewSearchQuery' |
38 | 38 | } |
39 | 39 | |
40 | +export const edgeAliasFilterTypes = new Array<string>( | |
41 | + AliasFilterType.edgeType, | |
42 | + AliasFilterType.edgeSearchQuery | |
43 | +); | |
44 | + | |
40 | 45 | export const aliasFilterTypeTranslationMap = new Map<AliasFilterType, string>( |
41 | 46 | [ |
42 | 47 | [ AliasFilterType.singleEntity, 'alias.filter-type-single-entity' ], | ... | ... |