From a35337e6a150412a5a7be8b4fe06eaba04dc4fa5 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 19 Aug 2008 17:02:40 +0000 Subject: [PATCH] Minor bugfixes Added possibility to add networks from Wifi page --- i18n/english/luasrc/i18n/admin-core.en.lua | 3 ++- i18n/german/luasrc/i18n/admin-core.de.lua | 1 + libs/cbi/htdocs/luci-static/resources/cbi.js | 6 ++++- libs/cbi/luasrc/view/cbi/value.htm | 7 +++++- .../model/cbi/admin_network/network.lua | 23 +++++++++++++++---- .../luasrc/model/cbi/admin_network/wifi.lua | 16 ++++++++++++- .../luasrc/model/cbi/mini/network.lua | 4 ++-- 7 files changed, 50 insertions(+), 10 deletions(-) diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua index 76fb6b2c6..ce1876a08 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.lua +++ b/i18n/english/luasrc/i18n/admin-core.en.lua @@ -112,6 +112,7 @@ a_w_connlimit = [[Connection Limit]] a_w_networks1 = [[You can run several wifi networks with one device. Be aware that there are certain hardware and driverspecific restrictions. Normally you can operate 1 Ad-Hoc or up to 3 Master-Mode and 1 Client-Mode network simultaneously.]] a_w_netid = [[Network Name (ESSID)]] a_w_network1 = [[Add the Wifi network to physical network]] +a_w_netmanual = [[ - Create new Network - ]] a_w_txpwr = [[Transmit Power]] a_w_brcmburst = [[Broadcom Frameburst]] a_w_athburst = [[Atheros Frameburst]] @@ -124,7 +125,7 @@ a_w_ap = [[Access Point]] a_w_adhoc = [[Ad-Hoc]] a_w_ahdemo = [[Pseudo Ad-Hoc (ahdemo)]] a_w_client = [[Client]] -a_w_wds = [[WDS]] +a_w_wds = [[WDS]] a_w_monitor = [[Monitor]] dhcp_dnsmasq_desc = [[Dnsmasq is a combined DHCP-Server and DNS-Forwarder for NAT firewalls]] dhcp_dnsmasq_domainneeded = [[Domain required]] diff --git a/i18n/german/luasrc/i18n/admin-core.de.lua b/i18n/german/luasrc/i18n/admin-core.de.lua index e0bc37745..4e96dc804 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.lua +++ b/i18n/german/luasrc/i18n/admin-core.de.lua @@ -132,6 +132,7 @@ a_w_diversity = [[Diversität]] a_w_hideessid = [[ESSID verstecken]] a_w_netid = [[Netzkennung (ESSID)]] a_w_network1 = [[WLAN-Netz zu Netzwerk hinzufügen]] +a_w_netmanual = [[ - Neues Netzwerk erstellen - ]] a_w_networks1 = [[Pro WLAN-Gerät können mehrere Netze bereitgestellt werden. Es sollte beachtet werden, dass es hardware- / treiberspezifische Einschränkungen gibt. So kann pro WLAN-Gerät in der Regel entweder 1 Ad-Hoc-Zugang ODER bis zu 3 Access-Point und 1 Client-Zugang diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js index d0e31e483..227e33269 100644 --- a/libs/cbi/htdocs/luci-static/resources/cbi.js +++ b/libs/cbi/htdocs/luci-static/resources/cbi.js @@ -98,7 +98,11 @@ function cbi_bind(obj, type, callback, mode) { function cbi_combobox(id, values, def, man) { var obj = document.getElementById(id) var sel = document.createElement("select"); - obj.parentNode.appendChild(sel); + if (obj.nextSibling) { + obj.parentNode.insertBefore(sel, obj.nextSibling); + } else { + obj.parentNode.appendChild(sel); + } if (!values[obj.value]) { if (obj.value == "") { diff --git a/libs/cbi/luasrc/view/cbi/value.htm b/libs/cbi/luasrc/view/cbi/value.htm index 0dc584146..d85fa81d9 100644 --- a/libs/cbi/luasrc/view/cbi/value.htm +++ b/libs/cbi/luasrc/view/cbi/value.htm @@ -26,7 +26,12 @@ $Id$ -%> }, '<%- if not self.rmempty and not self.optional then -%> <%-:cbi_select-%> - <%- end -%>', '<%:cbi_manual%>'); + <%- end -%>', ' + <%- if self.combobox_manual then -%> + <%-=self.combobox_manual-%> + <%- else -%> + <%-:cbi_manual-%> + <%- end -%>'); <% end -%> <%+cbi/valuefooter%> diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua index c0f66e965..1f10ac829 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua @@ -15,9 +15,12 @@ $Id$ require("luci.sys") require("luci.tools.webadmin") +luci.model.uci.load_state("network") +local netstate = luci.model.uci.get_all("network") +luci.model.uci.unload("network") + m = Map("network", translate("interfaces")) -m.stateful = true local created local netstat = luci.sys.net.deviceinfo() @@ -45,12 +48,25 @@ function s.parse(self, ...) end up = s:option(Flag, "up") +function up.cfgvalue(self, section) + return netstate[section] and netstate[section].up or "0" +end + function up.write(self, section, value) - local call = value == "1" and "ifup" or "ifdown" - os.execute(call .. " " .. section) + local call + if value == "1" then + call = "ifup" + elseif value == "0" then + call = "ifdown" + end + os.execute(call .. " " .. section .. " >/dev/null 2>&1") end ifname = s:option(DummyValue, "ifname", translate("device")) +function ifname.cfgvalue(self, section) + return netstate[section] and netstate[section].ifname +end + ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan") if luci.model.uci.load("firewall") then @@ -74,7 +90,6 @@ end ipaddr = s:option(DummyValue, "ipaddr", translate("addresses")) - function ipaddr.cfgvalue(self, section) local addr = luci.tools.webadmin.network_get_addresses(section) return table.concat(addr, ", ") diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua index 64a492879..3717c5b5b 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @@ -66,10 +66,24 @@ s.defaults.device = arg[1] s:option(Value, "ssid", translate("a_w_netid")).maxlength = 32 -network = s:option(ListValue, "network", translate("network"), translate("a_w_network1")) +network = s:option(Value, "network", translate("network"), translate("a_w_network1")) +network.rmempty = true network:value("") +network.combobox_manual = translate("a_w_netmanual") luci.tools.webadmin.cbi_add_networks(network) +function network.write(self, section, value) + if not luci.model.uci.get("network", value) then + m:chain("network") + luci.model.uci.set("network", value, "interface") + Value.write(self, section, value) + else + if luci.model.uci.get("network", value) == "interface" then + Value.write(self, section, value) + end + end +end + mode = s:option(ListValue, "mode", translate("mode")) mode:value("ap", translate("a_w_ap")) mode:value("adhoc", translate("a_w_adhoc")) diff --git a/modules/admin-mini/luasrc/model/cbi/mini/network.lua b/modules/admin-mini/luasrc/model/cbi/mini/network.lua index e36d7c030..692f7c456 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/network.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/network.lua @@ -16,13 +16,13 @@ require("luci.tools.webadmin") require("luci.sys") luci.model.uci.load_state("network") -local wireless = luci.model.uci.get_all("network") +local network = luci.model.uci.get_all("network") luci.model.uci.unload("network") local netstat = luci.sys.net.deviceinfo() local ifaces = {} -for k, v in pairs(wireless) do +for k, v in pairs(network) do if v[".type"] == "interface" and k ~= "loopback" then table.insert(ifaces, v) end -- 2.25.1