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