From 670648ad214ed26e74b25801e04f1430662de470 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 15 Oct 2010 21:53:28 +0000 Subject: modules/admin-full: rework changes/apply/revert pages --- modules/admin-full/luasrc/view/admin_uci/apply.htm | 38 +++++------- .../admin-full/luasrc/view/admin_uci/changelog.htm | 67 ++++++++++++++++++++++ .../admin-full/luasrc/view/admin_uci/changes.htm | 14 +++-- .../admin-full/luasrc/view/admin_uci/revert.htm | 15 +++-- 4 files changed, 99 insertions(+), 35 deletions(-) create mode 100644 modules/admin-full/luasrc/view/admin_uci/changelog.htm (limited to 'modules/admin-full/luasrc/view/admin_uci') diff --git a/modules/admin-full/luasrc/view/admin_uci/apply.htm b/modules/admin-full/luasrc/view/admin_uci/apply.htm index e9de29a91a..a9fbbfe9e5 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%> -

<%:Configuration%>

-

<%:The following changes have been applied%>:

- -
- <%=(changes or "-")%> -
- -
- -
- -
-
"> - -
-
+

<%:Configuration / Apply%>

+ +<% if changes then %> + <%+cbi/apply_xhr%> + <%+admin_uci/changelog%> + + <%- cbi_apply_xhr('uci-apply', configs) -%> + +

<%:The following changes have been comitted%>:

+ <%- uci_changelog(changes) -%> +<% else %> +

<%:There are no pending changes to apply!%>

+<% 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 0000000000..13bbdffcb4 --- /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 + +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) -%> +
+ <%:Legend:%> +
+
  <%:Section added%>
+
  <%:Section removed%>
+
  <%:Option changed%>
+
  <%:Option removed%>
+
+
+
+ +
<% + 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] = "%s.%s=%s" %{ r, s, os['.type'] } + for o, v in util.kspairs(os) do + if o:sub(1,1) ~= "." then + ret[#ret+1] = "
%s.%s.%s=%s" %{ r, s, o, util.pcdata(v) } + end + end + ret[#ret+1] = "

" + + -- section delete + elseif os['.type'] and os['.type'] == "" then + ret[#ret+1] = "%s.%s
" %{ r, s } + + -- modifications + else + ret[#ret+1] = "%s.%s
" %{ r, s } + for o, v in util.kspairs(os) do + if o:sub(1,1) ~= "." then + if v and v ~= "" then + ret[#ret+1] = "%s.%s.%s=%s
" %{ r, s, o, util.pcdata(v) } + else + ret[#ret+1] = "%s.%s.%s
" %{ r, s, o } + end + end + end + ret[#ret+1] = "

" + end + end + end + + write(table.concat(ret)) + %>
+
+<%- end) %> diff --git a/modules/admin-full/luasrc/view/admin_uci/changes.htm b/modules/admin-full/luasrc/view/admin_uci/changes.htm index 6dd3e5990d..34968c05ac 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%> -

<%:Configuration%>

-

<%:Changes%>:

+

<%:Configuration / Changes%>

-
- <%=changes%> -
+<% if changes then %> + <%+admin_uci/changelog%> + <%- uci_changelog(changes) -%> +<% else %> +

<%:There are no pending changes!%>

+<% end %>
"> - +
diff --git a/modules/admin-full/luasrc/view/admin_uci/revert.htm b/modules/admin-full/luasrc/view/admin_uci/revert.htm index 863cfda862..b0b3dabd94 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%> -

<%:Configuration%>

-

<%:The following changes have been reverted%>:

+

<%:Configuration / Revert%>

-
- <%=(changes or "-")%> -
+<% if changes then %> + <%+cbi/apply_xhr%> + <%+admin_uci/changelog%> + +

<%:The following changes have been reverted%>:

+ <%- uci_changelog(changes) -%> +<% else %> +

<%:There are no pending changes to revert!%>

+<% end %>
"> -- cgit v1.2.3