1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

fix button class and serial.list promise

This commit is contained in:
Dave Conway-Jones 2019-11-13 18:43:43 +00:00
parent 3ed1e72481
commit 0bef668028
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
3 changed files with 12 additions and 9 deletions

View File

@ -147,7 +147,7 @@
<div class="form-row">
<label for="node-config-input-serialport"><i class="fa fa-random"></i> <span data-i18n="serial.label.serialport"></span></label>
<input type="text" id="node-config-input-serialport" style="width:66%;" data-i18n="[placeholder]serial.placeholder.serialport">
<a id="node-config-lookup-serial" class="btn"><i id="node-config-lookup-serial-icon" class="fa fa-search"></i></a>
<a id="node-config-lookup-serial" class="red-ui-button"><i id="node-config-lookup-serial-icon" class="fa fa-search"></i></a>
</div>
<div class="form-row">
<table width="100%"><tr>
@ -354,10 +354,7 @@
$("#node-config-lookup-serial").addClass('disabled');
$.getJSON('serialports',function(data) {
$("#node-config-lookup-serial").removeClass('disabled');
var ports = [];
$.each(data, function(i, port) {
ports.push(port.comName);
});
var ports = data || [];
$("#node-config-input-serialport").autocomplete({
source:ports,
minLength:0,

View File

@ -444,8 +444,14 @@ module.exports = function(RED) {
}());
RED.httpAdmin.get("/serialports", RED.auth.needsPermission('serial.read'), function(req,res) {
serialp.list(function (err, ports) {
res.json(ports);
});
serialp.list().then(
ports => {
const a = ports.map(p => p.path);
res.json(a);
},
err => {
node.log('Error listing serial ports', err)
}
)
});
}

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-serialport",
"version" : "0.9.0",
"version" : "0.9.1",
"description" : "Node-RED nodes to talk to serial ports",
"dependencies" : {
"serialport" : "^8.0.5"