1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Update luci and theme

This commit is contained in:
Ycarus 2019-05-28 21:51:29 +02:00
parent fe03553aae
commit 4d7962337f
165 changed files with 74180 additions and 13802 deletions

View file

@ -0,0 +1,42 @@
requestAnimationFrame(function() {
document.querySelectorAll('[data-iface-status]').forEach(function(container) {
var network = container.getAttribute('data-iface-status'),
icon = container.querySelector('img'),
info = container.querySelector('span');
L.poll(5, L.url('admin/network/iface_status', network), null, function(xhr, ifaces) {
var ifc = Array.isArray(ifaces) ? ifaces[0] : null;
if (!ifc)
return;
L.itemlist(info, [
_('Device'), ifc.ifname,
_('Uptime'), ifc.is_up ? '%t'.format(ifc.uptime) : null,
_('MAC'), ifc.ifname ? ifc.macaddr : null,
_('RX'), ifc.ifname ? '%.2mB (%d %s)'.format(ifc.rx_bytes, ifc.rx_packets, _('Pkts.')) : null,
_('TX'), ifc.ifname ? '%.2mB (%d %s)'.format(ifc.tx_bytes, ifc.tx_packets, _('Pkts.')) : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[0] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[1] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[2] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[3] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[4] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[0] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[1] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[2] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[3] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[4] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[5] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[6] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[7] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[8] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[9] : null,
_('IPv6-PD'), ifc.ip6prefix,
null, ifc.ifname ? null : E('em', _('Interface not present or not connected yet.'))
]);
icon.src = L.resource('icons/%s%s.png').format(ifc.type, ifc.is_up ? '' : '_disabled');
});
L.run();
});
});

View file

@ -0,0 +1,136 @@
function iface_reconnect(id) {
L.halt();
L.dom.content(document.getElementById(id + '-ifc-description'), E('em', _('Interface is reconnecting...')));
L.post(L.url('admin/network/iface_reconnect', id), null, L.run);
}
function iface_delete(ev) {
if (!confirm(_('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface'))) {
ev.preventDefault();
return false;
}
ev.target.previousElementSibling.value = '1';
return true;
}
var networks = [];
document.querySelectorAll('[data-network]').forEach(function(n) {
networks.push(n.getAttribute('data-network'));
});
function render_iface(ifc) {
return E('span', { class: 'cbi-tooltip-container' }, [
E('img', { 'class' : 'middle', 'src': L.resource('icons/%s%s.png').format(
ifc.is_alias ? 'alias' : ifc.type,
ifc.is_up ? '' : '_disabled') }),
E('span', { 'class': 'cbi-tooltip ifacebadge large' }, [
E('img', { 'src': L.resource('icons/%s%s.png').format(
ifc.type, ifc.is_up ? '' : '_disabled') }),
L.itemlist(E('span', { 'class': 'left' }), [
_('Type'), ifc.typename,
_('Device'), ifc.ifname,
_('Connected'), ifc.is_up ? _('yes') : _('no'),
_('MAC'), ifc.macaddr,
_('RX'), '%.2mB (%d %s)'.format(ifc.rx_bytes, ifc.rx_packets, _('Pkts.')),
_('TX'), '%.2mB (%d %s)'.format(ifc.tx_bytes, ifc.tx_packets, _('Pkts.'))
])
])
]);
}
L.poll(5, L.url('admin/network/iface_status', networks.join(',')), null,
function(x, ifcs) {
if (ifcs) {
for (var idx = 0; idx < ifcs.length; idx++) {
var ifc = ifcs[idx];
var s = document.getElementById(ifc.id + '-ifc-devices');
if (s) {
var c = [ render_iface(ifc) ];
if (ifc.subdevices && ifc.subdevices.length)
{
var sifs = [ ' (' ];
for (var j = 0; j < ifc.subdevices.length; j++)
sifs.push(render_iface(ifc.subdevices[j]));
sifs.push(')');
c.push(E('span', {}, sifs));
}
c.push(E('br'));
c.push(E('small', {}, ifc.is_alias ? _('Alias of "%s"').format(ifc.is_alias) : ifc.name));
L.dom.content(s, c);
}
var d = document.getElementById(ifc.id + '-ifc-description');
if (d && ifc.proto && ifc.ifname) {
var desc = null, c = [];
if (ifc.is_dynamic)
desc = _('Virtual dynamic interface');
else if (ifc.is_alias)
desc = _('Alias Interface');
if (ifc.desc)
desc = desc ? '%s (%s)'.format(desc, ifc.desc) : ifc.desc;
L.itemlist(d, [
_('Protocol'), desc || '?',
_('Uptime'), ifc.is_up ? '%t'.format(ifc.uptime) : null,
_('MAC'), (!ifc.is_dynamic && !ifc.is_alias && ifc.macaddr) ? ifc.macaddr : null,
_('RX'), (!ifc.is_dynamic && !ifc.is_alias) ? '%.2mB (%d %s)'.format(ifc.rx_bytes, ifc.rx_packets, _('Pkts.')) : null,
_('TX'), (!ifc.is_dynamic && !ifc.is_alias) ? '%.2mB (%d %s)'.format(ifc.tx_bytes, ifc.tx_packets, _('Pkts.')) : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[0] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[1] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[2] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[3] : null,
_('IPv4'), ifc.ipaddrs ? ifc.ipaddrs[4] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[0] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[1] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[2] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[3] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[4] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[5] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[6] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[7] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[8] : null,
_('IPv6'), ifc.ip6addrs ? ifc.ip6addrs[9] : null,
_('IPv6-PD'), ifc.ip6prefix,
_('Information'), ifc.is_auto ? null : _('Not started on boot'),
_('Error'), ifc.errors ? ifc.errors[0] : null,
_('Error'), ifc.errors ? ifc.errors[1] : null,
_('Error'), ifc.errors ? ifc.errors[2] : null,
_('Error'), ifc.errors ? ifc.errors[3] : null,
_('Error'), ifc.errors ? ifc.errors[4] : null,
]);
}
else if (d && !ifc.proto) {
var e = document.getElementById(ifc.id + '-ifc-edit');
if (e) e.disabled = true;
var link = L.url('admin/system/opkg') + '?query=luci-proto';
L.dom.content(d, [
E('em', _('Unsupported protocol type.')), E('br'),
E('a', { href: link }, _('Install protocol extensions...'))
]);
}
else if (d && !ifc.ifname) {
var link = L.url('admin/network/network', ifc.name) + '?tab.network.%s=physical'.format(ifc.name);
L.dom.content(d, [
E('em', _('Network without interfaces.')), E('br'),
E('a', { href: link }, _('Assign interfaces...'))
]);
}
else if (d) {
L.dom.content(d, E('em' ,_('Interface not present or not connected yet.')));
}
}
}
}
);

