Browse Source

UI: SCADA symbols - ability to set default behavior settings.

pull/11391/head
Igor Kulikov 2 years ago
parent
commit
e59a9ced27
  1. 144
      application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg
  2. 189
      application/src/main/data/json/system/scada_symbols/level_and_fan.svg
  3. 144
      application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg
  4. 144
      application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg
  5. 144
      application/src/main/data/json/system/scada_symbols/vertical-pipe.svg
  6. 131
      ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts
  7. 64
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html
  8. 74
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts
  9. 30
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts
  10. 2
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html
  11. 22
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts
  12. 4
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html
  13. 8
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts
  14. 2
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html
  15. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

144
application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flow",
"name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value",
"valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "leak",
"name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null,
"falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}
],
"properties": [

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 30 KiB

189
application/src/main/data/json/system/scada_symbols/level_and_fan.svg

@ -77,74 +77,225 @@
"id": "level",
"name": "Level",
"hint": null,
"group": null,
"type": "value",
"valueType": "DOUBLE",
"defaultValue": 10,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"valueToDataType": null,
"constantValue": null,
"valueToDataFunction": null
"defaultGetValueSettings": {
"action": "GET_TIME_SERIES",
"defaultValue": null,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "level"
},
"getTimeSeries": {
"key": "level"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "disabled",
"name": "{i18n:widgets.rpc-state.disabled-state}",
"hint": "{i18n:widgets.rpc-state.disabled-state-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "",
"falseLabel": "",
"stateLabel": "{i18n:widgets.rpc-state.disabled}",
"valueToDataType": null,
"constantValue": null,
"valueToDataFunction": null
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "on",
"name": "On/Off state",
"hint": null,
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:widgets.rpc-state.on}",
"falseLabel": "{i18n:widgets.rpc-state.off}",
"stateLabel": "{i18n:widgets.rpc-state.on}",
"valueToDataType": null,
"constantValue": null,
"valueToDataFunction": null
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "onUpdateState",
"name": "{i18n:widgets.rpc-state.turn-on}",
"hint": "{i18n:widgets.rpc-state.turn-on-hint}",
"group": null,
"type": "action",
"valueType": "BOOLEAN",
"valueToDataType": "CONSTANT",
"constantValue": true
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "SET_ATTRIBUTE",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "state"
},
"valueToData": {
"type": "CONSTANT",
"constantValue": true,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
},
{
"id": "offUpdateState",
"name": "{i18n:widgets.rpc-state.turn-off}",
"hint": "{i18n:widgets.rpc-state.turn-off-hint}",
"group": null,
"type": "action",
"valueType": "BOOLEAN",
"valueToDataType": "CONSTANT",
"constantValue": false
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "SET_ATTRIBUTE",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "state"
},
"valueToData": {
"type": "CONSTANT",
"constantValue": false,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
},
{
"id": "levelUpdateState",
"name": "Update level",
"hint": null,
"group": null,
"type": "action",
"valueType": "DOUBLE",
"valueToDataType": "VALUE",
"constantValue": 0
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "ADD_TIME_SERIES",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "level"
},
"valueToData": {
"type": "VALUE",
"constantValue": false,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
},
{
"id": "levelValueClick",
"name": "On level value click",
"type": "widgetAction"
"hint": null,
"group": null,
"type": "widgetAction",
"valueType": null,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": {
"type": "doNothing",
"openInSeparateDialog": false,
"openInPopover": false
}
}
],
"properties": [

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 22 KiB

144
application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flow",
"name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value",
"valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "leak",
"name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null,
"falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}
],
"properties": [

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 45 KiB

144
application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flow",
"name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value",
"valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "leak",
"name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null,
"falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}
],
"properties": [

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 38 KiB

144
application/src/main/data/json/system/scada_symbols/vertical-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flow",
"name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value",
"valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
},
{
"id": "leak",
"name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value",
"valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null,
"falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT",
"constantValue": false,
"valueToDataFunction": ""
"defaultGetValueSettings": {
"action": "DO_NOTHING",
"defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}
],
"properties": [

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 30 KiB

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

@ -112,7 +112,7 @@ export interface ScadaSymbolBehaviorBase {
export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase {
valueType: ValueType;
defaultValue: any;
defaultGetValueSettings?: GetValueSettings<any>;
trueLabel?: string;
falseLabel?: string;
stateLabel?: string;
@ -120,9 +120,8 @@ export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase {
export interface ScadaSymbolBehaviorAction extends ScadaSymbolBehaviorBase {
valueType: ValueType;
valueToDataType: ValueToDataType;
constantValue: any;
valueToDataFunction: string;
defaultSetValueSettings?: SetValueSettings;
defaultWidgetActionSettings?: WidgetAction;
}
export type ScadaSymbolBehavior = ScadaSymbolBehaviorValue & ScadaSymbolBehaviorAction;
@ -312,30 +311,47 @@ export const scadaSymbolContentData = (svgContent: string): ScadaSymbolContentDa
return result;
};
const defaultGetValueSettings = (get: ScadaSymbolBehaviorValue): GetValueSettings<any> => ({
action: GetValueAction.DO_NOTHING,
defaultValue: get.defaultValue,
executeRpc: {
const defaultValueForValueType = (valueType: ValueType): any => {
if (!valueType) {
return null;
}
switch (valueType) {
case ValueType.STRING:
return '';
case ValueType.INTEGER:
case ValueType.DOUBLE:
return 0;
case ValueType.BOOLEAN:
return false;
case ValueType.JSON:
return {};
}
};
export const defaultGetValueSettings = (valueType: ValueType): GetValueSettings<any> => ({
action: GetValueAction.DO_NOTHING,
defaultValue: defaultValueForValueType(valueType),
executeRpc: {
method: 'getState',
requestTimeout: 5000,
requestPersistent: false,
persistentPollingInterval: 1000
},
getAttribute: {
key: 'state',
scope: null
},
getTimeSeries: {
key: 'state'
},
dataToValue: {
type: DataToValueType.NONE,
compareToValue: true,
dataToValueFunction: '/* Should return boolean value */\nreturn data;'
}
});
requestTimeout: 5000,
requestPersistent: false,
persistentPollingInterval: 1000
},
getAttribute: {
key: 'state',
scope: null
},
getTimeSeries: {
key: 'state'
},
dataToValue: {
type: DataToValueType.NONE,
compareToValue: true,
dataToValueFunction: '/* Should return boolean value */\nreturn data;'
}
});
const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettings => ({
export const defaultSetValueSettings = (valueType: ValueType): SetValueSettings => ({
action: SetValueAction.EXECUTE_RPC,
executeRpc: {
method: 'setState',
@ -351,20 +367,49 @@ const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettin
key: 'state'
},
valueToData: {
type: set.valueToDataType,
constantValue: set.constantValue,
valueToDataFunction: set.valueToDataFunction ? set.valueToDataFunction :
type: valueType !== ValueType.BOOLEAN ? ValueToDataType.VALUE : ValueToDataType.CONSTANT,
constantValue: false,
valueToDataFunction:
'/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;'
}
});
const defaultWidgetActionSettings = (widgetAction: ScadaSymbolBehavior): WidgetAction => ({
export const defaultWidgetActionSettings: WidgetAction = {
type: WidgetActionType.doNothing,
targetDashboardStateId: null,
openRightLayout: false,
setEntityId: false,
stateEntityParamName: null
});
};
export const updateBehaviorDefaultSettings = (behavior: ScadaSymbolBehavior): ScadaSymbolBehavior => {
if (behavior.type) {
switch (behavior.type) {
case ScadaSymbolBehaviorType.value:
delete behavior.defaultSetValueSettings;
delete behavior.defaultWidgetActionSettings;
if (!behavior.defaultGetValueSettings) {
behavior.defaultGetValueSettings = mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(behavior.valueType));
}
break;
case ScadaSymbolBehaviorType.action:
delete behavior.defaultGetValueSettings;
delete behavior.defaultWidgetActionSettings;
if (!behavior.defaultSetValueSettings) {
behavior.defaultSetValueSettings = mergeDeep({} as SetValueSettings, defaultSetValueSettings(behavior.valueType));
}
break;
case ScadaSymbolBehaviorType.widgetAction:
delete behavior.defaultGetValueSettings;
delete behavior.defaultSetValueSettings;
if (!behavior.defaultWidgetActionSettings) {
behavior.defaultWidgetActionSettings = mergeDeep({} as WidgetAction, defaultWidgetActionSettings);
}
break;
}
}
return behavior;
};
export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata): ScadaSymbolObjectSettings => {
const settings: ScadaSymbolObjectSettings = {
@ -373,11 +418,17 @@ export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata):
};
for (const behavior of metadata.behavior) {
if (behavior.type === ScadaSymbolBehaviorType.value) {
settings.behavior[behavior.id] = defaultGetValueSettings(behavior as ScadaSymbolBehaviorValue);
settings.behavior[behavior.id] =
mergeDeep({} as GetValueSettings<any>,
defaultGetValueSettings(behavior.valueType), (behavior as ScadaSymbolBehaviorValue).defaultGetValueSettings || {});
} else if (behavior.type === ScadaSymbolBehaviorType.action) {
settings.behavior[behavior.id] = defaultSetValueSettings(behavior as ScadaSymbolBehaviorAction);
settings.behavior[behavior.id] =
mergeDeep({} as SetValueSettings,
defaultSetValueSettings(behavior.valueType), (behavior as ScadaSymbolBehaviorAction).defaultSetValueSettings || {});
} else if (behavior.type === ScadaSymbolBehaviorType.widgetAction) {
settings.behavior[behavior.id] = defaultWidgetActionSettings(behavior);
settings.behavior[behavior.id] =
mergeDeep({} as WidgetAction,
defaultWidgetActionSettings, (behavior as ScadaSymbolBehaviorAction).defaultWidgetActionSettings || {});
}
}
for (const property of metadata.properties) {
@ -733,17 +784,7 @@ export class ScadaSymbolObject {
private normalizeValue(value: any, type: ValueType): any {
if (isUndefinedOrNull(value)) {
switch (type) {
case ValueType.STRING:
return '';
case ValueType.INTEGER:
case ValueType.DOUBLE:
return 0;
case ValueType.BOOLEAN:
return false;
case ValueType.JSON:
return {};
}
return defaultValueForValueType(type);
} else {
return value;
}

64
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html

@ -70,11 +70,6 @@
</mat-form-field>
</div>
<ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.value">
<div class="tb-form-row ">
<div class="fixed-title-width" translate>scada.behavior.default-value</div>
<tb-value-input fxFlex [valueType]="behaviorFormGroup.get('valueType').value"
formControlName="defaultValue"></tb-value-input>
</div>
<ng-container *ngIf="behaviorFormGroup.get('valueType').value === ValueType.BOOLEAN">
<div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.true-label</div>
@ -95,34 +90,41 @@
</mat-form-field>
</div>
</ng-container>
<div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.default-settings</div>
<tb-get-value-action-settings fxFlex
panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
[valueType]="behaviorFormGroup.get('valueType').value"
[trueLabel]="behaviorFormGroup.get('trueLabel').value | customTranslate"
[falseLabel]="behaviorFormGroup.get('falseLabel').value | customTranslate"
[stateLabel]="behaviorFormGroup.get('stateLabel').value | customTranslate"
[aliasController]="aliasController"
[widgetType]="widgetType.rpc"
formControlName="defaultGetValueSettings">
</tb-get-value-action-settings>
</div>
</ng-container>
<ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.action">
<div class="tb-form-panel stroked">
<div class="tb-form-row no-padding no-border column-xs">
<div class="fixed-title-width">{{ 'scada.behavior.default-payload' | translate }}</div>
<tb-toggle-select fxFlex formControlName="valueToDataType">
<tb-toggle-option *ngIf="behaviorFormGroup.get('valueType').value !== ValueType.BOOLEAN" [value]="ValueToDataType.VALUE">{{ 'widgets.value-action.converter-value' | translate }}</tb-toggle-option>
<tb-toggle-option *ngIf="behaviorFormGroup.get('valueType').value === ValueType.BOOLEAN" [value]="ValueToDataType.CONSTANT">{{ 'widgets.value-action.converter-constant' | translate }}</tb-toggle-option>
<tb-toggle-option [value]="ValueToDataType.FUNCTION">{{ 'widgets.value-action.converter-function' | translate }}</tb-toggle-option>
<tb-toggle-option [value]="ValueToDataType.NONE">{{ 'widgets.value-action.converter-none' | translate }}</tb-toggle-option>
</tb-toggle-select>
</div>
<tb-value-input *ngIf="behaviorFormGroup.get('valueToDataType').value === ValueToDataType.CONSTANT"
fxFlex
[layout]="{
layout: 'row',
breakpoints: {xs: 'column'}
}"
formControlName="constantValue">
</tb-value-input>
<tb-js-func *ngIf="behaviorFormGroup.get('valueToDataType').value === ValueToDataType.FUNCTION"
formControlName="valueToDataFunction"
required
[globalVariables]="functionScopeVariables"
[functionArgs]="['value']"
functionTitle="{{ 'widgets.value-action.convert-value-function' | translate }}"
helpId="widget/lib/rpc/convert_value_fn">
</tb-js-func>
<div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.default-settings</div>
<tb-set-value-action-settings fxFlex
panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
[valueType]="behaviorFormGroup.get('valueType').value"
[aliasController]="aliasController"
[widgetType]="widgetType.rpc"
formControlName="defaultSetValueSettings">
</tb-set-value-action-settings>
</div>
</ng-container>
<ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.widgetAction">
<div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.default-settings</div>
<tb-widget-action-settings fxFlex
panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
[callbacks]="callbacks"
[widgetType]="widgetType.rpc"
formControlName="defaultWidgetActionSettings">
</tb-widget-action-settings>
</div>
</ng-container>
</div>

74
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts

@ -19,14 +19,19 @@ import { TbPopoverComponent } from '@shared/components/popover.component';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { merge } from 'rxjs';
import {
defaultGetValueSettings, defaultSetValueSettings, defaultWidgetActionSettings,
ScadaSymbolBehavior,
ScadaSymbolBehaviorType,
scadaSymbolBehaviorTypes,
scadaSymbolBehaviorTypeTranslations
} from '@app/modules/home/components/widget/lib/scada/scada-symbol.models';
import { ValueType, valueTypesMap } from '@shared/models/constants';
import { ValueToDataType } from '@shared/models/action-widget-settings.models';
import { GetValueSettings, SetValueSettings, ValueToDataType } from '@shared/models/action-widget-settings.models';
import { WidgetService } from '@core/http/widget.service';
import { mergeDeep } from '@core/utils';
import { WidgetAction, widgetType } from '@shared/models/widget.models';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({
selector: 'tb-scada-symbol-behavior-panel',
@ -36,6 +41,8 @@ import { WidgetService } from '@core/http/widget.service';
})
export class ScadaSymbolBehaviorPanelComponent implements OnInit {
widgetType = widgetType;
ScadaSymbolBehaviorType = ScadaSymbolBehaviorType;
ValueType = ValueType;
@ -55,6 +62,12 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
@Input()
behavior: ScadaSymbolBehavior;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input()
disabled: boolean;
@ -84,21 +97,19 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
group: [this.behavior.group, []],
type: [this.behavior.type, [Validators.required]],
valueType: [this.behavior.valueType, [Validators.required]],
defaultValue: [this.behavior.defaultValue, [Validators.required]],
trueLabel: [this.behavior.trueLabel, []],
falseLabel: [this.behavior.falseLabel, []],
stateLabel: [this.behavior.stateLabel, []],
valueToDataType: [this.behavior.valueToDataType, [Validators.required]],
constantValue: [this.behavior.constantValue, [Validators.required]],
valueToDataFunction: [this.behavior.valueToDataFunction, [Validators.required]]
defaultGetValueSettings: [this.behavior.defaultGetValueSettings, [Validators.required]],
defaultSetValueSettings: [this.behavior.defaultSetValueSettings, [Validators.required]],
defaultWidgetActionSettings: [this.behavior.defaultWidgetActionSettings, [Validators.required]]
}
);
if (this.disabled) {
this.behaviorFormGroup.disable({emitEvent: false});
} else {
merge(this.behaviorFormGroup.get('type').valueChanges,
this.behaviorFormGroup.get('valueType').valueChanges,
this.behaviorFormGroup.get('valueToDataType').valueChanges).subscribe(() => {
this.behaviorFormGroup.get('valueType').valueChanges).subscribe(() => {
this.updateValidators();
});
this.updateValidators();
@ -117,7 +128,9 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
private updateValidators() {
const type: ScadaSymbolBehaviorType = this.behaviorFormGroup.get('type').value;
const valueType: ValueType = this.behaviorFormGroup.get('valueType').value;
let valueToDataType: ValueToDataType = this.behaviorFormGroup.get('valueToDataType').value;
let defaultGetValueSettingsValue = this.behaviorFormGroup.get('defaultGetValueSettings').value;
let defaultSetValueSettingsValue = this.behaviorFormGroup.get('defaultSetValueSettings').value;
let defaultWidgetActionSettingsValue = this.behaviorFormGroup.get('defaultWidgetActionSettings').value;
this.behaviorFormGroup.disable({emitEvent: false});
this.behaviorFormGroup.get('id').enable({emitEvent: false});
this.behaviorFormGroup.get('name').enable({emitEvent: false});
@ -127,30 +140,49 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
switch (type) {
case ScadaSymbolBehaviorType.value:
this.behaviorFormGroup.get('valueType').enable({emitEvent: false});
this.behaviorFormGroup.get('defaultValue').enable({emitEvent: false});
this.behaviorFormGroup.get('defaultGetValueSettings').enable({emitEvent: false});
if (valueType === ValueType.BOOLEAN) {
this.behaviorFormGroup.get('trueLabel').enable({emitEvent: false});
this.behaviorFormGroup.get('falseLabel').enable({emitEvent: false});
this.behaviorFormGroup.get('stateLabel').enable({emitEvent: false});
}
if (!defaultGetValueSettingsValue) {
defaultGetValueSettingsValue = mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(valueType));
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(defaultGetValueSettingsValue, {emitEvent: true});
}
if (defaultSetValueSettingsValue) {
this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultWidgetActionSettingsValue) {
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(null, {emitEvent: true});
}
break;
case ScadaSymbolBehaviorType.action:
if (valueType === ValueType.BOOLEAN && valueToDataType === ValueToDataType.VALUE) {
this.behaviorFormGroup.patchValue({valueToDataType: ValueToDataType.CONSTANT}, {emitEvent: false});
valueToDataType = ValueToDataType.CONSTANT;
} else if (valueType !== ValueType.BOOLEAN && valueToDataType === ValueToDataType.CONSTANT) {
this.behaviorFormGroup.patchValue({valueToDataType: ValueToDataType.VALUE}, {emitEvent: false});
valueToDataType = ValueToDataType.VALUE;
}
this.behaviorFormGroup.get('valueType').enable({emitEvent: false});
this.behaviorFormGroup.get('valueToDataType').enable({emitEvent: false});
if (valueToDataType === ValueToDataType.CONSTANT) {
this.behaviorFormGroup.get('constantValue').enable({emitEvent: false});
} else if (valueToDataType === ValueToDataType.FUNCTION) {
this.behaviorFormGroup.get('valueToDataFunction').enable({emitEvent: false});
this.behaviorFormGroup.get('defaultSetValueSettings').enable({emitEvent: false});
if (!defaultSetValueSettingsValue) {
defaultSetValueSettingsValue = mergeDeep({} as SetValueSettings, defaultSetValueSettings(valueType));
this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(defaultSetValueSettingsValue, {emitEvent: true});
}
if (defaultGetValueSettingsValue) {
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultWidgetActionSettingsValue) {
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(null, {emitEvent: true});
}
break;
case ScadaSymbolBehaviorType.widgetAction:
this.behaviorFormGroup.get('defaultWidgetActionSettings').enable({emitEvent: false});
if (!defaultWidgetActionSettingsValue) {
defaultWidgetActionSettingsValue = mergeDeep({} as WidgetAction, defaultWidgetActionSettings);
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(defaultWidgetActionSettingsValue, {emitEvent: true});
}
if (defaultGetValueSettingsValue) {
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultSetValueSettingsValue) {
this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(null, {emitEvent: true});
}
break;
}
}

30
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts

@ -43,7 +43,7 @@ import {
ScadaSymbolBehavior,
ScadaSymbolBehaviorType,
scadaSymbolBehaviorTypes,
scadaSymbolBehaviorTypeTranslations
scadaSymbolBehaviorTypeTranslations, updateBehaviorDefaultSettings
} from '@home/components/widget/lib/scada/scada-symbol.models';
import { deepClone, isUndefinedOrNull } from '@core/utils';
import { MatButton } from '@angular/material/button';
@ -55,6 +55,8 @@ import { ValueToDataType } from '@shared/models/action-widget-settings.models';
import {
ScadaSymbolBehaviorsComponent
} from '@home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => {
if (!behavior.id || !behavior.name || !behavior.type) {
@ -62,20 +64,20 @@ export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => {
}
switch (behavior.type) {
case ScadaSymbolBehaviorType.value:
if (!behavior.valueType || isUndefinedOrNull(behavior.defaultValue)) {
if (!behavior.valueType || !behavior.defaultGetValueSettings) {
return false;
}
break;
case ScadaSymbolBehaviorType.action:
if (!behavior.valueToDataType) {
if (!behavior.defaultSetValueSettings) {
return false;
}
if (behavior.valueToDataType === ValueToDataType.CONSTANT
&& isUndefinedOrNull(behavior.constantValue)) {
if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.CONSTANT
&& isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.constantValue)) {
return false;
}
if (behavior.valueToDataType === ValueToDataType.FUNCTION
&& isUndefinedOrNull(behavior.valueToDataFunction)) {
if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.FUNCTION
&& isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.valueToDataFunction)) {
return false;
}
break;
@ -120,6 +122,12 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
@Input()
index: number;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Output()
behaviorRemoved = new EventEmitter();
@ -190,6 +198,8 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
const ctx: any = {
isAdd: add,
disabled: this.disabled,
aliasController: this.aliasController,
callbacks: this.callbacks,
behavior: deepClone(this.modelValue)
};
const scadaSymbolBehaviorPanelPopover = this.popoverService.displayPopover(trigger, this.renderer,
@ -265,13 +275,15 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
}
private onTypeChanged(newType: ScadaSymbolBehaviorType) {
const prevType = this.modelValue.type;
const prevModel = deepClone(this.modelValue);
this.modelValue = {...this.modelValue, ...{type: newType}};
this.modelValue = updateBehaviorDefaultSettings(this.modelValue);
if (!behaviorValid(this.modelValue)) {
this.editBehavior(null, this.editButton, false, () => {
this.modelValue = prevModel;
this.behaviorRowFormGroup.patchValue(
{
type: prevType
type: prevModel.type
}, {emitEvent: true}
);
});

2
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html

@ -33,6 +33,8 @@
<tb-scada-symbol-metadata-behavior-row fxFlex
[index]="$index"
[formControl]="behaviorControl"
[aliasController]="aliasController"
[callbacks]="callbacks"
(behaviorRemoved)="removeBehavior($index)">
</tb-scada-symbol-metadata-behavior-row>
<div class="tb-form-table-row-cell-buttons">

22
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts

@ -35,15 +35,22 @@ import {
UntypedFormGroup,
Validator
} from '@angular/forms';
import { ScadaSymbolBehavior, ScadaSymbolBehaviorType } from '@home/components/widget/lib/scada/scada-symbol.models';
import {
defaultGetValueSettings,
ScadaSymbolBehavior,
ScadaSymbolBehaviorType
} from '@home/components/widget/lib/scada/scada-symbol.models';
import { ValueType } from '@shared/models/constants';
import { CdkDragDrop } from '@angular/cdk/drag-drop';
import {
behaviorValid,
ScadaSymbolBehaviorRowComponent
} from '@home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component';
import { ValueToDataType } from '@shared/models/action-widget-settings.models';
import { GetValueSettings, ValueToDataType } from '@shared/models/action-widget-settings.models';
import { TranslateService } from '@ngx-translate/core';
import { mergeDeep } from '@core/utils';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({
selector: 'tb-scada-symbol-metadata-behaviors',
@ -71,6 +78,12 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn
@ViewChildren(ScadaSymbolBehaviorRowComponent)
behaviorRows: QueryList<ScadaSymbolBehaviorRowComponent>;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input()
disabled: boolean;
@ -181,10 +194,7 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn
name: '',
type: ScadaSymbolBehaviorType.value,
valueType: ValueType.BOOLEAN,
defaultValue: false,
valueToDataType: ValueToDataType.CONSTANT,
constantValue: false,
valueToDataFunction: ''
defaultGetValueSettings: mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(ValueType.BOOLEAN))
};
const behaviorsArray = this.behaviorsFormGroup.get('behaviors') as UntypedFormArray;
const behaviorControl = this.fb.control(behavior, []);

4
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html

@ -101,7 +101,9 @@
</div>
<div [fxShow]="selectedOption === 'behavior'" class="mat-content overflow-hidden">
<tb-scada-symbol-metadata-behaviors
formControlName="behavior">
formControlName="behavior"
[aliasController]="aliasController"
[callbacks]="callbacks">
</tb-scada-symbol-metadata-behaviors>
</div>
<div [fxShow]="selectedOption === 'properties'" class="mat-content overflow-hidden">

8
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts

@ -53,6 +53,8 @@ import {
scadaSymbolGeneralStateRenderPropertiesHighlightRules
} from '@home/pages/scada-symbol/scada-symbol-editor.models';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({
selector: 'tb-scada-symbol-metadata',
@ -77,6 +79,12 @@ export class ScadaSymbolMetadataComponent extends PageComponent implements OnIni
@ViewChild('symbolMetadataTags')
symbolMetadataTags: ScadaSymbolMetadataTagsComponent;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input()
disabled: boolean;

2
ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html

@ -80,6 +80,8 @@
<tb-scada-symbol-metadata
#symbolMetadata
[tags]="tags"
[aliasController]="aliasController"
[callbacks]="widgetActionCallbacks"
formControlName="metadata">
<div class="tb-scada-symbol-metadata-header-prefix">
<button fxHide.gt-sm

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -3622,7 +3622,8 @@
"false-label": "False label",
"state-label": "State label",
"default-payload": "Default payload",
"not-unique-behavior-ids-error": "Behavior Ids must be unique!"
"not-unique-behavior-ids-error": "Behavior Ids must be unique!",
"default-settings": "Default settings"
},
"property": {
"property": "Property",

Loading…
Cancel
Save