node("admin", "uci", "apply").target = call("action_apply")
end
+function convert_changes(changes)
+ local ret = {}
+ for r, tbl in pairs(changes) do
+ for s, os in pairs(tbl) do
+ for o, v in pairs(os) do
+ local val, str
+ if (v == "") then
+ str = "-"
+ val = ""
+ else
+ str = ""
+ val = "="..v
+ end
+ str = str.."."..r
+ if o ~= ".type" then
+ str = str.."."..o
+ end
+ table.insert(ret, str..val)
+ end
+ end
+ end
+end
+
-- This function has a higher priority than the admin_uci/apply template
function action_apply()
local changes = luci.model.uci.changes()
local run = {}
-- Collect files to be applied and commit changes
- for i, line in ipairs(luci.util.split(changes)) do
- local r = line:match("^-?([^.]+)")
+ for r, tbl in pairs(changes) do
if r then
com[r] = true
end
end
- luci.template.render("admin_uci/apply", {changes=changes, output=output})
+
+ luci.template.render("admin_uci/apply", {changes=convert_changes(changes), output=output})
end
local revert = {}
-- Collect files to be reverted
- for i, line in ipairs(luci.util.split(changes)) do
- local r = line:match("^-?([^.]+)")
+ for r, tbl in ipairs(changes) do
if r then
revert[r] = true
end
end
end
- luci.template.render("admin_uci/revert", {changes=changes})
-end
\ No newline at end of file
+ luci.template.render("admin_uci/revert", {changes=convert_changes(changes)})
+end