diff options
Diffstat (limited to 'modules/luci-base/htdocs')
3 files changed, 85 insertions, 9 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 3f4707d4e5..7c1831376f 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2831,9 +2831,9 @@ * returned promise runs to completion before the button * is reenabled. */ - handleSaveApply: function(ev) { + handleSaveApply: function(ev, mode) { return this.handleSave(ev).then(function() { - L.ui.changes.apply(true); + L.ui.changes.apply(mode == '0'); }); }, @@ -2905,12 +2905,20 @@ addFooter: function() { var footer = E([]); + var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', { + 0: [ _('Save & Apply') ], + 1: [ _('Apply unchecked') ] + }, { + classes: { + 0: 'cbi-button cbi-button-apply important', + 1: 'cbi-button cbi-button-negative important' + }, + click: L.ui.createHandlerFn(this, 'handleSaveApply') + }).render() : E([]); + if (this.handleSaveApply || this.handleSave || this.handleReset) { footer.appendChild(E('div', { 'class': 'cbi-page-actions' }, [ - this.handleSaveApply ? E('button', { - 'class': 'cbi-button cbi-button-apply', - 'click': L.ui.createHandlerFn(this, 'handleSaveApply') - }, [ _('Save & Apply') ]) : '', ' ', + saveApplyBtn, ' ', this.handleSave ? E('button', { 'class': 'cbi-button cbi-button-save', 'click': L.ui.createHandlerFn(this, 'handleSave') diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js index 3cc51ed40a..504f592978 100644 --- a/modules/luci-base/htdocs/luci-static/resources/network.js +++ b/modules/luci-base/htdocs/luci-static/resources/network.js @@ -385,6 +385,7 @@ function initNetworkState(refresh) { type: dev.type, mtu: dev.mtu, qlen: dev.qlen, + wireless: dev.wireless, ipaddrs: [], ip6addrs: [] }; @@ -1148,7 +1149,10 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { if (devices.hasOwnProperty(ifname)) continue; - if (isIgnoredIfname(ifname) || isVirtualIfname(ifname) || isWifiIfname(ifname)) + if (isIgnoredIfname(ifname) || isWifiIfname(ifname)) + continue; + + if (_state.netdevs[ifname].wireless) continue; devices[ifname] = this.instantiateDevice(ifname); diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index c82b397c19..2e360410df 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -1188,6 +1188,51 @@ var UICombobox = UIDropdown.extend({ } }); +var UIComboButton = UIDropdown.extend({ + __init__: function(value, choices, options) { + this.super('__init__', [ value, choices, Object.assign({ + sort: true + }, options, { + multiple: false, + create: false, + optional: false + }) ]); + }, + + render: function(/* ... */) { + var node = UIDropdown.prototype.render.apply(this, arguments), + val = this.getValue(); + + if (L.isObject(this.options.classes) && this.options.classes.hasOwnProperty(val)) + node.setAttribute('class', 'cbi-dropdown ' + this.options.classes[val]); + + return node; + }, + + handleClick: function(ev) { + var sb = ev.currentTarget, + t = ev.target; + + if (sb.hasAttribute('open') || L.dom.matches(t, '.cbi-dropdown > span.open')) + return UIDropdown.prototype.handleClick.apply(this, arguments); + + if (this.options.click) + return this.options.click.call(sb, ev, this.getValue()); + }, + + toggleItem: function(sb /*, ... */) { + var rv = UIDropdown.prototype.toggleItem.apply(this, arguments), + val = this.getValue(); + + if (L.isObject(this.options.classes) && this.options.classes.hasOwnProperty(val)) + sb.setAttribute('class', 'cbi-dropdown ' + this.options.classes[val]); + else + sb.setAttribute('class', 'cbi-dropdown'); + + return rv; + } +}); + var UIDynamicList = UIElement.extend({ __init__: function(values, choices, options) { if (!Array.isArray(values)) @@ -2232,7 +2277,23 @@ return L.Class.extend({ type: 'file', style: 'display:none', change: function(ev) { - L.dom.parent(ev.target, '.modal').querySelector('.cbi-button-action.important').disabled = false; + var modal = L.dom.parent(ev.target, '.modal'), + body = modal.querySelector('p'), + upload = modal.querySelector('.cbi-button-action.important'), + file = ev.currentTarget.files[0]; + + if (file == null) + return; + + L.dom.content(body, [ + E('ul', {}, [ + E('li', {}, [ '%s: %s'.format(_('Name'), file.name.replace(/^.*[\\\/]/, '')) ]), + E('li', {}, [ '%s: %1024mB'.format(_('Size'), file.size) ]) + ]) + ]); + + upload.disabled = false; + upload.focus(); } }), E('button', { @@ -2700,8 +2761,10 @@ return L.Class.extend({ if (typeof(fn) != 'function') return null; + var arg_offset = arguments.length - 2; + return Function.prototype.bind.apply(function() { - var t = arguments[arguments.length - 1].target; + var t = arguments[arg_offset].target; t.classList.add('spinning'); t.disabled = true; @@ -2724,6 +2787,7 @@ return L.Class.extend({ Dropdown: UIDropdown, DynamicList: UIDynamicList, Combobox: UICombobox, + ComboButton: UIComboButton, Hiddenfield: UIHiddenfield, FileUpload: UIFileUpload }); |