UI: unitService to ctx, ref id from settings to objectHashCode and remove showZeroDecimals
@ -39,7 +39,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "firstPhaseValue",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.firstPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, id: 0}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.firstPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -49,7 +49,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "secondPhaseValue",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.secondPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, id: 1}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.secondPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -59,7 +59,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "thirdPhaseValue",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.thirdPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, id: 2}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.values.running) {\n element.show();\n ctx.api.font(element, ctx.properties.currentVoltageFont, ctx.properties.currentVoltageColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.thirdPhaseVoltage, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
@ -78,7 +78,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@ -78,7 +78,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.measured, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.measured, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 17 KiB |
@ -38,7 +38,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "export-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.exportValueFont, ctx.properties.exportValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.exportRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 3}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.exportValueFont, ctx.properties.exportValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.exportRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -48,7 +48,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "night-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 1}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -58,7 +58,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "off-peak-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.offPeakValueFont, ctx.properties.offPeakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.offPeakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 0}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.offPeakValueFont, ctx.properties.offPeakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.offPeakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -68,7 +68,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "peak-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.peakValueFont, ctx.properties.peakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.peakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 2}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.peakValueFont, ctx.properties.peakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.peakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
@ -78,7 +78,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -78,7 +78,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false}));\n} else {\n element.hide();\n}",
|
||||
"stateRenderFunction": "if (ctx.properties.value) {\n element.show();\n ctx.api.font(element, ctx.properties.valueFont, ctx.properties.valueColor);\n ctx.api.text(element, ctx.api.formatValue(ctx.values.value, {units: ctx.properties.units, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true}));\n} else {\n element.hide();\n}",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -38,7 +38,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "night-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 1}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -48,7 +48,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "off-peak-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.offPeakValueFont, ctx.properties.offPeakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.offPeakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 0}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.offPeakValueFont, ctx.properties.offPeakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.offPeakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -58,7 +58,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "peak-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.peakValueFont, ctx.properties.peakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.peakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 2}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.peakValueFont, ctx.properties.peakValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.peakRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@ -38,7 +38,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "day-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.dayValueFont, ctx.properties.dayValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.dayRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 0}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.dayValueFont, ctx.properties.dayValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.dayRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
@ -48,7 +48,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "night-rate",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true, showZeroDecimals: false, id: 1}));",
|
||||
"stateRenderFunction": "ctx.api.font(element, ctx.properties.nightValueFont, ctx.properties.nightValueColor);\nctx.api.text(element, ctx.api.formatValue(ctx.values.nightRate, {units: ctx.properties.units, decimals: 0, ignoreUnitSymbol: true}));",
|
||||
"actions": null
|
||||
},
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"tag": "value",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true, showZeroDecimals: false});\nctx.api.text(element, value);\n",
|
||||
"stateRenderFunction": "var value = ctx.api.formatValue(ctx.values.value, {units: ctx.properties.valueUnits, decimals: ctx.properties.valueDecimals, ignoreUnitSymbol: true});\nctx.api.text(element, value);\n",
|
||||
"actions": {
|
||||
"click": {
|
||||
"actionFunction": "ctx.api.callAction(event, 'displayClick');"
|
||||
|
||||
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@ -52,6 +52,7 @@ import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-
|
||||
import { UserSettingsService } from '@core/http/user-settings.service';
|
||||
import { ImagePipe } from '@shared/pipe/image.pipe';
|
||||
import { UtilsService } from '@core/services/utils.service';
|
||||
import { UnitService } from '@core/services/unit.service';
|
||||
|
||||
@Directive()
|
||||
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
||||
@ -92,6 +93,7 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid
|
||||
this.ctx.userSettingsService = this.$injector.get(UserSettingsService);
|
||||
this.ctx.utilsService = this.$injector.get(UtilsService);
|
||||
this.ctx.telemetryWsService = this.$injector.get(TelemetryWebsocketService);
|
||||
this.ctx.unitService = this.$injector.get(UnitService);
|
||||
this.ctx.date = this.$injector.get(DatePipe);
|
||||
this.ctx.imagePipe = this.$injector.get(ImagePipe);
|
||||
this.ctx.milliSecondsToTimeString = this.$injector.get(MillisecondsToTimeStringPipe);
|
||||
|
||||
@ -51,7 +51,7 @@ import {
|
||||
isUndefined,
|
||||
isUndefinedOrNull,
|
||||
mergeDeep,
|
||||
mergeDeepIgnoreArray,
|
||||
mergeDeepIgnoreArray, objectHashCode,
|
||||
parseFunction
|
||||
} from '@core/utils';
|
||||
import { BehaviorSubject, forkJoin, Observable, Observer, of, Subject } from 'rxjs';
|
||||
@ -82,7 +82,7 @@ import { TbUnit } from '@shared/models/unit.models';
|
||||
export interface ScadaSymbolApi {
|
||||
generateElementId: () => string;
|
||||
formatValue(value: any, dec?: number, units?: string, showZeroDecimals?: boolean): string | undefined;
|
||||
formatValue(value: any, settings: ValueFormatIdSettings): string;
|
||||
formatValue(value: any, settings: ValueFormatSettings): string;
|
||||
text: (element: Element | Element[], text: string) => void;
|
||||
font: (element: Element | Element[], font: Font, color: string) => void;
|
||||
icon: (element: Element | Element[], icon: string, size?: number, color?: string, center?: boolean) => void;
|
||||
@ -184,10 +184,6 @@ export interface ScadaSymbolMetadata {
|
||||
properties: FormProperty[];
|
||||
}
|
||||
|
||||
interface ValueFormatIdSettings extends ValueFormatSettings {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
export const emptyMetadata = (width?: number, height?: number): ScadaSymbolMetadata => ({
|
||||
title: '',
|
||||
widgetSizeX: width ? Math.max(Math.round(width/100), 1) : 3,
|
||||
@ -828,28 +824,28 @@ export class ScadaSymbolObject {
|
||||
}
|
||||
|
||||
private unitSymbol(unit: TbUnit): string {
|
||||
return this.ctx.$scope.$injector.get(this.ctx.servicesMap.get('unitService')).getTargetUnitSymbol(unit);
|
||||
return this.ctx.unitService.getTargetUnitSymbol(unit);
|
||||
}
|
||||
|
||||
private convertUnitValue(value: number, unit: TbUnit): number {
|
||||
return this.ctx.$scope.$injector.get(this.ctx.servicesMap.get('unitService')).convertUnitValue(value, unit);
|
||||
return this.ctx.unitService.convertUnitValue(value, unit);
|
||||
}
|
||||
|
||||
private formatValue(value: any, settings: ValueFormatIdSettings): string;
|
||||
private formatValue(value: any, settings: ValueFormatSettings): string;
|
||||
private formatValue(value: any, dec?: number, units?: string, showZeroDecimals?: boolean): string | undefined;
|
||||
private formatValue(value: any, settingsOrDec?: ValueFormatIdSettings | number, units?: string, showZeroDecimals?: boolean): string {
|
||||
const id = (settingsOrDec as ValueFormatIdSettings)?.id || 0;
|
||||
if (!this.valueProcessor[id]) {
|
||||
let valueFormatSettings: ValueFormatSettings;
|
||||
if (typeof settingsOrDec === 'object') {
|
||||
valueFormatSettings = deepClone(settingsOrDec, ['id']);
|
||||
} else {
|
||||
valueFormatSettings = {
|
||||
units,
|
||||
decimals: settingsOrDec,
|
||||
showZeroDecimals
|
||||
}
|
||||
private formatValue(value: any, settingsOrDec?: ValueFormatSettings | number, units?: string, showZeroDecimals?: boolean): string {
|
||||
let valueFormatSettings: ValueFormatSettings;
|
||||
if (typeof settingsOrDec === 'object') {
|
||||
valueFormatSettings = deepClone(settingsOrDec);
|
||||
} else {
|
||||
valueFormatSettings = {
|
||||
units,
|
||||
decimals: settingsOrDec,
|
||||
showZeroDecimals
|
||||
}
|
||||
}
|
||||
const id = objectHashCode(valueFormatSettings) + '';
|
||||
if (!this.valueProcessor[id]) {
|
||||
this.valueProcessor[id] = ValueFormatProcessor.fromSettings(this.ctx.$injector, valueFormatSettings);
|
||||
}
|
||||
return this.valueProcessor[id].format(value);
|
||||
|
||||
@ -118,6 +118,7 @@ import { CompiledTbFunction } from '@shared/models/js-function.models';
|
||||
import { FormProperty } from '@shared/models/dynamic-form.models';
|
||||
import { ExportableEntity } from '@shared/models/base-data';
|
||||
import { TbUnit } from '@shared/models/unit.models';
|
||||
import { UnitService } from '@core/services/unit.service';
|
||||
|
||||
export interface IWidgetAction {
|
||||
name: string;
|
||||
@ -225,6 +226,7 @@ export class WidgetContext {
|
||||
userSettingsService: UserSettingsService;
|
||||
utilsService: UtilsService;
|
||||
telemetryWsService: TelemetryWebsocketService;
|
||||
unitService: UnitService;
|
||||
telemetrySubscribers?: Array<TelemetrySubscriber | SharedTelemetrySubscriber>;
|
||||
date: DatePipe;
|
||||
imagePipe: ImagePipe;
|
||||
|
||||
@ -1313,7 +1313,8 @@ export const scadaSymbolContextCompletion = (metadata: ScadaSymbolMetadata, tags
|
||||
},
|
||||
{
|
||||
name: 'settingsOrDec',
|
||||
description: 'Either a ValueFormatIdSettings object containing formatting settings or the number of decimal digits. ValueFormatIdSettings includes: decimals (number of decimal digits, optional), units (unit specification as string or TbUnitMapping, optional), showZeroDecimals (whether to keep zero decimal digits, optional), ignoreUnitSymbol (whether to exclude unit symbol from output, optional), and id (unique identifier for the processor, optional).', type: 'ValueFormatIdSettings | number',
|
||||
description: 'Either a ValueFormatSettings object containing formatting settings or the number of decimal digits. ValueFormatSettings includes: decimals (number of decimal digits, optional), units (unit specification as string or TbUnitMapping, optional), showZeroDecimals (whether to keep zero decimal digits, optional), ignoreUnitSymbol (whether to exclude unit symbol from output, optional).',
|
||||
type: 'ValueFormatSettings | number',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
|
||||