luci-mod-status: Adding scroll buttons on syslog and kernellog status pages
authorRamon Van Gorkom <Ramon00c00@gmail.com>
Sun, 11 Feb 2024 10:51:45 +0000 (11:51 +0100)
committerPaul Donald <newtwen@gmail.com>
Wed, 14 Feb 2024 22:11:19 +0000 (23:11 +0100)
Signed-off-by: Ramon Van Gorkom <Ramon00c00@gmail.com>
(cherry picked from commit eb6b2bdaae9c6f8d6d8969b47e21895d6508f396)

modules/luci-mod-status/htdocs/luci-static/resources/view/status/dmesg.js
modules/luci-mod-status/htdocs/luci-static/resources/view/status/syslog.js

index f3ee539bd154d20a064c50d1fdc5768bad1a772c..89e2000abda6fc3d7460d343f0c5a1227f1d8d75 100644 (file)
@@ -16,16 +16,36 @@ return view.extend({
                        return line.replace(/^<\d+>/, '');
                });
 
+               var scrollDownButton = E('button', { 
+                               'id': 'scrollDownButton',
+                               'class': 'cbi-button cbi-button-neutral',
+                       }, _('Scroll to tail', 'scroll to bottom (the tail) of the log file')
+               );
+               scrollDownButton.addEventListener('click', function() {
+                       window.scrollTo(0, document.body.scrollHeight);
+               });
+
+               var scrollUpButton = E('button', { 
+                               'id' : 'scrollUpButton',
+                               'class': 'cbi-button cbi-button-neutral',
+                       }, _('Scroll to head', 'scroll to top (the head) of the log file')
+               );
+               scrollUpButton.addEventListener('click', function() {
+                       window.scrollTo(0, 0);
+               });
+
                return E([], [
                        E('h2', {}, [ _('Kernel Log') ]),
                        E('div', { 'id': 'content_syslog' }, [
+                               E('div', {'style': 'padding-bottom: 20px'}, [scrollDownButton]),
                                E('textarea', {
                                        'id': 'syslog',
                                        'style': 'font-size:12px',
                                        'readonly': 'readonly',
                                        'wrap': 'off',
                                        'rows': loglines.length + 1
-                               }, [ loglines.join('\n') ])
+                               }, [ loglines.join('\n') ]),
+                               E('div', {'style': 'padding-bottom: 20px'}, [scrollUpButton])
                        ])
                ]);
        },
index 2bd29194d25e2fa43077c6d049c974ba669284df..d3de8af756b02a9e41455754a30c4325139660d7 100644 (file)
@@ -21,16 +21,37 @@ return view.extend({
        render: function(logdata) {
                var loglines = logdata.trim().split(/\n/);
 
+
+               var scrollDownButton = E('button', { 
+                               'id': 'scrollDownButton',
+                               'class': 'cbi-button cbi-button-neutral'
+                       }, _('Scroll to tail', 'scroll to bottom (the tail) of the log file')
+               );
+               scrollDownButton.addEventListener('click', function() {
+                       window.scrollTo(0, document.body.scrollHeight);
+               });
+
+               var scrollUpButton = E('button', { 
+                               'id' : 'scrollUpButton',
+                               'class': 'cbi-button cbi-button-neutral'
+                       }, _('Scroll to head', 'scroll to top (the head) of the log file')
+               );
+               scrollUpButton.addEventListener('click', function() {
+                       window.scrollTo(0, 0);
+               });
+
                return E([], [
                        E('h2', {}, [ _('System Log') ]),
                        E('div', { 'id': 'content_syslog' }, [
+                               E('div', {'style': 'padding-bottom: 20px'}, [scrollDownButton]),
                                E('textarea', {
                                        'id': 'syslog',
                                        'style': 'font-size:12px',
                                        'readonly': 'readonly',
                                        'wrap': 'off',
                                        'rows': loglines.length + 1
-                               }, [ loglines.join('\n') ])
+                               }, [ loglines.join('\n') ]),
+                               E('div', {'style': 'padding-bottom: 20px'}, [scrollUpButton])
                        ])
                ]);
        },