luci-app-travelmate: sync with update 2.2.1-3
authorDirk Brenken <[email protected]>
Wed, 22 Oct 2025 19:02:44 +0000 (21:02 +0200)
committerDirk Brenken <[email protected]>
Wed, 22 Oct 2025 19:03:27 +0000 (21:03 +0200)
Signed-off-by: Dirk Brenken <[email protected]>
(cherry picked from commit 8c07e199e1b71bf6b47c652015a333f8a9ce2b52)

applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logread.js
applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logtemplate.js [new file with mode: 0644]

index fc9323aa148c9939fb4d9d26c81f93b3c0dceee6..425ab03895493dd3eeb003ce1bdddfd4f95fb6e8 100644 (file)
@@ -1,4 +1,4 @@
 'use strict';
-'require tools.views as views';
+'require view.travelmate.logtemplate as LogTemplate';
 
-return views.LogreadBox("trm-", "travelmate");
+return LogTemplate.Logview('trm-', 'travelmate');
diff --git a/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logtemplate.js b/applications/luci-app-travelmate/htdocs/luci-static/resources/view/travelmate/logtemplate.js
new file mode 100644 (file)
index 0000000..23a8fbe
--- /dev/null
@@ -0,0 +1,48 @@
+'use strict';
+'require fs';
+
+function Logview(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) {
+                       let logger = stat[0]?.path || stat[1]?.path || null;
+
+                       if (!logger) {
+                               return E('div', { class: 'error' }, _('logread not found on system.'));
+                       }
+                       L.Poll.add(function() {
+                               return L.resolveDefault(fs.exec_direct(logger, ['-e', logtag])).then(function(res) {
+                                       var log = document.getElementById('logfile');
+                                       if (log) {
+                                               log.value = res ? res.trim() : _('No %s related logs yet!').format(name);
+                                               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: %s').format(name)),
+                                       E('textarea', {
+                                               id: 'logfile',
+                                               style: 'min-height: 500px; max-height: 90vh; width: 100%; padding: 5px; font-family: monospace; resize: vertical;',
+                                               readonly: 'readonly',
+                                               wrap: 'off'
+                                       })
+                               ])
+                       ]);
+               },
+               handleSaveApply: null,
+               handleSave: null,
+               handleReset: null
+       });
+}
+
+return L.Class.extend({
+       Logview: Logview
+});