1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
3 -- Licensed to the public under the Apache License 2.0.
5 module("luci.controller.admin.uci", package.seeall)
8 local redir = luci.http.formvalue("redir", true) or
9 luci.dispatcher.build_url(unpack(luci.dispatcher.context.request))
11 entry({"admin", "uci"}, nil, _("Configuration"))
12 entry({"admin", "uci", "changes"}, call("action_changes"), _("Changes"), 40).query = {redir=redir}
13 entry({"admin", "uci", "revert"}, call("action_revert"), _("Revert"), 30).query = {redir=redir}
14 entry({"admin", "uci", "apply"}, call("action_apply"), _("Apply"), 20).query = {redir=redir}
15 entry({"admin", "uci", "saveapply"}, call("action_apply"), _("Save & Apply"), 10).query = {redir=redir}
18 function action_changes()
19 local uci = luci.model.uci.cursor()
20 local changes = uci:changes()
22 luci.template.render("admin_uci/changes", {
23 changes = next(changes) and changes
27 function action_apply()
28 local path = luci.dispatcher.context.path
29 local uci = luci.model.uci.cursor()
30 local changes = uci:changes()
33 -- Collect files to be applied and commit changes
34 for r, tbl in pairs(changes) do
35 table.insert(reload, r)
36 if path[#path] ~= "apply" then
43 luci.template.render("admin_uci/apply", {
44 changes = next(changes) and changes,
50 function action_revert()
51 local uci = luci.model.uci.cursor()
52 local changes = uci:changes()
54 -- Collect files to be reverted
55 for r, tbl in pairs(changes) do
61 luci.template.render("admin_uci/revert", {
62 changes = next(changes) and changes