Commit 886016c049b10bfe45d3b4c05a1620085b9e0e5e
Committed by
GitHub
Merge pull request #5212 from volodymyr-babak/dashboard-alias-fix
[Bug] Fixed alias issue due to edgesEnabled changes
Showing
4 changed files
with
26 additions
and
21 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,11 @@ 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 | + let allAliasFilterTypes: Array<AliasFilterType> = Object.values(AliasFilterType); | |
506 | + if (!authState.edgesSupportEnabled) { | |
507 | + allAliasFilterTypes = allAliasFilterTypes.filter(aliasFilterType => !edgeAliasFilterTypes.includes(aliasFilterType)); | |
508 | + } | |
499 | 509 | if (!entityTypes || !entityTypes.length) { |
500 | 510 | return allAliasFilterTypes; |
501 | 511 | } |
... | ... | @@ -622,14 +632,14 @@ export class EntityService { |
622 | 632 | case Authority.TENANT_ADMIN: |
623 | 633 | entityTypes.push(EntityType.DEVICE); |
624 | 634 | entityTypes.push(EntityType.ASSET); |
625 | - if (authState.edgesSupportEnabled) { | |
626 | - entityTypes.push(EntityType.EDGE); | |
627 | - } | |
628 | 635 | entityTypes.push(EntityType.ENTITY_VIEW); |
629 | 636 | entityTypes.push(EntityType.TENANT); |
630 | 637 | entityTypes.push(EntityType.CUSTOMER); |
631 | 638 | entityTypes.push(EntityType.USER); |
632 | 639 | entityTypes.push(EntityType.DASHBOARD); |
640 | + if (authState.edgesSupportEnabled) { | |
641 | + entityTypes.push(EntityType.EDGE); | |
642 | + } | |
633 | 643 | if (useAliasEntityTypes) { |
634 | 644 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
635 | 645 | entityTypes.push(AliasEntityType.CURRENT_TENANT); |
... | ... | @@ -638,13 +648,13 @@ export class EntityService { |
638 | 648 | case Authority.CUSTOMER_USER: |
639 | 649 | entityTypes.push(EntityType.DEVICE); |
640 | 650 | entityTypes.push(EntityType.ASSET); |
641 | - if (authState.edgesSupportEnabled) { | |
642 | - entityTypes.push(EntityType.EDGE); | |
643 | - } | |
644 | 651 | entityTypes.push(EntityType.ENTITY_VIEW); |
645 | 652 | entityTypes.push(EntityType.CUSTOMER); |
646 | 653 | entityTypes.push(EntityType.USER); |
647 | 654 | entityTypes.push(EntityType.DASHBOARD); |
655 | + if (authState.edgesSupportEnabled) { | |
656 | + entityTypes.push(EntityType.EDGE); | |
657 | + } | |
648 | 658 | if (useAliasEntityTypes) { |
649 | 659 | entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); |
650 | 660 | } | ... | ... |
... | ... | @@ -121,7 +121,6 @@ import { |
121 | 121 | DisplayWidgetTypesPanelData |
122 | 122 | } from '@home/components/dashboard-page/widget-types-panel.component'; |
123 | 123 | import { DashboardWidgetSelectComponent } from '@home/components/dashboard-page/dashboard-widget-select.component'; |
124 | -import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; | |
125 | 124 | import { MobileService } from '@core/services/mobile.service'; |
126 | 125 | |
127 | 126 | import { |
... | ... | @@ -193,8 +192,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC |
193 | 192 | isToolbarOpenedAnimate = false; |
194 | 193 | isRightLayoutOpened = false; |
195 | 194 | |
196 | - allowedEntityTypes: Array<EntityType | AliasEntityType> = null; | |
197 | - | |
198 | 195 | editingWidget: Widget = null; |
199 | 196 | editingWidgetLayout: WidgetLayout = null; |
200 | 197 | editingWidgetOriginal: Widget = null; |
... | ... | @@ -409,8 +406,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC |
409 | 406 | }; |
410 | 407 | this.window.parent.postMessage(JSON.stringify(message), '*'); |
411 | 408 | } |
412 | - | |
413 | - this.allowedEntityTypes = this.entityService.prepareAllowedEntityTypesList(null, true); | |
414 | 409 | } |
415 | 410 | |
416 | 411 | private reset() { |
... | ... | @@ -658,8 +653,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC |
658 | 653 | data: { |
659 | 654 | entityAliases: deepClone(this.dashboard.configuration.entityAliases), |
660 | 655 | widgets: this.dashboardUtils.getWidgetsArray(this.dashboard), |
661 | - isSingleEntityAlias: false, | |
662 | - allowedEntityTypes: this.allowedEntityTypes | |
656 | + isSingleEntityAlias: false | |
663 | 657 | } |
664 | 658 | }).afterClosed().subscribe((entityAliases) => { |
665 | 659 | if (entityAliases) { | ... | ... |
... | ... | @@ -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' ], | ... | ... |