summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-ledtrig-usbport/htdocs/luci-static
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-02-20 12:04:12 +0100
committerFlorian Eckert <fe@dev.tdt.de>2020-02-27 13:28:03 +0100
commit638f5ce071f229fb0c11456a0b59d425179ab288 (patch)
tree86b6c26b5eead5a6e7fa207a45a9e1784927410a /applications/luci-app-ledtrig-usbport/htdocs/luci-static
parenteffb720741534acc12891c149bafa832f9419a6c (diff)
luci-mod-system: add led plugin infrastructure
This commit creates the possibility that not only kernel-led-triggers can be selected but also application-led-triggers from user space. This is done via a plugin mechanism. The application-led-triggers are scripts that set kernel-led-triggers on system events or services. Until now this has not been possible. The package rssileds is a kind of application-led-trigger. The following new packages are added: * luci-app-ledtrig-rssi (application-led-trigger) * luci-app-ledtrig-switch (kernel-led-trigger) not needed on every most devices * luci-app-ledtrig-usport (kernel-led-trigger) optional trigger Since we have now a plugin mechanism I have added the following triggers as a dependency. So this triggers are now installed per default on LuCI installation. * kmod-ledtrig-default-on * kmod-ledtrig-heartbeat * kmod-ledtrig-netdev * kmod-ledtrig-timer The kernel trigger kmod-ledtrig-usbdev was removed with the commit https://github.com/openwrt/openwrt/commit/d0b50c2770a0e2d54b37153f2801e2e7dc865fa6 So I have not ported the relevant code anymore. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-ledtrig-usbport/htdocs/luci-static')
-rw-r--r--applications/luci-app-ledtrig-usbport/htdocs/luci-static/resources/view/system/led-trigger/usbport.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/applications/luci-app-ledtrig-usbport/htdocs/luci-static/resources/view/system/led-trigger/usbport.js b/applications/luci-app-ledtrig-usbport/htdocs/luci-static/resources/view/system/led-trigger/usbport.js
new file mode 100644
index 0000000000..970016c42b
--- /dev/null
+++ b/applications/luci-app-ledtrig-usbport/htdocs/luci-static/resources/view/system/led-trigger/usbport.js
@@ -0,0 +1,46 @@
+'use strict';
+'require rpc';
+'require uci';
+'require form';
+
+var callUSB = rpc.declare({
+ object: 'luci',
+ method: 'getUSBDevices',
+ expect: { 'ports': [] }
+});
+
+return L.Class.extend({
+ trigger: _('usbport (kernel)'),
+ kernel: true,
+ addFormOptions(s){
+ var o;
+
+ o = s.option(form.Value, 'port', _('USB Ports'));
+ o.depends('trigger', 'usbport');
+ o.rmempty = true;
+ o.modalonly = true;
+ o.load = function(s) {
+ return Promise.all([
+ callUSB()
+ ]).then(L.bind(function(usbport){
+ for (var i = 0; i < usbport[0].length; i++)
+ o.value(usbport[0][i].port, _('Port %s').format(usbport[0][i].port));
+ },this));
+ };
+ o.cfgvalue = function(section_id) {
+ var ports = [],
+ value = uci.get('system', section_id, 'port');
+
+ if (!Array.isArray(value))
+ value = String(value || '').split(/\s+/);
+
+ for (var i = 0; i < value.length; i++)
+ if (value[i].match(/^(\d+)-(\d+)$/))
+ ports.push('usb%d-port%d'.format(Regexp.$1, Regexp.$2));
+ else
+ ports.push(value[i]);
+
+ return ports;
+ };
+ }
+});