CBI-UVL integration part #1
This commit is contained in:
parent
1946740198
commit
451eacf8da
2 changed files with 25 additions and 5 deletions
|
@ -137,7 +137,7 @@ endif
|
||||||
### Libraries ###
|
### Libraries ###
|
||||||
define Package/luci-cbi
|
define Package/luci-cbi
|
||||||
$(call Package/luci/libtemplate)
|
$(call Package/luci/libtemplate)
|
||||||
DEPENDS+=+luci-web
|
DEPENDS+=+luci-web +luci-uvl +luci-uci
|
||||||
TITLE:=Configuration Binding Interface
|
TITLE:=Configuration Binding Interface
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ require("luci.template")
|
||||||
require("luci.util")
|
require("luci.util")
|
||||||
require("luci.http")
|
require("luci.http")
|
||||||
require("luci.model.uci")
|
require("luci.model.uci")
|
||||||
|
require("luci.uvl")
|
||||||
|
|
||||||
local uci = luci.model.uci
|
local uci = luci.model.uci
|
||||||
local class = luci.util.class
|
local class = luci.util.class
|
||||||
|
@ -160,6 +161,9 @@ function Map.__init__(self, config, ...)
|
||||||
if not uci.load_config(self.config) then
|
if not uci.load_config(self.config) then
|
||||||
error("Unable to read UCI data: " .. self.config)
|
error("Unable to read UCI data: " .. self.config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.validator = luci.uvl.UVL()
|
||||||
|
self.scheme = self.validator:get_scheme(self.config)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Map.render(self, ...)
|
function Map.render(self, ...)
|
||||||
|
@ -535,13 +539,22 @@ NamedSection - A fixed configuration section defined by its name
|
||||||
]]--
|
]]--
|
||||||
NamedSection = class(AbstractSection)
|
NamedSection = class(AbstractSection)
|
||||||
|
|
||||||
function NamedSection.__init__(self, map, section, type, ...)
|
function NamedSection.__init__(self, map, section, stype, ...)
|
||||||
AbstractSection.__init__(self, map, type, ...)
|
AbstractSection.__init__(self, map, stype, ...)
|
||||||
Node._i18n(self, map.config, section, nil, ...)
|
Node._i18n(self, map.config, section, nil, ...)
|
||||||
|
|
||||||
|
-- Defaults
|
||||||
|
self.addremove = false
|
||||||
|
|
||||||
|
-- Use defaults from UVL
|
||||||
|
if self.map.scheme and self.map.scheme.sections[self.sectiontype] then
|
||||||
|
local vs = self.map.scheme.sections[self.sectiontype]
|
||||||
|
self.addremove = not vs.unique and not vs.required
|
||||||
|
self.dynamic = vs.dynamic
|
||||||
|
end
|
||||||
|
|
||||||
self.template = "cbi/nsection"
|
self.template = "cbi/nsection"
|
||||||
self.section = section
|
self.section = section
|
||||||
self.addremove = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function NamedSection.parse(self)
|
function NamedSection.parse(self)
|
||||||
|
@ -587,8 +600,15 @@ function TypedSection.__init__(self, map, type, ...)
|
||||||
|
|
||||||
self.template = "cbi/tsection"
|
self.template = "cbi/tsection"
|
||||||
self.deps = {}
|
self.deps = {}
|
||||||
|
|
||||||
self.anonymous = false
|
self.anonymous = false
|
||||||
|
|
||||||
|
-- Use defaults from UVL
|
||||||
|
if self.map.scheme and self.map.scheme.sections[self.sectiontype] then
|
||||||
|
local vs = self.map.scheme.sections[self.sectiontype]
|
||||||
|
self.addremove = not vs.unique and not vs.required
|
||||||
|
self.dynamic = vs.dynamic
|
||||||
|
self.anonymous = not vs.named
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return all matching UCI sections for this TypedSection
|
-- Return all matching UCI sections for this TypedSection
|
||||||
|
|
Loading…
Reference in a new issue