View file

@ -0,0 +1,159 @@
var poll = null;
function format_signal(bss) {
var qval = bss.quality || 0,
qmax = bss.quality_max || 100,
scale = 100 / qmax * qval,
range = 'none';
if (!bss.bssid || bss.bssid == '00:00:00:00:00:00')
range = 'none';
else if (scale < 15)
range = '0';
else if (scale < 35)
range = '0-25';
else if (scale < 55)
range = '25-50';
else if (scale < 75)
range = '50-75';
else
range = '75-100';
return E('span', {
class: 'ifacebadge',
title: '%s: %d%s / %s: %d/%d'.format(_('Signal'), bss.signal, _('dB'), _('Quality'), qval, qmax)
}, [
E('img', { src: L.resource('icons/signal-%s.png').format(range) }),
' %d%%'.format(scale)
]);
}
function format_encryption(bss) {
var enc = bss.encryption || { }
if (enc.wep === true)
return 'WEP';
else if (enc.wpa > 0)
return E('abbr', {
title: 'Pairwise: %h / Group: %h'.format(
enc.pair_ciphers.join(', '),
enc.group_ciphers.join(', '))
},
'%h - %h'.format(
(enc.wpa === 3) ? _('mixed WPA/WPA2') : (enc.wpa === 2 ? 'WPA2' : 'WPA'),
enc.auth_suites.join(', ')));
else
return E('em', enc.enabled ? _('unknown') : _('open'));
}
function format_actions(dev, type, bss) {
var enc = bss.encryption || { },
input = [
E('input', { type: 'submit', class: 'cbi-button cbi-button-action important', value: _('Join Network') }),
E('input', { type: 'hidden', name: 'token', value: L.env.token }),
E('input', { type: 'hidden', name: 'device', value: dev }),
E('input', { type: 'hidden', name: 'join', value: bss.ssid }),
E('input', { type: 'hidden', name: 'mode', value: bss.mode }),
E('input', { type: 'hidden', name: 'bssid', value: bss.bssid }),
E('input', { type: 'hidden', name: 'channel', value: bss.channel }),
E('input', { type: 'hidden', name: 'clbridge', value: type === 'wl' ? 1 : 0 }),
E('input', { type: 'hidden', name: 'wep', value: enc.wep ? 1 : 0 })
];
if (enc.wpa) {
input.push(E('input', { type: 'hidden', name: 'wpa_version', value: enc.wpa }));
enc.auth_suites.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_suites', value: s }));
});
enc.group_ciphers.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_group', value: s }));
});
enc.pair_ciphers.forEach(function(s) {
input.push(E('input', { type: 'hidden', name: 'wpa_pairwise', value: s }));
});
}
return E('form', {
class: 'inline',
method: 'post',
action: L.url('admin/network/wireless_join')
}, input);
}
function fade(bss, content) {
if (bss.stale)
return E('span', { style: 'opacity:0.5' }, content);
else
return content;
}
function flush() {
L.stop(poll);
L.halt();
scan();
}
function scan() {
var tbl = document.querySelector('[data-wifi-scan]'),
dev = tbl.getAttribute('data-wifi-scan'),
type = tbl.getAttribute('data-wifi-type');
cbi_update_table(tbl, [], E('em', { class: 'spinning' }, _('Starting wireless scan...')));
L.post(L.url('admin/network/wireless_scan_trigger', dev), null, function(s) {
if (s.status !== 204) {
cbi_update_table(tbl, [], E('em', _('Scan request failed')));
return;
}
var count = 0;
poll = L.poll(3, L.url('admin/network/wireless_scan_results', dev), null, function(s, results) {
if (Array.isArray(results)) {
var bss = [];
results.sort(function(a, b) {
var diff = (b.quality - a.quality) || (a.channel - b.channel);
if (diff)
return diff;
if (a.ssid < b.ssid)
return -1;
else if (a.ssid > b.ssid)
return 1;
if (a.bssid < b.bssid)
return -1;
else if (a.bssid > b.bssid)
return 1;
}).forEach(function(res) {
bss.push([
fade(res, format_signal(res)),
fade(res, res.ssid ? '%h'.format(res.ssid) : E('em', {}, _('hidden'))),
fade(res, res.channel),
fade(res, res.mode),
fade(res, res.bssid),
fade(res, format_encryption(res)),
format_actions(dev, type, res)
]);
});
cbi_update_table(tbl, bss, E('em', { class: 'spinning' }, _('No scan results available yet...')));
}
if (count++ >= 3) {
count = 0;
L.post(L.url('admin/network/wireless_scan_trigger', dev, 1), null, function() {});
}
});
L.run();
});
}
document.addEventListener('DOMContentLoaded', scan);

