diff options
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/tools/views.js | 45 | ||||
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 16 |
2 files changed, 53 insertions, 8 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/tools/views.js b/modules/luci-base/htdocs/luci-static/resources/tools/views.js new file mode 100644 index 0000000000..f851f61dff --- /dev/null +++ b/modules/luci-base/htdocs/luci-static/resources/tools/views.js @@ -0,0 +1,45 @@ +'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, +}); diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index a4f002591d..afb590d8f8 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -4554,7 +4554,7 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { E('p', _('Failed to confirm apply within %ds, waiting for rollback…') .format(L.env.apply_rollback))); - var call = function(r, data, duration) { + var call = function(r) { if (r.status === 204) { UI.prototype.changes.displayStatus('warning', [ E('h4', _('Configuration changes have been rolled back!')), @@ -4578,13 +4578,13 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { return; } - var delay = isNaN(duration) ? 0 : Math.max(1000 - duration, 0); + var delay = isNaN(r.duration) ? 0 : Math.max(1000 - r.duration, 0); window.setTimeout(function() { request.request(L.url('admin/uci/confirm'), { method: 'post', timeout: L.env.apply_timeout * 1000, query: { sid: L.env.sessionid, token: L.env.token } - }).then(call, call.bind(null, { status: 0 }, null, 0)); + }).then(call, call.bind(null, { status: 0, duration: 0 })); }, delay); }; @@ -4608,13 +4608,13 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { if (override_token) this.confirm_auth = { token: override_token }; - var call = function(r, data, duration) { + var call = function(r) { if (Date.now() >= deadline) { window.clearTimeout(tt); UI.prototype.changes.rollback(checked); return; } - else if (r && (r.status === 200 || r.status === 204)) { + else if (r.status === 200 || r.status === 204) { document.dispatchEvent(new CustomEvent('uci-applied')); UI.prototype.changes.setIndicator(0); @@ -4630,13 +4630,13 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { return; } - var delay = isNaN(duration) ? 0 : Math.max(1000 - duration, 0); + var delay = isNaN(r.duration) ? 0 : Math.max(1000 - r.duration, 0); window.setTimeout(function() { request.request(L.url('admin/uci/confirm'), { method: 'post', timeout: L.env.apply_timeout * 1000, query: UI.prototype.changes.confirm_auth - }).then(call, call); + }).then(call, call.bind(null, { status: 0, duration: 0 })); }, delay); }; @@ -4657,7 +4657,7 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { tick(); /* wait a few seconds for the settings to become effective */ - window.setTimeout(call, Math.max(L.env.apply_holdoff * 1000 - ((ts + L.env.apply_rollback * 1000) - deadline), 1)); + window.setTimeout(call.bind(null, { status: 0 }), L.env.apply_holdoff * 1000); }, /** |