summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-network/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-03 10:00:06 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-03 10:00:06 +0200
commit3c4bc228a1f7b5731cf464f3f407c9ed9ace3cd2 (patch)
treed9ac0458c66dfa3c5d4922314df9d41499f578bc /modules/luci-mod-network/htdocs
parent1099aebdee29b8e5408688d0fd64d49e6ec4bd35 (diff)
treewide: import utility classes explicitly
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network/htdocs')
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js9
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js6
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js3
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js29
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js3
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js11
-rw-r--r--modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js41
7 files changed, 59 insertions, 43 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
index 81ea32d48c..525526d62f 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
@@ -1,4 +1,7 @@
'use strict';
+'require view';
+'require dom';
+'require poll';
'require rpc';
'require uci';
'require form';
@@ -123,7 +126,7 @@ function validateServerSpec(sid, s) {
return true;
}
-return L.view.extend({
+return view.extend({
load: function() {
return Promise.all([
callHostHints(),
@@ -440,7 +443,7 @@ return L.view.extend({
var node = ipopt.map.findElement('id', ipopt.cbid(section_id));
if (node)
- L.dom.callClassMethod(node, 'setValue', hosts[mac].ipv4);
+ dom.callClassMethod(node, 'setValue', hosts[mac].ipv4);
}, this, ipopt, section_id));
return node;
@@ -487,7 +490,7 @@ return L.view.extend({
o = s.taboption('leases', CBILease6Status, '__status6__');
return m.render().then(function(mapEl) {
- L.Poll.add(function() {
+ poll.add(function() {
return callDHCPLeases().then(function(leaseinfo) {
var leases = Array.isArray(leaseinfo.dhcp_leases) ? leaseinfo.dhcp_leases : [],
leases6 = Array.isArray(leaseinfo.dhcp6_leases) ? leaseinfo.dhcp6_leases : [];
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js
index 24ab84ab9e..a94cc6673f 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js
@@ -1,9 +1,11 @@
'use strict';
+'require view';
+'require dom';
'require fs';
'require ui';
'require uci';
-return L.view.extend({
+return view.extend({
handleCommand: function(exec, args) {
var buttons = document.querySelectorAll('.diag-action > .cbi-button');
@@ -14,7 +16,7 @@ return L.view.extend({
var out = document.querySelector('.command-output');
out.style.display = '';
- L.dom.content(out, [ res.stdout || '', res.stderr || '' ]);
+ dom.content(out, [ res.stdout || '', res.stderr || '' ]);
}).catch(function(err) {
ui.addNotification(null, E('p', [ err ]))
}).finally(function() {
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js
index 975ac2fec7..cd0dacbf67 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js
@@ -1,8 +1,9 @@
'use strict';
+'require view';
'require rpc';
'require form';
-return L.view.extend({
+return view.extend({
callHostHints: rpc.declare({
object: 'luci-rpc',
method: 'getHostHints',
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 0e6e5a2e25..fb3969e9d3 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,4 +1,7 @@
'use strict';
+'require view';
+'require dom';
+'require poll';
'require fs';
'require ui';
'require uci';
@@ -109,7 +112,7 @@ function render_status(node, ifc, with_device) {
function render_modal_status(node, ifc) {
var dev = ifc ? (ifc.getDevice() || ifc.getL3Device() || ifc.getL3Device()) : null;
- L.dom.content(node, [
+ dom.content(node, [
E('img', {
'src': L.resource('icons/%s%s.png').format(dev ? dev.getType() : 'ethernet', (dev && dev.isUp()) ? '' : '_disabled'),
'title': dev ? dev.getTypeI18n() : _('Not present')
@@ -140,7 +143,7 @@ function render_ifacebox_status(node, ifc) {
c.push(E('small', {}, ifc.isAlias() ? _('Alias of "%s"').format(ifc.isAlias())
: (dev ? dev.getName() : E('em', _('Not present')))));
- L.dom.content(node, c);
+ dom.content(node, c);
return firewall.getZoneByNetwork(ifc.getName()).then(L.bind(function(zone) {
this.style.backgroundColor = zone ? zone.getColor() : '#EEEEEE';
@@ -185,7 +188,7 @@ function iface_updown(up, id, ev, force) {
'class': 'cbi-button cbi-button-negative important',
'click': function(ev) {
dsc.setAttribute('disconnect', '');
- L.dom.content(dsc, E('em', _('Interface is shutting down...')));
+ dom.content(dsc, E('em', _('Interface is shutting down...')));
ui.hideModal();
}
@@ -195,13 +198,13 @@ function iface_updown(up, id, ev, force) {
}
else {
dsc.setAttribute('disconnect', '');
- L.dom.content(dsc, E('em', _('Interface is shutting down...')));
+ dom.content(dsc, E('em', _('Interface is shutting down...')));
}
});
}
else {
dsc.setAttribute(up ? 'reconnect' : 'disconnect', force ? 'force' : '');
- L.dom.content(dsc, E('em', up ? _('Interface is reconnecting...') : _('Interface is shutting down...')));
+ dom.content(dsc, E('em', up ? _('Interface is reconnecting...') : _('Interface is shutting down...')));
}
}
@@ -224,7 +227,7 @@ function get_netmask(s, use_cfgvalue) {
return mask;
}
-return L.view.extend({
+return view.extend({
poll_status: function(map, networks) {
var resolveZone = null;
@@ -245,10 +248,10 @@ return L.view.extend({
dynamic = ifc ? ifc.isDynamic() : false;
if (dsc.hasAttribute('reconnect')) {
- L.dom.content(dsc, E('em', _('Interface is starting...')));
+ dom.content(dsc, E('em', _('Interface is starting...')));
}
else if (dsc.hasAttribute('disconnect')) {
- L.dom.content(dsc, E('em', _('Interface is stopping...')));
+ dom.content(dsc, E('em', _('Interface is stopping...')));
}
else if (ifc.getProtocol() || uci.get('network', ifc.getName()) == null) {
render_status(dsc, ifc, false);
@@ -258,18 +261,18 @@ return L.view.extend({
if (e) e.disabled = true;
var link = L.url('admin/system/opkg') + '?query=luci-proto';
- L.dom.content(dsc, [
+ dom.content(dsc, [
E('em', _('Unsupported protocol type.')), E('br'),
E('a', { href: link }, _('Install protocol extensions...'))
]);
}
else {
- L.dom.content(dsc, E('em', _('Interface not present or not connected yet.')));
+ dom.content(dsc, E('em', _('Interface not present or not connected yet.')));
}
if (stat) {
var dev = ifc.getDevice();
- L.dom.content(stat, [
+ dom.content(stat, [
E('img', {
'src': L.resource('icons/%s%s.png').format(dev ? dev.getType() : 'ethernet', (dev && dev.isUp()) ? '' : '_disabled'),
'title': dev ? dev.getTypeI18n() : _('Not present')
@@ -336,7 +339,7 @@ return L.view.extend({
disabled = net ? !net.isUp() : true,
dynamic = net ? net.isDynamic() : false;
- L.dom.content(tdEl.lastChild, [
+ dom.content(tdEl.lastChild, [
E('button', {
'class': 'cbi-button cbi-button-neutral reconnect',
'click': iface_updown.bind(this, true, section_id),
@@ -979,7 +982,7 @@ return L.view.extend({
return m.render().then(L.bind(function(m, nodes) {
- L.Poll.add(L.bind(function() {
+ poll.add(L.bind(function() {
var section_ids = m.children[0].cfgsections(),
tasks = [];
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js
index 4a002c2520..58a151de08 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js
@@ -1,9 +1,10 @@
'use strict';
+'require view';
'require form';
'require network';
'require tools.widgets as widgets';
-return L.view.extend({
+return view.extend({
load: function() {
return network.getDevices();
},
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 63427f147f..3133d27250 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,7 @@
'use strict';
+'require view';
+'require dom';
+'require poll';
'require ui';
'require rpc';
'require uci';
@@ -67,13 +70,13 @@ function render_port_status(node, portstate) {
return null;
if (!portstate || !portstate.link)
- L.dom.content(node, [
+ dom.content(node, [
E('img', { src: L.resource('icons/port_down.png') }),
E('br'),
_('no link')
]);
else
- L.dom.content(node, [
+ dom.content(node, [
E('img', { src: L.resource('icons/port_up.png') }),
E('br'),
'%d'.format(portstate.speed) + _('baseT'),
@@ -112,7 +115,7 @@ var callSwconfigPortState = rpc.declare({
expect: { result: [] }
});
-return L.view.extend({
+return view.extend({
load: function() {
return network.getSwitchTopologies().then(function(topologies) {
var tasks = [];
@@ -365,7 +368,7 @@ return L.view.extend({
});
}
- L.Poll.add(L.bind(update_port_status, m, topologies));
+ poll.add(L.bind(update_port_status, m, topologies));
return m.render();
}
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 0bc15c26aa..35ef2ba03a 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,4 +1,7 @@
'use strict';
+'require view';
+'require dom';
+'require poll';
'require fs';
'require ui';
'require rpc';
@@ -167,7 +170,7 @@ function render_modal_status(node, radioNet) {
if (node == null)
node = E('span', { 'class': 'ifacebadge large', 'data-network': radioNet.getName() }, [ E('small'), E('span') ]);
- L.dom.content(node.firstElementChild, render_signal_badge(
+ dom.content(node.firstElementChild, render_signal_badge(
disabled ? -1 : radioNet.getSignalPercent(),
radioNet.getSignal(), noise, true, radioNet.getMode()));
@@ -185,7 +188,7 @@ function render_modal_status(node, radioNet) {
], [ ' | ', E('br'), E('br'), E('br'), E('br'), E('br'), ' | ', E('br'), ' | ' ]);
if (!is_assoc)
- L.dom.append(node.lastElementChild, E('em', disabled ? _('Wireless is disabled') : _('Wireless is not associated')));
+ dom.append(node.lastElementChild, E('em', disabled ? _('Wireless is disabled') : _('Wireless is not associated')));
return node;
}
@@ -216,7 +219,7 @@ function radio_restart(id, ev) {
btn.disabled = true;
dsc.setAttribute('restart', '');
- L.dom.content(dsc, E('em', _('Device is restarting…')));
+ dom.content(dsc, E('em', _('Device is restarting…')));
}
function network_updown(id, map, ev) {
@@ -432,7 +435,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
renderWidget: function(section_id, option_index, cfgvalue) {
var elem = E('div');
- L.dom.content(elem, [
+ dom.content(elem, [
E('label', { 'style': 'float:left; margin-right:3px' }, [
_('Mode'), E('br'),
E('select', {
@@ -520,7 +523,7 @@ var CBIWifiTxPowerValue = form.ListValue.extend({
var widget = form.ListValue.prototype.renderWidget.apply(this, [section_id, option_index, cfgvalue]);
widget.firstElementChild.style.width = 'auto';
- L.dom.append(widget, E('span', [
+ dom.append(widget, E('span', [
' - ', _('Current power'), ': ',
E('span', [ this.powerval != null ? '%d dBm'.format(this.powerval) : E('em', _('unknown')) ]),
this.poweroff ? ' + %d dB offset = %s dBm'.format(this.poweroff, this.powerval != null ? this.powerval + this.poweroff : '?') : ''
@@ -564,7 +567,7 @@ var CBIWifiCountryValue = form.Value.extend({
}
});
-return L.view.extend({
+return view.extend({
poll_status: function(map, data) {
var rows = map.querySelectorAll('.cbi-section-table-row[data-sid]');
@@ -578,16 +581,16 @@ return L.view.extend({
busy = btns[0].classList.contains('spinning') || btns[1].classList.contains('spinning') || btns[2].classList.contains('spinning');
if (radioDev) {
- L.dom.content(badge, render_radio_badge(radioDev));
- L.dom.content(stat, render_radio_status(radioDev, data[2].filter(function(n) { return n.getWifiDeviceName() == radioDev.getName() })));
+ dom.content(badge, render_radio_badge(radioDev));
+ dom.content(stat, render_radio_status(radioDev, data[2].filter(function(n) { return n.getWifiDeviceName() == radioDev.getName() })));
}
else {
- L.dom.content(badge, render_network_badge(radioNet));
- L.dom.content(stat, render_network_status(radioNet));
+ dom.content(badge, render_network_badge(radioNet));
+ dom.content(stat, render_network_status(radioNet));
}
if (stat.hasAttribute('restart'))
- L.dom.content(stat, E('em', _('Device is restarting…')));
+ dom.content(stat, E('em', _('Device is restarting…')));
btns[0].disabled = busy;
btns[1].disabled = busy;
@@ -645,7 +648,7 @@ return L.view.extend({
row.push(E('button', {
'class': 'cbi-button cbi-button-remove',
'click': L.bind(function(net, mac, ev) {
- L.dom.parent(ev.currentTarget, '.tr').style.opacity = 0.5;
+ dom.parent(ev.currentTarget, '.tr').style.opacity = 0.5;
ev.currentTarget.classList.add('spinning');
ev.currentTarget.disabled = true;
ev.currentTarget.blur();
@@ -1676,8 +1679,8 @@ return L.view.extend({
this.pollFn = L.bind(this.handleScanRefresh, this, radioDev, {}, table, stop);
- L.Poll.add(this.pollFn);
- L.Poll.start();
+ poll.add(this.pollFn);
+ poll.start();
};
s.handleScanRefresh = function(radioDev, scanCache, table, stop) {
@@ -1743,12 +1746,12 @@ return L.view.extend({
var btn = ev.currentTarget;
if (btn.getAttribute('data-state') == 'stop') {
- L.Poll.remove(this.pollFn);
+ poll.remove(this.pollFn);
btn.firstChild.data = _('Start refresh');
btn.setAttribute('data-state', 'start');
}
else {
- L.Poll.add(this.pollFn);
+ poll.add(this.pollFn);
btn.firstChild.data = _('Stop refresh');
btn.setAttribute('data-state', 'stop');
btn.classList.add('spinning');
@@ -1757,14 +1760,14 @@ return L.view.extend({
};
s.handleScanAbort = function(ev) {
- var md = L.dom.parent(ev.target, 'div[aria-modal="true"]');
+ var md = dom.parent(ev.target, 'div[aria-modal="true"]');
if (md) {
md.style.maxWidth = '';
md.style.maxHeight = '';
}
ui.hideModal();
- L.Poll.remove(this.pollFn);
+ poll.remove(this.pollFn);
this.pollFn = null;
};
@@ -1984,7 +1987,7 @@ return L.view.extend({
};
return m.render().then(L.bind(function(m, nodes) {
- L.Poll.add(L.bind(function() {
+ poll.add(L.bind(function() {
var section_ids = m.children[0].cfgsections(),
tasks = [ network.getHostHints(), network.getWifiDevices() ];