2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 module("luci.controller.admin.uci", package.seeall)
19 local redir = luci.http.formvalue("redir", true) or
20 luci.dispatcher.build_url(unpack(luci.dispatcher.context.request))
22 entry({"admin", "uci"}, nil, _("Configuration"))
23 entry({"admin", "uci", "changes"}, call("action_changes"), _("Changes"), 40).query = {redir=redir}
24 entry({"admin", "uci", "revert"}, call("action_revert"), _("Revert"), 30).query = {redir=redir}
25 entry({"admin", "uci", "apply"}, call("action_apply"), _("Apply"), 20).query = {redir=redir}
26 entry({"admin", "uci", "saveapply"}, call("action_apply"), _("Save & Apply"), 10).query = {redir=redir}
29 function action_changes()
30 local uci = luci.model.uci.cursor()
31 local changes = uci:changes()
33 luci.template.render("admin_uci/changes", {
34 changes = next(changes) and changes
38 function action_apply()
39 local path = luci.dispatcher.context.path
40 local uci = luci.model.uci.cursor()
41 local changes = uci:changes()
44 -- Collect files to be applied and commit changes
45 for r, tbl in pairs(changes) do
46 table.insert(reload, r)
47 if path[#path] ~= "apply" then
54 luci.template.render("admin_uci/apply", {
55 changes = next(changes) and changes,
61 function action_revert()
62 local uci = luci.model.uci.cursor()
63 local changes = uci:changes()
65 -- Collect files to be reverted
66 for r, tbl in pairs(changes) do
72 luci.template.render("admin_uci/revert", {
73 changes = next(changes) and changes