luci-app-attendedsysupgrade: remove outdated checks
[project/luci.git] / applications / luci-app-attendedsysupgrade / luasrc / view / attendedsysupgrade.htm
1 <%
2 -- all lua code provided by https://github.com/jow-/
3 -- thank you very much!
4
5 function apply_acls(filename, session)
6 local json = require "luci.jsonc"
7 local util = require "luci.util"
8 local fs = require "nixio.fs"
9
10 local grants = { }
11
12 local acl = json.parse(fs.readfile(filename))
13 if type(acl) ~= "table" then
14 return
15 end
16
17 local group, perms
18 for group, perms in pairs(acl) do
19 local perm, scopes
20 for perm, scopes in pairs(perms) do
21 if type(scopes) == "table" then
22 local scope, objects
23 for scope, objects in pairs(scopes) do
24 if type(objects) == "table" then
25 if not grants[scope] then
26 grants[scope] = { }
27 end
28
29 if next(objects) == 1 then
30 local _, object
31 for _, object in ipairs(objects) do
32 if not grants[scope][object] then
33 grants[scope][object] = { }
34 end
35 table.insert(grants[scope][object], perm)
36 end
37 else
38 local object, funcs
39 for object, funcs in pairs(objects) do
40 if type(funcs) == "table" then
41 local _, func
42 for _, func in ipairs(funcs) do
43 if not grants[scope][object] then
44 grants[scope][object] = { }
45 end
46 table.insert(grants[scope][object], func)
47 end
48 end
49 end
50 end
51 end
52 end
53 end
54 end
55 end
56
57 local _, scope, object, func
58 for scope, _ in pairs(grants) do
59 local objects = { }
60 for object, _ in pairs(_) do
61 for _, func in ipairs(_) do
62 table.insert(objects, { object, func })
63 end
64 end
65
66 util.ubus("session", "grant", {
67 ubus_rpc_session = session,
68 scope = scope, objects = objects
69 })
70 end
71 end
72
73 apply_acls("/usr/share/rpcd/acl.d/attendedsysupgrade.json", luci.dispatcher.context.authsession)
74 %>
75 <%+header%>
76 <h2 name="content"><%:Attended Sysupgrade%></h2>
77 <div class="cbi-map-descr">
78 Easily search and install new releases and package upgrades. Sysupgrade firmware are created on demand based on locally installed packages.
79 </div>
80 <div style="display: none" id="info_box" class="alert-message info"></div>
81 <div style="display: none" id="error_box" class="alert-message danger"></div>
82 <div style="display: none" id="packages" class="alert-message success"></div>
83 <p>
84 <textarea style="display: none; width: 100%;" id="edit_packages" rows="15"></textarea>
85 </p>
86 <fieldset class="cbi-section">
87 <form method="post" action="">
88 <div class="cbi-selection-node">
89 <div class="cbi-value" id="keep_container" style="display: none">
90 <div class="cbi-section-descr">
91 Check "Keep settings" to retain the current configuration (requires a compatible firmware).
92 </div>
93 <label class="cbi-value-title" for="keep">Keep settings:</label>
94 <div class="cbi-value-field">
95 <input name="keep" id="keep" checked="checked" type="checkbox">
96 </div>
97 </div>
98 <div class="cbi-value" id="edit_button" style="display: none">
99 <div class="cbi-value-field">
100 <input class="cbi-button" value="Edit installed packages" onclick="edit_packages()" type="button">
101 </div>
102 </div>
103 <div class="cbi-value cbi-value" id="server_div" style="display:none">
104 <label class="cbi-value-title" for="server">Server:</label>
105 <div class="cbi-value-field">
106 <input onclick="edit_server()" class="cbi-button cbi-button-edit" value="" type="button" id="server" name="server">
107 </div>
108 </div>
109 <div class="cbi-value cbi-value-last">
110 <div class="cbi-value-field">
111 <input class="cbi-button cbi-button-apply" value="Search for upgrades" style="display: none" onclick="upgrade_check()" type="button" id="upgrade_button">
112 </div>
113 </div>
114 </div>
115 </form>
116 </fieldset>
117 <script type="text/javascript">
118 data = {};
119 data["ubus_rpc_session"] = "<%=luci.dispatcher.context.authsession%>"
120 origin = document.location.href.replace(location.pathname, "")
121 ubus_url = origin + "/ubus/"
122 </script>
123 <script type="text/javascript" src="<%=resource%>/attendedsysupgrade.js"></script>
124 <%+footer%>