node-red-dashboard
Version:
A set of dashboard nodes for Node-RED
106 lines (103 loc) • 5.17 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('ui_numeric',{
category: 'dashboard',
color: 'rgb(176, 223, 227)',
defaults: {
name: {value: ''},
label: {value: 'numeric'},
group: {type: 'ui_group', required: true},
order: {value: 0},
width: {value: 0, validate: function(v) {
var width = v||0;
var currentGroup = $('#node-input-group').val()||this.group;
var groupNode = RED.nodes.node(currentGroup);
var valid = !groupNode || +width <= +groupNode.width;
$("#node-input-size").toggleClass("input-error",!valid);
return valid;
}
},
height: {value: 0},
passthru: {value: true},
topic: {value: ''},
format: {value: '{{value}}'},
min: {value: 0, required: true, validate: RED.validators.number()},
max: {value: 10, required: true, validate: RED.validators.number()},
step: {value: 1}
},
inputs:1,
outputs:1,
icon: "ui_numeric.png",
paletteLabel: 'numeric',
label: function() { return this.name || (~this.label.indexOf("{{") ? null : this.label) || 'numeric'; },
oneditprepare: function() {
$("#node-input-size").elementSizer({
width: "#node-input-width",
height: "#node-input-height",
group: "#node-input-group"
});
}
});
</script>
<script type="text/x-red" data-template-name="ui_numeric">
<div class="form-row">
<label for="node-input-group"><i class="fa fa-table"></i> Group</label>
<input type="text" id="node-input-group">
</div>
<div class="form-row">
<label><i class="fa fa-object-group"></i> Size</label>
<input type="hidden" id="node-input-width">
<input type="hidden" id="node-input-height">
<button class="editor-button" id="node-input-size"></button>
</div>
<div class="form-row">
<label for="node-input-label"><i class="fa fa-i-cursor"></i> Label</label>
<input type="text" id="node-input-label">
</div>
<div class="form-row">
<label for="node-input-format"><i class="fa fa-i-cursor"></i> Value Format</label>
<input type="text" id="node-input-format" placeholder="{{value}}">
</div>
<div class="form-row">
<label for="node-input-min">Range</label>
<span for="node-input-min">min</span>
<input type="text" id="node-input-min" style="width:60px">
<span for="not-input-max" style="margin-left:22px;">max</span>
<input type="text" id="node-input-max" style="width:60px">
<span for="not-input-step" style="margin-left:22px;">step</span>
<input type="text" id="node-input-step" style="width:60px">
</div>
<div class="form-row">
<label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> If <code>msg</code> arrives on input, pass through to output: </label>
<input type="checkbox" checked id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
</div>
<div class="form-row">
<label style="width:auto" for="node-input-payload"><i class="fa fa-envelope-o"></i> When changed, send:</label>
</div>
<div class="form-row">
<label style="padding-left:25px; margin-right:-25px">Payload</label>
<label style="width:auto">Current value</label>
</div>
<div class="form-row">
<label for="node-input-topic" style="padding-left:25px; margin-right:-25px">Topic</label>
<input type="text" id="node-input-topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="ui_numeric">
<p>Adds a numeric input widget to the user interface.</p>
<p>The user can set the value between
the limits (<b>min</b> and <b>max</b>). Each value change will generate a <code>msg.payload</code>.</p>
<p>If <b>Topic</b> is specified, it will be added as <code>msg.topic</code>.<p>
<p>Any input messages will be converted to a number, the <b>min</b> value will be used if conversion fails,
and it will update the user interface. If the value changes, it will also be passed to the output.</p>
<p>The <b>Value Format</b> field can be used to change the displayed format. For example, a <b>Value Format</b>
of <code>{{value}} %</code>
with a value of <b>23</b> will show <b>23 %</b> on the user interface. The <b>Value Format</b> field can contain
HTML or Angular filters to format the output (eg: <code>&deg;</code> will show the degree symbol).</p>
<p>The label can also be set by a message property by setting
the field to the name of the property, for example <code>{{msg.topic}}</code>.</p>
<p>Setting <code>msg.enabled</code> to <code>false</code> will disable the widget putput.</p>
</script>