mirror of
https://github.com/openwrt/luci.git
synced 2025-12-20 01:10:26 +08:00
luci-mod-network: diagnostics: add realtime command output
The diagnostics page is using `fs.exec()` to execute command, which blocks until command exit. Users have to wait for a while to see the result. When doing IPv6 traceroute, this may cause XHR timeout, if target host is unreachable. (See issue #7210) This commit uses new `responseProgress` callback and `stderr` option added in luci.js and fs.js to update command output. Signed-off-by: Richard Yu <yurichard3839@gmail.com> Link: https://github.com/openwrt/luci/pull/7920
This commit is contained in:
@@ -8,15 +8,16 @@
|
||||
|
||||
return view.extend({
|
||||
handleCommand: function(exec, args) {
|
||||
var buttons = document.querySelectorAll('.diag-action > .cbi-button');
|
||||
var buttons = document.querySelectorAll('.diag-action > .cbi-button'),
|
||||
out = document.querySelector('textarea');
|
||||
|
||||
for (var i = 0; i < buttons.length; i++)
|
||||
buttons[i].setAttribute('disabled', 'true');
|
||||
|
||||
return fs.exec(exec, args).then(function(res) {
|
||||
var out = document.querySelector('textarea');
|
||||
|
||||
dom.content(out, [ res.stdout || '', res.stderr || '' ]);
|
||||
return fs.exec_direct(exec, args, 'text', false, true, function(ev) {
|
||||
out.textContent = ev.target.response;
|
||||
}).then(function(res) {
|
||||
out.textContent = res;
|
||||
}).catch(function(err) {
|
||||
ui.addNotification(null, E('p', [ err ]))
|
||||
}).finally(function() {
|
||||
|
||||
Reference in New Issue
Block a user