-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.html
63 lines (56 loc) · 2.19 KB
/
controller.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
<script src="resources/@sammachin/node-red-matter-controller/editor.js"></script>
<script type="text/javascript">
RED.nodes.registerType('mattercontroller',{
category: 'config',
defaults: {
name: {value:""},
networkInterface : {required: true},
logLevel: {value: "ERROR"}
},
label: function() {
return this.name||"Controller";
},
oneditprepare: function(){
var nodeid=this.id
var selectedInterface = this.networkInterface
$.get('_mattercontroller/interfaces', function(r) {
let interfaces = document.getElementById('node-config-input-networkInterface');
r.forEach(i => {
interfaces.add(new Option(i, i));
});
console.log(selectedInterface)
if (typeof selectedInterface !== 'undefined'){
console.log('defined')
interfaces.value = selectedInterface
}
})
.error(function(e) {
console.log(e.status);
})
}
});
</script>
<script type="text/x-red" data-template-name="mattercontroller">
<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-config-input-networkInterface">Network interface</label>
<select type="text" id="node-config-input-networkInterface" style="width:50%;" >
</select>
</div>
<div class="form-row">
<label for="node-config-input-logLevel">Log Level</label>
<select type="text" id="node-config-input-logLevel" style="width:50%;" >
<option value="DEBUG">Debug</option>
<option value="INFO">Info</option>
<option value="WARN">Warn</option>
<option value="ERROR">Error</option>
<option value="FATAL">Fatal</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="mattercontroller">
<p>Controller Object to attach devices to</p>
</script>