summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/model
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc/model')
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua17
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua4
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua35
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_add.lua11
-rw-r--r--modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua9
5 files changed, 34 insertions, 42 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
index 38e5de7b39..5c630bb5ce 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/ifaces.lua
@@ -351,7 +351,6 @@ if has_firewall then
fwzone.template = "cbi/firewall_zonelist"
fwzone.network = arg[1]
- fwzone.rmempty = false
function fwzone.cfgvalue(self, section)
self.iface = section
@@ -360,22 +359,16 @@ if has_firewall then
end
function fwzone.write(self, section, value)
- local zone = fw:get_zone(value)
-
- if not zone and value == '-' then
- value = m:formvalue(self:cbid(section) .. ".newzone")
- if value and #value > 0 then
- zone = fw:add_zone(value)
- else
- fw:del_network(section)
- end
- end
-
+ local zone = fw:get_zone(value) or fw:add_zone(value)
if zone then
fw:del_network(section)
zone:add_network(section)
end
end
+
+ function fwzone.remove(self, section)
+ fw:del_network(section)
+ end
end
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua
index b52dff13ac..3e46628d3f 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/vlan.lua
@@ -260,7 +260,7 @@ m.uci:foreach("network", "switch",
end
- local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID", "<div id='portstatus-%s'></div>" % switch_name)
+ local vid = s:option(Value, has_vlan4k or "vlan", "VLAN ID")
local mx_vid = has_vlan4k and 4094 or (num_vlans - 1)
vid.rmempty = false
@@ -333,7 +333,7 @@ m.uci:foreach("network", "switch",
local _, pt
for _, pt in ipairs(topo.ports) do
- local po = s:option(ListValue, tostring(pt.num), pt.label, '<div id="portstatus-%s-%d"></div>' %{ switch_name, pt.num })
+ local po = s:option(ListValue, tostring(pt.num), pt.label)
po:value("", translate("off"))
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
index cacaa25958..d51a72aba1 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -390,22 +390,16 @@ network.novirtual = true
function network.write(self, section, value)
local i = nw:get_interface(section)
if i then
- if value == '-' then
- value = m:formvalue(self:cbid(section) .. ".newnet")
- if value and #value > 0 then
- local n = nw:add_network(value, {proto="none"})
- if n then n:add_interface(i) end
- else
- local n = i:get_network()
- if n then n:del_interface(i) end
- end
- else
- local v
- for _, v in ipairs(i:get_networks()) do
- v:del_interface(i)
- end
- for v in ut.imatch(value) do
- local n = nw:get_network(v)
+ local _, net, old, new = nil, nil, {}, {}
+
+ for _, net in ipairs(i:get_networks()) do
+ old[net:name()] = true
+ end
+
+ for net in ut.imatch(value) do
+ new[net] = true
+ if not old[net] then
+ local n = nw:get_network(net) or nw:add_network(net, { proto = "none" })
if n then
if not n:is_empty() then
n:set("type", "bridge")
@@ -414,6 +408,15 @@ function network.write(self, section, value)
end
end
end
+
+ for net, _ in pairs(old) do
+ if not new[net] then
+ local n = nw:get_network(net)
+ if n then
+ n:del_interface(i)
+ end
+ end
+ end
end
end
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_add.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
index 8277deb2f6..e8a3058826 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
@@ -94,14 +94,9 @@ function newnet.parse(self, section)
local net, zone
if has_firewall then
- local zval = fwzone:formvalue(section)
- zone = fw:get_zone(zval)
-
- if not zone and zval == '-' then
- zval = m:formvalue(fwzone:cbid(section) .. ".newzone")
- if zval and #zval > 0 then
- zone = fw:add_zone(zval)
- end
+ local value = fwzone:formvalue(section)
+ if value and #value > 0 then
+ zone = fw:get_zone(value) or fw:add_zone(value)
end
end
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua
index 493a735bde..6c1c1235c5 100644
--- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua
+++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/admin.lua
@@ -104,16 +104,17 @@ end
keys = s2:option(TextValue, "_data", "")
keys.wrap = "off"
keys.rows = 3
-keys.rmempty = false
function keys.cfgvalue()
return fs.readfile("/etc/dropbear/authorized_keys") or ""
end
function keys.write(self, section, value)
- if value then
- fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n"))
- end
+ return fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n"))
+end
+
+function keys.remove(self, section, value)
+ return fs.writefile("/etc/dropbear/authorized_keys", "")
end
end