View file

@ -0,0 +1,59 @@
requestAnimationFrame(function() {
document.querySelectorAll('[data-wifi-status]').forEach(function(container) {
var ifname = container.getAttribute('data-wifi-status'),
small = container.querySelector('small'),
info = container.querySelector('span');
L.poll(5, L.url('admin/network/wireless_status', ifname), null, function(xhr, iws) {
var iw = Array.isArray(iws) ? iws[0] : null;
if (!iw)
return;
var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled);
var p = iw.quality;
var q = iw.disabled ? -1 : p;
var icon;
if (q < 0)
icon = L.resource('icons/signal-none.png');
else if (q == 0)
icon = L.resource('icons/signal-0.png');
else if (q < 25)
icon = L.resource('icons/signal-0-25.png');
else if (q < 50)
icon = L.resource('icons/signal-25-50.png');
else if (q < 75)
icon = L.resource('icons/signal-50-75.png');
else
icon = L.resource('icons/signal-75-100.png');
L.dom.content(small, [
E('img', {
src: icon,
title: '%s: %d %s / %s: %d %s'.format(
_('Signal'), iw.signal, _('dBm'),
_('Noise'), iw.noise, _('dBm'))
}),
'\u00a0', E('br'), '%d%%\u00a0'.format(p)
]);
L.itemlist(info, [
_('Mode'), iw.mode,
_('SSID'), iw.ssid || '?',
_('BSSID'), is_assoc ? iw.bssid : null,
_('Encryption'), is_assoc ? iw.encryption || _('None') : null,
_('Channel'), is_assoc ? '%d (%.3f %s)'.format(iw.channel, iw.frequency || 0, _('GHz')) : null,
_('Tx-Power'), is_assoc ? '%d %s'.format(iw.txpower, _('dBm')) : null,
_('Signal'), is_assoc ? '%d %s'.format(iw.signal, _('dBm')) : null,
_('Noise'), is_assoc ? '%d %s'.format(iw.noise, _('dBm')) : null,
_('Bitrate'), is_assoc ? '%.1f %s'.format(iw.bitrate || 0, _('Mbit/s')) : null,
_('Country'), is_assoc ? iw.country : null
], [ ' | ', E('br'), E('br'), E('br'), E('br'), E('br'), ' | ', E('br'), ' | ' ]);
if (!is_assoc)
L.dom.append(info, E('em', iw.disabled ? _('Wireless is disabled') : _('Wireless is not associated')));
});
L.run();
});
});

