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] : []],