summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/admin-full/luasrc')
-rw-r--r--modules/admin-full/luasrc/controller/admin/network.lua17
-rw-r--r--modules/admin-full/luasrc/controller/admin/wifi.lua34
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua (renamed from modules/admin-full/luasrc/model/cbi/admin_wifi/networks.lua)54
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua135
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_wifi/devices.lua57
-rw-r--r--modules/admin-full/luasrc/view/admin_wifi/index.htm20
6 files changed, 199 insertions, 118 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua
index 3952fb868..23a575852 100644
--- a/modules/admin-full/luasrc/controller/admin/network.lua
+++ b/modules/admin-full/luasrc/controller/admin/network.lua
@@ -28,6 +28,23 @@ function index()
page.title = i18n("a_n_switch")
page.order = 20
+ local page = node("admin", "network", "wireless")
+ page.target = form("admin_network/wireless")
+ page.title = i18n("wifi")
+ page.order = 15
+ luci.model.uci.foreach("wireless", "wifi-device",
+ function (section)
+ local ifc = section[".name"]
+ entry({"admin", "network", "wireless", ifc},
+ alias("admin", "network", "wifi", ifc),
+ ifc:upper())
+ end
+ )
+
+ local page = node("admin", "network", "wifi")
+ page.target = cbi("admin_network/wifi")
+ page.leaf = true
+
local page = node("admin", "network", "network")
page.target = cbi("admin_network/network")
page.title = i18n("interfaces", "Schnittstellen")
diff --git a/modules/admin-full/luasrc/controller/admin/wifi.lua b/modules/admin-full/luasrc/controller/admin/wifi.lua
deleted file mode 100644
index 4bef0b7a5..000000000
--- a/modules/admin-full/luasrc/controller/admin/wifi.lua
+++ /dev/null
@@ -1,34 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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$
-]]--
-module("luci.controller.admin.wifi", package.seeall)
-
-function index()
- luci.i18n.loadc("admin-core")
- local i18n = luci.i18n.translate
-
- local page = node("admin", "wifi")
- page.target = template("admin_wifi/index")
- page.title = i18n("wifi", "Drahtlos")
- page.order = 60
-
- local page = node("admin", "wifi", "devices")
- page.target = cbi("admin_wifi/devices")
- page.title = i18n("devices", "Geräte")
- page.order = 10
-
- local page = node("admin", "wifi", "networks")
- page.target = cbi("admin_wifi/networks")
- page.title = i18n("networks", "Netze")
- page.order = 20
-end \ No newline at end of file
diff --git a/modules/admin-full/luasrc/model/cbi/admin_wifi/networks.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
index a109587d9..64a492879 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_wifi/networks.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -12,20 +12,60 @@ You may obtain a copy of the License at
$Id$
]]--
require("luci.tools.webadmin")
+arg[1] = arg[1] or ""
+
m = Map("wireless", translate("networks"), translate("a_w_networks1"))
-s = m:section(TypedSection, "wifi-iface", "")
+s = m:section(NamedSection, arg[1], "wifi-device", translate("device") .. " " .. arg[1])
+--s.addremove = true
+
+en = s:option(Flag, "disabled", translate("enable"))
+en.enabled = "0"
+en.disabled = "1"
+
+function en.cfgvalue(self, section)
+ return Flag.cfgvalue(self, section) or "0"
+end
+
+t = s:option(DummyValue, "type", translate("type"))
+
+mode = s:option(ListValue, "mode", translate("mode"))
+mode:value("", "standard")
+mode:value("11b", "802.11b")
+mode:value("11g", "802.11g")
+mode:value("11a", "802.11a")
+mode:value("11bg", "802.11b+g")
+mode.rmempty = true
+
+s:option(Value, "channel", translate("a_w_channel"))
+
+s:option(Value, "txantenna", translate("a_w_txantenna")).optional = true
+
+s:option(Value, "rxantenna", translate("a_w_rxantenna")).optional = true
+
+s:option(Value, "distance", translate("distance"),
+ translate("a_w_distance1")).optional = true
+
+s:option(Value, "diversity", translate("a_w_diversity")):depends("type", "atheros")
+
+country = s:option(Value, "country", translate("a_w_countrycode"))
+country.optional = true
+country:depends("type", "broadcom")
+
+maxassoc = s:option(Value, "maxassoc", translate("a_w_connlimit"))
+maxassoc:depends("type", "broadcom")
+maxassoc.optional = true
+
+
+
+s = m:section(TypedSection, "wifi-iface", translate("interfaces"))
s.addremove = true
s.anonymous = true
+s:depends("device", arg[1])
+s.defaults.device = arg[1]
s:option(Value, "ssid", translate("a_w_netid")).maxlength = 32
-device = s:option(ListValue, "device", translate("device"))
-luci.model.uci.foreach("wireless", "wifi-device",
- function (section)
- device:value(section[".name"])
- end)
-
network = s:option(ListValue, "network", translate("network"), translate("a_w_network1"))
network:value("")
luci.tools.webadmin.cbi_add_networks(network)
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua
new file mode 100644
index 000000000..ae2462838
--- /dev/null
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua
@@ -0,0 +1,135 @@
+--[[
+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$
+]]--
+require("luci.sys")
+require("luci.tools.webadmin")
+
+luci.model.uci.load_state("wireless")
+local wireless = luci.model.uci.get_all("wireless")
+luci.model.uci.unload("wireless")
+
+local wifidata = luci.sys.wifi.getiwconfig()
+local ifaces = {}
+
+for k, v in pairs(wireless) do
+ if v[".type"] == "wifi-iface" then
+ table.insert(ifaces, v)
+ end
+end
+
+
+m = SimpleForm("wireless", translate("wifi"))
+
+s = m:section(Table, ifaces, translate("networks"))
+
+function s.extedit(self, section)
+ local device = self.map:get(section, "device") or ""
+ return luci.http.getenv("REQUEST_URI") .. "/" .. device
+end
+
+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)
+ return "802." .. wireless[self.map:get(section, "device")].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"))
+
+
+s2 = m:section(SimpleSection, translate("a_w_create"))
+create = s2:option(ListValue, "create", translate("device"))
+create:value("", translate("cbi_select"))
+for k, v in pairs(wireless) do
+ if v[".type"] == "wifi-device" then
+ create:value(k)
+ end
+end
+
+function create.write(self, section, value)
+ luci.model.uci.load_config("wireless")
+ luci.model.uci.section("wireless", "wifi-iface", nil, {device=value})
+ luci.model.uci.save_config("wireless")
+ luci.http.redirect(luci.http.getenv("REQUEST_URI") .. "/" .. value)
+end
+
+function create.cbid(self, section)
+ return "priv.cbid.create"
+end
+
+return m \ No newline at end of file
diff --git a/modules/admin-full/luasrc/model/cbi/admin_wifi/devices.lua b/modules/admin-full/luasrc/model/cbi/admin_wifi/devices.lua
deleted file mode 100644
index e33f24161..000000000
--- a/modules/admin-full/luasrc/model/cbi/admin_wifi/devices.lua
+++ /dev/null
@@ -1,57 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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$
-]]--
-m = Map("wireless", translate("devices"), translate("a_w_devices1",
- "An dieser Stelle können eingebaute WLAN-Geräte konfiguriert werden."))
-
-s = m:section(TypedSection, "wifi-device", "")
---s.addremove = true
-
-en = s:option(Flag, "disabled", translate("enable"))
-en.enabled = "0"
-en.disabled = "1"
-
-function en.cfgvalue(self, section)
- return Flag.cfgvalue(self, section) or "0"
-end
-
-t = s:option(DummyValue, "type", translate("type"))
-
-mode = s:option(ListValue, "mode", translate("mode"))
-mode:value("", "standard")
-mode:value("11b", "802.11b")
-mode:value("11g", "802.11g")
-mode:value("11a", "802.11a")
-mode:value("11bg", "802.11b+g")
-mode.rmempty = true
-
-s:option(Value, "channel", translate("a_w_channel"))
-
-s:option(Value, "txantenna", translate("a_w_txantenna")).rmempty = true
-
-s:option(Value, "rxantenna", translate("a_w_rxantenna")).rmempty = true
-
-s:option(Value, "distance", translate("distance"),
- translate("a_w_distance1")).rmempty = true
-
-s:option(Value, "diversity", translate("a_w_diversity")):depends("type", "atheros")
-
-country = s:option(Value, "country", translate("a_w_countrycode"))
-country.optional = true
-country:depends("type", "broadcom")
-
-maxassoc = s:option(Value, "maxassoc", translate("a_w_connlimit"))
-maxassoc:depends("type", "broadcom")
-maxassoc.optional = true
-
-return m \ No newline at end of file
diff --git a/modules/admin-full/luasrc/view/admin_wifi/index.htm b/modules/admin-full/luasrc/view/admin_wifi/index.htm
deleted file mode 100644
index 58281d14f..000000000
--- a/modules/admin-full/luasrc/view/admin_wifi/index.htm
+++ /dev/null
@@ -1,20 +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><%:wifi%></h1>
-<p><%:a_w_wifi1%></p>
-<p><%:a_w_wifi2%></p>
-<p><%:a_w_wifi3%></p>
-<%+footer%> \ No newline at end of file