From c5a65a839713ab7ac70e6a6b5a7331593f67a9a0 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 18 Oct 2021 13:04:00 +0000 Subject: 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 app-nextdns: fix Logs title Minor typo, introduced in 625abbf (convert simple controllers to menu.json) Signed-off-by: Karl Palsson luci-base: implement shared log reader view Closes #5452 Signed-off-by: Paul Donald --- .../resources/view/travelmate/logread.js | 42 ++-------------------- 1 file changed, 2 insertions(+), 40 deletions(-) (limited to 'applications/luci-app-travelmate/htdocs/luci-static/resources/view') diff --git a/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logread.js b/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logread.js index d004ed4d2f..fc9323aa14 100644 --- a/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logread.js +++ b/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logread.js @@ -1,42 +1,4 @@ 'use strict'; -'require view'; -'require poll'; -'require fs'; +'require tools.views as views'; -return 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; - poll.add(function() { - return L.resolveDefault(fs.exec_direct(logger, ['-e', 'trm-'])).then(function(res) { - var log = document.getElementById("logfile"); - if (res) { - log.value = res.trim(); - } - else { - log.value = _('No travelmate 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 travelmate related messages only.')), - 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 views.LogreadBox("trm-", "travelmate"); -- cgit v1.2.3