0
0
mirror of https://github.com/openwrt/luci.git synced 2025-04-21 20:19:10 +00:00
Files
Karl Palsson c5a65a8397 widgets: add a re-useable filtered logread view
Multiple apps introduced their own implementation of a syslog view,
filtered for just their own application logs.  Pull that out as a shared
view.  Some of these had _minor_ style differences, which has been
"standardized" now.  A full "widget" conversion would allow more end app
tuning of that, but is not implemented.

Signed-off-by: Karl Palsson <karlp@etactica.com>

app-nextdns: fix Logs title

Minor typo, introduced in 625abbf (convert simple controllers to
menu.json)

Signed-off-by: Karl Palsson <karlp@etactica.com>

luci-base: implement shared log reader view

Closes #5452

Signed-off-by: Paul Donald <newtwen@gmail.com>
2024-03-17 01:02:19 +01:00

46 lines
1.2 KiB
JavaScript

'use strict';
'require fs';
var CBILogreadBox = function(logtag, name) {
return L.view.extend({
load: function() {
return Promise.all([
L.resolveDefault(fs.stat('/sbin/logread'), null),
L.resolveDefault(fs.stat('/usr/sbin/logread'), null)
]);
},
render: function(stat) {
var logger = stat[0] ? stat[0].path : stat[1] ? stat[1].path : null;
L.Poll.add(function() {
return L.resolveDefault(fs.exec_direct(logger, ['-e', logtag])).then(function(res) {
var log = document.getElementById("logfile");
if (res) {
log.value = res.trim();
} else {
log.value = _('No related logs yet!');
}
log.scrollTop = log.scrollHeight;
});
});
return E('div', { class: 'cbi-map' },
E('div', { class: 'cbi-section' }, [
E('div', { class: 'cbi-section-descr' }, _('The syslog output, pre-filtered for messages related to: ' + name)),
E('textarea', {
'id': 'logfile',
'style': 'width: 100% !important; padding: 5px; font-family: monospace',
'readonly': 'readonly',
'wrap': 'off',
'rows': 25
})
]));
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});
};
return L.Class.extend({
LogreadBox: CBILogreadBox,
});