luci-mod-system: add led-trigger description
authorFlorian Eckert <fe@dev.tdt.de>
Thu, 2 Sep 2021 12:52:23 +0000 (14:52 +0200)
committerFlorian Eckert <fe@dev.tdt.de>
Wed, 27 Oct 2021 08:38:34 +0000 (10:38 +0200)
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/default-on.js
modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/heartbeat.js
modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/netdev.js
modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/none.js
modules/luci-mod-system/htdocs/luci-static/resources/view/system/led-trigger/timer.js
modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js

index ba7b00ede319f40d1d8b43bd5da3eba6d010a603..77d62b6a79ef08a469009600da759305dd4ab434 100644 (file)
@@ -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;
index 9050063bf20e56631672c98caa66a49e3db0f66e..1a6eeebd2c4dfb1f9b6b60a82e96e660ed81e1dc 100644 (file)
@@ -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;
index 692c887ea4313c15b7053acc78ff44fbb46be402..af70f449d2e1142d93d9dfb4dce575f6769bdb80 100644 (file)
@@ -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;
index ef21adc7dcb302421706771748c57c776ee883c2..5b3b26344e93a452ef61d5804ce0c98c203949f4 100644 (file)
@@ -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;
index f8b89f1cdd5e93d5afeac01a78433783fe529725..6213604a1a200aeaf43c4c590d89a08fbbc6709f 100644 (file)
@@ -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;
index 23feebc005ec1ed0b9c033bfbda99bef1e8e4785..c0cbd7a4f1cd1d35b969f1ca5752ac6868f74b5d 100644 (file)
@@ -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++) {