Browse Source

UI: unitService to ctx, ref id from settings to objectHashCode and remove showZeroDecimals

pull/13529/head
Artem Dzhereleiko 1 year ago
parent
commit
2e1e6922f6
  1. 6
      application/src/main/data/json/system/scada_symbols/3-phase-voltage-relay-hp.svg
  2. 2
      application/src/main/data/json/system/scada_symbols/bottom-flow-meter.svg
  3. 2
      application/src/main/data/json/system/scada_symbols/dynamic-horizontal-scale-hp.svg
  4. 2
      application/src/main/data/json/system/scada_symbols/dynamic-vertical-scale-hp.svg
  5. 2
      application/src/main/data/json/system/scada_symbols/energy-meter-hp.svg
  6. 8
      application/src/main/data/json/system/scada_symbols/four-rate-energy-meter-hp.svg
  7. 2
      application/src/main/data/json/system/scada_symbols/horizontal-inline-flow-meter.svg
  8. 2
      application/src/main/data/json/system/scada_symbols/left-flow-meter.svg
  9. 2
      application/src/main/data/json/system/scada_symbols/right-flow-meter.svg
  10. 2
      application/src/main/data/json/system/scada_symbols/simple-horizontal-scale-hp.svg
  11. 2
      application/src/main/data/json/system/scada_symbols/simple-vertical-scale-hp.svg
  12. 6
      application/src/main/data/json/system/scada_symbols/three-rate-energy-meter-hp.svg
  13. 2
      application/src/main/data/json/system/scada_symbols/top-flow-meter.svg
  14. 4
      application/src/main/data/json/system/scada_symbols/two-rate-energy-meter-hp.svg
  15. 2
      application/src/main/data/json/system/scada_symbols/vertical-inline-flow-meter.svg
  16. 2
      ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts
  17. 38
      ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts
  18. 2
      ui-ngx/src/app/modules/home/models/widget-component.models.ts
  19. 3
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol-editor.models.ts

6
application/src/main/data/json/system/scada_symbols/3-phase-voltage-relay-hp.svg

