-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboard.html
137 lines (128 loc) · 3.8 KB
/
board.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
<script type='text/javascript'>
(function() {
'use strict';
var map = {
mqtt: 'device',
serial: 'path',
bluetooth: 'address',
websocket: 'url'
};
function updateButtonStatus() {
var tran = $('#node-config-input-transport').val(),
arg0 = tran ? $('#node-config-input-' + map[tran]).val() : null;
if (!(tran && arg0)) {
$('#node-config-dialog-ok').button('disable');
} else {
$('#node-config-dialog-ok').button('enable');
}
}
RED.nodes.registerType('board', {
category: 'config',
defaults: {
transport: {
value: '',
required: true
},
board: {
value: ''
},
device: {
value: ''
},
path: {
value: ''
},
address: {
value: ''
},
url: {
value: ''
}
},
exportable: false,
label: function() {
var tran = this.transport,
arg0 = tran ? this[map[tran]] : '';
return (tran && arg0) ? '[' + tran + '] ' + arg0 : '';
},
oneditprepare: function() {
$('#node-config-input-transport').on('change', function() {
switch (this.value) {
case 'mqtt':
$('.row-mqtt').show();
$('.row-serial').hide();
$('.row-bluetooth').hide();
$('.row-websocket').hide();
break;
case 'serial':
$('.row-mqtt').hide();
$('.row-serial').show();
$('.row-bluetooth').hide();
$('.row-websocket').hide();
break;
case 'bluetooth':
$('.row-mqtt').hide();
$('.row-serial').hide();
$('.row-bluetooth').show();
$('.row-websocket').hide();
break;
case 'websocket':
$('.row-mqtt').hide();
$('.row-serial').hide();
$('.row-bluetooth').hide();
$('.row-websocket').show();
break;
default:
$('.row-mqtt').hide();
$('.row-serial').hide();
$('.row-bluetooth').hide();
$('.row-websocket').hide();
break;
}
updateButtonStatus();
});
$('#node-config-input-device, #node-config-input-path, #node-config-input-address, #node-config-input-url').on('keyup', function () {
updateButtonStatus();
});
setTimeout(function() {
updateButtonStatus();
});
}
});
}());
</script>
<script type='text/x-red' data-template-name='board'>
<div class='form-row'>
<label for='node-config-input-transport'>Transport</label>
<select type='text' id='node-config-input-transport'>
<option value='mqtt'>mqtt</option>
<option value='serial'>serial</option>
<option value='bluetooth'>bluetooth</option>
<option value='websocket'>websocket</option>
</select>
</div>
<div class='form-row row-board'>
<label for='node-config-input-board'>Board</label>
<select type='text' id='node-config-input-board'>
<option value=''>Mark 1</option>
<option value=''>Fly</option>
<option value='Smart'>Smart</option>
</select>
</div>
<div class='form-row row-mqtt'>
<label for='node-config-input-deivce'>Device ID</label>
<input type='text' id='node-config-input-device' placeholder='Device ID'>
</div>
<div class='form-row row-serial'>
<label for='node-config-input-path'>Path</label>
<input type='text' id='node-config-input-path' placeholder='Path'>
</div>
<div class='form-row row-bluetooth'>
<label for='node-config-input-address'>Address</label>
<input type='text' id='node-config-input-address' placeholder='Address'>
</div>
<div class='form-row row-websocket'>
<label for='node-config-input-url'>Url</label>
<input type='text' id='node-config-input-url' placeholder='Url'>
</div>
</script>