-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui-value-trail.html
184 lines (174 loc) · 8.81 KB
/
ui-value-trail.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!--
MIT License
Copyright (c) 2019 hotNipi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<script type='text/javascript'>
RED.nodes.registerType('ui_valuetrail',{
category: 'dashboard',
color: 'rgb( 63, 173, 181)',
defaults: {
group: {type: 'ui_group', required:true},
order: {value: 0},
width: {
value: 0,
validate: function(v) {
var valid = true
var width = v||0;
var currentGroup = $('#node-input-group').val()|| this.group;
var groupNode = RED.nodes.node(currentGroup);
valid = !groupNode || +width <= +groupNode.width;
$('#node-input-size').toggleClass('input-error',!valid);
return valid;
}},
height: {value: 0},
name: {value: ''},
label:{value: ''},
unit:{value: ''},
blur:{value:false},
minmax:{value:false},
allowtoggle:{value:true},
showvalue:{value:false},
decimals: { value: 0, required: false, validate: RED.validators.number() },
colorLine: {value: '#ff9900'},
colorFromTheme:{value:true},
stroke:{value:2, required: true},
property: { value: "payload", required: true },
pointcount:{val:8, required: true}
},
inputs:1,
outputs:0,
icon: 'trail.png',
paletteLabel: 'value-trail',
label: function() {
return this.name||'Value-trail';
},
oneditprepare: function() {
$('#node-input-size').elementSizer({
width: '#node-input-width',
height: '#node-input-height',
group: '#node-input-group'
});
if (this.blur === undefined) {
$("#node-input-blur").prop('checked', false);
}
if (this.minmax === undefined) {
$("#node-input-minmax").prop('checked', false);
}
if (this.showvalue === undefined) {
$("#node-input-showvalue").prop('checked', false);
}
if (this.allowtoggle === undefined) {
$("#node-input-allowtoggle").prop('checked', true);
}
if (this.pointcount === undefined) {
this.pointcount = 8;
$('#node-input-pointcount').val('8');
}
if (this.property === undefined) {
$("#node-input-property").val("payload");
}
$("#node-input-property").typedInput({ default: 'msg', types: ['msg'] });
if (this.stroke === undefined) {
this.stroke = 2;
$('#node-input-stroke').val('2');
}
$('#node-input-colorFromTheme').change(function() {
if (this.checked == true) {
$('#node-input-colorLine').hide();
$('#node-input-colorLineSpan').hide();
}
else {
$('#node-input-colorLine').show();
$('#node-input-colorLineSpan').show();
}
});
},
oneditsave: function (){
// $('input[name=foo]').attr('checked', this.colorFromTheme);
}
});
</script>
<script type='text/x-red' data-template-name='ui_valuetrail'>
<div class='form-row' id='template-row-group'>
<label for='node-input-group'><i class='fa fa-table'></i> Group</span></label>
<input type='text' id='node-input-group'>
</div>
<div class='form-row' id='template-row-size'>
<label><i class='fa fa-object-group'></i> Size</span></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-property"><i class="fa fa-arrow-right"></i> Input</label>
<input type="text" id="node-input-property" style="width:70%;"/>
</div>
</br>
<div class='form-row' id='node-input-linecolor'>
<label for='node-input-colorFromTheme' style='padding-top:6px; padding-bottom:6px'><i class='fa fa-paint-brush'></i> Line color</span></label>
<input type="checkbox" id="node-input-colorFromTheme" checked style="display:inline-block; width:auto; vertical-align:baseline; margin-right:5px;">Use theme color
<span for='node-input-colorLine' id='node-input-colorLineSpan' style='margin-left:20px;'>Custom color</span>
<input type='color' id='node-input-colorLine' style='width:80px'/>
</div>
<div class='form-row' id='node-input-lineblur'>
<label for='node-input-blur'><i class='fa fa-paint-brush'></i> Line style</span></label>
<input type="checkbox" id="node-input-blur" checked style="display:inline-block; width:auto; vertical-align:baseline; margin-right:5px;">Use glow
</div>
<div class='form-row' id='node-input-showvaluecheck'>
<label for='node-input-showvalue'><i class='fa fa-paint-brush'></i> Value</span></label>
<input type="checkbox" id="node-input-showvalue" style="display:inline-block; width:auto; vertical-align:baseline; margin-right:5px;">Show value
<span for='node-input-decimals' style='margin-left:20px;'>decimals</span>
<input type='text' id='node-input-decimals' style='width:40px' placeholder='0' dir=''>
<span for='node-input-unit' style='margin-left:20px;'>unit</span>
<input type='text' id='node-input-unit' style='width:40px' placeholder='%' dir=''>
</div>
<div class='form-row' id='node-input-limits'>
<label for='node-input-minmax'><i class='fa fa-paint-brush'></i> Min-Max</span></label>
<input type="checkbox" id="node-input-minmax" style="display:inline-block; width:auto; vertical-align:baseline; margin-right:5px;">Show by default
<input type="checkbox" id="node-input-allowtoggle" checked style="display:inline-block; width:auto; vertical-align:baseline; margin-right:5px; margin-left:5px;">Allow toggle
</div>
</br>
<div class='form-row'>
<label for='node-input-stroke'><i class='fa fa-gear'></i> Stroke width</label>
<span for='node-input-stroke'</span>
<input type='number' id='node-input-stroke' min='1' max='6' value='2' size='1' style='width:60px' >
</div>
<div class='form-row'>
<label for='node-input-pointcount'><i class='fa fa-gear'></i> Points per unit</label>
<span for='node-input-pointcount'</span>
<input type='number' id='node-input-pointcount' min='2' max='24' value='8' size='1' style='width:60px' >
</div>
</br>
<div class='form-row'>
<label for='node-input-name'><i class='icon-tag'></i> Name</label>
<input type='text' id='node-input-name' placeholder='Name'>
</div>
</script>
<script type='text/x-red' data-help-name='ui_valuetrail'>
<p>Node-RED dashboard widget to show small trail of value history near some numeric value
<p>Configurable options:
<li>Color of line</li>
<li>Glow (on/off)</li>
<li>Show value (on/off) with rounding option (default is 0 so value is shown as integer)</li>
<li>Show min/max values (initial state). You can restrict toggling the min/max values at runtime by unticking the Allow toggle option.</li>
<li>Stroke width (1 ... 6)</li>
<li>Amount of datapoints per unit. (2 ... 24)</li>
<p style='margin-left: 30px'><code>unit</code> represents <code>1x1 Widget Size</code> in dashboard Site configuration</p>
<h3>Input</h3>
Configured <code>input property</code> should carry single numeric value.
</script>