-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice-out.html
66 lines (65 loc) · 1.99 KB
/
device-out.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
<script type="text/javascript">
RED.nodes.registerType('device out', {
oneditprepare: function () {
console.log('prepare');
$.getJSON('devices', function (data) {
console.log(data);
const keys = Object.keys(data);
keys.forEach((protocol) => {
const devices = data[protocol];
for (var i = 0; i < devices.length; i++) {
const element = devices[i];
var value = `${protocol}|${element.ieeeAddr}`;;
var text = `${element.name}`;
$('#node-input-friendly').append($("<option></option>").attr("value", value).text(text));
}
})
});
// Make sure the selected value is also selected in the <select> tag
$('#node-input-friendly').val(this.userValue);
$('#node-input-payload').typedInput({
default: 'json',
typeField: $("#node-input-payload"),
types: ['json']
});
},
category: 'instathings',
color: '#e57373',
defaults: {
name: {
value: '',
},
friendly: {
value: '',
required: true,
},
payload: {
value: '',
required: true,
}
},
inputs: 1,
outputs: 0,
icon: "instathings-logo.png",
label: function () {
return this.name || "Device";
}
});
</script>
<script type="text/html" data-template-name="device out">
<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>
<div class="form-row">
<label for="node-input-friendly"><i class="icon-tag"></i> Friendly name</label>
<select id="node-input-friendly"></select>
</div>
<div class="form-row">
<label for="node-input-payload"><i class="icon-tag"></i>Payload</label>
<input type="text" id="node-input-payload" placeholder="Payload">
</div>
</script>
<script type="text/html" data-help-name="device out">
<p>A node that sends data to control a device.</p>
</script>