1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<%- if firstmap and messages then local msg; for _, msg in ipairs(messages) do -%>
<div class="alert-message warning"><%=pcdata(msg)%></div>
<%- end end -%>
<%
local function has_access(config, level)
local rv = luci.util.ubus("session", "access", {
ubus_rpc_session = luci.dispatcher.context.authsession,
scope = "uci",
object = config,
["function"] = level
})
return (type(rv) == "table" and rv.access == true) or false
end
local is_readable = has_access(self.config, "read")
local is_writable = has_access(self.config, "write")
has_writeable_map = has_writeable_map or is_writable
%>
<% if is_readable then %>
<div class="cbi-map" id="cbi-<%=self.config%>"<%=ifattr(not is_writable, "style", "opacity:.6; pointer-events:none")%>>
<% if self.title and #self.title > 0 then %>
<h2 name="content"><%=self.title%></h2>
<% end %>
<% if self.description and #self.description > 0 then %>
<div class="cbi-map-descr"><%=self.description%></div>
<% end %>
<% if self.tabbed then %>
<div>
<% for i, section in ipairs(self.children) do
tab = section.section or section.sectiontype %>
<div class="cbi-tabcontainer"<%=
attr("id", "container.m-%s.%s" %{ self.config, tab }) ..
attr("data-tab", tab) ..
attr("data-tab-title", section.title or tab)
%>>
<% section:render() %>
</div>
<% end %>
</div>
<% if not self.save then -%>
<div class="cbi-section-error">
<% for _, section in ipairs(self.children) do %>
<% if section.error and section.error[section.section] then -%>
<ul><li>
<%:One or more invalid/required values on tab%>: <%=section.title or section.section or section.sectiontype%>
</li></ul>
<%- end %>
<% end %>
</div>
<%- end %>
<% else %>
<%- self:render_children() %>
<% end %>
</div>
<% else %>
<div class="alert-message warning"><%:Insufficient permissions to read UCI configuration.%></div>
<% end %>
|