@ -39,7 +39,7 @@
}, },
{ {
"tag": "firstPhaseValue", "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 "actions": null
}, },
{ {
@ -49,7 +49,7 @@
}, },
{ {
"tag": "secondPhaseValue", "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 "actions": null
}, },
{ {
@ -59,7 +59,7 @@
}, },
{ {
"tag": "thirdPhaseValue", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

2
application/src/main/data/json/system/scada_symbols/bottom-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

2
application/src/main/data/json/system/scada_symbols/dynamic-horizontal-scale-hp.svg

@ -78,7 +78,7 @@
}, },
{ {
"tag": "value", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

2
application/src/main/data/json/system/scada_symbols/dynamic-vertical-scale-hp.svg

@ -78,7 +78,7 @@
}, },
{ {
"tag": "value", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

2
application/src/main/data/json/system/scada_symbols/energy-meter-hp.svg

@ -43,7 +43,7 @@
}, },
{ {
"tag": "value", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

8
application/src/main/data/json/system/scada_symbols/four-rate-energy-meter-hp.svg

@ -38,7 +38,7 @@
}, },
{ {
"tag": "export-rate", "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 "actions": null
}, },
{ {
@ -48,7 +48,7 @@
}, },
{ {
"tag": "night-rate", "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 "actions": null
}, },
{ {
@ -58,7 +58,7 @@
}, },
{ {
"tag": "off-peak-rate", "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 "actions": null
}, },
{ {
@ -68,7 +68,7 @@
}, },
{ {
"tag": "peak-rate", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 31 KiB

2
application/src/main/data/json/system/scada_symbols/horizontal-inline-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

2
application/src/main/data/json/system/scada_symbols/left-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

2
application/src/main/data/json/system/scada_symbols/right-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

2
application/src/main/data/json/system/scada_symbols/simple-horizontal-scale-hp.svg

@ -78,7 +78,7 @@
}, },
{ {
"tag": "value", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

2
application/src/main/data/json/system/scada_symbols/simple-vertical-scale-hp.svg

@ -78,7 +78,7 @@
}, },
{ {
"tag": "value", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

6
application/src/main/data/json/system/scada_symbols/three-rate-energy-meter-hp.svg

@ -38,7 +38,7 @@
}, },
{ {
"tag": "night-rate", "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 "actions": null
}, },
{ {
@ -48,7 +48,7 @@
}, },
{ {
"tag": "off-peak-rate", "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 "actions": null
}, },
{ {
@ -58,7 +58,7 @@
}, },
{ {
"tag": "peak-rate", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

2
application/src/main/data/json/system/scada_symbols/top-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

4
application/src/main/data/json/system/scada_symbols/two-rate-energy-meter-hp.svg

@ -38,7 +38,7 @@
}, },
{ {
"tag": "day-rate", "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 "actions": null
}, },
{ {
@ -48,7 +48,7 @@
}, },
{ {
"tag": "night-rate", "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 "actions": null
}, },
{ {

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

2
application/src/main/data/json/system/scada_symbols/vertical-inline-flow-meter.svg

@ -57,7 +57,7 @@
}, },
{ {
"tag": "value", "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": { "actions": {
"click": { "click": {
"actionFunction": "ctx.api.callAction(event, 'displayClick');" "actionFunction": "ctx.api.callAction(event, 'displayClick');"

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

2
ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts

@ -52,6 +52,7 @@ import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-
import { UserSettingsService } from '@core/http/user-settings.service'; import { UserSettingsService } from '@core/http/user-settings.service';
import { ImagePipe } from '@shared/pipe/image.pipe'; import { ImagePipe } from '@shared/pipe/image.pipe';
import { UtilsService } from '@core/services/utils.service'; import { UtilsService } from '@core/services/utils.service';
import { UnitService } from '@core/services/unit.service';
@Directive() @Directive()
// eslint-disable-next-line @angular-eslint/directive-class-suffix // 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.userSettingsService = this.$injector.get(UserSettingsService);
this.ctx.utilsService = this.$injector.get(UtilsService); this.ctx.utilsService = this.$injector.get(UtilsService);
this.ctx.telemetryWsService = this.$injector.get(TelemetryWebsocketService); this.ctx.telemetryWsService = this.$injector.get(TelemetryWebsocketService);
this.ctx.unitService = this.$injector.get(UnitService);
this.ctx.date = this.$injector.get(DatePipe); this.ctx.date = this.$injector.get(DatePipe);
this.ctx.imagePipe = this.$injector.get(ImagePipe); this.ctx.imagePipe = this.$injector.get(ImagePipe);
this.ctx.milliSecondsToTimeString = this.$injector.get(MillisecondsToTimeStringPipe); this.ctx.milliSecondsToTimeString = this.$injector.get(MillisecondsToTimeStringPipe);

38
ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts

@ -51,7 +51,7 @@ import {
isUndefined, isUndefined,
isUndefinedOrNull, isUndefinedOrNull,
mergeDeep, mergeDeep,
mergeDeepIgnoreArray, mergeDeepIgnoreArray, objectHashCode,
parseFunction parseFunction
} from '@core/utils'; } from '@core/utils';
import { BehaviorSubject, forkJoin, Observable, Observer, of, Subject } from 'rxjs'; import { BehaviorSubject, forkJoin, Observable, Observer, of, Subject } from 'rxjs';
@ -82,7 +82,7 @@ import { TbUnit } from '@shared/models/unit.models';
export interface ScadaSymbolApi { export interface ScadaSymbolApi {
generateElementId: () => string; generateElementId: () => string;
formatValue(value: any, dec?: number, units?: string, showZeroDecimals?: boolean): string | undefined; 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; text: (element: Element | Element[], text: string) => void;
font: (element: Element | Element[], font: Font, color: string) => void; font: (element: Element | Element[], font: Font, color: string) => void;
icon: (element: Element | Element[], icon: string, size?: number, color?: string, center?: boolean) => void; icon: (element: Element | Element[], icon: string, size?: number, color?: string, center?: boolean) => void;
@ -184,10 +184,6 @@ export interface ScadaSymbolMetadata {
properties: FormProperty[]; properties: FormProperty[];
} }
interface ValueFormatIdSettings extends ValueFormatSettings {
id?: number;
}
export const emptyMetadata = (width?: number, height?: number): ScadaSymbolMetadata => ({ export const emptyMetadata = (width?: number, height?: number): ScadaSymbolMetadata => ({
title: '', title: '',
widgetSizeX: width ? Math.max(Math.round(width/100), 1) : 3, widgetSizeX: width ? Math.max(Math.round(width/100), 1) : 3,
@ -828,28 +824,28 @@ export class ScadaSymbolObject {
} }
private unitSymbol(unit: TbUnit): string { 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 { 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, dec?: number, units?: string, showZeroDecimals?: boolean): string | undefined;
private formatValue(value: any, settingsOrDec?: ValueFormatIdSettings | number, units?: string, showZeroDecimals?: boolean): string { private formatValue(value: any, settingsOrDec?: ValueFormatSettings | number, units?: string, showZeroDecimals?: boolean): string {
const id = (settingsOrDec as ValueFormatIdSettings)?.id || 0; let valueFormatSettings: ValueFormatSettings;
if (!this.valueProcessor[id]) { if (typeof settingsOrDec === 'object') {
let valueFormatSettings: ValueFormatSettings; valueFormatSettings = deepClone(settingsOrDec);
if (typeof settingsOrDec === 'object') { } else {
valueFormatSettings = deepClone(settingsOrDec, ['id']); valueFormatSettings = {
} else { units,
valueFormatSettings = { decimals: settingsOrDec,
units, showZeroDecimals
decimals: settingsOrDec,
showZeroDecimals
}
} }
}
const id = objectHashCode(valueFormatSettings) + '';
if (!this.valueProcessor[id]) {
this.valueProcessor[id] = ValueFormatProcessor.fromSettings(this.ctx.$injector, valueFormatSettings); this.valueProcessor[id] = ValueFormatProcessor.fromSettings(this.ctx.$injector, valueFormatSettings);
} }
return this.valueProcessor[id].format(value); return this.valueProcessor[id].format(value);

2
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -118,6 +118,7 @@ import { CompiledTbFunction } from '@shared/models/js-function.models';
import { FormProperty } from '@shared/models/dynamic-form.models'; import { FormProperty } from '@shared/models/dynamic-form.models';
import { ExportableEntity } from '@shared/models/base-data'; import { ExportableEntity } from '@shared/models/base-data';
import { TbUnit } from '@shared/models/unit.models'; import { TbUnit } from '@shared/models/unit.models';
import { UnitService } from '@core/services/unit.service';
export interface IWidgetAction { export interface IWidgetAction {
name: string; name: string;
@ -225,6 +226,7 @@ export class WidgetContext {
userSettingsService: UserSettingsService; userSettingsService: UserSettingsService;
utilsService: UtilsService; utilsService: UtilsService;
telemetryWsService: TelemetryWebsocketService; telemetryWsService: TelemetryWebsocketService;
unitService: UnitService;
telemetrySubscribers?: Array<TelemetrySubscriber | SharedTelemetrySubscriber>; telemetrySubscribers?: Array<TelemetrySubscriber | SharedTelemetrySubscriber>;
date: DatePipe; date: DatePipe;
imagePipe: ImagePipe; imagePipe: ImagePipe;

3
ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol-editor.models.ts

@ -1313,7 +1313,8 @@ export const scadaSymbolContextCompletion = (metadata: ScadaSymbolMetadata, tags
}, },
{ {
name: 'settingsOrDec', 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 optional: true
}, },
{ {

Loading…
Cancel
Save