luci2: various network function fixes
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 5 Oct 2013 20:13:17 +0000 (20:13 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 5 Oct 2013 20:13:17 +0000 (20:13 +0000)
 * fix empty device descriptions for alias interfaces in LuCI2.network.getNetworkStatus()
 * fix crash with inactive interfaces in LuCI2.network.findWanInterfaces()
 * fix LuCI2.network.getDeviceStatus() function name after only greedy search and replace

luci2/htdocs/luci2/luci2.js

index 52ea2e7a035600270e911853a59ed7edcf9839c5..fc5d84a458f71e3799ae5ecb0f15323a0993a831 100644 (file)
@@ -788,13 +788,13 @@ function LuCI2()
                                        var net = nets[i] = networks[i];
                                        var dev = net.l3_device || net.l2_device;
                                        if (dev)
-                                               net.device = devs[dev] = { };
+                                               net.device = devs[dev] || (devs[dev] = { });
                                }
 
                                _luci2.rpc.batch();
 
                                for (var dev in devs)
-                                       _luci2.network.listDeviceNamestatus(dev);
+                                       _luci2.network.getDeviceStatus(dev);
 
                                return _luci2.rpc.flush();
                        }).then(function(devices) {
@@ -817,7 +817,7 @@ function LuCI2()
                                                if (!devs[brm[j]])
                                                {
                                                        devs[brm[j]] = { };
-                                                       _luci2.network.listDeviceNamestatus(brm[j]);
+                                                       _luci2.network.getDeviceStatus(brm[j]);
                                                }
 
                                                devs[devices[i]['device']].subdevices[j] = devs[brm[j]];
@@ -867,6 +867,9 @@ function LuCI2()
 
                                for (var i = 0; i < interfaces.length; i++)
                                {
+                                       if (!interfaces[i].route)
+                                               continue;
+
                                        for (var j = 0; j < interfaces[i].route.length; j++)
                                        {
                                                var rt = interfaces[i].route[j];
@@ -928,7 +931,7 @@ function LuCI2()
                        }
                }),
 
-               listDeviceNamestatus: _luci2.rpc.declare({
+               getDeviceStatus: _luci2.rpc.declare({
                        object: 'network.device',
                        method: 'status',
                        params: [ 'name' ],