Skip to content

Commit

Permalink
Fixed status overview page to work better if wifi isn't present:
Browse files Browse the repository at this point in the history
  1. check for wifi existence by calling network model instead of checking for /etc/config/wireless.
  2. only try to retrieve list of wifi networks if we actually have wifi
  • Loading branch information
jschmidlapp committed Aug 26, 2012
1 parent 8687127 commit 403eff8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libs/core/luasrc/model/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ function has_ipv6(self)
return nfs.access("/proc/net/ipv6_route")
end

function has_wifi(self)
return nfs.access("/etc/config/wireless")
end

function add_network(self, n, options)
local oldnet = self:get_network(n)
if n and #n > 0 and n:match("^[a-zA-Z0-9_]+$") and not oldnet then
Expand Down
11 changes: 7 additions & 4 deletions modules/admin-full/luasrc/view/admin_status/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
require "luci.fs"
require "luci.tools.status"

local ntm = require "luci.model.network".init()

local has_ipv6 = luci.fs.access("/proc/net/ipv6_route")
local has_dhcp = luci.fs.access("/etc/config/dhcp")
local has_wifi = luci.fs.stat("/etc/config/wireless")
has_wifi = has_wifi and has_wifi.size > 0
local has_wifi = ntm:has_wifi()

if luci.http.formvalue("status") == "1" then
local ntm = require "luci.model.network".init()
local wan = ntm:get_wannet()
local wan6 = ntm:get_wan6net()

Expand All @@ -50,8 +50,11 @@
connmax = conn_max,
conncount = conn_count,
leases = luci.tools.status.dhcp_leases(),
wifinets = luci.tools.status.wifi_networks()
}

if has_wifi then
rv.wifinets = luci.tools.status.wifi_networks()
end

if wan then
rv.wan = {
Expand Down

0 comments on commit 403eff8

Please sign in to comment.