cbi: Increare responsiveness of "Save & Apply"
authorSteven Barth <steven@midlink.org>
Sat, 6 Sep 2008 14:59:48 +0000 (14:59 +0000)
committerSteven Barth <steven@midlink.org>
Sat, 6 Sep 2008 14:59:48 +0000 (14:59 +0000)
i18n/english/luasrc/i18n/cbi.en.lua
i18n/english/luasrc/i18n/cbi.en.xml
i18n/german/luasrc/i18n/cbi.de.lua
i18n/german/luasrc/i18n/cbi.de.xml
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/map.htm

index d302ee5..42f93d4 100644 (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'
index 89484e4..4766ad1 100644 (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>
index a8d6824..9e69075 100644 (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'
index dd37f2f..c989f8d 100644 (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>
index b00ccf8..09ba553 100644 (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
index e29b4fc..e61f854 100644 (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>