@mschaeffler/node-red-bthome 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bthome.html +71 -9
- package/package.json +1 -1
package/bthome.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
color: '#a6bbcf',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {value:""},
|
|
7
|
-
devices:{value:"
|
|
7
|
+
devices:{value:"{}",required:true},
|
|
8
8
|
counterMode:{value:"none",required:true},
|
|
9
9
|
statusPrefix:{value:""},
|
|
10
10
|
eventPrefix:{value:""},
|
|
@@ -26,10 +26,6 @@
|
|
|
26
26
|
outputLabels: ['state output','event output'],
|
|
27
27
|
oneditprepare: function() {
|
|
28
28
|
const node = this;
|
|
29
|
-
$("#node-input-devices").typedInput({
|
|
30
|
-
type:"json",
|
|
31
|
-
types:["json"]
|
|
32
|
-
});
|
|
33
29
|
// populate store names
|
|
34
30
|
$("#node-input-contextStore").empty();
|
|
35
31
|
$("#node-input-contextStore").append(`<option value="none">None</option>`);
|
|
@@ -54,6 +50,72 @@
|
|
|
54
50
|
});
|
|
55
51
|
// select the current option
|
|
56
52
|
$("#node-input-contextStore").val(currentStore);
|
|
53
|
+
// Devices-List
|
|
54
|
+
const devicesList = $("#node-input-devices-container").css('min-height','150px').css('min-width','450px').editableList({
|
|
55
|
+
addItem: function(container,i,device) {
|
|
56
|
+
container.css({
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
whiteSpace: 'nowrap'
|
|
59
|
+
});
|
|
60
|
+
const row1 = $('<div/>').appendTo(container);
|
|
61
|
+
const row2 = $('<div/>').appendTo(container);
|
|
62
|
+
$('<div/>',{style: 'display:inline-block; width:8%;'})
|
|
63
|
+
.text('mac')
|
|
64
|
+
.appendTo(row1);
|
|
65
|
+
const propertyMac = $('<input/>',{class:"node-input-device-mac",type:"text"})
|
|
66
|
+
.css("width","40%")
|
|
67
|
+
.appendTo(row1)
|
|
68
|
+
.typedInput({types:['str']});
|
|
69
|
+
$('<div/>',{style: 'display:inline-block; padding:0px 6px;'})
|
|
70
|
+
.text('=')
|
|
71
|
+
.appendTo(row1);
|
|
72
|
+
const propertyTopic = $('<input/>',{class:"node-input-device-topic",type:"text"})
|
|
73
|
+
.css("width","45%")
|
|
74
|
+
.appendTo(row1)
|
|
75
|
+
.typedInput({types:['str']});
|
|
76
|
+
$('<div/>',{style: 'display:inline-block; width: 8%;'})
|
|
77
|
+
.text('key')
|
|
78
|
+
.appendTo(row2);
|
|
79
|
+
const propertyKey = $('<input/>',{class:"node-input-device-key",type:"text"})
|
|
80
|
+
.css("width","89%")
|
|
81
|
+
.appendTo(row2)
|
|
82
|
+
.typedInput({types:['str']});
|
|
83
|
+
propertyMac .typedInput('value',device.mac ?? "");
|
|
84
|
+
propertyTopic.typedInput('value',device.topic ?? "");
|
|
85
|
+
propertyKey .typedInput('value',device.key ?? "");
|
|
86
|
+
},
|
|
87
|
+
//sortable: true,
|
|
88
|
+
removable: true
|
|
89
|
+
});
|
|
90
|
+
console.log(this.devices)
|
|
91
|
+
const help = JSON.parse( this.devices ?? "[]" );
|
|
92
|
+
for( const i in help ) {
|
|
93
|
+
const v = help[i];
|
|
94
|
+
devicesList.editableList('addItem',typeof v == "string" ? {name:v} : {mac:i,topic:v.topic,key:v.key});
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
oneditresize: function(size) {
|
|
98
|
+
const rows = $("#dialog-form>div:not(.node-input-devices-container-row)");
|
|
99
|
+
let height = size.height;
|
|
100
|
+
for(let i=0; i<rows.length; i++) {
|
|
101
|
+
height -= $(rows[i]).outerHeight(true);
|
|
102
|
+
}
|
|
103
|
+
const editorRow = $("#dialog-form>div.node-input-devices-container-row");
|
|
104
|
+
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
|
|
105
|
+
$("#node-input-devices-container").editableList('height',height);
|
|
106
|
+
},
|
|
107
|
+
oneditsave: function() {
|
|
108
|
+
const devices = $("#node-input-devices-container").editableList('items');
|
|
109
|
+
let help = {};
|
|
110
|
+
devices.each(function(i) {
|
|
111
|
+
const device = $(this);
|
|
112
|
+
const mac = device.find(".node-input-device-mac") .typedInput('value');
|
|
113
|
+
const topic = device.find(".node-input-device-topic").typedInput('value');
|
|
114
|
+
const key = device.find(".node-input-device-key") .typedInput('value');
|
|
115
|
+
help[mac] = key==="" ? { topic:topic } : { topic:topic, key:key };
|
|
116
|
+
});
|
|
117
|
+
console.log(JSON.stringify( help ))
|
|
118
|
+
this.devices = JSON.stringify( help );
|
|
57
119
|
}
|
|
58
120
|
});
|
|
59
121
|
</script>
|
|
@@ -63,10 +125,6 @@
|
|
|
63
125
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
64
126
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
65
127
|
</div>
|
|
66
|
-
<div class="form-row">
|
|
67
|
-
<label for="node-input-devices"><i class="fa fa-bluetooth-b"></i> Devices</label>
|
|
68
|
-
<input type="text" id="node-input-devices">
|
|
69
|
-
</div>
|
|
70
128
|
<div class="form-row">
|
|
71
129
|
<label for="node-input-counterMode"><i class="fa fa-clock-o"></i> Countermode</label>
|
|
72
130
|
<select type="text" id="node-input-counterMode">
|
|
@@ -95,6 +153,10 @@
|
|
|
95
153
|
<label for="node-input-batteryState"><i class="fa fa-"></i> battery is state</label>
|
|
96
154
|
<input type="checkbox" id="node-input-batteryState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
97
155
|
</div>
|
|
156
|
+
<div class="form-row node-input-devices-container-row">
|
|
157
|
+
<label for="node-input-devices"><i class="fa fa-bluetooth-b"></i> Devices</label>
|
|
158
|
+
<ol id="node-input-devices-container"></ol>
|
|
159
|
+
</div>
|
|
98
160
|
</script>
|
|
99
161
|
|
|
100
162
|
<script type="text/x-red" data-help-name="bthome">
|