From 4d1d384f52cfb5a286f323a057afa43da8f7c28c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 7 Sep 2008 23:53:20 +0000 Subject: [PATCH] Fixed DHCP-Options and some CBI stuff --- i18n/english/luasrc/i18n/admin-core.en.lua | 2 ++ i18n/english/luasrc/i18n/admin-core.en.xml | 2 ++ i18n/german/luasrc/i18n/admin-core.de.lua | 2 ++ i18n/german/luasrc/i18n/admin-core.de.xml | 2 ++ libs/cbi/luasrc/cbi.lua | 9 ++++++--- libs/cbi/luasrc/view/cbi/dynlist.htm | 2 +- libs/cbi/luasrc/view/cbi/mvalue.htm | 2 +- .../admin-full/luasrc/model/cbi/admin_network/dhcp.lua | 5 +---- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua index b34226459..88d6249c6 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.lua +++ b/i18n/english/luasrc/i18n/admin-core.en.lua @@ -182,6 +182,8 @@ dhcp_dhcp_ignore_desc = 'disable Force first address (last octet) number of leased addresses -1 +DHCP-Options +See "dnsmasq --help dhcp" for a list of available options. Leases Static Leases Leasetime remaining diff --git a/i18n/german/luasrc/i18n/admin-core.de.lua b/i18n/german/luasrc/i18n/admin-core.de.lua index 8bc4f1cd6..30258fbff 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.lua +++ b/i18n/german/luasrc/i18n/admin-core.de.lua @@ -141,6 +141,8 @@ dhcp_dhcp_force = 'Start erzwingen' dhcp_dhcp_ignore = 'Schnittstelle ignorieren' dhcp_dhcp_ignore_desc = 'DHCP für dieses Netzwerk deaktivieren' dhcp_dhcp_leasetime = 'Laufzeit' +dhcp_dhcp_dhcpoption = 'DHCP-Optionen' +dhcp_dhcp_dhcpoption_desc = 'Siehe "dnsmasq --help dhcp" für eine Liste verfügbarer Optionen.' dhcp_dhcp_limit_desc = 'Anzahl zu vergebender Adressen -1' dhcp_dhcp_start_desc = 'Erste vergebene Adresse (letztes Oktett)' dhcp_dnsmasq_addnhosts = 'Zusätzliche Hostdatei' diff --git a/i18n/german/luasrc/i18n/admin-core.de.xml b/i18n/german/luasrc/i18n/admin-core.de.xml index 9b7281972..3a821c3fd 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.xml +++ b/i18n/german/luasrc/i18n/admin-core.de.xml @@ -145,6 +145,8 @@ Schnittstelle ignorieren DHCP für dieses Netzwerk deaktivieren Laufzeit +DHCP-Optionen +Siehe "dnsmasq --help dhcp" für eine Liste verfügbarer Optionen. Anzahl zu vergebender Adressen -1 Erste vergebene Adresse (letztes Oktett) Zusätzliche Hostdatei diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 30727cef2..df7f29252 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -933,7 +933,7 @@ function AbstractValue.parse(self, section) local fvalue = self:formvalue(section) local cvalue = self:cfgvalue(section) - if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI + if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI fvalue = self:transform(self:validate(fvalue, section)) if not fvalue then self.tag_invalid[section] = true @@ -983,7 +983,9 @@ end -- Return the UCI value of this object function AbstractValue.cfgvalue(self, section) local value = self.map:get(section, self.option) - if not self.cast or self.cast == type(value) then + if not value then + return nil + elseif not self.cast or self.cast == type(value) then return value elseif self.cast == "string" then if type(value) == "table" then @@ -1251,7 +1253,8 @@ function DynamicList.value(self, key, val) table.insert(self.vallist, tostring(val)) end -function DynamicList.validate(self, value, section) +function DynamicList.formvalue(self, section) + local value = AbstractValue.formvalue(self, section) value = (type(value) == "table") and value or {value} local valid = {} diff --git a/libs/cbi/luasrc/view/cbi/dynlist.htm b/libs/cbi/luasrc/view/cbi/dynlist.htm index 1d28f95d9..1cfd6f03e 100644 --- a/libs/cbi/luasrc/view/cbi/dynlist.htm +++ b/libs/cbi/luasrc/view/cbi/dynlist.htm @@ -14,7 +14,7 @@ $Id$ -%> <%+cbi/valueheader%> <% - local vals = self:cfgvalue(section) + local vals = self:cfgvalue(section) or {} for i=1, #vals + 1 do local val = vals[i] %> diff --git a/libs/cbi/luasrc/view/cbi/mvalue.htm b/libs/cbi/luasrc/view/cbi/mvalue.htm index 4b69708ec..414089fb2 100644 --- a/libs/cbi/luasrc/view/cbi/mvalue.htm +++ b/libs/cbi/luasrc/view/cbi/mvalue.htm @@ -13,7 +13,7 @@ $Id$ -%> <% -local v = self:valuelist(section) +local v = self:valuelist(section) or {} %> <%+cbi/valueheader%> <% if self.widget == "select" then %> diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua index 42b93b599..17dcdb8f0 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -56,10 +56,7 @@ s:option(Value, "netmask", translate("netmask")).optional = true s:option(Flag, "force").optional = true -for i, line in pairs(luci.util.execl("dnsmasq --help dhcp")) do - k, v = line:match("([^ ]+) +([^ ]+)") - s:option(Value, "dhcp"..k, v).optional = true -end +s:option(DynamicList, "dhcp_option").optional = true for i, n in ipairs(s.children) do -- 2.25.1