diff --git a/ui-ngx/src/app/core/http/rule-chain.service.ts b/ui-ngx/src/app/core/http/rule-chain.service.ts index 749fb39e72..0e857c4570 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -33,6 +33,7 @@ import { LinkLabel, RuleNodeComponentDescriptor, RuleNodeConfiguration, + RuleNodeConfigurationComponent, ScriptLanguage, TestScriptInputParams, TestScriptResult @@ -181,7 +182,7 @@ export class RuleChainService { } public registerSystemRuleNodeConfigModule(module: any) { - Object.assign(this.ruleNodeConfigComponents, this.resourcesService.extractComponentsFromModule(module, true)); + Object.assign(this.ruleNodeConfigComponents, this.resourcesService.extractComponentsFromModule(module, RuleNodeConfigurationComponent, true)); } private loadRuleNodeComponents(ruleChainType: RuleChainType, config?: RequestConfig): Observable> { diff --git a/ui-ngx/src/app/core/http/widget.service.ts b/ui-ngx/src/app/core/http/widget.service.ts index ebf390866c..030d53de6f 100644 --- a/ui-ngx/src/app/core/http/widget.service.ts +++ b/ui-ngx/src/app/core/http/widget.service.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Injectable } from '@angular/core'; +import { Injectable, Type } from '@angular/core'; import { defaultHttpOptionsFromConfig, RequestConfig } from './http-utils'; import { Observable, of, ReplaySubject } from 'rxjs'; import { HttpClient } from '@angular/common/http'; @@ -24,7 +24,10 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; import { BaseWidgetType, DeprecatedFilter, - fullWidgetTypeFqn, migrateWidgetTypeToDynamicForms, + fullWidgetTypeFqn, + IWidgetSettingsComponent, + migrateWidgetTypeToDynamicForms, + WidgetSettingsComponent, WidgetType, widgetType, WidgetTypeDetails, @@ -36,6 +39,11 @@ import { filter, map, mergeMap, tap } from 'rxjs/operators'; import { WidgetTypeId } from '@shared/models/id/widget-type-id'; import { NULL_UUID } from '@shared/models/id/has-uuid'; import { ActivationEnd, Router } from '@angular/router'; +import { + BasicWidgetConfigComponent, + IBasicWidgetConfigComponent +} from '@home/components/widget/config/widget-config.component.models'; +import { ResourcesService } from '@core/services/resources.service'; @Injectable({ providedIn: 'root' @@ -50,9 +58,13 @@ export class WidgetService { private loadWidgetsBundleCacheSubject: ReplaySubject; + private basicWidgetSettingsComponentsMap: { [key: string]: Type } = {}; + private widgetSettingsComponentsMap: { [key: string]: Type } = {}; + constructor( private http: HttpClient, - private router: Router + private router: Router, + private resourcesService: ResourcesService, ) { this.router.events.pipe(filter(event => event instanceof ActivationEnd)).subscribe( () => { @@ -287,6 +299,30 @@ export class WidgetService { this.widgetsInfoInMemoryCache.set(widgetInfo.fullFqn, widgetInfo); } + public registerBasicWidgetConfigComponents(module: any) { + Object.assign(this.basicWidgetSettingsComponentsMap, this.resourcesService.extractComponentsFromModule(module, BasicWidgetConfigComponent)); + } + + public getBasicWidgetSettingsComponentBySelector(selector: string): Type { + return this.basicWidgetSettingsComponentsMap[selector]; + } + + public putBasicWidgetSettingsComponentToMap(selector: string, compType: Type) { + this.basicWidgetSettingsComponentsMap[selector] = compType; + } + + public registerWidgetSettingsComponents(module: any) { + Object.assign(this.widgetSettingsComponentsMap, this.resourcesService.extractComponentsFromModule(module, WidgetSettingsComponent)); + } + + public getWidgetSettingsComponentTypeBySelector(selector: string): Type { + return this.widgetSettingsComponentsMap[selector]; + } + + public putWidgetSettingsComponentToMap(selector: string, compType: Type) { + this.widgetSettingsComponentsMap[selector] = compType; + } + private widgetTypeUpdated(updatedWidgetType: BaseWidgetType): void { this.deleteWidgetInfoFromCache(fullWidgetTypeFqn(updatedWidgetType)); } diff --git a/ui-ngx/src/app/core/services/resources.service.ts b/ui-ngx/src/app/core/services/resources.service.ts index 72cea30a1a..e2ee21c738 100644 --- a/ui-ngx/src/app/core/services/resources.service.ts +++ b/ui-ngx/src/app/core/services/resources.service.ts @@ -265,12 +265,15 @@ export class ResourcesService { ); } - public extractComponentsFromModule(module: any, isCamelCaseSelector = false): ComponentsSelectorMap { + public extractComponentsFromModule(module: any, instanceFilter?: any, isCamelCaseSelector = false): ComponentsSelectorMap { const modulesWithComponents = this.extractModulesWithComponents(module); const componentMap: ComponentsSelectorMap = {}; const processComponents = (components: Array<ɵComponentDef>) => { components.forEach(item => { + if (instanceFilter && !(item.type.prototype instanceof instanceFilter)) { + return; + } let selector = extractSelectorFromComponent(item); if (isCamelCaseSelector) { selector = camelCase(selector); diff --git a/ui-ngx/src/app/modules/home/components/widget/config/basic/basic-widget-config.module.ts b/ui-ngx/src/app/modules/home/components/widget/config/basic/basic-widget-config.module.ts index 800deec7e5..24cb04cca6 100644 --- a/ui-ngx/src/app/modules/home/components/widget/config/basic/basic-widget-config.module.ts +++ b/ui-ngx/src/app/modules/home/components/widget/config/basic/basic-widget-config.module.ts @@ -14,10 +14,10 @@ /// limitations under the License. /// -import { NgModule, Type } from '@angular/core'; +import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SharedModule } from '@shared/shared.module'; -import { IBasicWidgetConfigComponent } from '@home/components/widget/config/widget-config.component.models'; +import { WidgetService } from '@core/http/widget.service'; import { WidgetConfigComponentsModule } from '@home/components/widget/config/widget-config-components.module'; import { SimpleCardBasicConfigComponent @@ -251,47 +251,7 @@ import { ] }) export class BasicWidgetConfigModule { + constructor(private widgetService: WidgetService) { + this.widgetService.registerBasicWidgetConfigComponents(this.constructor) + } } - -export const basicWidgetConfigComponentsMap: {[key: string]: Type} = { - 'tb-simple-card-basic-config': SimpleCardBasicConfigComponent, - 'tb-entities-table-basic-config': EntitiesTableBasicConfigComponent, - 'tb-timeseries-table-basic-config': TimeseriesTableBasicConfigComponent, - 'tb-flot-basic-config': FlotBasicConfigComponent, - 'tb-alarms-table-basic-config': AlarmsTableBasicConfigComponent, - 'tb-value-card-basic-config': ValueCardBasicConfigComponent, - 'tb-aggregated-value-card-basic-config': AggregatedValueCardBasicConfigComponent, - 'tb-alarm-count-basic-config': AlarmCountBasicConfigComponent, - 'tb-entity-count-basic-config': EntityCountBasicConfigComponent, - 'tb-battery-level-basic-config': BatteryLevelBasicConfigComponent, - 'tb-wind-speed-direction-basic-config': WindSpeedDirectionBasicConfigComponent, - 'tb-signal-strength-basic-config': SignalStrengthBasicConfigComponent, - 'tb-value-chart-card-basic-config': ValueChartCardBasicConfigComponent, - 'tb-progress-bar-basic-config': ProgressBarBasicConfigComponent, - 'tb-radial-gauge-basic-config': RadialGaugeBasicConfigComponent, - 'tb-thermometer-scale-gauge-basic-config': ThermometerScaleGaugeBasicConfigComponent, - 'tb-compass-gauge-basic-config': CompassGaugeBasicConfigComponent, - 'tb-liquid-level-card-basic-config': LiquidLevelCardBasicConfigComponent, - 'tb-doughnut-basic-config': DoughnutBasicConfigComponent, - 'tb-range-chart-basic-config': RangeChartBasicConfigComponent, - 'tb-bar-chart-with-labels-basic-config': BarChartWithLabelsBasicConfigComponent, - 'tb-single-switch-basic-config': SingleSwitchBasicConfigComponent, - 'tb-action-button-basic-config': ActionButtonBasicConfigComponent, - 'tb-segmented-button-basic-config': SegmentedButtonBasicConfigComponent, - 'tb-command-button-basic-config': CommandButtonBasicConfigComponent, - 'tb-power-button-basic-config': PowerButtonBasicConfigComponent, - 'tb-slider-basic-config': SliderBasicConfigComponent, - 'tb-toggle-button-basic-config': ToggleButtonBasicConfigComponent, - 'tb-time-series-chart-basic-config': TimeSeriesChartBasicConfigComponent, - 'tb-status-widget-basic-config': StatusWidgetBasicConfigComponent, - 'tb-pie-chart-basic-config': PieChartBasicConfigComponent, - 'tb-bar-chart-basic-config': BarChartBasicConfigComponent, - 'tb-polar-area-chart-basic-config': PolarAreaChartBasicConfigComponent, - 'tb-radar-chart-basic-config': RadarChartBasicConfigComponent, - 'tb-digital-simple-gauge-basic-config': DigitalSimpleGaugeBasicConfigComponent, - 'tb-mobile-app-qr-code-basic-config': MobileAppQrCodeBasicConfigComponent, - 'tb-label-card-basic-config': LabelCardBasicConfigComponent, - 'tb-label-value-card-basic-config': LabelValueCardBasicConfigComponent, - 'tb-unread-notification-basic-config': UnreadNotificationBasicConfigComponent, - 'tb-scada-symbol-basic-config': ScadaSymbolBasicConfigComponent -}; diff --git a/ui-ngx/src/app/modules/home/components/widget/config/widget-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/config/widget-settings.component.ts index ab63e0e55d..1f3e9bcbc7 100644 --- a/ui-ngx/src/app/modules/home/components/widget/config/widget-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/config/widget-settings.component.ts @@ -39,7 +39,6 @@ import { import { Subscription } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; import { DynamicFormData, IWidgetSettingsComponent, Widget, WidgetSettings } from '@shared/models/widget.models'; -import { widgetSettingsComponentsMap } from '@home/components/widget/lib/settings/widget-settings.module'; import { Dashboard } from '@shared/models/dashboard.models'; import { WidgetService } from '@core/http/widget.service'; import { IAliasController } from '@core/api/widget-api.models'; @@ -215,7 +214,7 @@ export class WidgetSettingsComponent implements ControlValueAccessor, OnDestroy, this.definedSettingsComponent = null; } if (this.settingsDirective && this.settingsDirective.length) { - const componentType = widgetSettingsComponentsMap[this.settingsDirective]; + const componentType = this.widgetService.getWidgetSettingsComponentTypeBySelector(this.settingsDirective); if (!componentType) { this.definedDirectiveError = this.translate.instant('widget-config.settings-component-not-found', {selector: this.settingsDirective}); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/widget-settings.module.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/widget-settings.module.ts index 4b5f3a1ad0..0aee57babb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/widget-settings.module.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/widget-settings.module.ts @@ -14,14 +14,14 @@ /// limitations under the License. /// -import { NgModule, Type } from '@angular/core'; -import { - QrCodeWidgetSettingsComponent -} from '@home/components/widget/lib/settings/cards/qrcode-widget-settings.component'; +import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SharedModule } from '@shared/shared.module'; +import { WidgetService } from '@core/http/widget.service'; import { SharedHomeComponentsModule } from '@home/components/shared-home-components.module'; -import { IWidgetSettingsComponent } from '@shared/models/widget.models'; +import { + QrCodeWidgetSettingsComponent +} from '@home/components/widget/lib/settings/cards/qrcode-widget-settings.component'; import { TimeseriesTableWidgetSettingsComponent } from '@home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component'; @@ -366,7 +366,7 @@ import { UnreadNotificationWidgetSettingsComponent } from '@home/components/widget/lib/settings/cards/unread-notification-widget-settings.component'; import { -ScadaSymbolWidgetSettingsComponent + ScadaSymbolWidgetSettingsComponent } from '@home/components/widget/lib/settings/scada/scada-symbol-widget-settings.component'; import { SegmentedButtonWidgetSettingsComponent @@ -643,105 +643,7 @@ import { ] }) export class WidgetSettingsModule { + constructor(private widgetService: WidgetService) { + this.widgetService.registerWidgetSettingsComponents(this.constructor) + } } - -export const widgetSettingsComponentsMap: {[key: string]: Type} = { - 'tb-qrcode-widget-settings': QrCodeWidgetSettingsComponent, - 'tb-mobile-app-qr-code-widget-settings': MobileAppQrCodeWidgetSettingsComponent, - 'tb-timeseries-table-widget-settings': TimeseriesTableWidgetSettingsComponent, - 'tb-timeseries-table-key-settings': TimeseriesTableKeySettingsComponent, - 'tb-timeseries-table-latest-key-settings': TimeseriesTableLatestKeySettingsComponent, - 'tb-markdown-widget-settings': MarkdownWidgetSettingsComponent, - 'tb-label-widget-settings': LabelWidgetSettingsComponent, - 'tb-simple-card-widget-settings': SimpleCardWidgetSettingsComponent, - 'tb-dashboard-state-widget-settings': DashboardStateWidgetSettingsComponent, - 'tb-entities-hierarchy-widget-settings': EntitiesHierarchyWidgetSettingsComponent, - 'tb-html-card-widget-settings': HtmlCardWidgetSettingsComponent, - 'tb-entities-table-widget-settings': EntitiesTableWidgetSettingsComponent, - 'tb-entities-table-key-settings': EntitiesTableKeySettingsComponent, - 'tb-alarms-table-widget-settings': AlarmsTableWidgetSettingsComponent, - 'tb-alarms-table-key-settings': AlarmsTableKeySettingsComponent, - 'tb-analogue-radial-gauge-widget-settings': AnalogueRadialGaugeWidgetSettingsComponent, - 'tb-analogue-linear-gauge-widget-settings': AnalogueLinearGaugeWidgetSettingsComponent, - 'tb-analogue-compass-widget-settings': AnalogueCompassWidgetSettingsComponent, - 'tb-digital-gauge-widget-settings': DigitalGaugeWidgetSettingsComponent, - 'tb-flot-line-widget-settings': FlotLineWidgetSettingsComponent, - 'tb-flot-bar-widget-settings': FlotBarWidgetSettingsComponent, - 'tb-flot-line-key-settings': FlotLineKeySettingsComponent, - 'tb-flot-bar-key-settings': FlotBarKeySettingsComponent, - 'tb-flot-latest-key-settings': FlotLatestKeySettingsComponent, - 'tb-flot-pie-widget-settings': FlotPieWidgetSettingsComponent, - 'tb-flot-pie-key-settings': FlotPieKeySettingsComponent, - 'tb-chart-widget-settings': ChartWidgetSettingsComponent, - 'tb-doughnut-chart-widget-settings': DoughnutChartWidgetSettingsComponent, - 'tb-round-switch-widget-settings': RoundSwitchWidgetSettingsComponent, - 'tb-switch-control-widget-settings': SwitchControlWidgetSettingsComponent, - 'tb-slide-toggle-widget-settings': SlideToggleWidgetSettingsComponent, - 'tb-persistent-table-widget-settings': PersistentTableWidgetSettingsComponent, - 'tb-update-device-attribute-widget-settings': UpdateDeviceAttributeWidgetSettingsComponent, - 'tb-send-rpc-widget-settings': SendRpcWidgetSettingsComponent, - 'tb-led-indicator-widget-settings': LedIndicatorWidgetSettingsComponent, - 'tb-knob-control-widget-settings': KnobControlWidgetSettingsComponent, - 'tb-rpc-terminal-widget-settings': RpcTerminalWidgetSettingsComponent, - 'tb-rpc-shell-widget-settings': RpcShellWidgetSettingsComponent, - 'tb-date-range-navigator-widget-settings': DateRangeNavigatorWidgetSettingsComponent, - 'tb-edge-quick-overview-widget-settings': EdgeQuickOverviewWidgetSettingsComponent, - 'tb-gateway-config-widget-settings': GatewayConfigWidgetSettingsComponent, - 'tb-gateway-config-single-device-widget-settings': GatewayConfigSingleDeviceWidgetSettingsComponent, - 'tb-gateway-events-widget-settings': GatewayEventsWidgetSettingsComponent, - 'tb-gpio-control-widget-settings': GpioControlWidgetSettingsComponent, - 'tb-gpio-panel-widget-settings': GpioPanelWidgetSettingsComponent, - 'tb-navigation-card-widget-settings': NavigationCardWidgetSettingsComponent, - 'tb-navigation-cards-widget-settings': NavigationCardsWidgetSettingsComponent, - 'tb-device-claiming-widget-settings': DeviceClaimingWidgetSettingsComponent, - 'tb-update-integer-attribute-widget-settings': UpdateIntegerAttributeWidgetSettingsComponent, - 'tb-update-double-attribute-widget-settings': UpdateDoubleAttributeWidgetSettingsComponent, - 'tb-update-string-attribute-widget-settings': UpdateStringAttributeWidgetSettingsComponent, - 'tb-update-boolean-attribute-widget-settings': UpdateBooleanAttributeWidgetSettingsComponent, - 'tb-update-image-attribute-widget-settings': UpdateImageAttributeWidgetSettingsComponent, - 'tb-update-date-attribute-widget-settings': UpdateDateAttributeWidgetSettingsComponent, - 'tb-update-location-attribute-widget-settings': UpdateLocationAttributeWidgetSettingsComponent, - 'tb-update-json-attribute-widget-settings': UpdateJsonAttributeWidgetSettingsComponent, - 'tb-photo-camera-input-widget-settings': PhotoCameraInputWidgetSettingsComponent, - 'tb-update-multiple-attributes-widget-settings': UpdateMultipleAttributesWidgetSettingsComponent, - 'tb-update-multiple-attributes-key-settings': UpdateMultipleAttributesKeySettingsComponent, - 'tb-map-widget-settings': MapWidgetSettingsComponent, - 'tb-route-map-widget-settings': RouteMapWidgetSettingsComponent, - 'tb-trip-animation-widget-settings': TripAnimationWidgetSettingsComponent, - 'tb-gateway-logs-settings': GatewayLogsSettingsComponent, - 'tb-gateway-service-rpc-settings':GatewayServiceRPCSettingsComponent, - 'tb-doc-links-widget-settings': DocLinksWidgetSettingsComponent, - 'tb-quick-links-widget-settings': QuickLinksWidgetSettingsComponent, - 'tb-value-card-widget-settings': ValueCardWidgetSettingsComponent, - 'tb-aggregated-value-card-key-settings': AggregatedValueCardKeySettingsComponent, - 'tb-aggregated-value-card-widget-settings': AggregatedValueCardWidgetSettingsComponent, - 'tb-alarm-count-widget-settings': AlarmCountWidgetSettingsComponent, - 'tb-entity-count-widget-settings': EntityCountWidgetSettingsComponent, - 'tb-battery-level-widget-settings': BatteryLevelWidgetSettingsComponent, - 'tb-wind-speed-direction-widget-settings': WindSpeedDirectionWidgetSettingsComponent, - 'tb-signal-strength-widget-settings': SignalStrengthWidgetSettingsComponent, - 'tb-value-chart-card-widget-settings': ValueChartCardWidgetSettingsComponent, - 'tb-progress-bar-widget-settings': ProgressBarWidgetSettingsComponent, - 'tb-liquid-level-card-widget-settings': LiquidLevelCardWidgetSettingsComponent, - 'tb-doughnut-widget-settings': DoughnutWidgetSettingsComponent, - 'tb-range-chart-widget-settings': RangeChartWidgetSettingsComponent, - 'tb-bar-chart-with-labels-widget-settings': BarChartWithLabelsWidgetSettingsComponent, - 'tb-single-switch-widget-settings': SingleSwitchWidgetSettingsComponent, - 'tb-action-button-widget-settings': ActionButtonWidgetSettingsComponent, - 'tb-segmented-button-widget-settings': SegmentedButtonWidgetSettingsComponent, - 'tb-command-button-widget-settings': CommandButtonWidgetSettingsComponent, - 'tb-power-button-widget-settings': PowerButtonWidgetSettingsComponent, - 'tb-slider-widget-settings': SliderWidgetSettingsComponent, - 'tb-toggle-button-widget-settings': ToggleButtonWidgetSettingsComponent, - 'tb-time-series-chart-key-settings': TimeSeriesChartKeySettingsComponent, - 'tb-time-series-chart-widget-settings': TimeSeriesChartWidgetSettingsComponent, - 'tb-status-widget-settings': StatusWidgetSettingsComponent, - 'tb-pie-chart-widget-settings': PieChartWidgetSettingsComponent, - 'tb-bar-chart-widget-settings': BarChartWidgetSettingsComponent, - 'tb-polar-area-chart-widget-settings': PolarAreaChartWidgetSettingsComponent, - 'tb-radar-chart-widget-settings': RadarChartWidgetSettingsComponent, - 'tb-label-card-widget-settings': LabelCardWidgetSettingsComponent, - 'tb-label-value-card-widget-settings': LabelValueCardWidgetSettingsComponent, - 'tb-unread-notification-widget-settings': UnreadNotificationWidgetSettingsComponent, - 'tb-scada-symbol-widget-settings': ScadaSymbolWidgetSettingsComponent -}; diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-component.service.ts b/ui-ngx/src/app/modules/home/components/widget/widget-component.service.ts index d9b18d896a..c044dca684 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-component.service.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-component.service.ts @@ -36,7 +36,8 @@ import { ResourcesService } from '@core/services/resources.service'; import { - IWidgetSettingsComponent, migrateWidgetTypeToDynamicForms, + IWidgetSettingsComponent, + migrateWidgetTypeToDynamicForms, Widget, widgetActionSources, WidgetControllerDescriptor, @@ -58,8 +59,6 @@ import tinycolor from 'tinycolor2'; import moment from 'moment'; import { IModulesMap } from '@modules/common/modules-map.models'; import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens'; -import { widgetSettingsComponentsMap } from '@home/components/widget/lib/settings/widget-settings.module'; -import { basicWidgetConfigComponentsMap } from '@home/components/widget/config/basic/basic-widget-config.module'; import { IBasicWidgetConfigComponent } from '@home/components/widget/config/widget-config.component.models'; import { compileTbFunction, TbFunction } from '@shared/models/js-function.models'; import { HttpClient } from '@angular/common/http'; @@ -437,17 +436,17 @@ export class WidgetComponentService { basicDirectives.push(widgetInfo.basicModeDirective); } - this.expandSettingComponentMap(widgetSettingsComponentsMap, directives, modulesWithComponents); - this.expandSettingComponentMap(basicWidgetConfigComponentsMap, basicDirectives, modulesWithComponents); + this.expandSettingComponentMap(this.widgetService.putWidgetSettingsComponentToMap, directives, modulesWithComponents); + this.expandSettingComponentMap(this.widgetService.putBasicWidgetSettingsComponentToMap, basicDirectives, modulesWithComponents); } - private expandSettingComponentMap(settingsComponentsMap: {[key: string]: Type}, + private expandSettingComponentMap(putComponentToMap: (selector: string, comp: Type) => void, directives: string[], modulesWithComponents: ModulesWithComponents): void { if (directives.length) { directives.forEach(selector => { const compType = componentTypeBySelector(modulesWithComponents, selector); if (compType) { - settingsComponentsMap[selector] = compType; + putComponentToMap(selector, compType); } }); } diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts index 1721a7f068..595a8a2914 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts @@ -79,11 +79,11 @@ import { Filter, singleEntityFilterFromDeviceId } from '@shared/models/query/que import { FilterDialogComponent, FilterDialogData } from '@home/components/filter/filter-dialog.component'; import { ToggleHeaderOption } from '@shared/components/toggle-header.component'; import { coerceBoolean } from '@shared/decorators/coercion'; -import { basicWidgetConfigComponentsMap } from '@home/components/widget/config/basic/basic-widget-config.module'; import { TimewindowConfigData } from '@home/components/widget/config/timewindow-config-panel.component'; import { DataKeySettingsFunction } from '@home/components/widget/config/data-keys.component.models'; import { defaultFormProperties, FormProperty } from '@shared/models/dynamic-form.models'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { WidgetService } from '@core/http/widget.service'; import Timeout = NodeJS.Timeout; @Component({ @@ -205,6 +205,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe public translate: TranslateService, private fb: UntypedFormBuilder, private cd: ChangeDetectorRef, + private widgetService: WidgetService, private destroyRef: DestroyRef) { super(store); } @@ -435,7 +436,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe } private setupBasicModeConfig(isAdd = false) { - const componentType = basicWidgetConfigComponentsMap[this.modelValue.basicModeDirective]; + const componentType = this.widgetService.getBasicWidgetSettingsComponentBySelector(this.modelValue.basicModeDirective); if (!componentType) { this.basicModeDirectiveError = this.translate.instant('widget-config.settings-component-not-found', {selector: this.modelValue.basicModeDirective});