luci-app-banip: various optimizations
[project/luci.git] / applications / luci-app-banip / htdocs / luci-static / resources / view / banip / firewall_log.js
index d12b8b46cecbac82c43248bd3f31b8892485bbbf..db4ce15fe3bc78d912f45327bc7e2a9cc8e3dd05 100644 (file)
@@ -1,41 +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', ' banIP/'])).then(function (res) {
-                               var log = document.getElementById("logfile");
-                               if (res) {
-                                       log.value = res.trim();
-                               } else {
-                                       log.value = _('No banIP related firewall 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, prefiltered for banIP-related firewall log entries 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(" banIP/", "banIP firewall logs");