Skip to content

Commit

Permalink
luci-mod-status: reimplement log pages as client side views
Browse files Browse the repository at this point in the history
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  • Loading branch information
jow- committed Dec 22, 2019
1 parent b9bb346 commit 939b371
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 45 deletions.
2 changes: 2 additions & 0 deletions modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json
Expand Up @@ -39,10 +39,12 @@
"/proc/sys/net/netfilter/nf_conntrack_*": [ "read" ],
"/proc/mounts": [ "read" ],
"/usr/lib/lua/luci/version.lua": [ "read" ],
"/bin/dmesg -r": [ "exec" ],
"/bin/ping *": [ "exec" ],
"/bin/ping6 *": [ "exec" ],
"/bin/traceroute *": [ "exec" ],
"/bin/traceroute6 *": [ "exec" ],
"/sbin/logread -e ^": [ "exec" ],
"/usr/bin/ping *": [ "exec" ],
"/usr/bin/ping6 *": [ "exec" ],
"/usr/bin/traceroute *": [ "exec" ],
Expand Down
@@ -0,0 +1,35 @@
'use strict';
'require fs';
'require ui';

return L.view.extend({
load: function() {
return fs.exec_direct('/bin/dmesg', [ '-r' ]).catch(function(err) {
ui.addNotification(null, E('p', {}, _('Unable to load log data: ' + err.message)));
return '';
});
},

render: function(logdata) {
var loglines = logdata.trim().split(/\n/).map(function(line) {
return line.replace(/^<\d+>/, '');
});

return E([], [
E('h2', {}, [ _('Kernel Log') ]),
E('div', { 'id': 'content_syslog' }, [
E('textarea', {
'id': 'syslog',
'style': 'font-size:12px',
'readonly': 'readonly',
'wrap': 'off',
'rows': loglines.length + 1
}, [ loglines.join('\n') ])
])
]);
},

handleSaveApply: null,
handleSave: null,
handleReset: null
});
@@ -0,0 +1,33 @@
'use strict';
'require fs';
'require ui';

return L.view.extend({
load: function() {
return fs.exec_direct('/sbin/logread', [ '-e', '^' ]).catch(function(err) {
ui.addNotification(null, E('p', {}, _('Unable to load log data: ' + err.message)));
return '';
});
},

render: function(logdata) {
var loglines = logdata.trim().split(/\n/);

return E([], [
E('h2', {}, [ _('System Log') ]),
E('div', { 'id': 'content_syslog' }, [
E('textarea', {
'id': 'syslog',
'style': 'font-size:12px',
'readonly': 'readonly',
'wrap': 'off',
'rows': loglines.length + 1
}, [ loglines.join('\n') ])
])
]);
},

handleSaveApply: null,
handleSave: null,
handleReset: null
});
15 changes: 0 additions & 15 deletions modules/luci-mod-status/luasrc/controller/admin/status.lua

This file was deleted.

12 changes: 0 additions & 12 deletions modules/luci-mod-status/luasrc/view/admin_status/dmesg.htm

This file was deleted.

12 changes: 0 additions & 12 deletions modules/luci-mod-status/luasrc/view/admin_status/syslog.htm

This file was deleted.

Expand Up @@ -30,19 +30,17 @@
"title": "System Log",
"order": 4,
"action": {
"type": "call",
"module": "luci.controller.admin.status",
"function": "action_syslog"
"type": "view",
"path": "status/syslog"
}
},

"admin/status/dmesg": {
"title": "Kernel Log",
"order": 5,
"action": {
"type": "call",
"module": "luci.controller.admin.status",
"function": "action_dmesg"
"type": "view",
"path": "status/dmesg"
}
},

Expand Down

0 comments on commit 939b371

Please sign in to comment.