summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-06-03 22:42:01 +0000
committerFelix Fietkau <nbd@openwrt.org>2008-06-03 22:42:01 +0000
commit77f8074a01277917ab9ab0d00778f59bb0a88817 (patch)
tree0a74c83baa97175d553a900ff1378b68fced149d /modules
parent3bcf6dbea363d7267d95bb0199d91603a33362b7 (diff)
make use of the new features in the binding for uci v0.4.0 - fixes remaining dependencies of libuci.lua on the cli
Diffstat (limited to 'modules')
-rw-r--r--modules/admin-core/luasrc/controller/admin/uci.lua36
1 files changed, 29 insertions, 7 deletions
diff --git a/modules/admin-core/luasrc/controller/admin/uci.lua b/modules/admin-core/luasrc/controller/admin/uci.lua
index 9c0e1beb5..e9209da6e 100644
--- a/modules/admin-core/luasrc/controller/admin/uci.lua
+++ b/modules/admin-core/luasrc/controller/admin/uci.lua
@@ -8,6 +8,29 @@ function index()
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()
@@ -18,8 +41,7 @@ function action_apply()
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
@@ -40,7 +62,8 @@ function action_apply()
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
@@ -50,8 +73,7 @@ function action_revert()
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
@@ -63,5 +85,5 @@ function action_revert()
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