cbi: Increare responsiveness of "Save & Apply"
This commit is contained in:
parent
03e11688ca
commit
9befed193a
6 changed files with 36 additions and 1 deletions
|
@ -11,3 +11,4 @@ cbi_sectempty = 'This section contains no values yet'
|
||||||
cbi_manual = '-- custom --'
|
cbi_manual = '-- custom --'
|
||||||
cbi_select = '-- Please choose --'
|
cbi_select = '-- Please choose --'
|
||||||
cbi_gorel = 'Go to relevant configuration page'
|
cbi_gorel = 'Go to relevant configuration page'
|
||||||
|
cbi_applying = 'Applying changes'
|
||||||
|
|
|
@ -15,5 +15,6 @@
|
||||||
<i18n:msg xml:id="cbi_manual">-- custom --</i18n:msg>
|
<i18n:msg xml:id="cbi_manual">-- custom --</i18n:msg>
|
||||||
<i18n:msg xml:id="cbi_select">-- Please choose --</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_gorel">Go to relevant configuration page</i18n:msg>
|
||||||
|
<i18n:msg xml:id="cbi_applying">Applying changes</i18n:msg>
|
||||||
|
|
||||||
</i18n:msgs>
|
</i18n:msgs>
|
||||||
|
|
|
@ -10,3 +10,4 @@ cbi_sectempty = 'Diese Sektion enthält noch keine Einträge'
|
||||||
cbi_manual = '-- benutzerdefiniert --'
|
cbi_manual = '-- benutzerdefiniert --'
|
||||||
cbi_select = '-- Bitte auswählen --'
|
cbi_select = '-- Bitte auswählen --'
|
||||||
cbi_gorel = 'Gehe zu relevanter Konfigurationsseite'
|
cbi_gorel = 'Gehe zu relevanter Konfigurationsseite'
|
||||||
|
cbi_applying = 'Änderungen werden angewandt'
|
||||||
|
|
|
@ -14,4 +14,6 @@
|
||||||
<i18n:msg xml:id="cbi_manual">-- benutzerdefiniert --</i18n:msg>
|
<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_select">-- Bitte auswählen --</i18n:msg>
|
||||||
<i18n:msg xml:id="cbi_gorel">Gehe zu relevanter Konfigurationsseite</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>
|
</i18n:msgs>
|
||||||
|
|
|
@ -211,6 +211,7 @@ function Map.__init__(self, config, ...)
|
||||||
self.config = config
|
self.config = config
|
||||||
self.parsechain = {self.config}
|
self.parsechain = {self.config}
|
||||||
self.template = "cbi/map"
|
self.template = "cbi/map"
|
||||||
|
self.apply_on_parse = nil
|
||||||
self.uci = uci.cursor()
|
self.uci = uci.cursor()
|
||||||
self.save = true
|
self.save = true
|
||||||
if not self.uci:load(self.config) then
|
if not self.uci:load(self.config) then
|
||||||
|
@ -252,7 +253,14 @@ function Map.parse(self, ...)
|
||||||
-- Refresh data because commit changes section names
|
-- Refresh data because commit changes section names
|
||||||
self.uci:load(config)
|
self.uci:load(config)
|
||||||
end
|
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
|
-- Reparse sections
|
||||||
Node.parse(self, ...)
|
Node.parse(self, ...)
|
||||||
|
@ -264,6 +272,15 @@ function Map.parse(self, ...)
|
||||||
end
|
end
|
||||||
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
|
-- Creates a child section
|
||||||
function Map.section(self, class, ...)
|
function Map.section(self, class, ...)
|
||||||
if instanceof(class, AbstractSection) then
|
if instanceof(class, AbstractSection) then
|
||||||
|
|
|
@ -16,6 +16,19 @@ $Id$
|
||||||
<div class="cbi-map" id="cbi-<%=self.config%>">
|
<div class="cbi-map" id="cbi-<%=self.config%>">
|
||||||
<h1><%=self.title%></h1>
|
<h1><%=self.title%></h1>
|
||||||
<div class="cbi-map-descr"><%=self.description%></div>
|
<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() %>
|
<%- self:render_children() %>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue