diff options
Diffstat (limited to 'modules/luci-mod-admin-full')
5 files changed, 34 insertions, 43 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/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/view/admin_network/iface_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm index 14be401697..420e5879fa 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/iface_overview.htm @@ -33,7 +33,7 @@ <script type="text/javascript" src="<%=resource%>/cbi.js"></script> <script type="text/javascript">//<![CDATA[ function iface_shutdown(id, reconnect) { - if (!reconnect && !confirm(String.format('<%_Really shutdown interface "%s" ?\nYou might lose access to this device if you are connected via this interface.%>', id))) + if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shutdown interface "%s"? You might lose access to this device if you are connected via this interface.'))%>.format(id))) return; var d = document.getElementById(id + '-ifc-description'); @@ -67,7 +67,7 @@ } function iface_delete(id) { - if (!confirm('<%:Really delete this interface? The deletion cannot be undone!\nYou might lose access to this device if you are connected via this interface.%>')) + if (!confirm(<%=luci.http.write_json(translate('Really delete this interface? The deletion cannot be undone! You might lose access to this device if you are connected via this interface.'))%>)) return; (new XHR()).post('<%=url('admin/network/iface_delete')%>/' + id, { token: '<%=token%>' }, diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm index 31f1fed81f..ceb810018b 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/wifi_overview.htm @@ -101,9 +101,9 @@ <%+header%> <% if not has_iwinfo then %> - <div class="errorbox"> - <strong><%:Package libiwinfo required!%></strong><br /> - <%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%> + <div class="alert-message warning"> + <h4><%:Package libiwinfo required!%></h4> + <p><%_The <em>libiwinfo-lua</em> package is not installed. You must install this component for working wireless configuration!%></p> </div> <% end %> @@ -138,7 +138,7 @@ function wifi_shutdown(id, toggle) { var reconnect = (toggle.getAttribute('active') == 'false'); - if (!reconnect && !confirm(String.format('<%:Really shut down network?\nYou might lose access to this device if you are connected via this interface.%>'))) + if (!reconnect && !confirm(<%=luci.http.write_json(translate('Really shut down network? You might lose access to this device if you are connected via this interface.'))%>)) return; is_reconnecting = true; @@ -176,7 +176,7 @@ } function wifi_delete(id) { - if (!confirm('<%:Really delete this wireless network? The deletion cannot be undone!\nYou might lose access to this device if you are connected via this network.%>')) + if (!confirm(<%=luci.http.write_json(translate('Really delete this wireless network? The deletion cannot be undone! You might lose access to this device if you are connected via this network.'))%>)) return; (new XHR()).post('<%=url('admin/network/wireless_delete')%>/' + id, { token: '<%=token%>' }, |