summaryrefslogtreecommitdiffhomepage
path: root/modules/freifunk/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-11-29 20:46:26 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-11-29 20:46:26 +0000
commitdda65d2b94f11f69537bed3c46d3c6e80234291b (patch)
tree3073130922cdb6a34ba1be32e2c020d064a6d5ae /modules/freifunk/luasrc
parent82f08a4a1d1f7d54ccc82326c02f40f11a028409 (diff)
libs/core/ip: optmizations
libs/sys: implement defaultroute6(), change return values of routes() and routes6() modules/admin-full: adept route config page to new api modules/freifunk: adept overview page to new routes api
Diffstat (limited to 'modules/freifunk/luasrc')
-rw-r--r--modules/freifunk/luasrc/controller/freifunk/freifunk.lua37
-rw-r--r--modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua68
2 files changed, 59 insertions, 46 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
index 9399d50930..533211b001 100644
--- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
+++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
@@ -30,18 +30,18 @@ function index()
page.setgroup = "nogroup"
page.i18n = "freifunk"
page.index = true
-
+
local page = node("freifunk", "index")
page.target = template("freifunk/index")
page.title = "Übersicht"
page.order = 10
page.indexignore = true
-
+
local page = node("freifunk", "index", "contact")
page.target = template("freifunk/contact")
page.title = "Kontakt"
-
-
+
+
local page = node("freifunk", "status")
page.target = form("freifunk/public_status")
page.title = "Status"
@@ -49,43 +49,22 @@ function index()
page.i18n = "admin-core"
page.setuser = false
page.setgroup = false
-
+
assign({"freifunk", "olsr"}, {"admin", "status", "olsr"}, "OLSR", 30)
-
+
if luci.fs.isfile("/etc/config/luci_statistics") then
assign({"freifunk", "graph"}, {"admin", "statistics", "graph"}, i18n("stat_statistics", "Statistiken"), 40)
end
-
+
assign({"mini", "freifunk"}, {"admin", "freifunk"}, "Freifunk", 15)
entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), "Freifunk", 15)
local page = node("admin", "freifunk", "index")
page.target = cbi("freifunk/freifunk")
page.title = "Freifunk"
page.order = 30
-
+
local page = node("admin", "freifunk", "contact")
page.target = cbi("freifunk/contact")
page.title = "Kontakt"
page.order = 40
end
-
-function action_status()
- local data = {}
-
- data.system, data.model, data.memtotal, data.memcached, data.membuffers, data.memfree = luci.sys.sysinfo()
- data.perc_memfree = math.floor((data.memfree/data.memtotal)*100)
- data.perc_membuffers = math.floor((data.membuffers/data.memtotal)*100)
- data.perc_memcached = math.floor((data.memcached/data.memtotal)*100)
-
- data.wifi = luci.sys.wifi.getiwconfig()
-
- data.routes = {}
- for i, r in pairs(luci.sys.net.routes()) do
- if r.Destination == "00000000" then
- table.insert(data.routes, r)
- end
- end
-
-
- luci.template.render("public_status/index", data)
-end \ No newline at end of file
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua b/modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua
index 08201f7036..5971e2a2f2 100644
--- a/modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua
+++ b/modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua
@@ -19,23 +19,23 @@ f:field(DummyValue, "_system", translate("system")).value = system
f:field(DummyValue, "_cpu", translate("m_i_processor")).value = model
local load1, load5, load15 = luci.sys.loadavg()
-f:field(DummyValue, "_la", translate("load")).value =
+f:field(DummyValue, "_la", translate("load")).value =
string.format("%.2f, %.2f, %.2f", load1, load5, load15)
-f:field(DummyValue, "_memtotal", translate("m_i_memory")).value =
+f:field(DummyValue, "_memtotal", translate("m_i_memory")).value =
string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
tonumber(memtotal) / 1024,
100 * memcached / memtotal,
translate("mem_cached") or "",
100 * membuffers / memtotal,
- translate("mem_buffered") or "",
- 100 * memfree / memtotal,
- translate("mem_free") or "")
+ translate("mem_buffered") or "",
+ 100 * memfree / memtotal,
+ translate("mem_free") or "")
f:field(DummyValue, "_systime", translate("m_i_systemtime")).value =
os.date("%c")
-f:field(DummyValue, "_uptime", translate("m_i_uptime")).value =
+f:field(DummyValue, "_uptime", translate("m_i_uptime")).value =
luci.tools.webadmin.date_format(tonumber(uptime))
@@ -69,7 +69,7 @@ essid = s:option(DummyValue, "ssid", "ESSID")
bssid = s:option(DummyValue, "_bsiid", "BSSID")
function bssid.cfgvalue(self, section)
local ifname = self.map:get(section, "ifname")
- return (wifidata[ifname] and (wifidata[ifname].Cell
+ return (wifidata[ifname] and (wifidata[ifname].Cell
or wifidata[ifname]["Access Point"])) or "-"
end
@@ -124,7 +124,7 @@ function chan.cfgvalue(self, section)
return self.map:get(section, "Channel")
or self.map:get(section, "Frequency")
or "-"
-end
+end
t2:option(DummyValue, "Encryption key", translate("iwscan_encr"))
@@ -137,37 +137,71 @@ t2:option(DummyValue, "Noise level", translate("iwscan_noise"))
r = SimpleForm("routes", "Standardrouten")
r.submit = false
r.reset = false
+
local routes = {}
for i, route in ipairs(luci.sys.net.routes()) do
- if route.Destination == "00000000" then
+ if route.dest:prefix() == 0 then
routes[#routes+1] = route
end
end
-
+
v = r:section(Table, routes)
-
+
net = v:option(DummyValue, "iface", translate("network"))
function net.cfgvalue(self, section)
- return luci.tools.webadmin.iface_get_network(routes[section].Iface)
- or routes[section].Iface
+ return luci.tools.webadmin.iface_get_network(routes[section].device)
+ or routes[section].device
end
target = v:option(DummyValue, "target", translate("target"))
function target.cfgvalue(self, section)
- return luci.ip.Hex(routes[section].Destination, 32):string()
+ return routes[section].dest:network():string()
end
netmask = v:option(DummyValue, "netmask", translate("netmask"))
function netmask.cfgvalue(self, section)
- return luci.ip.Hex(routes[section].Mask, 32):string()
+ return routes[section].dest:mask():string()
end
gateway = v:option(DummyValue, "gateway", translate("gateway"))
function gateway.cfgvalue(self, section)
- return luci.ip.Hex(routes[section].Gateway, 32):string()
+ return routes[section].gateway:string()
+end
+
+metric = v:option(DummyValue, "metric", translate("metric"))
+function metric.cfgvalue(self, section)
+ return routes[section].metric
+end
+
+
+local routes6 = {}
+for i, route in ipairs(luci.sys.net.routes6()) do
+ if route.dest:prefix() == 0 then
+ routes6[#routes6+1] = route
+ end
end
-metric = v:option(DummyValue, "Metric", translate("metric"))
+v6 = r:section(Table, routes6)
+net = v6:option(DummyValue, "iface", translate("network"))
+function net.cfgvalue(self, section)
+ return luci.tools.webadmin.iface_get_network(routes[section].device)
+ or routes6[section].device
+end
+
+target = v6:option(DummyValue, "target", translate("target"))
+function target.cfgvalue(self, section)
+ return routes6[section].dest:string()
+end
+
+gateway = v6:option(DummyValue, "gateway6", translate("gateway6"))
+function gateway.cfgvalue(self, section)
+ return routes6[section].source:string()
+end
+
+metric = v6:option(DummyValue, "metric", translate("metric"))
+function metric.cfgvalue(self, section)
+ return string.format("%X", routes6[section].metric)
+end
return f, m, r