Skip to content

Commit

Permalink
Fixed server side data storing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanSandamal authored and joepavitt committed Aug 29, 2024
1 parent 68e21e7 commit 7afa023
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
51 changes: 50 additions & 1 deletion nodes/widgets/ui_gauge.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const statestore = require('../store/state.js')
const { appendTopic } = require('../utils/index.js')

module.exports = function (RED) {
function GaugeNode (config) {
RED.nodes.createNode(this, config)
Expand All @@ -7,7 +10,53 @@ module.exports = function (RED) {
const group = RED.nodes.getNode(config.group)

const evts = {
onChange: true
beforeSend: async function (msg) {
const updates = msg.ui_update
if (updates) {
if (typeof updates.title !== 'undefined') {
// dynamically set "label" property
statestore.set(group.getBase(), node, msg, 'title', updates.title)
}
if (typeof updates.gtype !== 'undefined') {
// dynamically set "gauge type" property
statestore.set(group.getBase(), node, msg, 'gtype', updates.gtype)
}
if (typeof updates.gstyle !== 'undefined') {
// dynamically set "gauge style" property
statestore.set(group.getBase(), node, msg, 'gstyle', updates.gstyle)
}
if (typeof updates.prefix !== 'undefined') {
// dynamically set "prefix" property
statestore.set(group.getBase(), node, msg, 'prefix', updates.prefix)
}
if (typeof updates.suffix !== 'undefined') {
// dynamically set "suffix" property
statestore.set(group.getBase(), node, msg, 'suffix', updates.suffix)
}
if (typeof updates.units !== 'undefined') {
// dynamically set "units" property
statestore.set(group.getBase(), node, msg, 'units', updates.units)
}
if (typeof updates.icon !== 'undefined') {
// dynamically set "icon" property
statestore.set(group.getBase(), node, msg, 'icon', updates.icon)
}
if (typeof updates.segments !== 'undefined') {
// dynamically set "segments" property
statestore.set(group.getBase(), node, msg, 'segments', updates.segments)
}
if (typeof updates.min !== 'undefined') {
// dynamically set "min" property
statestore.set(group.getBase(), node, msg, 'min', updates.min)
}
if (typeof updates.max !== 'undefined') {
// dynamically set "max" property
statestore.set(group.getBase(), node, msg, 'max', updates.max)
}
}
msg = await appendTopic(RED, config, node, msg)
return msg
}
}

// ensure values are numerical, not strings
Expand Down
1 change: 0 additions & 1 deletion ui/src/widgets/ui-gauge/UIGauge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export default {
min: this.min,
max: this.max
}
console.log('props', this.props, props)
return props
}
},
Expand Down

0 comments on commit 7afa023

Please sign in to comment.