Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nodes/widgets/locales/en-US/ui_gauge.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"units": "Units",
"icon": "Icon",
"defaults": "Defaults",
"value": "Value"
"value": "Value",
"valueAsPercent": "Display Value as Percent"
},
"errors": {
"unique": "All 'from' values must be unique."
Expand Down
14 changes: 14 additions & 0 deletions nodes/widgets/ui_gauge.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
order: { value: 0 },
value: { value: 'payload', required: false },
valueType: { value: 'msg' },
valueAsPercent: { value: Boolean(this.gtype === 'gauge-tank') }, // default to true for tank gauges
width: {
value: 3,
validate: function (v) {
Expand Down Expand Up @@ -256,10 +257,16 @@
$('#node-input-container-label-extras').hide()
if (type === 'gauge-tile') {
$('#node-input-container-tile-options').show()
$('#node-input-valueAsPercent').prop('checked', false)
} else if (type === 'gauge-tank') {
$('#node-input-container-label-extras').show()
$('#node-input-valueAsPercent').prop('checked', true)
} else {
$('#node-input-valueAsPercent').prop('checked', false)
$('#node-input-container-tile-options').hide()
}
} else {
$('#node-input-valueAsPercent').prop('checked', false)
$('#node-input-container-sizes').show()
$('#node-input-container-gstyle').show()
$('#node-input-container-label-extras').show()
Expand Down Expand Up @@ -416,6 +423,13 @@ <h3><span data-i18n="ui-gauge.label.value"></span></h3>
<input type="text" id="node-input-value" style="width:70%">
<input type="hidden" id="node-input-valueType">
</div>
<div class="form-row" style="margin-left:100px;">
<label for="node-input-value-as-percent" style="display:flex; align-items: center; gap: 6px; width:auto;">
<input type="checkbox" id="node-input-valueAsPercent" style="width:auto; margin: 0; vertical-align: middle;" />
<span data-i18n="ui-gauge.label.valueAsPercent" style="white-space: nowrap;">Display Value as Percent</span>
<i class="fa fa-percent"></i>
</label>
</div>
<div class="form-row">
<h3><span data-i18n="ui-gauge.label.limits"></span></h3>
</div>
Expand Down
24 changes: 0 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion ui/src/widgets/ui-gauge/types/UIGaugeTank.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
</path>
</svg>
<div ref="labels" class="nrdb-ui-gauge-tank-labels">
<label class="nrdb-ui-gauge-tank--fglabel" :style="{'line-height': labelLineHeight}">{{ pc }}%</label>
<label class="nrdb-ui-gauge-tank--fglabel" :style="{'line-height': labelLineHeight}">
{{ displayValue }}
</label>
</div>
</div>
</div>
Expand Down Expand Up @@ -66,6 +68,13 @@ export default {
return 0
}
},
displayValue: function () {
if (this.props.valueAsPercent) {
return `${this.pc}%`
} else {
return `${this.props.prefix}${this.value ?? this.props.min}${this.props.suffix}`
}
},
clipId: function () {
return `clip-${this.id}`
},
Expand Down