From: Florian Eckert Date: Thu, 2 Sep 2021 12:52:23 +0000 (+0200) Subject: luci-mod-system: add led-trigger description X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=bff0878f9134e58aeec915733173b25071024f64;p=project%2Fluci.git luci-mod-system: add led-trigger description Signed-off-by: Florian Eckert --- diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/default-on.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/default-on.js index ba7b00ede3..77d62b6a79 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/default-on.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/default-on.js @@ -4,6 +4,7 @@ return baseclass.extend({ trigger: _('Always on (kernel: default-on)'), + description: _('The LED is always in default state on.'), kernel: true, addFormOptions(s){ var o; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/heartbeat.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/heartbeat.js index 9050063bf2..1a6eeebd2c 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/heartbeat.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/heartbeat.js @@ -3,6 +3,8 @@ return baseclass.extend({ trigger: _('Heartbeat interval (kernel: heartbeat)'), + description: _('The LED flashes to simulate actual heart beat.') + + _('The frequency is in direct proportion to 1-minute average CPU load.'), kernel: true, addFormOptions(s){ var o; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/netdev.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/netdev.js index 692c887ea4..af70f449d2 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/netdev.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/netdev.js @@ -5,6 +5,7 @@ return baseclass.extend({ trigger: _("Network device activity (kernel: netdev)"), + description: _('The LED flashes with link status and activity on the configured interface.'), kernel: true, addFormOptions(s){ var o; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/none.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/none.js index ef21adc7dc..5b3b26344e 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/none.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/none.js @@ -3,6 +3,7 @@ return baseclass.extend({ trigger: _('Always off (kernel: none)'), + description: _('The LED is always in default state off.'), kernel: true, addFormOptions(s){ var o; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/timer.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/timer.js index f8b89f1cdd..6213604a1a 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/timer.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/timer.js @@ -4,6 +4,7 @@ return baseclass.extend({ trigger: _('Custom flash interval (kernel: timer)'), + description: _('The LED blinks with the configured on/off frequency'), kernel: true, addFormOptions(s){ var o; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js index 23feebc005..c0cbd7a4f1 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js @@ -63,6 +63,7 @@ return view.extend({ s.addremove = true; s.sortable = true; s.addbtntitle = _('Add LED action'); + s.nodescriptions = true; s.option(form.Value, 'name', _('Name')); @@ -75,13 +76,31 @@ return view.extend({ for (var i = 0; i < plugins.length; i++) { var plugin = plugins[i]; - if ( plugin.form.kernel == false ) + if ( plugin.form.kernel == false ) { o.value(plugin.name, plugin.form.trigger); - else - for (var k = 0; k < triggers.length; k++) - if ( plugin.name == triggers[k] ) - o.value(plugin.name, plugin.form.trigger); + } + else { + if (triggers.indexOf(plugin.name) >= 0) + o.value(plugin.name, plugin.form.trigger); + } + } + o.onchange = function(ev, section, value) { + for (var i = 0; i < plugins.length; i++) { + var plugin = plugins[i]; + if ( plugin.name === value ) + this.map.findElement('id', 'cbid.system.%s.trigger'.format(section)) + .nextElementSibling.innerHTML = plugin.form.description || ''; + } } + o.load = function(section_id) { + var trigger = uci.get('system', section_id, 'trigger'); + for (var i = 0; i < plugins.length; i++) { + var plugin = plugins[i]; + if ( plugin.name === trigger) + this.description = plugin.form.description || ''; + } + return trigger; + }; s.addModalOptions = function(s) { for (var i = 0; i < plugins.length; i++) {