treewide: rework uci change display
- Use native rpcd uci changes format instead of incompletely converting back and forth between the old and the new format - Rework uci changelog template to print the equivalent uci commands for the various changes - Rework theme headers to properly count the uncomitted changes - Rework theme CSS to properly style new changelog Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
c2d36ba280
commit
849d153851
7 changed files with 119 additions and 151 deletions
|
@ -95,41 +95,15 @@ end
|
||||||
|
|
||||||
|
|
||||||
function changes(self, config)
|
function changes(self, config)
|
||||||
local rv = call("changes", { config = config })
|
local rv, err = call("changes", { config = config })
|
||||||
local res = {}
|
|
||||||
|
|
||||||
if type(rv) == "table" and type(rv.changes) == "table" then
|
if type(rv) == "table" and type(rv.changes) == "table" then
|
||||||
local package, changes
|
return rv.changes
|
||||||
for package, changes in pairs(rv.changes) do
|
elseif err then
|
||||||
res[package] = {}
|
return nil, ERRSTR[err]
|
||||||
|
else
|
||||||
local _, change
|
return { }
|
||||||
for _, change in ipairs(changes) do
|
|
||||||
local operation, section, option, value = unpack(change)
|
|
||||||
if option and operation ~= "add" then
|
|
||||||
res[package][section] = res[package][section] or { }
|
|
||||||
|
|
||||||
if operation == "list-add" then
|
|
||||||
local v = res[package][section][option]
|
|
||||||
if type(v) == "table" then
|
|
||||||
v[#v+1] = value or ""
|
|
||||||
elseif v ~= nil then
|
|
||||||
res[package][section][option] = { v, value }
|
|
||||||
else
|
|
||||||
res[package][section][option] = { value }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
res[package][section][option] = value or ""
|
|
||||||
end
|
|
||||||
else
|
|
||||||
res[package][section] = res[package][section] or {}
|
|
||||||
res[package][section][".type"] = option or ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return res
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%#
|
<%#
|
||||||
Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
|
Copyright 2010 Jo-Philipp Wich <jo@mein.io>
|
||||||
Licensed to the public under the Apache License 2.0.
|
Licensed to the public under the Apache License 2.0.
|
||||||
-%>
|
-%>
|
||||||
|
|
||||||
|
@ -17,65 +17,50 @@
|
||||||
|
|
||||||
<div class="uci-change-list"><%
|
<div class="uci-change-list"><%
|
||||||
local util = luci.util
|
local util = luci.util
|
||||||
local ret = { }
|
local tpl = {
|
||||||
|
["add-3"] = "<ins>uci add %0 <strong>%3</strong> # =%2</ins>",
|
||||||
|
["set-3"] = "<ins>uci set %0.<strong>%2</strong></ins>=%3",
|
||||||
|
["set-4"] = "<var><ins>uci set %0.%2.%3=<strong>%4</strong></ins></var>",
|
||||||
|
["remove-2"] = "<del>uci del %0.<strong>%2</strong></del>",
|
||||||
|
["remove-3"] = "<var><del>uci del %0.%2.<strong>%3</strong></del></var>",
|
||||||
|
["order-3"] = "<var>uci reorder %0.%2=<strong>%3</strong></var>",
|
||||||
|
["list-add-4"] = "<var><ins>uci add_list %0.%2.%3=<strong>%4</strong></ins></var>",
|
||||||
|
["list-del-4"] = "<var><del>uci del_list %0.%2.%3=<strong>%4</strong></del></var>",
|
||||||
|
["rename-3"] = "<var>uci rename %0.%2=<strong>%3</strong></var>",
|
||||||
|
["rename-4"] = "<var>uci rename %0.%2.%3=<strong>%4</strong></var>"
|
||||||
|
}
|
||||||
|
|
||||||
for r, tbl in pairs(changes) do
|
local conf, deltas
|
||||||
for s, os in pairs(tbl) do
|
for conf, deltas in util.kspairs(changes) do
|
||||||
-- section add
|
write("<h3># /etc/config/%s</h3>" % conf)
|
||||||
if os['.type'] and os['.type'] ~= "" then
|
|
||||||
ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] }
|
local _, delta, added
|
||||||
for o, v in util.kspairs(os) do
|
for _, delta in pairs(deltas) do
|
||||||
if o:sub(1,1) ~= "." then
|
local t = tpl["%s-%d" %{ delta[1], #delta }]
|
||||||
if type(v) == "table" then
|
|
||||||
local i
|
write(t:gsub("%%(%d)", function(n)
|
||||||
for i = 1, #v do
|
if n == "0" then
|
||||||
ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>"
|
return conf
|
||||||
%{ r, s, o, util.pcdata(v[i]) }
|
elseif n == "2" then
|
||||||
end
|
if added and delta[2] == added[1] then
|
||||||
elseif v ~= "" then
|
return "@%s[-1]" % added[2]
|
||||||
ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>"
|
else
|
||||||
%{ r, s, o, util.pcdata(v) }
|
return delta[2]
|
||||||
else
|
|
||||||
ret[#ret+1] = "<br /><del>%s.%s.<strong>%s</strong></del>" %{ r, s, o }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
elseif n == "4" then
|
||||||
|
return util.shellquote(delta[4])
|
||||||
|
else
|
||||||
|
return delta[tonumber(n)]
|
||||||
end
|
end
|
||||||
ret[#ret+1] = "</ins><br />"
|
end))
|
||||||
|
|
||||||
-- section delete
|
if delta[1] == "add" then
|
||||||
elseif os['.type'] and os['.type'] == "" then
|
added = { delta[2], delta[3] }
|
||||||
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 > 0 then
|
|
||||||
ret[#ret+1] = "<ins>"
|
|
||||||
if type(v) == "table" then
|
|
||||||
local i
|
|
||||||
for i = 1, #v do
|
|
||||||
ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />"
|
|
||||||
%{ r, s, o, util.pcdata(v[i]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />"
|
|
||||||
%{ r, s, o, util.pcdata(v) }
|
|
||||||
end
|
|
||||||
ret[#ret+1] = "</ins>"
|
|
||||||
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
|
end
|
||||||
end
|
|
||||||
|
|
||||||
write(table.concat(ret))
|
write("<br />")
|
||||||
|
end
|
||||||
%></div>
|
%></div>
|
||||||
</div>
|
</div>
|
||||||
<%- end) %>
|
<%- end) %>
|
||||||
|
|
|
@ -23,7 +23,7 @@ body {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6, p, pre, a, abbr, acronym, code, del, em, img, q, s,
|
h1, h2, h3, h4, h5, h6, p, pre, a, abbr, acronym, code, del, em, img, ins, q, s,
|
||||||
small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset,
|
small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset,
|
||||||
form, label, legend, button, table, caption, tbody, tfoot, thead, tr, th, td,
|
form, label, legend, button, table, caption, tbody, tfoot, thead, tr, th, td,
|
||||||
.table, .tbody, .tfoot, .thead, .tr, .th, .td {
|
.table, .tbody, .tfoot, .thead, .tr, .th, .td {
|
||||||
|
@ -1956,47 +1956,51 @@ div.cbi-value var,
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list {
|
.uci-change-list {
|
||||||
|
line-height: 170%;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uci-change-list del,
|
||||||
|
.uci-change-list ins,
|
||||||
|
.uci-change-list var,
|
||||||
|
.uci-change-legend-label del,
|
||||||
|
.uci-change-legend-label ins,
|
||||||
|
.uci-change-legend-label var {
|
||||||
|
text-decoration: none;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
font-style: normal;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background: #eee;
|
||||||
|
padding: 2px;
|
||||||
|
display: block;
|
||||||
|
line-height: 15px;
|
||||||
|
margin-bottom: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list ins,
|
.uci-change-list ins,
|
||||||
.uci-change-legend-label ins {
|
.uci-change-legend-label ins {
|
||||||
text-decoration: none;
|
border-color: #0f0;
|
||||||
border: 1px solid #0f0;
|
background: #cfc;
|
||||||
background-color: #cfc;
|
|
||||||
display: block;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list del,
|
.uci-change-list del,
|
||||||
.uci-change-legend-label del {
|
.uci-change-legend-label del {
|
||||||
text-decoration: none;
|
border-color: #f00;
|
||||||
border: 1px solid #f00;
|
background: #fcc;
|
||||||
background-color: #fcc;
|
|
||||||
display: block;
|
|
||||||
font-style: normal;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list var,
|
.uci-change-list var,
|
||||||
.uci-change-legend-label var {
|
.uci-change-legend-label var {
|
||||||
text-decoration: none;
|
border-color: #ccc;
|
||||||
border: 1px solid #ccc;
|
background: #eee;
|
||||||
background-color: #eee;
|
|
||||||
display: block;
|
|
||||||
font-style: normal;
|
|
||||||
padding: 2px;
|
|
||||||
line-height: 19px;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list var ins,
|
.uci-change-list var ins,
|
||||||
.uci-change-list var del {
|
.uci-change-list var del {
|
||||||
display: inline;
|
display: inline-block;
|
||||||
/*border: none;*/
|
border: none;
|
||||||
white-space: pre;
|
width: 100%;
|
||||||
font-style: normal;
|
padding: 0;
|
||||||
padding: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-legend {
|
.uci-change-legend {
|
||||||
|
@ -2016,12 +2020,17 @@ div.cbi-value var,
|
||||||
width: 10px;
|
width: 10px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
display: block;
|
display: block;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-legend-label var ins,
|
.uci-change-legend-label var ins,
|
||||||
.uci-change-legend-label var del {
|
.uci-change-legend-label var del {
|
||||||
line-height: 6px;
|
|
||||||
border: none;
|
border: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
right: 2px;
|
||||||
|
bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
html body.apply-overlay-active {
|
html body.apply-overlay-active {
|
||||||
|
|
|
@ -136,12 +136,9 @@
|
||||||
if tree.nodes[category] and tree.nodes[category].ucidata then
|
if tree.nodes[category] and tree.nodes[category].ucidata then
|
||||||
local ucichanges = 0
|
local ucichanges = 0
|
||||||
|
|
||||||
|
local i, j
|
||||||
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
||||||
for k, l in pairs(j) do
|
ucichanges = ucichanges + #j
|
||||||
for m, n in pairs(l) do
|
|
||||||
ucichanges = ucichanges + 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ucichanges > 0 then
|
if ucichanges > 0 then
|
||||||
|
|
|
@ -160,13 +160,9 @@
|
||||||
-- calculate the number of unsaved changes
|
-- calculate the number of unsaved changes
|
||||||
if tree.nodes[category] and tree.nodes[category].ucidata then
|
if tree.nodes[category] and tree.nodes[category].ucidata then
|
||||||
local ucichanges = 0
|
local ucichanges = 0
|
||||||
|
local i, j
|
||||||
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
||||||
for k, l in pairs(j) do
|
ucichanges = ucichanges + #j
|
||||||
for m, n in pairs(l) do
|
|
||||||
ucichanges = ucichanges + 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ucichanges > 0 then
|
if ucichanges > 0 then
|
||||||
|
|
|
@ -1397,44 +1397,49 @@ select + .cbi-button {
|
||||||
|
|
||||||
.uci-change-list {
|
.uci-change-list {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uci-change-list del,
|
||||||
|
.uci-change-list ins,
|
||||||
|
.uci-change-list var,
|
||||||
|
.uci-change-legend-label del,
|
||||||
|
.uci-change-legend-label ins,
|
||||||
|
.uci-change-legend-label var {
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background: #eee;
|
||||||
|
padding: 2px;
|
||||||
|
display: block;
|
||||||
|
line-height: 15px;
|
||||||
|
margin-bottom: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list ins,
|
.uci-change-list ins,
|
||||||
.uci-change-legend-label ins {
|
.uci-change-legend-label ins {
|
||||||
text-decoration: none;
|
border-color: #0f0;
|
||||||
border: 1px solid #00FF00;
|
background: #cfc;
|
||||||
background-color: #CCFFCC;
|
|
||||||
display: block;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list del,
|
.uci-change-list del,
|
||||||
.uci-change-legend-label del {
|
.uci-change-legend-label del {
|
||||||
text-decoration: none;
|
border-color: #f00;
|
||||||
border: 1px solid #FF0000;
|
background: #fcc;
|
||||||
background-color: #FFCCCC;
|
|
||||||
display: block;
|
|
||||||
font-style: normal;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list var,
|
.uci-change-list var,
|
||||||
.uci-change-legend-label var {
|
.uci-change-legend-label var {
|
||||||
text-decoration: none;
|
border-color: #ccc;
|
||||||
border: 1px solid #CCCCCC;
|
background: #eee;
|
||||||
background-color: #EEEEEE;
|
|
||||||
display: block;
|
|
||||||
font-style: normal;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-list var ins,
|
.uci-change-list var ins,
|
||||||
.uci-change-list var del {
|
.uci-change-list var del {
|
||||||
/*display: inline;*/
|
display: inline-block;
|
||||||
border: none;
|
border: none;
|
||||||
white-space: pre;
|
width: 100%;
|
||||||
font-style: normal;
|
padding: 0;
|
||||||
padding: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-legend {
|
.uci-change-legend {
|
||||||
|
@ -1452,15 +1457,20 @@ select + .cbi-button {
|
||||||
.uci-change-legend-label>var {
|
.uci-change-legend-label>var {
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
width: 10px;
|
width: 12px;
|
||||||
height: 10px;
|
height: 12px;
|
||||||
display: block;
|
display: block;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uci-change-legend-label var ins,
|
.uci-change-legend-label var ins,
|
||||||
.uci-change-legend-label var del {
|
.uci-change-legend-label var del {
|
||||||
line-height: 6px;
|
|
||||||
border: none;
|
border: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 1px;
|
||||||
|
left: 1px;
|
||||||
|
right: 1px;
|
||||||
|
bottom: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,9 @@
|
||||||
local function render_changes()
|
local function render_changes()
|
||||||
if tree.nodes[category] and tree.nodes[category].ucidata then
|
if tree.nodes[category] and tree.nodes[category].ucidata then
|
||||||
local ucic = 0
|
local ucic = 0
|
||||||
|
local i, j
|
||||||
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
for i, j in pairs(require("luci.model.uci").cursor():changes()) do
|
||||||
for k, l in pairs(j) do
|
ucic = ucic + #j
|
||||||
for m, n in pairs(l) do
|
|
||||||
ucic = ucic + 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ucic > 0 then
|
if ucic > 0 then
|
||||||
|
|
Loading…
Reference in a new issue