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 18078d3255..46fe0ed9cb 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 5617ddcc9b..dbd20189ad 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/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]], 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 81086f046c..acc5dcbb79 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 bcd0cd4c80..b18806bce3 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; @@ -475,3 +476,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 6aad331561..2b1eb11de7 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -4679,6 +4679,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",