From 9cae3b9e67aef68cd579213bee1865ce1b815027 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 8 Sep 2019 16:12:25 +0200 Subject: protocols: replace luci/getTTYDevices calls with generic file/list ones Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/resources/protocol/3g.js | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'protocols/luci-proto-3g/htdocs/luci-static/resources/protocol') diff --git a/protocols/luci-proto-3g/htdocs/luci-static/resources/protocol/3g.js b/protocols/luci-proto-3g/htdocs/luci-static/resources/protocol/3g.js index d1273ce563..07bed36c23 100644 --- a/protocols/luci-proto-3g/htdocs/luci-static/resources/protocol/3g.js +++ b/protocols/luci-proto-3g/htdocs/luci-static/resources/protocol/3g.js @@ -4,11 +4,18 @@ 'require form'; 'require network'; -var callTTYDevices = rpc.declare({ - object: 'luci', - method: 'getTTYDevices', - params: [ 'with_cdc', 'with_tts' ], - expect: { result: [] } +var callFileList = rpc.declare({ + object: 'file', + method: 'list', + params: [ 'path' ], + expect: { entries: [] }, + filter: function(list, params) { + var rv = []; + for (var i = 0; i < list.length; i++) + if (list[i].name.match(/^tty[A-Z]/) || list[i].name.match(/^cdc-wdm/) || list[i].name.match(/^[0-9]+$/)) + rv.push(params.path + list[i].name); + return rv.sort(); + } }); network.registerPatternVirtual(/^3g-.+$/); @@ -66,11 +73,13 @@ return network.registerProtocol('3g', { o = s.taboption('general', form.Value, 'device', _('Modem device')); o.rmempty = false; o.load = function(section_id) { - return callTTYDevices(false, true).then(L.bind(function(devices) { - if (Array.isArray(devices)) - for (var i = 0; i < devices.length; i++) - this.value(devices[i]); - + return callFileList('/dev/').then(L.bind(function(devices) { + for (var i = 0; i < devices.length; i++) + this.value(devices[i]); + return callFileList('/dev/tts/'); + }, this)).then(L.bind(function(devices) { + for (var i = 0; i < devices.length; i++) + this.value(devices[i]); return form.Value.prototype.load.apply(this, [section_id]); }, this)); }; -- cgit v1.2.3