summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-full/luasrc/view/admin_uci
diff options
context:
space:
mode:
Diffstat (limited to 'modules/admin-full/luasrc/view/admin_uci')
-rw-r--r--modules/admin-full/luasrc/view/admin_uci/apply.htm38
-rw-r--r--modules/admin-full/luasrc/view/admin_uci/changelog.htm67
-rw-r--r--modules/admin-full/luasrc/view/admin_uci/changes.htm14
-rw-r--r--modules/admin-full/luasrc/view/admin_uci/revert.htm15
4 files changed, 99 insertions, 35 deletions
diff --git a/modules/admin-full/luasrc/view/admin_uci/apply.htm b/modules/admin-full/luasrc/view/admin_uci/apply.htm
index e9de29a91..a9fbbfe9e 100644
--- a/modules/admin-full/luasrc/view/admin_uci/apply.htm
+++ b/modules/admin-full/luasrc/view/admin_uci/apply.htm
@@ -12,31 +12,21 @@ You may obtain a copy of the License at
$Id$
-%>
+
<%+header%>
-<h2><a id="content" name="content"><%:Configuration%></a></h2>
-<p><strong><%:The following changes have been applied%>:</strong></p>
-
-<div class="cbi-section">
- <code><%=(changes or "-")%></code>
-</div>
-
-<fieldset class="cbi-section">
- <ul class="cbi-apply"><%-
- local fp = reload()
- local line = fp:read()
- while line do
- write("<li>" .. luci.util.pcdata(line) .. "</li>\n")
- line = fp:read()
- end
- fp:close()
- -%></ul>
-</fieldset>
-
-<div class="cbi-page-actions">
- <form class="inline" method="get" action="<%=luci.util.pcdata(luci.http.formvalue("redir"))%>">
- <input class="cbi-button" style="margin:0" type="submit" value="« <%:back%>" />
- </form>
-</div>
+<h2><a id="content" name="content"><%:Configuration / Apply%></a></h2>
+
+<% if changes then %>
+ <%+cbi/apply_xhr%>
+ <%+admin_uci/changelog%>
+
+ <%- cbi_apply_xhr('uci-apply', configs) -%>
+
+ <p><strong><%:The following changes have been comitted%>:</strong></p>
+ <%- uci_changelog(changes) -%>
+<% else %>
+ <p><strong><%:There are no pending changes to apply!%></strong></p>
+<% end %>
<%+footer%>
diff --git a/modules/admin-full/luasrc/view/admin_uci/changelog.htm b/modules/admin-full/luasrc/view/admin_uci/changelog.htm
new file mode 100644
index 000000000..13bbdffcb
--- /dev/null
+++ b/modules/admin-full/luasrc/view/admin_uci/changelog.htm
@@ -0,0 +1,67 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<% export("uci_changelog", function(changes) -%>
+<fieldset class="cbi-section">
+ <strong><%:Legend:%></strong>
+ <div class="uci-change-legend">
+ <div class="uci-change-legend-label"><ins>&nbsp;</ins> <%:Section added%></div>
+ <div class="uci-change-legend-label"><del>&nbsp;</del> <%:Section removed%></div>
+ <div class="uci-change-legend-label"><var><ins>&nbsp;</ins></var> <%:Option changed%></div>
+ <div class="uci-change-legend-label"><var><del>&nbsp;</del></var> <%:Option removed%></div>
+ <br style="clear:both" />
+ </div>
+ <br />
+
+ <div class="uci-change-list"><%
+ local util = luci.util
+ local ret = { }
+
+ for r, tbl in pairs(changes) do
+ for s, os in pairs(tbl) do
+ -- section add
+ if os['.type'] and os['.type'] ~= "" then
+ ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] }
+ for o, v in util.kspairs(os) do
+ if o:sub(1,1) ~= "." then
+ ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>" %{ r, s, o, util.pcdata(v) }
+ end
+ end
+ ret[#ret+1] = "</ins><br />"
+
+ -- section delete
+ elseif os['.type'] and os['.type'] == "" then
+ ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s }
+
+ -- modifications
+ else
+ ret[#ret+1] = "<var>%s.%s<br />" %{ r, s }
+ for o, v in util.kspairs(os) do
+ if o:sub(1,1) ~= "." then
+ if v and v ~= "" then
+ ret[#ret+1] = "<ins>%s.%s.%s=<strong>%s</strong><br /></ins>" %{ r, s, o, util.pcdata(v) }
+ else
+ ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o }
+ end
+ end
+ end
+ ret[#ret+1] = "</var><br />"
+ end
+ end
+ end
+
+ write(table.concat(ret))
+ %></div>
+</fieldset>
+<%- end) %>
diff --git a/modules/admin-full/luasrc/view/admin_uci/changes.htm b/modules/admin-full/luasrc/view/admin_uci/changes.htm
index 6dd3e5990..34968c05a 100644
--- a/modules/admin-full/luasrc/view/admin_uci/changes.htm
+++ b/modules/admin-full/luasrc/view/admin_uci/changes.htm
@@ -15,17 +15,19 @@ $Id$
<%+header%>
-<h2><a id="content" name="content"><%:Configuration%></a></h2>
-<p><strong><%:Changes%>:</strong></p>
+<h2><a id="content" name="content"><%:Configuration / Changes%></a></h2>
-<div class="cbi-section">
- <code><%=changes%></code>
-</div>
+<% if changes then %>
+ <%+admin_uci/changelog%>
+ <%- uci_changelog(changes) -%>
+<% else %>
+ <p><strong><%:There are no pending changes!%></strong></p>
+<% end %>
<div class="cbi-page-actions">
<div style="float:left">
<form class="inline" method="get" action="<%=luci.util.pcdata(luci.http.formvalue("redir"))%>">
- <input class="cbi-button" style="float:left; margin:0" type="submit" value="« <%:back%>" />
+ <input class="cbi-button" style="float:left; margin:0" type="submit" value="<%:« Back%>" />
</form>
</div>
diff --git a/modules/admin-full/luasrc/view/admin_uci/revert.htm b/modules/admin-full/luasrc/view/admin_uci/revert.htm
index 863cfda86..b0b3dabd9 100644
--- a/modules/admin-full/luasrc/view/admin_uci/revert.htm
+++ b/modules/admin-full/luasrc/view/admin_uci/revert.htm
@@ -15,12 +15,17 @@ $Id$
<%+header%>
-<h2><a id="content" name="content"><%:Configuration%></a></h2>
-<p><strong><%:The following changes have been reverted%>:</strong></p>
+<h2><a id="content" name="content"><%:Configuration / Revert%></a></h2>
-<div class="cbi-section">
- <code><%=(changes or "-")%></code>
-</div>
+<% if changes then %>
+ <%+cbi/apply_xhr%>
+ <%+admin_uci/changelog%>
+
+ <p><strong><%:The following changes have been reverted%>:</strong></p>
+ <%- uci_changelog(changes) -%>
+<% else %>
+ <p><strong><%:There are no pending changes to revert!%></strong></p>
+<% end %>
<div class="cbi-page-actions">
<form class="inline" method="get" action="<%=luci.util.pcdata(luci.http.formvalue("redir"))%>">