luci-mod-network: wifi scan: add button to start/stop refreshes
Fixes: #3662 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
9b024767d7
commit
a2fe3d9fc4
1 changed files with 35 additions and 4 deletions
|
@ -1744,27 +1744,37 @@ return L.view.extend({
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var stop = E('button', {
|
||||||
|
'class': 'btn',
|
||||||
|
'click': L.bind(this.handleScanStartStop, this),
|
||||||
|
'style': 'display:none',
|
||||||
|
'data-state': 'stop'
|
||||||
|
}, _('Stop refresh'));
|
||||||
|
|
||||||
cbi_update_table(table, [], E('em', { class: 'spinning' }, _('Starting wireless scan...')));
|
cbi_update_table(table, [], E('em', { class: 'spinning' }, _('Starting wireless scan...')));
|
||||||
|
|
||||||
var md = ui.showModal(_('Join Network: Wireless Scan'), [
|
var md = ui.showModal(_('Join Network: Wireless Scan'), [
|
||||||
table,
|
table,
|
||||||
E('div', { 'class': 'right' },
|
E('div', { 'class': 'right' }, [
|
||||||
|
stop,
|
||||||
|
' ',
|
||||||
E('button', {
|
E('button', {
|
||||||
'class': 'btn',
|
'class': 'btn',
|
||||||
'click': L.bind(this.handleScanAbort, this)
|
'click': L.bind(this.handleScanAbort, this)
|
||||||
}, _('Dismiss')))
|
}, _('Dismiss'))
|
||||||
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
md.style.maxWidth = '90%';
|
md.style.maxWidth = '90%';
|
||||||
md.style.maxHeight = 'none';
|
md.style.maxHeight = 'none';
|
||||||
|
|
||||||
this.pollFn = L.bind(this.handleScanRefresh, this, radioDev, {}, table);
|
this.pollFn = L.bind(this.handleScanRefresh, this, radioDev, {}, table, stop);
|
||||||
|
|
||||||
L.Poll.add(this.pollFn);
|
L.Poll.add(this.pollFn);
|
||||||
L.Poll.start();
|
L.Poll.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
s.handleScanRefresh = function(radioDev, scanCache, table) {
|
s.handleScanRefresh = function(radioDev, scanCache, table, stop) {
|
||||||
return radioDev.getScanList().then(L.bind(function(results) {
|
return radioDev.getScanList().then(L.bind(function(results) {
|
||||||
var rows = [];
|
var rows = [];
|
||||||
|
|
||||||
|
@ -1816,9 +1826,30 @@ return L.view.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
cbi_update_table(table, rows);
|
cbi_update_table(table, rows);
|
||||||
|
|
||||||
|
stop.disabled = false;
|
||||||
|
stop.style.display = '';
|
||||||
|
stop.classList.remove('spinning');
|
||||||
}, this));
|
}, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
s.handleScanStartStop = function(ev) {
|
||||||
|
var btn = ev.currentTarget;
|
||||||
|
|
||||||
|
if (btn.getAttribute('data-state') == 'stop') {
|
||||||
|
L.Poll.remove(this.pollFn);
|
||||||
|
btn.firstChild.data = _('Start refresh');
|
||||||
|
btn.setAttribute('data-state', 'start');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
L.Poll.add(this.pollFn);
|
||||||
|
btn.firstChild.data = _('Stop refresh');
|
||||||
|
btn.setAttribute('data-state', 'stop');
|
||||||
|
btn.classList.add('spinning');
|
||||||
|
btn.disabled = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
s.handleScanAbort = function(ev) {
|
s.handleScanAbort = function(ev) {
|
||||||
var md = L.dom.parent(ev.target, 'div[aria-modal="true"]');
|
var md = L.dom.parent(ev.target, 'div[aria-modal="true"]');
|
||||||
if (md) {
|
if (md) {
|
||||||
|
|
Loading…
Reference in a new issue