diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 21:54:40 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 21:55:50 +0100 |
commit | 86f492173d1daab8b75e4d4bd70ba06872ea70fa (patch) | |
tree | 3a64f76424681b0a0bb613c6966079a530ffd057 /modules/luci-mod-network | |
parent | b2a46e131b778ae14156676de8daf8231ab8e151 (diff) |
treewide: require ui.js explicitly
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network')
3 files changed, 36 insertions, 33 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index 12d28808f..9ca7773fe 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -1,5 +1,6 @@ 'use strict'; 'require fs'; +'require ui'; 'require uci'; 'require form'; 'require network'; @@ -7,7 +8,7 @@ 'require tools.widgets as widgets'; function count_changes(section_id) { - var changes = L.ui.changes.changes, n = 0; + var changes = ui.changes.changes, n = 0; if (!L.isObject(changes)) return n; @@ -100,7 +101,7 @@ function render_status(node, ifc, with_device) { _('Error'), errors ? errors[4] : null, null, changecount ? E('a', { href: '#', - click: L.bind(L.ui.changes.displayChanges, L.ui.changes) + click: L.bind(ui.changes.displayChanges, ui.changes) }, _('Interface has %d pending changes').format(changecount)) : null ]); } @@ -166,7 +167,7 @@ function iface_updown(up, id, ev, force) { Array.isArray(info.inbound_interfaces) && info.inbound_interfaces.filter(function(i) { return i == id })[0]) { - L.ui.showModal(_('Confirm disconnect'), [ + ui.showModal(_('Confirm disconnect'), [ E('p', _('You appear to be currently connected to the device via the "%h" interface. Do you really want to shut down the interface?').format(id)), E('div', { 'class': 'right' }, [ E('button', { @@ -176,7 +177,7 @@ function iface_updown(up, id, ev, force) { btns[1].disabled = false; btns[0].disabled = false; - L.ui.hideModal(); + ui.hideModal(); } }, _('Cancel')), ' ', @@ -186,7 +187,7 @@ function iface_updown(up, id, ev, force) { dsc.setAttribute('disconnect', ''); L.dom.content(dsc, E('em', _('Interface is shutting down...'))); - L.ui.hideModal(); + ui.hideModal(); } }, _('Disconnect')) ]) @@ -557,7 +558,7 @@ return L.view.extend({ E('button', { 'class': 'cbi-button cbi-button-add', 'title': _('Setup DHCP Server'), - 'click': L.ui.createHandlerFn(this, function(section_id, ev) { + 'click': ui.createHandlerFn(this, function(section_id, ev) { this.map.save(function() { uci.add('dhcp', 'dhcp', section_id); uci.set('dhcp', section_id, 'interface', section_id); @@ -748,16 +749,16 @@ return L.view.extend({ } m2.render().then(L.bind(function(nodes) { - L.ui.showModal(_('Add new interface...'), [ + ui.showModal(_('Add new interface...'), [ nodes, E('div', { 'class': 'right' }, [ E('button', { 'class': 'btn', - 'click': L.ui.hideModal + 'click': ui.hideModal }, _('Cancel')), ' ', E('button', { 'class': 'cbi-button cbi-button-positive important', - 'click': L.ui.createHandlerFn(this, function(ev) { + 'click': ui.createHandlerFn(this, function(ev) { var nameval = name.isValid('_new_') ? name.formvalue('_new_') : null, protoval = proto.isValid('_new_') ? proto.formvalue('_new_') : null; @@ -977,13 +978,13 @@ return L.view.extend({ if (dsc.getAttribute('reconnect') == '') { dsc.setAttribute('reconnect', '1'); tasks.push(fs.exec('/sbin/ifup', [section_ids[i]]).catch(function(e) { - L.ui.addNotification(null, E('p', e.message)); + ui.addNotification(null, E('p', e.message)); })); } else if (dsc.getAttribute('disconnect') == '') { dsc.setAttribute('disconnect', '1'); tasks.push(fs.exec('/sbin/ifdown', [section_ids[i]]).catch(function(e) { - L.ui.addNotification(null, E('p', e.message)); + ui.addNotification(null, E('p', e.message)); })); } else if (dsc.getAttribute('reconnect') == '1') { diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js index b281bb180..80c8437fc 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js @@ -1,4 +1,5 @@ 'use strict'; +'require ui'; 'require rpc'; 'require uci'; 'require form'; @@ -55,7 +56,7 @@ function update_interfaces(old_ifname, new_ifname) { if (changed) { uci.set('network', interfaces[i]['.name'], 'ifname', new_ifnames.join(' ')); - L.ui.addNotification(null, E('p', _('Interface %q device auto-migrated from %q to %q.') + ui.addNotification(null, E('p', _('Interface %q device auto-migrated from %q to %q.') .replace(/%q/g, '"%s"').format(interfaces[i]['.name'], old_ifname, new_ifname))); } } @@ -143,7 +144,7 @@ return L.view.extend({ topology = topologies[switch_name]; if (!topology) { - L.ui.addNotification(null, _('Switch %q has an unknown topology - the VLAN settings might not be accurate.').replace(/%q/, switch_name)); + ui.addNotification(null, _('Switch %q has an unknown topology - the VLAN settings might not be accurate.').replace(/%q/, switch_name)); topology = { features: {}, diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js index 1909f3c24..1a98c4302 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js @@ -1,5 +1,6 @@ 'use strict'; 'require fs'; +'require ui'; 'require rpc'; 'require uci'; 'require form'; @@ -8,7 +9,7 @@ 'require tools.widgets as widgets'; function count_changes(section_id) { - var changes = L.ui.changes.changes, n = 0; + var changes = ui.changes.changes, n = 0; if (!L.isObject(changes)) return n; @@ -97,7 +98,7 @@ function render_network_status(radioNet) { if (changecount) status_text = E('a', { href: '#', - click: L.bind(L.ui.changes.displayChanges, L.ui.changes) + click: L.bind(ui.changes.displayChanges, ui.changes) }, _('Interface has %d pending changes').format(changecount)); else if (!is_assoc) status_text = E('em', disabled ? _('Wireless is disabled') : _('Wireless is not associated')); @@ -196,7 +197,7 @@ function network_updown(id, map, ev) { } return map.save().then(function() { - L.ui.changes.apply() + ui.changes.apply() }); } @@ -605,18 +606,18 @@ return L.view.extend({ } return Promise.all(tasks) - .then(L.bind(L.ui.changes.init, L.ui.changes)) - .then(L.bind(L.ui.changes.apply, L.ui.changes)); + .then(L.bind(ui.changes.init, ui.changes)) + .then(L.bind(ui.changes.apply, ui.changes)); }, renderMigration: function() { - L.ui.showModal(_('Wireless configuration migration'), [ + ui.showModal(_('Wireless configuration migration'), [ E('p', _('The existing wireless configuration needs to be changed for LuCI to function properly.')), E('p', _('Upon pressing "Continue", anonymous "wifi-iface" sections will be assigned with a name in the form <em>wifinet#</em> and the network will be restarted to apply the updated configuration.')), E('div', { 'class': 'right' }, E('button', { 'class': 'btn cbi-button-action important', - 'click': L.ui.createHandlerFn(this, 'handleMigration') + 'click': ui.createHandlerFn(this, 'handleMigration') }, _('Continue'))) ]); }, @@ -691,17 +692,17 @@ return L.view.extend({ E('button', { 'class': 'cbi-button cbi-button-neutral', 'title': _('Restart radio interface'), - 'click': L.ui.createHandlerFn(this, radio_restart, section_id) + 'click': ui.createHandlerFn(this, radio_restart, section_id) }, _('Restart')), E('button', { 'class': 'cbi-button cbi-button-action important', 'title': _('Find and join network'), - 'click': L.ui.createHandlerFn(this, 'handleScan', inst) + 'click': ui.createHandlerFn(this, 'handleScan', inst) }, _('Scan')), E('button', { 'class': 'cbi-button cbi-button-add', 'title': _('Provide new network'), - 'click': L.ui.createHandlerFn(this, 'handleAdd', inst) + 'click': ui.createHandlerFn(this, 'handleAdd', inst) }, _('Add')) ]; } @@ -713,17 +714,17 @@ return L.view.extend({ E('button', { 'class': 'cbi-button cbi-button-neutral enable-disable', 'title': isDisabled ? _('Enable this network') : _('Disable this network'), - 'click': L.ui.createHandlerFn(this, network_updown, section_id, this.map) + 'click': ui.createHandlerFn(this, network_updown, section_id, this.map) }, isDisabled ? _('Enable') : _('Disable')), E('button', { 'class': 'cbi-button cbi-button-action important', 'title': _('Edit this network'), - 'click': L.ui.createHandlerFn(this, 'renderMoreOptionsModal', section_id) + 'click': ui.createHandlerFn(this, 'renderMoreOptionsModal', section_id) }, _('Edit')), E('button', { 'class': 'cbi-button cbi-button-negative remove', 'title': _('Delete this network'), - 'click': L.ui.createHandlerFn(this, 'handleRemove', section_id) + 'click': ui.createHandlerFn(this, 'handleRemove', section_id) }, _('Remove')) ]; } @@ -755,7 +756,7 @@ return L.view.extend({ o = ss.taboption('general', form.Button, '_toggle', isDisabled ? _('Wireless network is disabled') : _('Wireless network is enabled')); o.inputstyle = isDisabled ? 'apply' : 'reset'; o.inputtitle = isDisabled ? _('Enable') : _('Disable'); - o.onclick = L.ui.createHandlerFn(s, network_updown, s.section, s.map); + o.onclick = ui.createHandlerFn(s, network_updown, s.section, s.map); o = ss.taboption('general', CBIWifiFrequencyValue, '_freq', '<br />' + _('Operating frequency')); o.ucisection = s.section; @@ -1630,7 +1631,7 @@ return L.view.extend({ cbi_update_table(table, [], E('em', { class: 'spinning' }, _('Starting wireless scan...'))); - var md = L.ui.showModal(_('Join Network: Wireless Scan'), [ + var md = ui.showModal(_('Join Network: Wireless Scan'), [ table, E('div', { 'class': 'right' }, E('button', { @@ -1710,7 +1711,7 @@ return L.view.extend({ md.style.maxHeight = ''; } - L.ui.hideModal(); + ui.hideModal(); L.Poll.remove(this.pollFn); this.pollFn = null; @@ -1848,16 +1849,16 @@ return L.view.extend({ zone.default = 'wan'; return m2.render().then(L.bind(function(nodes) { - L.ui.showModal(_('Joining Network: %q').replace(/%q/, '"%h"'.format(bss.ssid)), [ + ui.showModal(_('Joining Network: %q').replace(/%q/, '"%h"'.format(bss.ssid)), [ nodes, E('div', { 'class': 'right' }, [ E('button', { 'class': 'btn', - 'click': L.ui.hideModal + 'click': ui.hideModal }, _('Cancel')), ' ', E('button', { 'class': 'cbi-button cbi-button-positive important', - 'click': L.ui.createHandlerFn(this, 'handleJoinConfirm', radioDev, bss, m2) + 'click': ui.createHandlerFn(this, 'handleJoinConfirm', radioDev, bss, m2) }, _('Submit')) ]) ], 'cbi-modal').querySelector('[id="%s"] input[class][type]'.format((passphrase || name).cbid('_new_'))).focus(); @@ -1919,7 +1920,7 @@ return L.view.extend({ if (dsc.getAttribute('restart') == '') { dsc.setAttribute('restart', '1'); tasks.push(fs.exec('/sbin/wifi', ['up', section_ids[i]]).catch(function(e) { - L.ui.addNotification(null, E('p', e.message)); + ui.addNotification(null, E('p', e.message)); })); } else if (dsc.getAttribute('restart') == '1') { |