summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard
diff options
context:
space:
mode:
authorPaul Donald <newtwen+github@gmail.com>2024-04-30 16:01:26 +0200
committerPaul Donald <newtwen+github@gmail.com>2024-04-30 16:01:26 +0200
commitfd3d14e9a4a54a2a4fa45d645d5cbbf351a4d5c1 (patch)
tree824d7a688f32e1167d8e2c7322bbd71a89c9a004 /modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard
parent0f7ba7b9a204a37673cf38d9d7748747591510d1 (diff)
luci-mod-dashboard: prevent null or undefined 'ifc'
This can happen on factory fresh settings, or a box not yet connected. follow-up fix for c75232d8d29ba5a9cc5c07c3fff65248f12f1b08 Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Diffstat (limited to 'modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard')
-rw-r--r--modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js b/modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js
index f5002df84d..4cc671da52 100644
--- a/modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js
+++ b/modules/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js
@@ -153,24 +153,25 @@ return baseclass.extend({
}
var ifc = data[min_metric_i];
-
- if (v6) {
- var uptime = ifc.getUptime();
- this.params.internet.v6.uptime.value = (uptime > 0) ? '%t'.format(uptime) : '-';
- this.params.internet.v6.ipprefixv6.value = ifc.getIP6Prefix() || '-';
- this.params.internet.v6.gatewayv6.value = ifc.getGateway6Addr() || '-';
- this.params.internet.v6.protocol.value= ifc.getI18n() || E('em', _('Not connected'));
- this.params.internet.v6.addrsv6.value = ifc.getIP6Addrs() || [ '-' ];
- this.params.internet.v6.dnsv6.value = ifc.getDNS6Addrs() || [ '-' ];
- this.params.internet.v6.connected.value = ifc.isUp();
- } else {
- var uptime = ifc.getUptime();
- this.params.internet.v4.uptime.value = (uptime > 0) ? '%t'.format(uptime) : '-';
- this.params.internet.v4.protocol.value= ifc.getI18n() || E('em', _('Not connected'));
- this.params.internet.v4.gatewayv4.value = ifc.getGatewayAddr() || '0.0.0.0';
- this.params.internet.v4.connected.value = ifc.isUp();
- this.params.internet.v4.addrsv4.value = ifc.getIPAddrs() || [ '-'];
- this.params.internet.v4.dnsv4.value = ifc.getDNSAddrs() || [ '-' ];
+ if(ifc){
+ if (v6) {
+ var uptime = ifc.getUptime();
+ this.params.internet.v6.uptime.value = (uptime > 0) ? '%t'.format(uptime) : '-';
+ this.params.internet.v6.ipprefixv6.value = ifc.getIP6Prefix() || '-';
+ this.params.internet.v6.gatewayv6.value = ifc.getGateway6Addr() || '-';
+ this.params.internet.v6.protocol.value= ifc.getI18n() || E('em', _('Not connected'));
+ this.params.internet.v6.addrsv6.value = ifc.getIP6Addrs() || [ '-' ];
+ this.params.internet.v6.dnsv6.value = ifc.getDNS6Addrs() || [ '-' ];
+ this.params.internet.v6.connected.value = ifc.isUp();
+ } else {
+ var uptime = ifc.getUptime();
+ this.params.internet.v4.uptime.value = (uptime > 0) ? '%t'.format(uptime) : '-';
+ this.params.internet.v4.protocol.value= ifc.getI18n() || E('em', _('Not connected'));
+ this.params.internet.v4.gatewayv4.value = ifc.getGatewayAddr() || '0.0.0.0';
+ this.params.internet.v4.connected.value = ifc.isUp();
+ this.params.internet.v4.addrsv4.value = ifc.getIPAddrs() || [ '-'];
+ this.params.internet.v4.dnsv4.value = ifc.getDNSAddrs() || [ '-' ];
+ }
}
},