forked from mblackstock/node-red-contrib-influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfluxdb.html
executable file
·397 lines (381 loc) · 19.8 KB
/
influxdb.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<script type="text/x-red" data-template-name="influxdb">
<div class="form-row">
<label for="node-config-input-hostname"><i class="fa fa-server"></i> <span data-i18n="influxdb.label.host"></span></label>
<input class="input-append-left" type="text" id="node-config-input-hostname" placeholder="localhost" style="width: 40%;" >
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> <span data-i18n="influxdb.label.port"></span></label>
<input type="text" id="node-config-input-port" style="width:45px">
</div>
<div class="form-row">
<label for="node-config-input-database"><i class="fa fa-database"></i> <span data-i18n="influxdb.label.database"></span></label>
<input type="text" id="node-config-input-database">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="node-red:common.label.username"></span></label>
<input type="text" id="node-config-input-username">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> <span data-i18n="node-red:common.label.password"></span></label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<input type="checkbox" id="node-config-input-usetls" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-usetls" style="width: auto" data-i18n="influxdb.label.use-tls"></label>
<div id="node-config-row-tls" class="hide">
<label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-config-input-tls"><span data-i18n="influxdb.label.tls-config"></span></label>
<input style="width: 300px;" type="text" id="node-config-input-tls">
</div>
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-config-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('influxdb', {
category: 'config',
color: "rgb(218, 196, 180)",
defaults: {
hostname: {value: "127.0.0.1", required: true},
port: {value: 8086, required: true},
protocol: {value: "http", required: true},
database: {value: "", required: true},
name: {value: ""},
usetls: {value: false},
tls: {type:"tls-config",required: false}
},
credentials: {
username: {type: "text"},
password: {type: "password"}
},
label: function() {
return this.name || this.hostname + ":" + this.port + "/" + this.database;
},
oneditprepare: function() {
if (typeof this.usetls === 'undefined') {
this.usetls = false;
$("#node-config-input-usetls").prop("checked",false);
}
function updateTLSOptions() {
if ($("#node-config-input-usetls").is(':checked')) {
$("#node-config-row-tls").show();
} else {
$("#node-config-row-tls").hide();
}
}
updateTLSOptions();
$("#node-config-input-usetls").on("click",function() {
updateTLSOptions();
});
}
});
</script>
<script type="text/x-red" data-template-name="influxdb out">
<div class="form-row">
<label for="node-input-influxdb"><i class="fa fa-server"></i> <span data-i18n="influxdb.label.server"></span></label>
<input type="text" id="node-input-influxdb">
</div>
<div class="form-row">
<label for="node-input-measurement"><i style="width: 10px;" class="fa fa-rss"></i> <span data-i18n="influxdb.label.measurement"></span></label>
<input type="text" id="node-input-measurement">
</div>
<div class="form-row">
<input type="checkbox" id="advanced-options-checkbox" style="display: inline-block; width: auto; vertical-align: top;">
<label for="advanced-options-checkbox" style="width: 70%;"><span data-i18n="influxdb.label.use-advanced-query"></span></label>
<div id="advanced-options-div" class="hide" style="margin-left: 20px; margin-top: 10px;">
<div class="form-row">
<label for="node-input-precision" style="width:35%"><i class="fa fa-clock-o"></i> <span data-i18n="influxdb.label.time-precision"></span></label>
<select type="text" id="node-input-precision" style="width:55%">
<option value="">Default</option>
<option value="n">Nanoseconds (n)</option>
<option value="u">Microseconds (u)</option>
<option value="ms">Milliseconds (ms)</option>
<option value="s">Seconds (s)</option>
<option value="m">Minute (m)</option>
<option value="h">Hour (h)</option>
<option value="d">Day (d)</option>
<option value="w">Week (w)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-retentionPolicy" style="width:35%"><i class="fa fa-gavel"></i> <span data-i18n="influxdb.label.retention-policy"></span></label>
<input type="text" style="width:55%" id="node-input-retentionPolicy">
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]influxdb.tip"></span></div>
</script>
<script type="text/x-red" data-help-name="influxdb out">
<p>A simple influxdb output node to write values and tags to an influxdb measurement.</p>
<p>The fields and tags to write are in <b>msg.payload</b>. If <b>msg.payload</b> is a string, number, or boolean,
it will be written as a single value to the specified measurement (called <i>value</i>).</p>
<p>If <b>msg.payload</b> is an object containing multiple properties, the fields will be written to the measurement.</p>
<p>If <b>msg.payload</b> is an array containing two objects, the first object will be written as the set of named fields,
the second is the set of named tags.</p>
<p>Finally, if <b>msg.payload</b> is an array of arrays, it will be written as a series of points containing fields and tags.</p>
<p>If the <i>measurement</i> field is not set in the node configuration, the user can send in data with a specified
measurement name in <b>msg.measurement</b> to overwrite the <i>measurement</i> field in the configuration of the node.</p>
<p>Check <i>Advanced Query Options</i> to specify a time precision and retention policy for the insertion.<p>
<p>The advanced query options <i>Time Precision</i> and <i>Retention Policy</i> can be overwritten using
message properties <b>msg.precision</b> and <b>msg.retentionPolicy</b>.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('influxdb out', {
category: 'storage-output',
color: "rgb(218, 196, 180)",
defaults: {
influxdb: {type: "influxdb", required: true},
name: {value: ""},
measurement: {value: ""},
precision: {value: ""},
retentionPolicy: {value: ""}
},
inputs: 1,
outputs: 0,
icon: "influxdb.png",
align: "right",
label: function() {
var influxNode = RED.nodes.node(this.influxdb);
return this.name || (influxNode ? influxNode.label() + " " + this.measurement: "influxdb");
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
$("#node-input-measurement").change(function () {
if($("#node-input-measurement").val() === "") {
$("#node-warning").show();
} else {
$("#node-warning").hide();
}
});
$("#advanced-options-checkbox").change( function () {
if ($('#advanced-options-checkbox').is(":checked")) {
$("#advanced-options-div").show();
} else {
$("#advanced-options-div").hide();
}
});
// show advanced options if a query option is set on startup
if (($('#node-input-precision').val() === "")
&& ($('#node-input-retentionPolicy').val() === "")) {
$("#advanced-options-div").hide();
} else {
$('#advanced-options-checkbox').prop('checked', true);
$("#advanced-options-div").show();
}
},
oneditsave: function() {
// reset inputs if we are not using advanced options
if (!$("#advanced-options-checkbox").is(':checked')) {
$("#node-input-precision").val("");
$("#node-input-retentionPolicy").val("");
}
}
});
</script>
<script type="text/x-red" data-template-name="influxdb batch">
<div class="form-row">
<label for="node-input-influxdb"><i class="fa fa-server"></i> <span data-i18n="influxdb.label.server"></span></label>
<input type="text" id="node-input-influxdb">
</div>
<div class="form-row">
<input type="checkbox" id="advanced-options-checkbox" style="display: inline-block; width: auto; vertical-align: top;">
<label for="advanced-options-checkbox" style="width: 70%;"><span data-i18n="influxdb.label.use-advanced-query"></span></label>
<div id="advanced-options-div" class="hide" style="margin-left: 20px; margin-top: 10px;">
<div class="form-row">
<label for="node-input-precision" style="width:35%"><i class="fa fa-clock-o"></i> <span data-i18n="influxdb.label.time-precision"></span></label>
<select type="text" id="node-input-precision" style="width:55%">
<option value="">Default</option>
<option value="n">Nanoseconds (n)</option>
<option value="u">Microseconds (u)</option>
<option value="ms">Milliseconds (ms)</option>
<option value="s">Seconds (s)</option>
<option value="m">Minute (m)</option>
<option value="h">Hour (h)</option>
<option value="d">Day (d)</option>
<option value="w">Week (w)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-retentionPolicy" style="width:35%"><i class="fa fa-gavel"></i> <span data-i18n="influxdb.label.retention-policy"></span></label>
<input type="text" style="width:55%" id="node-input-retentionPolicy">
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]influxdb.tip"></span></div>
</script>
<script type="text/x-red" data-help-name="influxdb batch">
<p>A influxdb output node to write multiple points (fields and tags) to multiple influxdb measurements.</p>
<p>The <b>msg.payload</b> needs to be an array of <i>point</i> objects.</p>
<p>The <b>measurement</b> property of a point contains the name of the measurement for the point. The <b>fields</b> property will contain the
fields of the point. If supplied, the <b>tags</b> property will contain the tags for the point. To set the time
for the point, supply a <b>timestamp</b> property.</p>
<p>Check <i>Advanced Query Options</i> to specify a time precision and retention policy for the insertion.<p>
<p>The advanced query options <i>Time Precision</i> and <i>Retention Policy</i> can be overwritten using
message properties <b>msg.precision</b> and <b>msg.retentionPolicy</b>.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('influxdb batch', {
category: 'storage-output',
color: "rgb(218, 196, 180)",
paletteLabel: 'influx batch',
defaults: {
influxdb: {type: "influxdb", required: true},
precision: {value: ""},
retentionPolicy: {value: ""},
name: {value: ""}
},
inputs: 1,
outputs: 0,
icon: "influxdb.png",
align: "right",
label: function() {
var influxNode = RED.nodes.node(this.influxdb);
return this.name || (influxNode ? influxNode.label() : "influxdb batch");
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
$("#advanced-options-checkbox").change( function () {
if ($('#advanced-options-checkbox').is(":checked")) {
$("#advanced-options-div").show();
} else {
$("#advanced-options-div").hide();
}
});
// show advanced options if a query option is set on startup
if (($('#node-input-precision').val() === "")
&& ($('#node-input-retentionPolicy').val() === "")) {
$("#advanced-options-div").hide();
} else {
$('#advanced-options-checkbox').prop('checked', true);
$("#advanced-options-div").show();
}
},
oneditsave: function() {
// reset inputs if we are not using advanced options
if (!$("#advanced-options-checkbox").is(':checked')) {
$("#node-input-precision").val("");
$("#node-input-retentionPolicy").val("");
}
}
});
</script>
<script type="text/x-red" data-template-name="influxdb in">
<div class="form-row">
<label for="node-input-influxdb"><i class="fa fa-server"></i> <span data-i18n="influxdb.label.server"></span></label>
<input type="text" id="node-input-influxdb">
</div>
<div class="form-row">
<label for="node-input-query"><i class="fa fa-briefcase"></i> <span data-i18n="influxdb.label.query"></span></label>
<input type="text" id="node-input-query">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-rawOutput" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-rawOutput"><span data-i18n="influxdb.label.use-raw-output"></span></label>
</div>
<div class="form-row">
<input type="checkbox" id="advanced-options-checkbox" style="display: inline-block; width: auto; vertical-align: top;">
<label for="advanced-options-checkbox" style="width: 70%;"><span data-i18n="influxdb.label.use-advanced-query"></span></label>
<div id="advanced-options-div" class="hide" style="margin-left: 20px; margin-top: 10px;">
<div class="form-row">
<label for="node-input-precision" style="width:35%"><i class="fa fa-clock-o"></i> <span data-i18n="influxdb.label.time-precision"></span></label>
<select type="text" id="node-input-precision" style="width:55%">
<option value="">Default</option>
<option value="n">Nanoseconds (n)</option>
<option value="u">Microseconds (u)</option>
<option value="ms">Milliseconds (ms)</option>
<option value="s">Seconds (s)</option>
<option value="m">Minute (m)</option>
<option value="h">Hour (h)</option>
<option value="d">Day (d)</option>
<option value="w">Week (w)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-retentionPolicy" style="width:35%"><i class="fa fa-gavel"></i> <span data-i18n="influxdb.label.retention-policy"></span></label>
<input type="text" style="width:55%" id="node-input-retentionPolicy">
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]influxdb.querytip"></span></div>
</script>
<script type="text/x-red" data-help-name="influxdb in">
<p>Allows basic queries to be made to an influxdb time series database.</p>
<p>The query can be specified in the configuration property or using the property
<b>msg.query</b>. The results will be returned in <b>msg.payload</b>.</p>
<p>To output the results of the query in the raw output format returned by InfluxDb,
check the <i>Raw Output</i> checkbox.</p>
<p>Check <i>Advanced Query Options</i> to specify a time precision and retention policy for the query.<p>
<p>The raw output configuration can be overwritten by the message property <b>msg.rawOutput</b>. </p>
<p>The advanced query options <i>Time Precision</i> and <i>Retention Policy</i> can be overwritten using
message properties <b>msg.precision</b> and <b>msg.retentionPolicy</b>.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('influxdb in', {
category: 'storage-input',
color: "rgb(218, 196, 180)",
defaults: {
influxdb: {type: "influxdb", required: true},
name: {value: ""},
query: {value: ""},
rawOutput: {value: false},
precision: {value: ""},
retentionPolicy: {value: ""}
},
inputs: 1,
outputs: 1,
icon: "influxdb.png",
label: function() {
var influxNode = RED.nodes.node(this.influxdb);
return this.name || (influxNode ? influxNode.label() + " " + this.query: "influxdb");
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
$("#node-input-query").change(function () {
if($("#node-input-query").val() === "") {
$("#node-warning").show();
} else {
$("#node-warning").hide();
}
});
$("#advanced-options-checkbox").change( function () {
if ($('#advanced-options-checkbox').is(":checked")) {
$("#advanced-options-div").show();
} else {
$("#advanced-options-div").hide();
}
});
// show advanced options if a query option is set on startup
if (($('#node-input-precision').val() === "")
&& ($('#node-input-retentionPolicy').val() === "")) {
$("#advanced-options-div").hide();
} else {
$('#advanced-options-checkbox').prop('checked', true);
$("#advanced-options-div").show();
}
},
oneditsave: function() {
// reset inputs if we are not using advanced options
if (!$("#advanced-options-checkbox").is(':checked')) {
$("#node-input-precision").val("");
$("#node-input-retentionPolicy").val("");
}
}
});
</script>