Browse Source

UI: added pattern support for widget title on export

pull/10500/head
rusikv 2 years ago
parent
commit
bb027cb987
  1. 5
      ui-ngx/src/app/modules/home/models/dashboard-component.models.ts
  2. 2
      ui-ngx/src/app/shared/import-export/import-export.service.ts
  3. 1
      ui-ngx/src/app/shared/models/widget.models.ts

5
ui-ngx/src/app/modules/home/models/dashboard-component.models.ts

@ -26,7 +26,7 @@ import {
import { WidgetLayout, WidgetLayouts } from '@app/shared/models/dashboard.models';
import { IDashboardWidget, WidgetAction, WidgetContext, WidgetHeaderAction } from './widget-component.models';
import { Timewindow } from '@shared/models/time/time.models';
import { Observable, of, Subject } from 'rxjs';
import { Observable, of, Subject, tap } from 'rxjs';
import {
convertKeysToCamelCase,
formattedDataFormDatasourceData,
@ -440,7 +440,8 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
const title = isDefined(this.widgetContext.widgetTitle)
&& this.widgetContext.widgetTitle.length ? this.widgetContext.widgetTitle : this.widget.config.title;
this.title$ = this.widgetContext.registerLabelPattern(title, this.title$);
this.title$ = this.widgetContext.registerLabelPattern(title, this.title$).pipe(
tap(value => this.widget.config.titleByPattern = value));
this.titleTooltip = isDefined(this.widgetContext.widgetTitleTooltip)
&& this.widgetContext.widgetTitleTooltip.length ? this.widgetContext.widgetTitleTooltip : this.widget.config.titleTooltip;
this.titleTooltip = this.dashboard.utils.customTranslation(this.titleTooltip, this.titleTooltip);

2
ui-ngx/src/app/shared/import-export/import-export.service.ts

@ -200,7 +200,7 @@ export class ImportExportService {
public exportWidget(dashboard: Dashboard, sourceState: string, sourceLayout: DashboardLayoutId, widget: Widget) {
const widgetItem = this.itembuffer.prepareWidgetItem(dashboard, sourceState, sourceLayout, widget);
let name = widgetItem.widget.config.title;
let name = widgetItem.widget.config.titleByPattern;
name = name.toLowerCase().replace(/\W/g, '_');
this.exportToPc(this.prepareExport(widgetItem), name);
}

1
ui-ngx/src/app/shared/models/widget.models.ts

@ -726,6 +726,7 @@ export enum WidgetConfigMode {
export interface WidgetConfig {
configMode?: WidgetConfigMode;
title?: string;
titleByPattern?: string;
titleFont?: Font;
titleColor?: string;
titleIcon?: string;

Loading…
Cancel
Save