summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-18 07:19:18 +0200
committerJo-Philipp Wich <jo@mein.io>2019-09-18 07:19:18 +0200
commit10880b565f3050e1808333f3246bc791d35f69dd (patch)
treee844030dd1c2a0f0ff33e357500bb894389ed7c0 /modules/luci-base/htdocs/luci-static/resources
parenta67175cab1f441b23c0b12091e10710d7dfc69b3 (diff)
luci-base: network.js: get low level device details from getifaddr() info
Fixes: #3078 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/network.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js
index 525b7c9f19..c3c20304e5 100644
--- a/modules/luci-base/htdocs/luci-static/resources/network.js
+++ b/modules/luci-base/htdocs/luci-static/resources/network.js
@@ -1756,10 +1756,16 @@ Device = L.Class.extend({
this.network = network;
},
- _ubus: function(field) {
- var dump = _state.devices[this.ifname] || {};
+ _devstate: function(/* ... */) {
+ var rv = this.dev;
- return (field != null ? dump[field] : dump);
+ for (var i = 0; i < arguments.length; i++)
+ if (L.isObject(rv))
+ rv = rv[arguments[i]];
+ else
+ return null;
+
+ return rv;
},
getName: function() {
@@ -1767,24 +1773,21 @@ Device = L.Class.extend({
},
getMAC: function() {
- var mac = (this.dev != null ? this.dev.macaddr : null);
- if (mac == null)
- mac = this._ubus('macaddr');
-
+ var mac = this._devstate('macaddr');
return mac ? mac.toUpperCase() : null;
},
getMTU: function() {
- return this.dev ? this.dev.mtu : null;
+ return this._devstate('mtu');
},
getIPAddrs: function() {
- var addrs = (this.dev != null ? this.dev.ipaddrs : null);
+ var addrs = this._devstate('ipaddrs');
return (Array.isArray(addrs) ? addrs : []);
},
getIP6Addrs: function() {
- var addrs = (this.dev != null ? this.dev.ip6addrs : null);
+ var addrs = this._devstate('ip6addrs');
return (Array.isArray(addrs) ? addrs : []);
},
@@ -1874,7 +1877,7 @@ Device = L.Class.extend({
},
isUp: function() {
- var up = this._ubus('up');
+ var up = this._devstate('flags', 'up');
if (up == null)
up = (this.getType() == 'alias');
@@ -1887,26 +1890,26 @@ Device = L.Class.extend({
},
isBridgePort: function() {
- return (this.dev != null && this.dev.bridge != null);
+ return (this._devstate('bridge') != null);
},
getTXBytes: function() {
- var stat = this._ubus('statistics');
+ var stat = this._devstate('stats');
return (stat != null ? stat.tx_bytes || 0 : 0);
},
getRXBytes: function() {
- var stat = this._ubus('statistics');
+ var stat = this._devstate('stats');
return (stat != null ? stat.rx_bytes || 0 : 0);
},
getTXPackets: function() {
- var stat = this._ubus('statistics');
+ var stat = this._devstate('stats');
return (stat != null ? stat.tx_packets || 0 : 0);
},
getRXPackets: function() {
- var stat = this._ubus('statistics');
+ var stat = this._devstate('stats');
return (stat != null ? stat.rx_packets || 0 : 0);
},