From 42f3a2def0548d65cbd1b392e24595f7008537d7 Mon Sep 17 00:00:00 2001 From: devaskim Date: Thu, 6 Oct 2022 19:32:19 +0500 Subject: [PATCH 1/2] Added support of custom title instead of data key label. --- .../widget/lib/alarms-table-widget.component.ts | 5 +++-- .../widget/lib/entities-table-widget.component.ts | 5 +++-- .../cards/entities-table-key-settings.component.html | 4 ++++ .../cards/entities-table-key-settings.component.ts | 2 ++ .../home/components/widget/lib/table-widget.models.ts | 8 ++++++++ ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts index 2412f59f5f..88cb82e8fd 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts @@ -75,6 +75,7 @@ import { getColumnWidth, getRowStyleInfo, getTableCellButtonActions, + getHeaderTitle, noDataMessage, prepareTableCellButtonActions, RowStyleInfo, @@ -407,11 +408,11 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, if (this.subscription.alarmSource) { this.subscription.alarmSource.dataKeys.forEach((alarmDataKey) => { const dataKey: EntityColumn = deepClone(alarmDataKey) as EntityColumn; + const keySettings: TableWidgetDataKeySettings = dataKey.settings; dataKey.entityKey = dataKeyToEntityKey(alarmDataKey); dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label); - dataKey.title = dataKey.label; + dataKey.title = getHeaderTitle(dataKey, keySettings, this.utils); dataKey.def = 'def' + this.columns.length; - const keySettings: TableWidgetDataKeySettings = dataKey.settings; if (dataKey.type === DataKeyType.alarm && !isDefined(keySettings.columnWidth)) { const alarmField = alarmFields[dataKey.name]; if (alarmField && alarmField.time) { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts index 8685fb8e86..84b8bd50cd 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts @@ -78,6 +78,7 @@ import { getColumnDefaultVisibility, getColumnSelectionAvailability, getColumnWidth, + getHeaderTitle, getEntityValue, getRowStyleInfo, getTableCellButtonActions, @@ -426,11 +427,11 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni } dataKeys.push(dataKey); + const keySettings: TableWidgetDataKeySettings = dataKey.settings; dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label); - dataKey.title = dataKey.label; + dataKey.title = getHeaderTitle(dataKey, keySettings, this.utils); dataKey.def = 'def' + this.columns.length; dataKey.sortable = !dataKey.usePostProcessing && (!dataKey.aggregationType || dataKey.aggregationType === AggregationType.NONE); - const keySettings: TableWidgetDataKeySettings = dataKey.settings; if (dataKey.type === DataKeyType.entityField && !isDefined(keySettings.columnWidth) || keySettings.columnWidth === '0px') { const entityField = entityFields[dataKey.name]; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.html index 8714a5b820..736fbade96 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.html @@ -16,6 +16,10 @@ -->
+ + widgets.table.custom-title + + widgets.table.column-width diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.ts index 738e99223c..8301e81bfb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/entities-table-key-settings.component.ts @@ -40,6 +40,7 @@ export class EntitiesTableKeySettingsComponent extends WidgetSettingsComponent { protected defaultSettings(): WidgetSettings { return { + customTitle: '', columnWidth: '0px', useCellStyleFunction: false, cellStyleFunction: '', @@ -52,6 +53,7 @@ export class EntitiesTableKeySettingsComponent extends WidgetSettingsComponent { protected onSettingsSet(settings: WidgetSettings) { this.entitiesTableKeySettingsForm = this.fb.group({ + customTitle: [settings.customTitle, []], columnWidth: [settings.columnWidth, []], useCellStyleFunction: [settings.useCellStyleFunction, []], cellStyleFunction: [settings.cellStyleFunction, [Validators.required]], diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts index 0747ddffc1..6b2dd016da 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts @@ -43,6 +43,7 @@ export interface TableWidgetSettings { } export interface TableWidgetDataKeySettings { + customTitle?: string; columnWidth?: string; useCellStyleFunction: boolean; cellStyleFunction?: string; @@ -474,3 +475,10 @@ export function constructTableCssString(widgetConfig: WidgetConfig): string { '}'; return cssString; } + +export function getHeaderTitle(dataKey: DataKey, keySettings: TableWidgetDataKeySettings, utils: UtilsService) { + if (isDefined(keySettings.customTitle) && isNotEmptyStr(keySettings.customTitle)) { + return utils.customTranslation(keySettings.customTitle, keySettings.customTitle); + } + return dataKey.label; +} diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 434535a785..dd8b2e006c 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -4656,6 +4656,7 @@ "entity-label-column-title": "Entity label column title", "display-entity-type": "Display entity type column", "default-sort-order": "Default sort order", + "custom-title": "Custom header title", "column-width": "Column width (px or %)", "default-column-visibility": "Default column visibility", "column-visibility-visible": "Visible", From 760e3805521d08e40cd612edc3108b94cd28af22 Mon Sep 17 00:00:00 2001 From: devaskim Date: Wed, 12 Oct 2022 11:07:31 +0500 Subject: [PATCH 2/2] Add custom title for data keys in alarm table widget. --- .../settings/alarm/alarms-table-key-settings.component.html | 4 ++++ .../lib/settings/alarm/alarms-table-key-settings.component.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.html index 6931d256e8..d592bb3749 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.html @@ -16,6 +16,10 @@ -->
+ + widgets.table.custom-title + + widgets.table.column-width diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.ts index 9f9cbbf5e1..3f5c257b38 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/alarm/alarms-table-key-settings.component.ts @@ -40,6 +40,7 @@ export class AlarmsTableKeySettingsComponent extends WidgetSettingsComponent { protected defaultSettings(): WidgetSettings { return { + customTitle: '', columnWidth: '0px', useCellStyleFunction: false, cellStyleFunction: '', @@ -52,6 +53,7 @@ export class AlarmsTableKeySettingsComponent extends WidgetSettingsComponent { protected onSettingsSet(settings: WidgetSettings) { this.alarmsTableKeySettingsForm = this.fb.group({ + customTitle: [settings.customTitle, []], columnWidth: [settings.columnWidth, []], useCellStyleFunction: [settings.useCellStyleFunction, []], cellStyleFunction: [settings.cellStyleFunction, [Validators.required]],