cbi: Increare responsiveness of "Save & Apply"

This commit is contained in:
Steven Barth 2008-09-06 14:59:48 +00:00
parent 03e11688ca
commit 9befed193a
6 changed files with 36 additions and 1 deletions

View file

@ -11,3 +11,4 @@ cbi_sectempty = 'This section contains no values yet'
cbi_manual = '-- custom --'
cbi_select = '-- Please choose --'
cbi_gorel = 'Go to relevant configuration page'
cbi_applying = 'Applying changes'

View file

@ -15,5 +15,6 @@
<i18n:msg xml:id="cbi_manual">-- custom --</i18n:msg>
<i18n:msg xml:id="cbi_select">-- Please choose --</i18n:msg>
<i18n:msg xml:id="cbi_gorel">Go to relevant configuration page</i18n:msg>
<i18n:msg xml:id="cbi_applying">Applying changes</i18n:msg>
</i18n:msgs>

View file

@ -10,3 +10,4 @@ cbi_sectempty = 'Diese Sektion enthält noch keine Einträge'
cbi_manual = '-- benutzerdefiniert --'
cbi_select = '-- Bitte auswählen --'
cbi_gorel = 'Gehe zu relevanter Konfigurationsseite'
cbi_applying = 'Änderungen werden angewandt'

View file

@ -14,4 +14,6 @@
<i18n:msg xml:id="cbi_manual">-- benutzerdefiniert --</i18n:msg>
<i18n:msg xml:id="cbi_select">-- Bitte auswählen --</i18n:msg>
<i18n:msg xml:id="cbi_gorel">Gehe zu relevanter Konfigurationsseite</i18n:msg>
<i18n:msg xml:id="cbi_applying">Änderungen werden angewandt</i18n:msg>
</i18n:msgs>

View file

@ -211,6 +211,7 @@ function Map.__init__(self, config, ...)
self.config = config
self.parsechain = {self.config}
self.template = "cbi/map"
self.apply_on_parse = nil
self.uci = uci.cursor()
self.save = true
if not self.uci:load(self.config) then
@ -252,7 +253,14 @@ function Map.parse(self, ...)
-- Refresh data because commit changes section names
self.uci:load(config)
end
self.uci:apply(self.parsechain)
if self.apply_on_parse then
self.uci:apply(self.parsechain)
else
self._apply = function()
local cmd = self.uci:apply(self.parsechain, true)
return io.popen(cmd)
end
end
-- Reparse sections
Node.parse(self, ...)
@ -264,6 +272,15 @@ function Map.parse(self, ...)
end
end
function Map.render(self, ...)
Node.render(self, ...)
if self._apply then
local fp = self._apply()
fp:read("*a")
fp:close()
end
end
-- Creates a child section
function Map.section(self, class, ...)
if instanceof(class, AbstractSection) then

View file

@ -16,6 +16,19 @@ $Id$
<div class="cbi-map" id="cbi-<%=self.config%>">
<h1><%=self.title%></h1>
<div class="cbi-map-descr"><%=self.description%></div>
<%- if self._apply then -%><code><%:cbi_applying%>:
<%
local fp = self._apply()
self._apply = nil
local line = fp:read()
while line do
write(line)
line = fp:read()
end
fp:close()
-%>
</code><%- end -%>
<%- self:render_children() %>
<br />
</div>