Browse Source

Add custom translate support for gauge widget titles and label widget

Apply CustomTranslatePipe to unitTitle and title properties in analogue
and digital gauge widgets, and add customTranslation to the label widget
controller script to support i18n translations.
pull/15239/head
Vladyslav_Prykhodko 7 months ago
committed by Vladyslav Prykhodko
parent
commit
ba5840ebd7
  1. 2
      application/src/main/data/json/system/widget_types/label_widget.json
  2. 3
      ui-ngx/src/app/modules/home/components/widget/lib/analogue-gauge.models.ts
  3. 5
      ui-ngx/src/app/modules/home/components/widget/lib/digital-gauge.ts

2
application/src/main/data/json/system/widget_types/label_widget.json

File diff suppressed because one or more lines are too long

3
ui-ngx/src/app/modules/home/components/widget/lib/analogue-gauge.models.ts

@ -26,6 +26,7 @@ import { TbUnit } from '@shared/models/unit.models';
import { ValueFormatProcessor } from '@shared/models/widget-settings.models';
import { UnitService } from '@core/services/unit.service';
import { DataKey } from '@shared/models/widget.models';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
export type AnimationRule = 'linear' | 'quad' | 'quint' | 'cycle'
| 'bounce' | 'elastic' | 'dequad' | 'dequint'
@ -201,7 +202,7 @@ export abstract class TbAnalogueGauge<S extends AnalogueGaugeSettings, O extends
minorTicks: settings.minorTicks || 2,
units: unitSymbols,
title: ((settings.showUnitTitle !== false) ?
(settings.unitTitle && settings.unitTitle.length > 0 ?
this.ctx.$injector.get(CustomTranslatePipe).transform(settings.unitTitle && settings.unitTitle.length > 0 ?
settings.unitTitle : dataKey.label) : ''),
borders: settings.showBorder !== false,

5
ui-ngx/src/app/modules/home/components/widget/lib/digital-gauge.ts

@ -34,6 +34,7 @@ import {
} from '@shared/models/widget-settings.models';
import { UnitService } from '@core/services/unit.service';
import { isNotEmptyTbUnits } from '@shared/models/unit.models';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import GenericOptions = CanvasGauges.GenericOptions;
// @dynamic
@ -55,7 +56,7 @@ export class TbCanvasDigitalGauge {
const keyColor = settings.defaultColor || dataKey.color;
this.localSettings.unitTitle = ((settings.showUnitTitle === true) ?
(settings.unitTitle && settings.unitTitle.length > 0 ?
ctx.$injector.get(CustomTranslatePipe).transform(settings.unitTitle && settings.unitTitle.length > 0 ?
settings.unitTitle : dataKey.label) : '');
this.localSettings.showUnitTitle = settings.showUnitTitle === true;
@ -87,7 +88,7 @@ export class TbCanvasDigitalGauge {
-TbCanvasDigitalGauge.toRadians(settings.donutStartAngle) : null;
this.localSettings.title = ((settings.showTitle === true) ?
(settings.title && settings.title.length > 0 ?
ctx.$injector.get(CustomTranslatePipe).transform(settings.title && settings.title.length > 0 ?
settings.title : dataKey.label) : '');
if (!this.localSettings.unitTitle && this.localSettings.showTimestamp) {

Loading…
Cancel
Save