From 7a4493887a5077fd87baece8c99aa765566f72ae Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 10 Mar 2021 17:43:27 +0200 Subject: [PATCH 1/2] UI: Change default datasource type in alarm widget to created widget --- .../dashboard-page/dashboard-page.component.ts | 5 +++++ .../home/components/widget/widget-config.component.html | 9 --------- .../home/components/widget/widget-config.component.ts | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index 5b8c7a17dc..4562e8ba23 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -62,6 +62,7 @@ import { MediaBreakpoints } from '@shared/models/constants'; import { AuthUser } from '@shared/models/user.model'; import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { + DatasourceType, Widget, WidgetConfig, WidgetInfo, @@ -891,6 +892,10 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); config.title = 'New ' + widgetTypeInfo.widgetName; config.datasources = []; + config.alarmSource = { + type: DatasourceType.entity, + dataKeys: config.alarmSource.dataKeys + }; const newWidget: Widget = { isSystemType: widget.isSystemType, bundleAlias: widget.bundleAlias, diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html index 8b745c480f..ea1cd70932 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html @@ -263,15 +263,6 @@
- - - - - - Date: Wed, 10 Mar 2021 18:36:17 +0200 Subject: [PATCH 2/2] UI: Refactoring --- .../dashboard-page/dashboard-page.component.ts | 12 +++++++----- .../components/widget/widget-config.component.ts | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index 4562e8ba23..70ee0c269c 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -47,7 +47,7 @@ import { } from '@app/shared/models/dashboard.models'; import { WINDOW } from '@core/services/window.service'; import { WindowMessage } from '@shared/models/window-message.model'; -import { deepClone, isDefined } from '@app/core/utils'; +import { deepClone, isDefined, isDefinedAndNotNull } from '@app/core/utils'; import { DashboardContext, DashboardPageLayout, @@ -892,10 +892,12 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); config.title = 'New ' + widgetTypeInfo.widgetName; config.datasources = []; - config.alarmSource = { - type: DatasourceType.entity, - dataKeys: config.alarmSource.dataKeys - }; + if (isDefinedAndNotNull(config.alarmSource)) { + config.alarmSource = { + type: DatasourceType.entity, + dataKeys: config.alarmSource.dataKeys || [] + }; + } const newWidget: Widget = { isSystemType: widget.isSystemType, bundleAlias: widget.bundleAlias, 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 51bc8ad027..523913afe4 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 @@ -526,6 +526,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont const datasourceFormGroup = this.fb.group( { type: [datasource ? datasource.type : null, [Validators.required]], + name: [datasource ? datasource.name : null, []], entityAliasId: [datasource ? datasource.entityAliasId : null, datasource && (datasource.type === DatasourceType.entity || datasource.type === DatasourceType.entityCount) ? [Validators.required] : []],