summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/logread.js
blob: 4dc2a2e53313b624ac5a57ddaf40c9b70f5d98be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
'require view';
'require poll';
'require fs';

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', 'adblock-'])).then(function(res) {
				var log = document.getElementById("logfile");
				if (res) {
					log.value = res.trim();
				} else {
					log.value = _('No adblock 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 adblock 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
});