diff options
author | Steven Barth <steven@midlink.org> | 2008-09-14 01:05:11 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-14 01:05:11 +0000 |
commit | 15345d3615c3956c3f8fb86a03e180a8c13f0e97 (patch) | |
tree | 268a5c20e09040cf35d90a3d62c8c0c45edfe865 /modules/freifunk | |
parent | e8557bbe60eba7ed45305c99167e0bbb2c53be52 (diff) |
Reworked Freifunk public status pages
Diffstat (limited to 'modules/freifunk')
4 files changed, 175 insertions, 108 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index 07b12f3f7c..af584cd83c 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -39,14 +39,13 @@ function index() local page = node("freifunk", "status") - page.target = call("action_status") + page.target = form("freifunk/public_status") page.title = "Status" page.order = 20 + page.i18n = "admin-core" page.setuser = false page.setgroup = false - assign({"freifunk", "status", "iwscan"}, {"admin", "status", "iwscan"}, "WLAN-Scan", 20) - assign({"freifunk", "olsr"}, {"admin", "status", "olsr"}, "OLSR", 30) if luci.fs.isfile("/etc/config/luci_statistics") then diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua index 54d984988e..f1bf641632 100644 --- a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua @@ -18,14 +18,6 @@ für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konf des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]]) c:option(Value, "name", "Gemeinschaft") c:option(Value, "homepage", "Webseite") -c:option(Value, "essid", "ESSID") -c:option(Value, "bssid", "BSSID") -c:option(Value, "channel", "Funkkanal") c:option(Value, "realm", "Realm") -c:option(Value, "net", "Adressbereich") -c:option(Value, "mask", "Netzmaske") -c:option(Value, "dns", "DNS-Server") -c:option(Value, "dhcp", "DHCP-Bereich") -c:option(Value, "dhcpmask", "DHCP-Maske") return m
\ 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 new file mode 100644 index 0000000000..08201f7036 --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua @@ -0,0 +1,173 @@ +require "luci.sys" +require "luci.tools.webadmin" + +local uci = luci.model.uci.cursor_state() + +local ffzone = luci.tools.webadmin.firewall_find_zone("freifunk") +local ffznet = ffzone and uci:get("firewall", ffzone, "network") +local ffwifs = ffznet and luci.util.split(ffznet, " ") or {} + +-- System -- + +f = SimpleForm("system", "System") +f.submit = false +f.reset = false +local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo() +local uptime = luci.sys.uptime() + +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 = +string.format("%.2f, %.2f, %.2f", load1, load5, load15) + +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 "") + +f:field(DummyValue, "_systime", translate("m_i_systemtime")).value = +os.date("%c") + +f:field(DummyValue, "_uptime", translate("m_i_uptime")).value = +luci.tools.webadmin.date_format(tonumber(uptime)) + + +-- Wireless -- + +local wireless = uci:get_all("wireless") +local wifidata = luci.sys.wifi.getiwconfig() +local ifaces = {} + +for k, v in pairs(wireless) do + if v[".type"] == "wifi-iface" and luci.util.contains(ffwifs, v.device) then + table.insert(ifaces, v) + end +end + + +m = SimpleForm("wireless", "Freifunk WLAN") +m.submit = false +m.reset = false + +s = m:section(Table, ifaces, translate("networks")) + +link = s:option(DummyValue, "_link", translate("link")) +function link.cfgvalue(self, section) + local ifname = self.map:get(section, "ifname") + return wifidata[ifname] and wifidata[ifname]["Link Quality"] or "-" +end + +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 + or wifidata[ifname]["Access Point"])) or "-" +end + +channel = s:option(DummyValue, "channel", translate("channel")) + function channel.cfgvalue(self, section) + return wireless[self.map:get(section, "device")].channel +end + +protocol = s:option(DummyValue, "_mode", translate("protocol")) +function protocol.cfgvalue(self, section) + local mode = wireless[self.map:get(section, "device")].mode + return mode and "802." .. mode +end + +mode = s:option(DummyValue, "mode", translate("mode")) +encryption = s:option(DummyValue, "encryption", translate("iwscan_encr")) + +power = s:option(DummyValue, "_power", translate("power")) +function power.cfgvalue(self, section) + local ifname = self.map:get(section, "ifname") + return wifidata[ifname] and wifidata[ifname]["Tx-Power"] or "-" +end + +scan = s:option(Button, "_scan", translate("scan")) +scan.inputstyle = "find" + +function scan.cfgvalue(self, section) + return self.map:get(section, "ifname") or false +end + +t2 = m:section(Table, {}, translate("iwscan"), translate("iwscan1")) + +function scan.write(self, section) + t2.render = t2._render + local ifname = self.map:get(section, "ifname") + luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname)) +end + +t2._render = t2.render +t2.render = function() end + +t2:option(DummyValue, "Quality", translate("iwscan_link")) +essid = t2:option(DummyValue, "ESSID", "ESSID") +function essid.cfgvalue(self, section) + return luci.util.pcdata(self.map:get(section, "ESSID")) +end + +t2:option(DummyValue, "Address", "BSSID") +t2:option(DummyValue, "Mode", translate("mode")) +chan = t2:option(DummyValue, "channel", translate("channel")) +function chan.cfgvalue(self, section) + return self.map:get(section, "Channel") + or self.map:get(section, "Frequency") + or "-" +end + +t2:option(DummyValue, "Encryption key", translate("iwscan_encr")) + +t2:option(DummyValue, "Signal level", translate("iwscan_signal")) + +t2:option(DummyValue, "Noise level", translate("iwscan_noise")) + + +-- Routes -- +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 + 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 +end + +target = v:option(DummyValue, "target", translate("target")) +function target.cfgvalue(self, section) + return luci.ip.Hex(routes[section].Destination, 32):string() +end + +netmask = v:option(DummyValue, "netmask", translate("netmask")) +function netmask.cfgvalue(self, section) + return luci.ip.Hex(routes[section].Mask, 32):string() +end + +gateway = v:option(DummyValue, "gateway", translate("gateway")) +function gateway.cfgvalue(self, section) + return luci.ip.Hex(routes[section].Gateway, 32):string() +end + +metric = v:option(DummyValue, "Metric", translate("metric")) + + +return f, m, r diff --git a/modules/freifunk/luasrc/view/public_status/index.htm b/modules/freifunk/luasrc/view/public_status/index.htm deleted file mode 100644 index aa56834ba1..0000000000 --- a/modules/freifunk/luasrc/view/public_status/index.htm +++ /dev/null @@ -1,97 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth <steven@midlink.org> -Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> -<%+header%> -<h1><%:status%></h1> -<h2><%:system%></h2> - -<br /> -<table cellspacing="0" cellpadding="6" class="smalltext"> -<tr> -<th><%:system_type%>:</th> -<td><%=system%></td> -</tr> -<tr> -<th><%:cpu%>:</th> -<td><%=model%></td> -</tr> -<tr> -<th><%:ram%>:<br /><small><%:total%>/<%:cached%>/<%:buffers%>/<%:free%></small></th> -<td><%=memtotal%> / <%=memcached%> / <%=membuffers%> / <%=memfree%> KB<br /> -<div id="memorybar"> - <div id="memfree" style="width:<%=perc_memfree%>%"></div> - <div id="membuffers" style="width:<%=perc_membuffers%>%"></div> - <div id="memcached" style="width:<%=perc_memcached%>%"></div> -</div> -</td> -</tr> -</table> -<br /><br /> - -<h2><%:wifi%></h2> -<br /> -<table cellspacing="0" cellpadding="6" class="smalltext"> -<tr> -<th><%:name%></th> -<th><%:protocol%></th> -<th><%:frequency%></th> -<th><%:power%></th> -<th><%:bitrate%></th> -<th><%:rts%></th> -<th><%:frag%></th> -<th><%:link%></th> -<th><%:signal%></th> -<th><%:noise%></th> -</tr> -<%for k, v in pairs(luci.sys.wifi.getiwconfig()) do -%> -<tr> -<td rowspan="2"><%=k%></td> -<td><%=v[1]%></td> -<td><%=v.Frequency%></td> -<td><%=v["Tx-Power"]%></td> -<td><%=v["Bit Rate"]%></td> -<td><%=v["RTS thr"]%></td> -<td><%=v["Fragment thr"]%></td> -<td><%=v["Link Quality"]%></td> -<td><%=v["Signal level"]%></td> -<td><%=v["Noise level"]%></td> -</tr> -<tr> -<td colspan="4"><strong>ESSID: </strong><%=v.ESSID%></td> -<td colspan="5"><strong>BSSID: </strong><%=(v.Cell or v["Access Point"])%></td> -</tr> -<%end%> -</table> -<br /> -<br /> -<h2><%:defroutes%></h2> -<br /> -<table cellspacing="0" cellpadding="6" class="smalltext"> -<tr> -<th><%:gateway%></th> -<th><%:metric%></th> -<th><%:iface%></th> -</tr> -<% -for i, rt in pairs(routes) do -%> -<tr> -<td><%=luci.ip.Hex(rt.Gateway, 32):string()%></th> -<td><%=rt.Metric%></th> -<td><%=rt.Iface%></th> -</tr> -<% end %> -</table> -<%+footer%>
\ No newline at end of file |