From 01cefed7f008c9cdbd8b1312336c7a358b523856 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sat, 10 Oct 2020 00:50:19 +0200 Subject: luci-theme-material: fix bigger button for combo-box Combobox are bigger than any other button. Align the dimension to all the other buttons. Signed-off-by: Ansuel Smith --- .../htdocs/luci-static/material/cascade.css | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/themes/luci-theme-material/htdocs/luci-static/material/cascade.css b/themes/luci-theme-material/htdocs/luci-static/material/cascade.css index dfa9c5dc0..10d8a02bd 100644 --- a/themes/luci-theme-material/htdocs/luci-static/material/cascade.css +++ b/themes/luci-theme-material/htdocs/luci-static/material/cascade.css @@ -1414,6 +1414,23 @@ body:not(.Interfaces) .cbi-rowstyle-2:first-child { outline: 0; } +.cbi-dropdown.btn { + min-height: 1.8rem; + padding-top: 0px; + padding-bottom: 0px; + padding-right: 0px; +} + +.cbi-dropdown.btn > .open { + font-size: 0.8rem; + padding: 0px; + margin: 0 5px; +} + +.cbi-dropdown.btn > div { + margin: 0px; +} + .cbi-dropdown > .more, .cbi-dropdown > ul > li[placeholder] { font-weight: bold; -- cgit v1.2.3 From ef94c52680ab2743627fb821e16b0bb202f7b35c Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sat, 10 Oct 2020 01:05:55 +0200 Subject: luci-mod-status: add support for add device to wifi black/whitelist Add support for one-click add device to wifi black/whitelist in the status page. If the black/whitelist feature is enabled a combobox is displayed with the disconnect option. Device already added will display only the disconnect button. Fixes: #3675 Signed-off-by: Ansuel Smith --- .../resources/view/status/include/60_wifi.js | 55 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js index 928b5959b..101936583 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js @@ -40,12 +40,28 @@ return baseclass.extend({ return s; }, - handleDelClient: function(wifinet, mac, ev) { + handleDelClient: function(wifinet, mac, ev, cmd) { + var exec = cmd || 'disconnect'; + dom.parent(ev.currentTarget, '.tr').style.opacity = 0.5; ev.currentTarget.classList.add('spinning'); ev.currentTarget.disabled = true; ev.currentTarget.blur(); + if (exec == 'addlist') { + var macs = [ mac ] + + for (var mac in this.iface_maclist) { + macs.push(mac) + } + + uci.set('wireless', wifinet.sid, 'maclist', macs); + + return uci.save() + .then(L.bind(L.ui.changes.init, L.ui.changes)) + .then(L.bind(L.ui.changes.displayChanges, L.ui.changes)); + } + wifinet.disconnectClient(mac, true, 5, 60000); }, @@ -188,6 +204,8 @@ return baseclass.extend({ }, this)); }, + isDeviceAdded: {}, + render: function(data) { var seen = {}, radios = data[0], @@ -218,6 +236,17 @@ return baseclass.extend({ var rows = []; for (var i = 0; i < networks.length; i++) { + var macfilter = uci.get('wireless', networks[i].sid, 'macfilter'); + + if (macfilter != null && macfilter != 'disable') { + this.isDeviceAdded = {}; + var macs = L.toArray(uci.get('wireless', networks[i].sid, 'maclist')); + for (var j = 0; j < macs.length; j++) { + var mac = macs[j].toUpperCase(); + this.isDeviceAdded[mac] = true; + } + } + for (var k = 0; k < networks[i].assoclist.length; k++) { var bss = networks[i].assoclist[k], name = hosthints.getHostnameByMACAddr(bss.mac), @@ -297,10 +326,26 @@ return baseclass.extend({ if (assoclist.firstElementChild.childNodes.length < 6) assoclist.firstElementChild.appendChild(E('div', { 'class': 'th cbi-section-actions' })); - row.push(E('button', { - 'class': 'cbi-button cbi-button-remove', - 'click': L.bind(this.handleDelClient, this, networks[i], bss.mac) - }, [ _('Disconnect') ])); + if (macfilter != null && macfilter != 'disable' && !this.isDeviceAdded[bss.mac]) { + row.push(new L.ui.ComboButton('button', { + 'addlist': macfilter == 'allow' ? _('Add to Whitelist') : _('Add to Blacklist'), + 'disconnect': _('Disconnect') + }, { + 'click': L.bind(this.handleDelClient, this, networks[i], bss.mac), + 'sort': [ 'disconnect', 'addlist' ], + 'classes': { + 'addlist': 'btn cbi-button cbi-button-remove', + 'disconnect': 'btn cbi-button cbi-button-remove' + } + }).render() + ) + } + else { + row.push(E('button', { + 'class': 'cbi-button cbi-button-remove', + 'click': L.bind(this.handleDelClient, this, networks[i], bss.mac) + }, [ _('Disconnect') ])); + } } else { row.push('-'); -- cgit v1.2.3