View file

@ -0,0 +1,93 @@
function wifi_delete(ev) {
if (!confirm(_('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))) {
ev.preventDefault();
return false;
}
ev.target.previousElementSibling.value = '1';
return true;
}
function wifi_restart(ev) {
L.halt();
findParent(ev.target, '.table').querySelectorAll('[data-disabled="false"]').forEach(function(s) {
L.dom.content(s, E('em', _('Wireless is restarting...')));
});
L.post(L.url('admin/network/wireless_reconnect', ev.target.getAttribute('data-radio')), L.run);
}
var networks = [ ];
document.querySelectorAll('[data-network]').forEach(function(n) {
networks.push(n.getAttribute('data-network'));
});
L.poll(5, L.url('admin/network/wireless_status', networks.join(',')), null,
function(x, st) {
if (st) {
var rowstyle = 1;
var radiostate = { };
st.forEach(function(s) {
var r = radiostate[s.device.device] || (radiostate[s.device.device] = {});
s.is_assoc = (s.bssid && s.bssid != '00:00:00:00:00:00' && s.channel && s.mode != 'Unknown' && !s.disabled);
r.up = r.up || s.is_assoc;
r.channel = r.channel || s.channel;
r.bitrate = r.bitrate || s.bitrate;
r.frequency = r.frequency || s.frequency;
});
for (var i = 0; i < st.length; i++) {
var iw = st[i],
sig = document.getElementById(iw.id + '-iw-signal'),
info = document.getElementById(iw.id + '-iw-status'),
disabled = (info && info.getAttribute('data-disabled') === 'true');
var p = iw.quality;
var q = disabled ? -1 : p;
var icon;
if (q < 0)
icon = L.resource('icons/signal-none.png');
else if (q == 0)
icon = L.resource('icons/signal-0.png');
else if (q < 25)
icon = L.resource('icons/signal-0-25.png');
else if (q < 50)
icon = L.resource('icons/signal-25-50.png');
else if (q < 75)
icon = L.resource('icons/signal-50-75.png');
else
icon = L.resource('icons/signal-75-100.png');
L.dom.content(sig, E('span', {
class: 'ifacebadge',
title: '%s %d %s / %s: %d %s'.format(_('Signal'), iw.signal, _('dBm'), _('Noise'), iw.noise, _('dBm'))
}, [ E('img', { src: icon }), ' %d%%'.format(p) ]));
L.itemlist(info, [
_('SSID'), iw.ssid || '?',
_('Mode'), iw.mode,
_('BSSID'), iw.is_assoc ? iw.bssid : null,
_('Encryption'), iw.is_assoc ? iw.encryption || _('None') : null,
null, iw.is_assoc ? null : E('em', disabled ? _('Wireless is disabled') : _('Wireless is not associated'))
], [ ' | ', E('br') ]);
}
for (var dev in radiostate) {
var img = document.getElementById(dev + '-iw-upstate');
if (img) img.src = L.resource('icons/wifi' + (radiostate[dev].up ? '' : '_disabled') + '.png');
var stat = document.getElementById(dev + '-iw-devinfo');
L.itemlist(stat, [
_('Channel'), '%s (%s %s)'.format(radiostate[dev].channel || '?', radiostate[dev].frequency || '?', _('GHz')),
_('Bitrate'), '%s %s'.format(radiostate[dev].bitrate || '?', _('Mbit/s'))
], ' | ');
}
}
}
);