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/luasrc/model/cbi | |
parent | e8557bbe60eba7ed45305c99167e0bbb2c53be52 (diff) |
Reworked Freifunk public status pages
Diffstat (limited to 'modules/freifunk/luasrc/model/cbi')
-rw-r--r-- | modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua | 8 | ||||
-rw-r--r-- | modules/freifunk/luasrc/model/cbi/freifunk/public_status.lua | 173 |
2 files changed, 173 insertions, 8 deletions
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 |