1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.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 table.concat(disp.context.request, "/")
10 entry({"admin", "uci"}, nil, _("Configuration"))
11 entry({"admin", "uci", "changes"}, call("action_changes"), _("Changes"), 40).query = {redir=redir}
12 entry({"admin", "uci", "revert"}, post("action_revert"), _("Revert"), 30).query = {redir=redir}
13 entry({"admin", "uci", "apply"}, post("action_apply"), _("Apply"), 20).query = {redir=redir}
14 entry({"admin", "uci", "saveapply"}, post("action_apply"), _("Save & Apply"), 10).query = {redir=redir}
17 function action_changes()
18 local uci = luci.model.uci.cursor()
19 local changes = uci:changes()
21 luci.template.render("admin_uci/changes", {
22 changes = next(changes) and changes
26 function action_apply()
27 local path = luci.dispatcher.context.path
28 local uci = luci.model.uci.cursor()
29 local changes = uci:changes()
32 -- Collect files to be applied and commit changes
33 for r, tbl in pairs(changes) do
34 table.insert(reload, r)
35 if path[#path] ~= "apply" then
42 luci.template.render("admin_uci/apply", {
43 changes = next(changes) and changes,
49 function action_revert()
50 local uci = luci.model.uci.cursor()
51 local changes = uci:changes()
53 -- Collect files to be reverted
54 for r, tbl in pairs(changes) do
60 luci.template.render("admin_uci/revert", {
61 changes = next(changes) and changes